css-loader 5.1.0 → 5.1.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [5.1.4](https://github.com/webpack-contrib/css-loader/compare/v5.1.3...v5.1.4) (2021-03-24)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * crash with thread-loader ([#1281](https://github.com/webpack-contrib/css-loader/issues/1281)) ([7095a7c](https://github.com/webpack-contrib/css-loader/commit/7095a7ca7d985d5447aed80cf3e41a4f8c19b954))
11
+
12
+ ### [5.1.3](https://github.com/webpack-contrib/css-loader/compare/v5.1.2...v5.1.3) (2021-03-15)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * the `auto` option works using inline module syntax ([#1274](https://github.com/webpack-contrib/css-loader/issues/1274)) ([1db2f4d](https://github.com/webpack-contrib/css-loader/commit/1db2f4df3ff9ae8f0667a2304853c8e7cdd0afc1))
18
+ * ident generation for CSS modules using inline module syntax ([#1274](https://github.com/webpack-contrib/css-loader/issues/1274)) ([1db2f4d](https://github.com/webpack-contrib/css-loader/commit/1db2f4df3ff9ae8f0667a2304853c8e7cdd0afc1))
19
+
20
+ ### [5.1.2](https://github.com/webpack-contrib/css-loader/compare/v5.1.1...v5.1.2) (2021-03-10)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * handling `@import` with spaces before and after and any extensions ([#1272](https://github.com/webpack-contrib/css-loader/issues/1272)) ([0c47cf7](https://github.com/webpack-contrib/css-loader/commit/0c47cf7ccbe3635900e8e8840650f69a7eca004d))
26
+ * inline loader syntax in `@import` and modules ([3f49ed0](https://github.com/webpack-contrib/css-loader/commit/3f49ed0864457f9467f560856377c890c392aee7))
27
+
28
+ ### [5.1.1](https://github.com/webpack-contrib/css-loader/compare/v5.1.0...v5.1.1) (2021-03-01)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * crash on modified AST from `postcss-loader` ([#1268](https://github.com/webpack-contrib/css-loader/issues/1268)) ([d2a1a84](https://github.com/webpack-contrib/css-loader/commit/d2a1a84afc63fdfb2a4ce6668ed9f2d7f1ba56ca))
34
+
5
35
  ## [5.1.0](https://github.com/webpack-contrib/css-loader/compare/v5.0.2...v5.1.0) (2021-02-25)
6
36
 
7
37
 
package/dist/index.js CHANGED
@@ -63,8 +63,7 @@ async function loader(content, map, meta) {
63
63
  conditionNames: ["style"],
64
64
  extensions: [".css"],
65
65
  mainFields: ["css", "style", "main", "..."],
66
- mainFiles: ["index", "..."],
67
- restrictions: [/\.css$/i]
66
+ mainFiles: ["index", "..."]
68
67
  });
69
68
  plugins.push((0, _plugins.importParser)({
70
69
  imports: importPluginImports,
@@ -73,7 +72,7 @@ async function loader(content, map, meta) {
73
72
  rootContext: this.rootContext,
74
73
  filter: (0, _utils.getFilter)(options.import, this.resourcePath),
75
74
  resolver,
76
- urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, (0, _utils.getPreRequester)(this)(options.importLoaders) + url)
75
+ urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, (0, _utils.combineRequests)((0, _utils.getPreRequester)(this)(options.importLoaders), url))
77
76
  }));
78
77
  }
79
78
 
@@ -115,7 +114,7 @@ async function loader(content, map, meta) {
115
114
  context: this.context,
116
115
  rootContext: this.rootContext,
117
116
  resolver: icssResolver,
118
- urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, (0, _utils.getPreRequester)(this)(options.importLoaders) + url)
117
+ urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, (0, _utils.combineRequests)((0, _utils.getPreRequester)(this)(options.importLoaders), url))
119
118
  }));
120
119
  } // Reuse CSS AST (PostCSS AST e.g 'postcss-loader') to avoid reparsing
121
120
 
@@ -17,7 +17,7 @@ function visitor(result, parsedResults, node, key) {
17
17
  return;
18
18
  }
19
19
 
20
- if (node.raws.afterName && node.raws.afterName.trim().length > 0) {
20
+ if (node.raws && node.raws.afterName && node.raws.afterName.trim().length > 0) {
21
21
  const lastCommentIndex = node.raws.afterName.lastIndexOf("/*");
22
22
  const matched = node.raws.afterName.slice(lastCommentIndex).match(_utils.webpackIgnoreCommentRegexp);
23
23
 
@@ -70,10 +70,10 @@ function visitor(result, parsedResults, node, key) {
70
70
  return;
71
71
  }
72
72
 
73
- const parsed = (0, _postcssValueParser.default)(typeof node.raws.value === "undefined" ? node[key] : node.raws.value.raw);
73
+ const parsed = (0, _postcssValueParser.default)(node.raws && node.raws.value && node.raws.value.raw ? node.raws.value.raw : node[key]);
74
74
  let inBetween;
75
75
 
76
- if (typeof node.raws.between !== "undefined") {
76
+ if (node.raws && node.raws.between) {
77
77
  const lastCommentIndex = node.raws.between.lastIndexOf("/*");
78
78
  const matched = node.raws.between.slice(lastCommentIndex).match(_utils.webpackIgnoreCommentRegexp);
79
79
 
package/dist/utils.js CHANGED
@@ -21,6 +21,7 @@ exports.getExportCode = getExportCode;
21
21
  exports.resolveRequests = resolveRequests;
22
22
  exports.isUrlRequestable = isUrlRequestable;
23
23
  exports.sort = sort;
24
+ exports.combineRequests = combineRequests;
24
25
  exports.webpackIgnoreCommentRegexp = void 0;
25
26
 
26
27
  var _url = require("url");
@@ -86,21 +87,21 @@ function escapeLocalIdent(localident) {
86
87
  }
87
88
 
88
89
  function defaultGetLocalIdent(loaderContext, localIdentName, localName, options) {
89
- const {
90
- context,
91
- hashPrefix
92
- } = options;
93
- const {
94
- resourcePath
95
- } = loaderContext;
96
- const request = normalizePath(_path.default.relative(context, resourcePath)); // eslint-disable-next-line no-param-reassign
90
+ let relativeMatchResource = ""; // eslint-disable-next-line no-underscore-dangle
91
+
92
+ if (loaderContext._module && loaderContext._module.matchResource) {
93
+ relativeMatchResource = `${normalizePath( // eslint-disable-next-line no-underscore-dangle
94
+ _path.default.relative(options.context, loaderContext._module.matchResource))}\x00`;
95
+ }
97
96
 
98
- options.content = `${hashPrefix + request}\x00${localName}`;
97
+ const relativeResourcePath = normalizePath(_path.default.relative(options.context, loaderContext.resourcePath)); // eslint-disable-next-line no-param-reassign
98
+
99
+ options.content = `${options.hashPrefix}${relativeMatchResource}${relativeResourcePath}\x00${localName}`;
99
100
  return (0, _loaderUtils.interpolateName)(loaderContext, localIdentName, options);
100
101
  }
101
102
 
102
103
  function normalizeUrl(url, isStringValue) {
103
- let normalizedUrl = url;
104
+ let normalizedUrl = url.replace(/^( |\t\n|\r\n|\r|\f)*/g, "").replace(/( |\t\n|\r\n|\r|\f)*$/g, "");
104
105
 
105
106
  if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) {
106
107
  normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, "");
@@ -143,9 +144,8 @@ const moduleRegExp = /\.module(s)?\.\w+$/i;
143
144
  const icssRegExp = /\.icss\.\w+$/i;
144
145
 
145
146
  function getModulesOptions(rawOptions, loaderContext) {
146
- const {
147
- resourcePath
148
- } = loaderContext;
147
+ const resourcePath = // eslint-disable-next-line no-underscore-dangle
148
+ loaderContext._module && loaderContext._module.matchResource || loaderContext.resourcePath;
149
149
  let isIcss;
150
150
 
151
151
  if (typeof rawOptions.modules === "undefined") {
@@ -643,4 +643,9 @@ function isUrlRequestable(url) {
643
643
 
644
644
  function sort(a, b) {
645
645
  return a.index - b.index;
646
+ }
647
+
648
+ function combineRequests(preRequest, url) {
649
+ const idx = url.indexOf("!=!");
650
+ return idx !== -1 ? url.slice(0, idx + 3) + preRequest + url.slice(idx + 3) : preRequest + url;
646
651
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "5.1.0",
3
+ "version": "5.1.4",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/css-loader",
@@ -33,8 +33,7 @@
33
33
  "pretest": "npm run lint",
34
34
  "test": "npm run test:coverage",
35
35
  "prepare": "npm run build",
36
- "release": "standard-version",
37
- "defaults": "webpack-defaults"
36
+ "release": "standard-version"
38
37
  },
39
38
  "files": [
40
39
  "dist"
@@ -47,7 +46,7 @@
47
46
  "cssesc": "^3.0.0",
48
47
  "icss-utils": "^5.1.0",
49
48
  "loader-utils": "^2.0.0",
50
- "postcss": "^8.2.6",
49
+ "postcss": "^8.2.8",
51
50
  "postcss-modules-extract-imports": "^3.0.0",
52
51
  "postcss-modules-local-by-default": "^4.0.0",
53
52
  "postcss-modules-scope": "^3.0.0",
@@ -57,20 +56,19 @@
57
56
  "semver": "^7.3.4"
58
57
  },
59
58
  "devDependencies": {
60
- "@babel/cli": "^7.12.17",
61
- "@babel/core": "^7.12.17",
62
- "@babel/preset-env": "^7.12.17",
63
- "@commitlint/cli": "^11.0.0",
64
- "@commitlint/config-conventional": "^11.0.0",
65
- "@webpack-contrib/defaults": "^6.3.0",
59
+ "@babel/cli": "^7.13.10",
60
+ "@babel/core": "^7.13.10",
61
+ "@babel/preset-env": "^7.13.10",
62
+ "@commitlint/cli": "^12.0.1",
63
+ "@commitlint/config-conventional": "^12.0.1",
66
64
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
67
65
  "babel-jest": "^26.6.3",
68
66
  "cross-env": "^7.0.3",
69
67
  "del": "^6.0.0",
70
68
  "del-cli": "^3.0.1",
71
- "es-check": "^5.2.0",
72
- "eslint": "^7.20.0",
73
- "eslint-config-prettier": "^7.2.0",
69
+ "es-check": "^5.2.3",
70
+ "eslint": "^7.22.0",
71
+ "eslint-config-prettier": "^8.1.0",
74
72
  "eslint-plugin-import": "^2.22.1",
75
73
  "file-loader": "^6.2.0",
76
74
  "husky": "^4.3.8",
@@ -79,7 +77,7 @@
79
77
  "less-loader": "^7.1.0",
80
78
  "lint-staged": "^10.5.4",
81
79
  "memfs": "^3.2.0",
82
- "mini-css-extract-plugin": "^1.3.8",
80
+ "mini-css-extract-plugin": "^1.3.9",
83
81
  "npm-run-all": "^4.1.5",
84
82
  "postcss-loader": "^4.0.4",
85
83
  "postcss-preset-env": "^6.7.0",
@@ -92,7 +90,7 @@
92
90
  "stylus": "^0.54.8",
93
91
  "stylus-loader": "^4.3.0",
94
92
  "url-loader": "^4.1.1",
95
- "webpack": "^5.23.0"
93
+ "webpack": "^5.26.0"
96
94
  },
97
95
  "keywords": [
98
96
  "webpack",