Skip to content

Commit

Permalink
Add missing webpack exports
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tagliala committed Sep 1, 2024
1 parent 1801a04 commit f37df70
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
".": {
"types": "./public/types/src/index.d.ts",
"import": "./public/assets/scripts/choices.mjs",
"require": "./public/assets/scripts/choices.js"
"require": "./public/assets/scripts/choices.js",
"style": "./public/assets/styles/choices.css",
"sass": "./src/styles/choices.scss"
},
"./search-basic": {
"types": "./public/types/src/index.d.ts",
Expand All @@ -23,9 +25,15 @@
"types": "./public/types/src/index.d.ts",
"import": "./public/assets/scripts/choices.search-none.mjs",
"require": "./public/assets/scripts/choices.search-none.min.js"
}
},
"./public/assets/styles/*.css": "./public/assets/styles/*.css",
"./src/styles/*.scss": "./src/styles/*.scss",
"./src/styles/*": "./src/styles/*.scss"
},
"sideEffects": false,
"sideEffects": [
"*.scss",
"*.css"
],
"scripts": {
"start": "run-p js:watch css:watch",
"build": "run-p js:build css:build",
Expand Down

0 comments on commit f37df70

Please sign in to comment.