css-loader 6.8.0 → 6.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1538,7 +1538,7 @@ import "./styles.css";
1538
1538
 
1539
1539
  > **Warning**
1540
1540
  >
1541
- > The `esModules` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1541
+ > The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1542
1542
 
1543
1543
  The default export is `string`.
1544
1544
 
@@ -1577,7 +1577,7 @@ console.log(sheet);
1577
1577
 
1578
1578
  > **Warning**
1579
1579
  >
1580
- > The `esModules` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1580
+ > The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1581
1581
 
1582
1582
  > **Warning**
1583
1583
  >
@@ -1688,7 +1688,7 @@ module.exports = {
1688
1688
 
1689
1689
  For `production` builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
1690
1690
  This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin), because it creates separate css files.
1691
- For `development` mode (including `webpack-dev-server`) you can use [style-loader](https://github.com/webpack-contrib/style-loader), because it injects CSS into the DOM using multiple <style></style> and works faster.
1691
+ For `development` mode (including `webpack-dev-server`) you can use [style-loader](https://github.com/webpack-contrib/style-loader), because it injects CSS into the DOM using multiple `<style></style>` and works faster.
1692
1692
 
1693
1693
  > **Note**
1694
1694
  >
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
19
  async function loader(content, map, meta) {
20
20
  const rawOptions = this.getOptions(_options.default);
21
21
  const callback = this.async();
22
- if (this._compiler && this._compiler.options && this._compiler.options.experiments && this._compiler.options.experiments.css && this._module && this._module.type === "css") {
22
+ if (this._compiler && this._compiler.options && this._compiler.options.experiments && this._compiler.options.experiments.css && this._module && (this._module.type === "css" || this._module.type === "css/auto" || this._module.type === "css/global" || this._module.type === "css/module")) {
23
23
  this.emitWarning(new Error('You can\'t use `experiments.css` (`experiments.futureDefaults` enable built-in CSS support by default) and `css-loader` together, please set `experiments.css` to `false` or set `{ type: "javascript/auto" }` for rules with `css-loader` in your webpack config (now css-loader does nothing).'));
24
24
  callback(null, content, map, meta);
25
25
  return;
@@ -79,7 +79,6 @@ async function loader(content, map, meta) {
79
79
  // Support data urls as input in new URL added in webpack@5.38.0
80
80
  }));
81
81
  }
82
-
83
82
  const icssPluginImports = [];
84
83
  const icssPluginApi = [];
85
84
  const needToUseIcssPlugin = (0, _utils.shouldUseIcssPlugin)(options);
@@ -110,5 +110,4 @@ const plugin = (options = {}) => {
110
110
  };
111
111
  };
112
112
  plugin.postcss = true;
113
- var _default = plugin;
114
- exports.default = _default;
113
+ var _default = exports.default = plugin;
@@ -279,5 +279,4 @@ const plugin = (options = {}) => {
279
279
  };
280
280
  };
281
281
  plugin.postcss = true;
282
- var _default = plugin;
283
- exports.default = _default;
282
+ var _default = exports.default = plugin;
@@ -353,5 +353,4 @@ const plugin = (options = {}) => {
353
353
  };
354
354
  };
355
355
  plugin.postcss = true;
356
- var _default = plugin;
357
- exports.default = _default;
356
+ var _default = exports.default = plugin;
package/dist/utils.js CHANGED
@@ -41,8 +41,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
41
41
  Author Tobias Koppers @sokra
42
42
  */
43
43
 
44
- const WEBPACK_IGNORE_COMMENT_REGEXP = /webpackIgnore:(\s+)?(true|false)/;
45
- exports.WEBPACK_IGNORE_COMMENT_REGEXP = WEBPACK_IGNORE_COMMENT_REGEXP;
44
+ const WEBPACK_IGNORE_COMMENT_REGEXP = exports.WEBPACK_IGNORE_COMMENT_REGEXP = /webpackIgnore:(\s+)?(true|false)/;
46
45
  const matchRelativePath = /^\.\.?[/\\]/;
47
46
  function isAbsolutePath(str) {
48
47
  return _path.default.posix.isAbsolute(str) || _path.default.win32.isAbsolute(str);
@@ -545,7 +544,7 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
545
544
  }
546
545
  if (needNamedExport) {
547
546
  if (rawOptions.esModule === false) {
548
- throw new Error("The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModules' option to be enabled");
547
+ throw new Error("The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModule' option to be enabled");
549
548
  }
550
549
  if (modulesOptions.namedExport === false) {
551
550
  throw new Error("The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'modules.namedExport' option to be enabled");
@@ -553,7 +552,7 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
553
552
  }
554
553
  if (modulesOptions.namedExport === true) {
555
554
  if (rawOptions.esModule === false) {
556
- throw new Error("The 'modules.namedExport' option requires the 'esModules' option to be enabled");
555
+ throw new Error("The 'modules.namedExport' option requires the 'esModule' option to be enabled");
557
556
  }
558
557
  if (typeof exportLocalsConventionType === "string" && exportLocalsConventionType !== "camelCaseOnly" && exportLocalsConventionType !== "dashesOnly") {
559
558
  throw new Error('The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly" or "dashesOnly"');
@@ -619,7 +618,7 @@ function getModulesPlugins(options, loaderContext) {
619
618
  plugins = [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
620
619
  mode
621
620
  }), (0, _postcssModulesExtractImports.default)(), (0, _postcssModulesScope.default)({
622
- generateScopedName(exportName) {
621
+ generateScopedName(exportName, resourceFile, rawCss, node) {
623
622
  let localIdent;
624
623
  if (typeof getLocalIdent !== "undefined") {
625
624
  localIdent = getLocalIdent(loaderContext, localIdentName, unescape(exportName), {
@@ -629,7 +628,8 @@ function getModulesPlugins(options, loaderContext) {
629
628
  hashDigest: localIdentHashDigest,
630
629
  hashDigestLength: localIdentHashDigestLength,
631
630
  hashStrategy,
632
- regExp: localIdentRegExp
631
+ regExp: localIdentRegExp,
632
+ node
633
633
  });
634
634
  }
635
635
 
@@ -643,7 +643,8 @@ function getModulesPlugins(options, loaderContext) {
643
643
  hashDigest: localIdentHashDigest,
644
644
  hashDigestLength: localIdentHashDigestLength,
645
645
  hashStrategy,
646
- regExp: localIdentRegExp
646
+ regExp: localIdentRegExp,
647
+ node
647
648
  });
648
649
  return escapeLocalIdent(localIdent).replace(/\\\[local\\]/gi, exportName);
649
650
  }
@@ -1009,37 +1010,41 @@ function combineRequests(preRequest, url) {
1009
1010
  const idx = url.indexOf("!=!");
1010
1011
  return idx !== -1 ? url.slice(0, idx + 3) + preRequest + url.slice(idx + 3) : preRequest + url;
1011
1012
  }
1012
- function warningFactory(obj) {
1013
+ function warningFactory(warning) {
1013
1014
  let message = "";
1014
- if (typeof obj.line !== "undefined") {
1015
- message += `(${obj.line}:${obj.column}) `;
1015
+ if (typeof warning.line !== "undefined") {
1016
+ message += `(${warning.line}:${warning.column}) `;
1016
1017
  }
1017
- if (typeof obj.plugin !== "undefined") {
1018
- message += `from "${obj.plugin}" plugin: `;
1018
+ if (typeof warning.plugin !== "undefined") {
1019
+ message += `from "${warning.plugin}" plugin: `;
1019
1020
  }
1020
- message += obj.text;
1021
- if (obj.node) {
1022
- message += `\n\nCode:\n ${obj.node.toString()}\n`;
1021
+ message += warning.text;
1022
+ if (warning.node) {
1023
+ message += `\n\nCode:\n ${warning.node.toString()}\n`;
1023
1024
  }
1024
- const warning = new Error(message);
1025
- warning.stack = null;
1026
- return warning;
1025
+ const obj = new Error(message, {
1026
+ cause: warning
1027
+ });
1028
+ obj.stack = null;
1029
+ return obj;
1027
1030
  }
1028
- function syntaxErrorFactory(obj) {
1031
+ function syntaxErrorFactory(error) {
1029
1032
  let message = "\nSyntaxError\n\n";
1030
- if (typeof obj.line !== "undefined") {
1031
- message += `(${obj.line}:${obj.column}) `;
1033
+ if (typeof error.line !== "undefined") {
1034
+ message += `(${error.line}:${error.column}) `;
1032
1035
  }
1033
- if (typeof obj.plugin !== "undefined") {
1034
- message += `from "${obj.plugin}" plugin: `;
1036
+ if (typeof error.plugin !== "undefined") {
1037
+ message += `from "${error.plugin}" plugin: `;
1035
1038
  }
1036
- message += obj.file ? `${obj.file} ` : "<css input> ";
1037
- message += `${obj.reason}`;
1038
- const code = obj.showSourceCode();
1039
+ message += error.file ? `${error.file} ` : "<css input> ";
1040
+ message += `${error.reason}`;
1041
+ const code = error.showSourceCode();
1039
1042
  if (code) {
1040
1043
  message += `\n\n${code}\n`;
1041
1044
  }
1042
- const error = new Error(message);
1043
- error.stack = null;
1044
- return error;
1045
+ const obj = new Error(message, {
1046
+ cause: error
1047
+ });
1048
+ obj.stack = null;
1049
+ return obj;
1045
1050
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "6.8.0",
3
+ "version": "6.9.0",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/css-loader",
@@ -47,44 +47,44 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "icss-utils": "^5.1.0",
50
- "postcss": "^8.4.21",
50
+ "postcss": "^8.4.31",
51
51
  "postcss-modules-extract-imports": "^3.0.0",
52
52
  "postcss-modules-local-by-default": "^4.0.3",
53
- "postcss-modules-scope": "^3.0.0",
53
+ "postcss-modules-scope": "^3.1.0",
54
54
  "postcss-modules-values": "^4.0.0",
55
55
  "postcss-value-parser": "^4.2.0",
56
- "semver": "^7.3.8"
56
+ "semver": "^7.5.4"
57
57
  },
58
58
  "devDependencies": {
59
- "@babel/cli": "^7.21.0",
60
- "@babel/core": "^7.21.4",
61
- "@babel/preset-env": "^7.21.4",
59
+ "@babel/cli": "^7.23.4",
60
+ "@babel/core": "^7.23.7",
61
+ "@babel/preset-env": "^7.23.7",
62
62
  "@commitlint/cli": "^16.3.0",
63
63
  "@commitlint/config-conventional": "^16.2.4",
64
64
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
65
65
  "babel-jest": "^28.1.3",
66
66
  "cross-env": "^7.0.3",
67
- "cspell": "^6.31.1",
67
+ "cspell": "^6.31.2",
68
68
  "del": "^6.1.1",
69
69
  "del-cli": "^4.0.1",
70
70
  "es-check": "^7.1.0",
71
- "eslint": "^8.37.0",
72
- "eslint-config-prettier": "^8.8.0",
73
- "eslint-plugin-import": "^2.27.5",
71
+ "eslint": "^8.54.0",
72
+ "eslint-config-prettier": "^8.9.0",
73
+ "eslint-plugin-import": "^2.29.0",
74
74
  "file-loader": "^6.2.0",
75
75
  "husky": "^7.0.1",
76
76
  "jest": "^28.1.3",
77
77
  "jest-environment-jsdom": "^28.1.3",
78
- "less": "^4.1.3",
78
+ "less": "^4.2.0",
79
79
  "less-loader": "^10.0.1",
80
80
  "lint-staged": "^12.5.0",
81
- "memfs": "^3.4.13",
81
+ "memfs": "^3.5.3",
82
82
  "mini-css-extract-plugin": "^2.7.5",
83
83
  "npm-run-all": "^4.1.5",
84
84
  "postcss-loader": "^6.2.1",
85
85
  "postcss-preset-env": "^7.8.3",
86
86
  "prettier": "^2.8.7",
87
- "sass": "^1.60.0",
87
+ "sass": "^1.69.7",
88
88
  "sass-loader": "^12.6.0",
89
89
  "standard-version": "^9.5.0",
90
90
  "strip-ansi": "^6.0.0",
@@ -92,7 +92,7 @@
92
92
  "stylus": "^0.59.0",
93
93
  "stylus-loader": "^6.1.0",
94
94
  "url-loader": "^4.1.1",
95
- "webpack": "^5.77.0"
95
+ "webpack": "^5.89.0"
96
96
  },
97
97
  "keywords": [
98
98
  "webpack",