-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Server Side Rendering doesn't work with latest NextJS #1156
Comments
The error seems to be complaining about your postcss config. Are you sure it's correct and you have all of those modules installed properly? |
@devongovett: Yes, I'm pretty sure my setup is correct. Everything was working before I installed The first error is about the PostCSS, but the second complains about this line: // node_modules/@react-spectrum/actiongroup/dist/module.js
import "./main.css"; |
Did you check out the example project? https://github.com/devongovett/rsp-next |
So, I could finally make the build work without errors after changing module.exports = {
plugins: [
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer')],
} However, it turns out that Any chance that the built-in CSS in Next will be supported by Spectrum in the near future? |
TBH I'm not sure what we could do about it. Next doesn't load CSS files from node_modules so I'm not sure how we're expected to distribute the styles or how that would play with other tools. The current recommendation in the docs is the best we could come up with after talking to the Next team without completely changing how we distribute the styles. If anyone has any better ideas we'd love to hear them though. 😄 |
@devongovett: please check related issue in tailwindcss: tailwindlabs/tailwindcss#2547 |
Importing css from 3rd party components is supported in Next v10: https://nextjs.org/blog/next-10#importing-css-from-third-party-react-components |
Hmm still can't import css from within node_modules though. I don't think we want to force people to manually import the css file for each component they use... |
No, that would be overcomplicated. Weird that it doesn't work from within node_modules... |
It's worth noting that asking users to import CSS for every component *is the approach that Reach UI takes, and it's not overly complicated (though there are comparatively fewer components). |
Using a Babel plugin may help here. Alternatively an approach like https://github.com/atlassian-labs/compiled might make sense? |
Agreed. Also you avoid importing CSS for components you never use. |
both nextjs and react spectrum are awesome but it sad they are not easy to use them together |
Hi, I'm running into this with a bare nextjs application, and I opened a issue in the example repo, so just wanted to reference here. Does anyone know if theres a work around? |
I was thinking maybe there's a way to ignore the css imports from webpack config side and then just import the styles manually. I don't know enough about webpack, does anyone with more web pack knowledge know a way for this to be possible? I tried https://webpack.js.org/plugins/ignore-plugin/ out but it didn't seem to work |
Hey I'm new to this, so forgive me for not completely understanding the problem but couldn't Spectrum just publish using CSS modules instead of global css? Or do the distributed version necessarily convert the modules into global css? |
Starting a new Typescript + Next.js (10.2.0) project and I've hit a brick wall with this too |
Hi, anyone came up with a solution? |
I've had this same issue. If anyone has a workaround, that would be great! |
FWIW -- i think i was able to get this running. according to this issue in next-transpile-modules, a fix shipped in 7.2. to get it to run without error, i had to do the following:
after that npm run dev loads the site. no idea if it's actually working though. i'm new to both nextjs and spectrum. Edit: yeah.... that got rid of the errors but it still doesn't work. There is a lengthy issue open at nextjs without any solutions too so... 🤷 In the meantime maybe docs could be updated to mention it only works with nextjs v9 and an explanation? AFAICT it's a nextjs issue not spectrum |
@cmawhorter did you do this in NextJS 10 or 11? |
@DaveStein pretty sure it was v10 |
Ah I'm on 11 so I'm scared to even try vs await what the maintainer says over at martpie/next-transpile-modules#222 |
Posting here for visibility, but it seems to be working with the config posted over at martpie/next-transpile-modules#222 (comment). Big thanks to @fabianishere and @DaveStein. next.config.js:
You may need to remove some of these if you're using an older version, or add some if new components become available. Hopefully we can update the docs and add an example pretty soon. |
A key thing for debugging in 222 was that using the error messages as normal,I was able to nail down all the |
It's not working for me. Spent two days already trying to get a large project to build. |
@sarnason I've got working examples at rsp-next-ts and rsp-next for reference. Both fresh from create-next-app. |
Thanks @reidbarber! I was able to find my problem by comparing the two. Turns out that using the nightly wasn't such a good idea. Shall I file a bug for it being broken? |
@sarnason Feel free to create one if you still have good details about the error you were getting |
🐛 Bug Report
The guide for setting up SSR configuration in NextJS doesn't work with its latest version.
🤔 Expected Behavior
No errors.
😯 Current Behavior
After following the guide: https://react-spectrum.adobe.com/react-spectrum/ssr.html#nextjs I'm getting an error:
Content of
postcss.config.js
:The
@zeit/next-css
plugin is considered to be obsolete according to: https://err.sh/next.js/built-in-css-disabledAfter removing
@zeit/next-css
plugin, I'm getting:💁 Possible Solution
The suggestion is that the maintainer should publish a compiled version of the dependency: https://github.com/vercel/next.js/blob/master/errors/css-npm.md
🌍 Your Environment
The text was updated successfully, but these errors were encountered: