From 5721e9a9aeb9be017e5dc73341aad2ae9aaad4c4 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 1 Sep 2024 10:45:59 +0200 Subject: [PATCH] Add missing webpack exports 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/ - https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-import-partial-extension/README.md Close #1184 --- package.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 78e95445..324f3a60 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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",