-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
ESM library generated with rollup-plugin-postcss throws Cannot find module '../node_modules/style-inject/dist/style-inject.es.js' #381
Comments
I've fixed this for our project by doing two things:
It works, but this seems like a hack for what should just work out of the box. Is there a reason for the relative import path to |
I'll raise a PR shortly |
We are experiencing this issue as well, and have probably a very similar solution to @mummybot. For anybody else that encounters this problem while it remains unsolved in this plugin, here was the custom inline-plugin we built:
|
Looks like somebody already created a PR in May, but some tests are failing. |
…ort for ESM libraries
Let's see if this gets reviewed and merged 🙏 |
We are also running into this issue. Would love to see this get merged in! Update: actually don't care if this gets merged in as we have found that style-inject has a flaw in that it will inject style tags in reverse order causing css priority issues. egoist/style-inject#23. The lib has also not been touched in 4 years, so don't expect any fixes to go in. Rollup should move away from depending on this lib. |
This is not a bug at all. It works properly because stylesInject is just a function from 'styles-inject' package, so we can allow it to be bundled. But it is not bundled because most likely you have this setting in your rollup.config.js:
So, replace it with a code bellow and it will work:
also, you can write a regexp for it instead |
The above answer is incorrect since it's assuming you do want to bundle everything together. When you are generating a library with preserved modules, the nasty |
If you do want to abide for the way rollup decided to implement this, you can "force" NPM to pack the nested modules by adding the folder explicitly on your "files": [
"dist/*",
"dist/node_modules/*"
], |
Has this been resolved? I got this issue too |
As a dependency , |
Is there any update on this? I'm running the same issue |
Any update here? I have the same issue. Thanks, |
This helped me out, thanks to @dandrewgarvin !
|
Apologies if this is more of a usage question than a bug, I have posted here at Stackoverflow.
We are maintaining an internal library which is exporting ESM modules using Rollup. We have just recently switched to using CSS modules, which we have set with rollup-plugin-postcss. We want to inject these styles into the head rather than have an external file.
Our built bundle generates the ESM file with:
Our consuming library then fails with
Uncaught Error: Cannot find module '../node_modules/style-inject/dist/style-inject.es.js'
I would expect the ESM export to
import styleInject from 'style-inject'
and style-inject to be included in the package-lock.json as a dependency. Even manually adding the dependency as part of our library which then includes it in the consuming app doesn't allow it to resolve. What is the correct way of using CSS Modules and injecting into the head for the consumer of a library?rollup.config.js
The text was updated successfully, but these errors were encountered: