css-loader 7.1.1 → 7.1.2

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/dist/index.js CHANGED
@@ -148,20 +148,7 @@ async function loader(content, map, meta) {
148
148
  });
149
149
  }
150
150
  }
151
- let isTemplateLiteralSupported = false;
152
- if (
153
- // eslint-disable-next-line no-underscore-dangle
154
- this._compilation &&
155
- // eslint-disable-next-line no-underscore-dangle
156
- this._compilation.options &&
157
- // eslint-disable-next-line no-underscore-dangle
158
- this._compilation.options.output &&
159
- // eslint-disable-next-line no-underscore-dangle
160
- this._compilation.options.output.environment &&
161
- // eslint-disable-next-line no-underscore-dangle
162
- this._compilation.options.output.environment.templateLiteral) {
163
- isTemplateLiteralSupported = true;
164
- }
151
+ const isTemplateLiteralSupported = (0, _utils.supportTemplateLiteral)(this);
165
152
  const importCode = (0, _utils.getImportCode)(imports, options);
166
153
  let moduleCode;
167
154
  try {
@@ -7,25 +7,32 @@ exports.default = void 0;
7
7
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
8
  var _utils = require("../utils");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- function parseNode(atRule, key, options) {
11
- // Convert only top-level @import
12
- if (atRule.parent.type !== "root") {
13
- return;
14
- }
10
+ function isIgnoredAfterName(atRule) {
15
11
  if (atRule.raws && atRule.raws.afterName && atRule.raws.afterName.trim().length > 0) {
16
12
  const lastCommentIndex = atRule.raws.afterName.lastIndexOf("/*");
17
13
  const matched = atRule.raws.afterName.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
18
14
  if (matched && matched[2] === "true") {
19
- return;
15
+ return true;
20
16
  }
21
17
  }
18
+ return false;
19
+ }
20
+ function isIgnoredPrevNode(atRule) {
22
21
  const prevNode = atRule.prev();
23
22
  if (prevNode && prevNode.type === "comment") {
24
23
  const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
25
24
  if (matched && matched[2] === "true") {
26
- return;
25
+ return true;
27
26
  }
28
27
  }
28
+ return false;
29
+ }
30
+ function parseNode(atRule, key, options) {
31
+ // Convert only top-level @import
32
+ if (atRule.parent.type !== "root") {
33
+ return;
34
+ }
35
+ const isIgnored = isIgnoredAfterName(atRule) || isIgnoredPrevNode(atRule);
29
36
 
30
37
  // Nodes do not exists - `@import url('http://') :root {}`
31
38
  if (atRule.nodes) {
@@ -61,10 +68,14 @@ function parseNode(atRule, key, options) {
61
68
  url = isStringValue ? paramsNodes[0].nodes[0].value : _postcssValueParser.default.stringify(paramsNodes[0].nodes);
62
69
  }
63
70
  url = (0, _utils.normalizeUrl)(url, isStringValue);
64
- const {
65
- requestable,
66
- needResolve
67
- } = (0, _utils.isURLRequestable)(url, options);
71
+ let requestable = false;
72
+ let needResolve = false;
73
+ if (!isIgnored) {
74
+ ({
75
+ requestable,
76
+ needResolve
77
+ } = (0, _utils.isURLRequestable)(url, options));
78
+ }
68
79
  let prefix;
69
80
  if (requestable && needResolve) {
70
81
  const queryParts = url.split("!");
package/dist/utils.js CHANGED
@@ -27,6 +27,7 @@ exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
27
27
  exports.shouldUseURLPlugin = shouldUseURLPlugin;
28
28
  exports.sort = sort;
29
29
  exports.stringifyRequest = stringifyRequest;
30
+ exports.supportTemplateLiteral = supportTemplateLiteral;
30
31
  exports.syntaxErrorFactory = syntaxErrorFactory;
31
32
  exports.warningFactory = warningFactory;
32
33
  var _url = require("url");
@@ -1033,4 +1034,25 @@ function syntaxErrorFactory(error) {
1033
1034
  });
1034
1035
  obj.stack = null;
1035
1036
  return obj;
1037
+ }
1038
+ function supportTemplateLiteral(loaderContext) {
1039
+ if (loaderContext.environment && loaderContext.environment.templateLiteral) {
1040
+ return true;
1041
+ }
1042
+
1043
+ // TODO remove in the next major release
1044
+ if (
1045
+ // eslint-disable-next-line no-underscore-dangle
1046
+ loaderContext._compilation &&
1047
+ // eslint-disable-next-line no-underscore-dangle
1048
+ loaderContext._compilation.options &&
1049
+ // eslint-disable-next-line no-underscore-dangle
1050
+ loaderContext._compilation.options.output &&
1051
+ // eslint-disable-next-line no-underscore-dangle
1052
+ loaderContext._compilation.options.output.environment &&
1053
+ // eslint-disable-next-line no-underscore-dangle
1054
+ loaderContext._compilation.options.output.environment.templateLiteral) {
1055
+ return true;
1056
+ }
1057
+ return false;
1036
1058
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/css-loader",
@@ -65,15 +65,15 @@
65
65
  "semver": "^7.5.4"
66
66
  },
67
67
  "devDependencies": {
68
- "@babel/cli": "^7.23.4",
69
- "@babel/core": "^7.23.7",
70
- "@babel/preset-env": "^7.23.7",
71
- "@commitlint/cli": "^19.2.1",
72
- "@commitlint/config-conventional": "^19.1.0",
68
+ "@babel/cli": "^7.24.5",
69
+ "@babel/core": "^7.24.5",
70
+ "@babel/preset-env": "^7.24.5",
71
+ "@commitlint/cli": "^19.3.0",
72
+ "@commitlint/config-conventional": "^19.2.2",
73
73
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
74
74
  "babel-jest": "^29.7.0",
75
75
  "cross-env": "^7.0.3",
76
- "cspell": "^8.6.1",
76
+ "cspell": "^8.7.0",
77
77
  "del-cli": "^5.1.0",
78
78
  "es-check": "^7.1.0",
79
79
  "eslint": "^8.54.0",
@@ -86,14 +86,14 @@
86
86
  "less": "^4.2.0",
87
87
  "less-loader": "^12.2.0",
88
88
  "lint-staged": "^15.2.2",
89
- "memfs": "^4.8.1",
90
- "mini-css-extract-plugin": "^2.7.5",
89
+ "memfs": "^4.9.2",
90
+ "mini-css-extract-plugin": "^2.9.0",
91
91
  "npm-run-all": "^4.1.5",
92
92
  "postcss-loader": "^8.1.1",
93
- "postcss-preset-env": "^9.5.4",
93
+ "postcss-preset-env": "^9.5.9",
94
94
  "prettier": "^3.2.5",
95
- "sass": "^1.69.7",
96
- "sass-loader": "^14.1.1",
95
+ "sass": "^1.76.0",
96
+ "sass-loader": "^14.2.1",
97
97
  "standard-version": "^9.5.0",
98
98
  "strip-ansi": "^6.0.0",
99
99
  "style-loader": "^3.3.4",