-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to render when using with NextJS v13 & React Server Components #929
Comments
@nick-kang I've tried your code and the suggested workaround, but I could not get the blue background style to apply. I expect the background of the container to be blue, but the class style is missing and I get a 404 on http://localhost:3000/_next/app/page:app/page |
I think that the linked swc plugin only emulates the previous babel plugin / test transform and doesn't actually create the css resource. |
Is maintainers of this library planning to support Next.js 13 (appDir) and React Server Component? |
@audifaxdev Did you also change the import from |
@nick-kang what does your next.config.js look like with this workaround? Trying to use the same one. |
I'm having the same problem. gonna sit here and wait on Next.js 13 (+ appDir) supports 👀 |
Alternative workaround: two small patches for NextJS + VE NextJS plugin: https://gist.github.com/bizarre/825cab8224c28e93ff1a3933642f9271 (use with patch-package). Only caveat I've found so far is that |
@bizarre I tested your patch and it works for me as well. I don't see any problem with globalStyle. Do you want to submit a PR for VE? Not sure what we should do about the (Tagging @shuding hoping they might be able to help us) |
@bizarre This patch works great for me, although I've noticed some strange behaviour where if I have a .css.ts file that uses vanilla-extract/sprinkles and I have lots of properties passed to If I reduce the number of properties passed to EDIT: It looks like an issue triggered by Webpack chunk splitting if the CSS chunks are large and the way that NextJS 13 flight-manifest-plugin picks up CSS chunks. EDIT 2: I fixed it with this extremely horrible hack, this will probably break other stuff and affect ordering of CSS imports but it seems to work well for me https://gist.github.com/madjam002/55c7d60b247c12e30b65a395e29d5871 |
Any updates here? Looking forward to using VE with RSC 😄 |
Using styled mdx pages as ServerComponents and Currently on experimental: {
appDir: true,
}, The issue of @madjam002 Observing the same behaviour still with large chunks from sprinkles. Splitting up the property definitions and sprinkles solved it, except for the color options which seem to be too many classes generated - no matter which way I split it. @graup There are some changes in app.render.js and checking for mod.default does not do anything for me anymore since it seems to be always defined. I was thinking about submitting a PR to VE, but appDir won't work without the regex fix in next and it will crash with As of now able to work fine in 'dev' and 'storybook', but would be happy to work on a PR or come back to this issue later when upgrading dependencies. |
Setting up Next.js 13 w/appDir and Vanilla Extract today and ran into this as well. Updated the above patches based on current versions (Next.js 13.2.4, Vanilla Extract Next Plugin 2.1.1). If you haven't used
|
I downloaded the zip and did as you said but I never used the patch-package, how to use it to install the patches? |
@thiagop90: the steps that @bradcerasani provided are all you need. You should be able to see the patches being applied in the terminal after running You may need to update your package versions to match those from the patches |
@bradcerasani you patch works great when running locally, but when I build the app the styles don't get applied. Any idea why that could be? Did you run into the issue as well? |
Does it still work with |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Also running into the same issues. Patches work fine and |
This comment was marked as off-topic.
This comment was marked as off-topic.
@adri1wald Ah, I'm sorry. I should also clarify that I'm using macOS. Based on reports from other folks, it seems like there could be an issue when running in Windows. If your example project code is available, I can see what happens when I try to build it. |
I run macOS too and this also failed in the vercel cloud |
I just tested a Vercel build, and everything seems to be working correctly for me. |
It seems there are a few different issues here (1. builds not outputting css on Windows, 2. not working without the experimental.appDir setting). Could someone open new issues for these? I have a hunch that both of those will require help from the Next.js side. |
Here's a link to my repo. @juice49 Maybe you can see what is wrong? |
There also seem to be a 3rd issue, unrelated to the platform (I'm on MacOS), with the css being output in the build, but not included in the page, this happens with sprinkles when there are too many output classes, yet I am unsure if this is sprinkles specific, or just that sprinkles tend to increase faster than the rest.
The simultaneous usage of two different sets of sprinkles (defined separately in different
This feels similar to what madjam002 described Happy to open a dedicated issue if needed (edit: someone did, see #1085) |
Done |
Thanks for this. Works with experimental appDir flag. Curious though why after many weeks there's still no vanilla-extract update to remove this requirement. |
We're waiting for feedback from the Next.js team. It's not clear how to fix this on the Vanill Extract end. vercel/next.js#49892 |
Also, the CSS not appearing in builds isn't just a Windows issue. Happening for me on Ubuntu also. |
Tried several versions of Next.js 13.4.* on Windows 10. Class names are added, but no styles, even with "experimental.appDir: true". 😢 |
@i-bsd & @thevisioner Try this for now #1085 (comment) |
@jere-co Unfortunately, this solution doesn't work for me either. |
Having a similar issue, running ubuntu, on dev, everything works fine, when doing a production build, CSS file is not linked in the HTML. I tried the solution @jere-co pointed it worked for me: needs to disable splitChunks in the next.config.js:
|
I'm on the same boat with @thevisioner const nextConfig = {
experimental: {
appDir: true,
},
webpack: config => {
config.optimization.splitChunks = false;
return config;
},
}; It seems the issue is Windows only. I have to use page routes instead of app dir for now. old page routes does not have the issue. |
Using above config does workaround for unix. Without it we're seeing this issue across the board |
Unfortunately, due to the great lack of specificity, I've completely moved away from trying CSS-in-JS at the moment. For me personally, full compatibility with the React Server Component model is important and that's why I've gone back to the basics - using CSS Modules. It is also noticeable that throughout the ecosystem many of the solutions are going back to the basics/standards. I don't know if it will be the same with CSS, but in a sense, I myself am willing to accept this path.
|
@thevisioner I am using it on mac and linux without problems--without using a custom next.config.js |
Yes, but vanilla-extract still doesn't generate stylesheets on Windows machine. I also can't judge full compatibility with the React Server Components, for that reason. 😞 |
@thevisioner I don't see how CSS Modules solve the specificity issue. The loading order of CSS Modules is still handled by a bundler (e.g. Webpack). |
@Dremora I seem to have been vague. I don't mean the specificity of CSS, but rather the specifics (lack of clarity) in the context of the RSC (React Server Components) compatibility issues of various CSS-in-JS solutions. And for now, RSC compatibility is one of my self-imposed requirements. |
I've recently been in the process of migrating my blog from Gatsby to Next.js, and I'm also experiencing problems with the Next.js RSC not outputting CSS on Windows. I found a solution at style9-webpack (SukkaW/style9-webpack#1) and made another Next.js plugin for vanilla-extract that works fine on Windows/Linux/macOS, if you're having a similar problem, you can try @syfxlin/next-plugin-vanilla-extract. |
Using windows and can confirm that this worked |
Since the release of @syfxlin's patch, I'm hoping that the issues mentioned in this thread have been fixed. The windows-specific issue was being tracked in #1086, but I see that there have been some users reporting a similar issue on Ubuntu. If the issue is still occurring with the latest patch, please raise a separate issue instead of commenting on this one. |
Long awaited fixes. 🙌 I can also confirm that it now works on a Windows system. Many thanks to the contributors! You're giving me a choice again. 😅 |
Describe the bug
App does not render when I import a
.css.ts
file in a React Server Component. See component in repro repo.Workaround is to convert the
.css.ts
to a default export and use swc-plugin-vanilla-extract instead of@vanilla-extract/next-plugin
Reproduction
https://github.com/nick-kang/vanilla-extract-repro-001
System Info
Used Package Manager
pnpm
Logs
The text was updated successfully, but these errors were encountered: