-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Global CSS cannot be imported from within node_modules #146
Comments
I upgraded the library and now I'm getting another issue, I'll investigate more first, closing for now. |
I'm re-opening the issue, it is happening on v6 as well. |
Where are you trying to import this CSS? From a component or |
Hi @martpie I'm importing them from a component, it works fine importing them from |
|
What do you mean @martpie? Next.js supports css import from components since 9.5.4, see: https://nextjs.org/docs/basic-features/built-in-css-support#import-styles-from-node_modules |
Ah good to know, so it's on my side 👍 |
@samuelcastro @martpie from nextjs v10, nextjs stop support third 3rd like react-spectrum import css. I think we can close this issue or add a note in readme about this issue check out this issue in react-spectrum Workaround: use |
I don't think you're right @nhducit, Next.js still supports 3rd party css import, see: https://nextjs.org/docs/basic-features/built-in-css-support#import-styles-from-node_modules |
@samuelcastro you still can import 3rd css to
|
This is indeed a gray area and I am not 100% sure if adding/fixing that would not break some Next.js optimizations. I'd need to talk to Vercel a little bit. |
@martpie nextjs team drop support this import style and require ui libraries change the way their import component css
|
Do you have a link about that? What's the recommended way then? |
I'm using this workaround, use the old and deprecated withCSS plugin, combine with next transpile module https://github.com/devongovett/rsp-next/blob/master/next.config.js
|
@martpie checkout this link. This is the error when using react-spectrum with next.js v10
|
So right now I'm in a sabbatical, so open-source support is limited 😝 I will try to have a deeper look tomorrow. In general, if anyone has the time to work on anything on this project, there are two things you can help me with:
If you get lost in the codebase, or you are afraid to dive in, know that the first point is the best thing you can do, as it will probably save me 80% time. Cheers! |
Ok, So I've tested things a little bit:
So this is getting super weird and shady and I am still not sure if this is a bad or good idea to support this scenario. |
there are two more cases:
|
The first scenario never worked for me. ( |
FWIW I've given #166 a tryout on our large project and it's working great with global CSS in our internal modules. Appreciate the work on that - it's great to be able to ditch |
Thank you for testing the branch and confirming it was working for your use-case, I will try to complete it soon. |
@martpie Can I help You somehow with e.g. testing this feature? |
@karol-f if you can:
those two things would help a lot edit: it seems that my rebase with master broke it, so let me fix the checks first |
Use-case:
And the problem is that without e.g.
So basically P.S. I'll try to run and test the mentioned branch. Thank You for preparing that! |
Sorry, I was not precise enough:
Can you detail this in particular? Your setup, how your files are organized, are you using exactly the same convention as Next.js with |
@martpie Ok, I run some tests on My project folder structure is something like this:
Next.js app is one of a few that consume
As these components are used also in other apps that are non-next.js, the Example error on
Regards! |
Ok, so let's ignore
|
Workaround for now, if you are using something like styled components in packages consumed by Next, you can use something like this:
and
Works for me. |
Support for global CSS was added by @fabianishere in 7.2.0 🙌 |
Are you trying to transpile a local package or an npm package?
local package
Describe the bug
My transpiled UI library imports a css file from
react-datepicker
, and this is throwing an error which is described below. Next.js 10.x now supports the ability to import css from 3rd party modules without the need to include it in the_app.tsx
(https://nextjs.org/docs/basic-features/built-in-css-support#import-styles-from-node_modules).Initially I thought this was a bug on Next.js then I opened up this bug: vercel/next.js#19936, although @timneutkens suggested me that this might be a bug on this library instead.
This is the error I'm getting:
To Reproduce
Import a css in a transpiled library.
Expected behavior
Be able to import the css and successfully run the application.
Setup
next-transpile-modules
version: 6.0.0npm
/yarn
version: 1.22.4Any thoughts?
The text was updated successfully, but these errors were encountered: