-
Notifications
You must be signed in to change notification settings - Fork 608
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
[v11] missing style
package export for webpack based asset pipelines
#1184
Comments
styles
package exportstyle
package export
style
package exportstyle
package export for webpack based asset pipelines
style
package export for webpack based asset pipelinesstyle
package export for webpack based asset pipelines
Mimic FontAwesome's package.json Close Choices-js#1184
Mimic FontAwesome's package.json Close Choices-js#1184
Mimic FontAwesome's `package.json`. - Add `style` package export - Add `styles.scss` and `styles` exports - Add `styles.scss` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import the style with the following approaches: ```scss @import "choices.js"; @import "choices.js/styles"; @import "choices.js/styles.scss"; ``` Refs: - https://webpack.js.org/guides/package-exports/ - FortAwesome/Font-Awesome#18654 Close Choices-js#1184
Hello, unfortunately this does not work with my specific use case, but I can also see that fontawesome's package.json contains I've tried
And the error is always the same
Back in 2022, when Font Awesome 6 was released, we had to deal with a lot of use cases and asset pipelines. I can still provide a script to create a reproducible test case, but that would be specific to Rails, Ruby, webpack, shakapacker. Let me know if it is the case However, according to our finding back at the times, the following commit should contain all the necessary parts to make webpack work and prevent tree-shaking issues: Please also check the side effects |
Can you try using the following syntax against the proposed PR?
The |
Hi,
I do have those, but using Ref: https://webpack.js.org/loaders/sass-loader/#resolving-import-at-rules
Ref: diowa/ruby3-rails6-bootstrap-heroku@370f749 I've get rid of all Unfortunately we had a lot of struggles with Said so, I will provide you the script that I've used in Font Awesome when we had to deal with this EDIT: sorry, I've seen the |
Mimic FontAwesome's `package.json`. - Add `style` package export for webpack - Add `sass` package export for webpack - Add `styles.css` and `styles` exports for main CSS file - Add `*.scss` and `*.css` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import the style with the following approaches: ```css @import "choices.js"; @import "choices.js/styles"; @import "choices.js/styles.css"; ``` ```scss @import "choices.js"; ``` Refs: - https://webpack.js.org/guides/package-exports/ - FortAwesome/Font-Awesome#18654 Close Choices-js#1184
@tagliala Can you create a PR for your requested changes? |
@Xon Yes I can, I'm now investigating also |
WORK IN PROGRESSTools and versions required to replicate
Actual behaviorWhen updating from Choices.js 10 to Choices.js 11, shakapacker is not able
This is due to the new How to reproduceInitial apprails _7.2.1_ new test-choices-package-exports --skip-active-record --skip-javascript --skip-git --skip-test
cd test-choices-package-exports
echo "{ \"private\": true, \"packageManager\": \"npm@10.8.2\" }" > package.json
echo "gem 'shakapacker', '8.0.2'" >> Gemfile
bundle
rails shakapacker:install
npm add css-loader style-loader mini-css-extract-plugin css-minimizer-webpack-plugin
npm add choices.js@10.2.0
echo "module.exports = { plugins: [require('postcss-import')] }" > postcss.config.js
git add .
git commit -am "First commit"
git branch tests/scss main
git branch tests/css main CSS import from javascript
Error:
Sass
Error:
CauseThe cause is the new Suggested solutionhttps://github.com/ifad/Choices/tree/bugfix/style-export
Details are in the commit message Ref: https://webpack.js.org/guides/package-exports/#reference-syntax |
Mimic FontAwesome's `package.json`. - Add `style` package export for webpack - Add `sass` package export for webpack - Add `styles.css` and `styles` exports for main CSS file - Add `*.scss` and `*.css` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import the style with the following approaches: ```css @import "choices.js"; @import "choices.js/styles"; @import "choices.js/styles.css"; ``` ```scss @import "choices.js"; ``` Refs: - https://webpack.js.org/guides/package-exports/ - FortAwesome/Font-Awesome#18654 Close Choices-js#1184
Mimic FontAwesome's `package.json` to improve compatibility with webpack - Add `style` package export to allow main CSS import from JavaScript - Add `sass` package export to allow - Add `styles.css` and `styles` exports for main CSS file - Add `*.scss` and `*.css` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import the style with the following approaches: ```js import "choices.js"; import "choices.js/styles"; import "choices.js/styles.css"; ``` ```scss @import "choices.js"; ``` Refs: - https://webpack.js.org/guides/package-exports/ - FortAwesome/Font-Awesome#18654 Close Choices-js#1184
Add some entries to `package.json` to improve compatibility with webpack - Add `style` package export to allow main CSS import from JavaScript - Add `sass` package export to allow - Add `styles.css` and `styles` exports for main CSS file - Add `*.scss` and `*.css` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import the style with the following approaches: ```js import "choices.js"; import "choices.js/styles"; ``` ```scss @import "choices.js/scss/styles"; ``` I was expecting that `@import "choices.js";` in scss would have imported the Scss file, but it is not the case. It is taking the CSS. Refs: - https://webpack.js.org/guides/package-exports/ Close Choices-js#1184
Add some entries to `package.json` to improve compatibility with webpack - Add default `style` and `sass` exports as per webpack requirements - Add `styles/*` exports for CSS files - Add `scss/styles/*` exports for Scss files - Add `*.scss` and `*.css` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import the style with the following approaches: ```js import "choices.js/styles/choices.css"; // CSS import "choices.js/scss/styles/choices.scss"; // Scss ``` ```scss @import "choices.js/scss/styles/choices"; ``` Refs: - https://webpack.js.org/guides/package-exports/ Close Choices-js#1184
Add some entries to `package.json` to improve compatibility with webpack - Add default `style` and `sass` exports as per webpack requirements - Add `public/assets/styles/*` exports for CSS files - Add `src/styles/*` exports for Scss files. Extension can be omitted to prevent linting issues with `stylelint` - Add `*.scss` and `*.css` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import styles with the same syntax of v10 to prevent a breaking change in webpack based applications Refs: - https://webpack.js.org/guides/package-exports/ - Close Choices-js#1184
Describe the bug
Hello, I'm trying to upgrade a working app using shakapacker (a pre-processor based on webpack) to Choices v11 but I'm getting an error related to scss import
When updating from Choices.js 10 to Choices.js 11, shakapacker is not able
to resolve
@import "choices.js/src/styles/choices";
in Scssimport "choices.js/public/assets/styles/choices.css";
in JSThis is due to the new
exports
entry inpackage.json
, which requirespecific entries for webpack, such as
style
To Reproduce
Tools and versions required to replicate
Initial app
CSS import from JavaScript
Error:
Sass
Error:
Suggested solution
https://github.com/ifad/Choices/tree/bugfix/style-export
npm add choices.js@ifad/choices#bugfix/style-export
bin/shakapacker
Details are in the commit message
Ref: https://webpack.js.org/guides/package-exports/#reference-syntax
The text was updated successfully, but these errors were encountered: