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
Package path ./dist/slimselect.css is not exported from package "\node_modules\slim-select\package.json"" #269
Comments
Are you using Webpack 5? This seems to be the root cause: webpack/webpack#9509 A new release is needed where the package.json also exposes the css files as "exported" |
except using copy-webpack-plugin i couldn't find any other way around it |
i have this problem to, css are not loaded with js, the slim select are not styled.
no way neither to import the scss from my sass files
i tried to modify the slim-select package.json without success so far "exports": {
".":{
"require": "./dist/slimselect.min.js",
"import": "./dist/slimselect.min.mjs"
},
"style": "./dist/slimselect.min.css",
"sass": "./src/slim-select/slimselect.scss",
"./src/": "./src/",
"./dist/": "./dist/"
} |
could you elaborate on your solution with copy-webpack-plugin please ? |
with "exports": {
".":{
"require": "./dist/slimselect.min.js",
"import": "./dist/slimselect.min.mjs"
},
"./slimselect.min.css": {
"require": "./dist/slimselect.min.css",
"import": "./dist/slimselect.min.css"
}
} i can import css from main.js |
I removed exports key from slim-select package.json, and it works |
remove exports section from slim-select package.json |
I have been testing a global export from From https://webpack.js.org/guides/package-exports/
This fixes the broken imports from scss files
I can open a PR if this is an acceptable fix. |
I suppose i dont fully follow the issue. Why do most other people not have this issue? Do you have an example comparison of another package that i can look at for reference? |
I encountered the issue only when I upgraded my toolchain to webpack 5 and upgraded Slim Select to 1.27.0 from 1.26.0. It's mentioned in the issue on webpack's repo (linked above in stepha-lacatus's comment) webpack/webpack#9509 (comment)
So the combination of adding the exports field in v1.27 and upgrading webpack caused it for me. I downgraded to v1.26 until I had time to look closer. For what it's worth bachy's solution didn't work for my use case. Based on the docs here https://webpack.js.org/guides/package-exports/#reference-syntax maybe it would have worked if I added I had a look around at a few open source repos and I'm struggling to find any that have |
@brianvoe While trying to resolve a webpack build issue in an unrelated package, I encountered the same CSS "is not exported from package" error. In case it's helpful, here's the background: I ended up going with: "./": "./dist/" because the resulting @timdk Thanks for the code! |
I just made a symlink: After that you can |
New update coming soon. Not sure if this is still an issue but if it pops up again after the update we can reopen this. |
yes. still an issue. specifically with webpack 5. without proper |
All the build process stuff is the most frustrating thing in the world. Please submit a pr and ill merge it in if you think you have an update that will help "fix" this |
indeed it is. i'll see what i can do. for everybody else i guess it's something similar to hotwired/stimulus#569. only need to figure out how to treat all the other exports... |
I found a workaround for this, by doing the import in a |
|
In case someone else lands here with this issue while migrating from some older version to this or from lack of documentation on this particular part. Code I added here seems to have been added in v2.5.1 so make sure to have at least that version 6dbd0b5 I'm using latest (as of now) v2.6.0 and I managed to import styles using this import statement: import "slim-select/styles"; Discovered this by checking out the package.json for this project and exports field declares this: "exports": {
".": {
"require": "./dist/slimselect.umd.js",
"import": "./dist/slimselect.es.js"
},
"./styles": "./dist/slimselect.css"
}, So doing |
No description provided.
The text was updated successfully, but these errors were encountered: