css-loader 6.10.0 → 7.0.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 +51 -38
- package/dist/index.js +2 -2
- package/dist/options.json +5 -1
- package/dist/utils.js +27 -58
- package/package.json +27 -28
package/README.md
CHANGED
|
@@ -192,7 +192,7 @@ type importFn =
|
|
|
192
192
|
media: string,
|
|
193
193
|
resourcePath: string,
|
|
194
194
|
supports?: string,
|
|
195
|
-
layer?: string
|
|
195
|
+
layer?: string,
|
|
196
196
|
) => boolean;
|
|
197
197
|
};
|
|
198
198
|
```
|
|
@@ -315,16 +315,16 @@ type modules =
|
|
|
315
315
|
getLocalIdent: (
|
|
316
316
|
context: LoaderContext,
|
|
317
317
|
localIdentName: string,
|
|
318
|
-
localName: string
|
|
318
|
+
localName: string,
|
|
319
319
|
) => string;
|
|
320
320
|
namedExport: boolean;
|
|
321
321
|
exportGlobals: boolean;
|
|
322
322
|
exportLocalsConvention:
|
|
323
|
-
| "
|
|
324
|
-
| "
|
|
325
|
-
| "
|
|
323
|
+
| "as-is"
|
|
324
|
+
| "camel-case"
|
|
325
|
+
| "camel-case-only"
|
|
326
326
|
| "dashes"
|
|
327
|
-
| "
|
|
327
|
+
| "dashes-only"
|
|
328
328
|
| ((name: string) => string);
|
|
329
329
|
exportOnlyLocals: boolean;
|
|
330
330
|
};
|
|
@@ -487,6 +487,18 @@ To import a local classname from another module.
|
|
|
487
487
|
|
|
488
488
|
To import from multiple modules use multiple `composes:` rules.
|
|
489
489
|
|
|
490
|
+
```css
|
|
491
|
+
:local(.className) {
|
|
492
|
+
composes:
|
|
493
|
+
edit highlight from "./edit.css",
|
|
494
|
+
button from "module/button.css",
|
|
495
|
+
classFromThisModule;
|
|
496
|
+
background: red;
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
or
|
|
501
|
+
|
|
490
502
|
```css
|
|
491
503
|
:local(.className) {
|
|
492
504
|
composes: edit highlight from "./edit.css";
|
|
@@ -590,7 +602,7 @@ module.exports = {
|
|
|
590
602
|
localIdentContext: path.resolve(__dirname, "src"),
|
|
591
603
|
localIdentHashSalt: "my-custom-hash",
|
|
592
604
|
namedExport: true,
|
|
593
|
-
exportLocalsConvention: "
|
|
605
|
+
exportLocalsConvention: "as-is",
|
|
594
606
|
exportOnlyLocals: false,
|
|
595
607
|
},
|
|
596
608
|
},
|
|
@@ -611,7 +623,7 @@ type auto =
|
|
|
611
623
|
| ((
|
|
612
624
|
resourcePath: string,
|
|
613
625
|
resourceQuery: string,
|
|
614
|
-
resourceFragment: string
|
|
626
|
+
resourceFragment: string,
|
|
615
627
|
) => boolean);
|
|
616
628
|
```
|
|
617
629
|
|
|
@@ -717,7 +729,7 @@ type mode =
|
|
|
717
729
|
| ((
|
|
718
730
|
resourcePath: string,
|
|
719
731
|
resourceQuery: string,
|
|
720
|
-
resourceFragment: string
|
|
732
|
+
resourceFragment: string,
|
|
721
733
|
) => "local" | "global" | "pure" | "icss");
|
|
722
734
|
```
|
|
723
735
|
|
|
@@ -1085,7 +1097,7 @@ Type:
|
|
|
1085
1097
|
type getLocalIdent = (
|
|
1086
1098
|
context: LoaderContext,
|
|
1087
1099
|
localIdentName: string,
|
|
1088
|
-
localName: string
|
|
1100
|
+
localName: string,
|
|
1089
1101
|
) => string;
|
|
1090
1102
|
```
|
|
1091
1103
|
|
|
@@ -1126,21 +1138,13 @@ Type:
|
|
|
1126
1138
|
type namedExport = boolean;
|
|
1127
1139
|
```
|
|
1128
1140
|
|
|
1129
|
-
Default: `false
|
|
1141
|
+
Default: Depends on the value of the `esModule` option. If the value of the `esModule` options is `true`, this value will also be `true`, otherwise it will be `false`.
|
|
1130
1142
|
|
|
1131
1143
|
Enables/disables ES modules named export for locals.
|
|
1132
1144
|
|
|
1133
1145
|
> **Warning**
|
|
1134
1146
|
>
|
|
1135
|
-
>
|
|
1136
|
-
> `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
|
|
1137
|
-
> which are not valid JavaScript identifiers may run into problems which do not implement the entire
|
|
1138
|
-
> modules specification.
|
|
1139
|
-
|
|
1140
|
-
> **Warning**
|
|
1141
|
-
>
|
|
1142
|
-
> It is not allowed to use JavaScript reserved words in css class names unless
|
|
1143
|
-
> `exportLocalsConvention` is `"asIs"`.
|
|
1147
|
+
> It is not allowed to use the `default` reserved word in css classes.
|
|
1144
1148
|
|
|
1145
1149
|
**styles.css**
|
|
1146
1150
|
|
|
@@ -1158,8 +1162,10 @@ Enables/disables ES modules named export for locals.
|
|
|
1158
1162
|
```js
|
|
1159
1163
|
import * as styles from "./styles.css";
|
|
1160
1164
|
|
|
1165
|
+
// If using `exportLocalsConvention: "camel-case-only"`:
|
|
1161
1166
|
console.log(styles.fooBaz, styles.bar);
|
|
1162
|
-
|
|
1167
|
+
|
|
1168
|
+
// If using `exportLocalsConvention: "as-is"`:
|
|
1163
1169
|
console.log(styles["foo-baz"], styles.bar);
|
|
1164
1170
|
```
|
|
1165
1171
|
|
|
@@ -1227,29 +1233,35 @@ Type:
|
|
|
1227
1233
|
|
|
1228
1234
|
```ts
|
|
1229
1235
|
type exportLocalsConvention =
|
|
1230
|
-
| "
|
|
1231
|
-
| "
|
|
1232
|
-
| "
|
|
1236
|
+
| "as-is"
|
|
1237
|
+
| "camel-case"
|
|
1238
|
+
| "camel-case-only"
|
|
1233
1239
|
| "dashes"
|
|
1234
|
-
| "
|
|
1240
|
+
| "dashes-only"
|
|
1235
1241
|
| ((name: string) => string);
|
|
1236
1242
|
```
|
|
1237
1243
|
|
|
1238
|
-
Default:
|
|
1244
|
+
Default: Depends on the value of the `modules.namedExport` option, if `true` - `as-is`, otherwise `camel-case-only`.
|
|
1245
|
+
|
|
1246
|
+
> **Warning**
|
|
1247
|
+
>
|
|
1248
|
+
> Names of locals are converted to camelcase when the named export is `false`, i.e. the `exportLocalsConvention` option has
|
|
1249
|
+
> `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
|
|
1250
|
+
> which are not valid JavaScript identifiers may run into problems which do not implement the entire modules specification.
|
|
1239
1251
|
|
|
1240
1252
|
Style of exported class names.
|
|
1241
1253
|
|
|
1242
1254
|
###### `string`
|
|
1243
1255
|
|
|
1244
|
-
By default, the exported JSON keys mirror the class names (i.e `
|
|
1256
|
+
By default, the exported JSON keys mirror the class names (i.e `as-is` value).
|
|
1245
1257
|
|
|
1246
|
-
|
|
|
1247
|
-
|
|
|
1248
|
-
|
|
|
1249
|
-
| **`'
|
|
1250
|
-
| **`'
|
|
1251
|
-
|
|
|
1252
|
-
|
|
|
1258
|
+
| Name | Type | Description |
|
|
1259
|
+
| :---------------------: | :------: | :----------------------------------------------------------------------------------------------- |
|
|
1260
|
+
| **`'as-is'`** | `string` | Class names will be exported as is. |
|
|
1261
|
+
| **`'camel-case'`** | `string` | Class names will be camelized, the original class name will not to be removed from the locals |
|
|
1262
|
+
| **`'camel-case-only'`** | `string` | Class names will be camelized, the original class name will be removed from the locals |
|
|
1263
|
+
| **`'dashes'`** | `string` | Only dashes in class names will be camelized |
|
|
1264
|
+
| **`'dashes-only'`** | `string` | Dashes in class names will be camelized, the original class name will be removed from the locals |
|
|
1253
1265
|
|
|
1254
1266
|
**file.css**
|
|
1255
1267
|
|
|
@@ -1275,7 +1287,7 @@ module.exports = {
|
|
|
1275
1287
|
loader: "css-loader",
|
|
1276
1288
|
options: {
|
|
1277
1289
|
modules: {
|
|
1278
|
-
exportLocalsConvention: "
|
|
1290
|
+
exportLocalsConvention: "camel-case-only",
|
|
1279
1291
|
},
|
|
1280
1292
|
},
|
|
1281
1293
|
},
|
|
@@ -1324,7 +1336,7 @@ module.exports = {
|
|
|
1324
1336
|
name.replace(/-/g, "_"),
|
|
1325
1337
|
// dashesCamelCase
|
|
1326
1338
|
name.replace(/-+(\w)/g, (match, firstLetter) =>
|
|
1327
|
-
firstLetter.toUpperCase()
|
|
1339
|
+
firstLetter.toUpperCase(),
|
|
1328
1340
|
),
|
|
1329
1341
|
];
|
|
1330
1342
|
},
|
|
@@ -1761,7 +1773,8 @@ With the help of the `/* webpackIgnore: true */`comment, it is possible to disab
|
|
|
1761
1773
|
.class {
|
|
1762
1774
|
/* Disabled url handling for the second url in the 'background' declaration */
|
|
1763
1775
|
color: red;
|
|
1764
|
-
background:
|
|
1776
|
+
background:
|
|
1777
|
+
url("./url/img.png"),
|
|
1765
1778
|
/* webpackIgnore: true */ url("./url/img.png");
|
|
1766
1779
|
}
|
|
1767
1780
|
|
|
@@ -1895,7 +1908,7 @@ module.exports = {
|
|
|
1895
1908
|
alias: {
|
|
1896
1909
|
"/assets/unresolved/img.png": path.resolve(
|
|
1897
1910
|
__dirname,
|
|
1898
|
-
"assets/real-path-to-img/img.png"
|
|
1911
|
+
"assets/real-path-to-img/img.png",
|
|
1899
1912
|
),
|
|
1900
1913
|
},
|
|
1901
1914
|
},
|
package/dist/index.js
CHANGED
|
@@ -45,9 +45,9 @@ async function loader(content, map, meta) {
|
|
|
45
45
|
if (this._compilation && this._compilation.options && this._compilation.options.experiments && this._compilation.options.experiments.buildHttp) {
|
|
46
46
|
isSupportAbsoluteURL = true;
|
|
47
47
|
}
|
|
48
|
-
const isSupportDataURL = options.esModule && Boolean("fsStartTime" in this._compiler);
|
|
49
48
|
if ((0, _utils.shouldUseImportPlugin)(options)) {
|
|
50
49
|
plugins.push((0, _plugins.importParser)({
|
|
50
|
+
// TODO need to fix on webpack side, webpack tries to resolve `./runtime/api.js paths like `http://site.com/runtime/api.js`, maybe we should try first request like absolute, the second like a relative to context
|
|
51
51
|
isSupportAbsoluteURL: false,
|
|
52
52
|
isSupportDataURL: false,
|
|
53
53
|
isCSSStyleSheet: options.exportType === "css-style-sheet",
|
|
@@ -63,7 +63,7 @@ async function loader(content, map, meta) {
|
|
|
63
63
|
const needToResolveURL = !options.esModule;
|
|
64
64
|
plugins.push((0, _plugins.urlParser)({
|
|
65
65
|
isSupportAbsoluteURL,
|
|
66
|
-
isSupportDataURL,
|
|
66
|
+
isSupportDataURL: options.esModule,
|
|
67
67
|
imports: urlPluginImports,
|
|
68
68
|
replacements,
|
|
69
69
|
context: this.context,
|
package/dist/options.json
CHANGED
package/dist/utils.js
CHANGED
|
@@ -42,43 +42,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
const WEBPACK_IGNORE_COMMENT_REGEXP = exports.WEBPACK_IGNORE_COMMENT_REGEXP = /webpackIgnore:(\s+)?(true|false)/;
|
|
45
|
-
const matchRelativePath = /^\.\.?[/\\]/;
|
|
46
|
-
function isAbsolutePath(str) {
|
|
47
|
-
return _path.default.posix.isAbsolute(str) || _path.default.win32.isAbsolute(str);
|
|
48
|
-
}
|
|
49
|
-
function isRelativePath(str) {
|
|
50
|
-
return matchRelativePath.test(str);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// TODO simplify for the next major release
|
|
54
45
|
function stringifyRequest(loaderContext, request) {
|
|
55
|
-
|
|
56
|
-
return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
|
|
57
|
-
}
|
|
58
|
-
const splitted = request.split("!");
|
|
59
|
-
const {
|
|
60
|
-
context
|
|
61
|
-
} = loaderContext;
|
|
62
|
-
return JSON.stringify(splitted.map(part => {
|
|
63
|
-
// First, separate singlePath from query, because the query might contain paths again
|
|
64
|
-
const splittedPart = part.match(/^(.*?)(\?.*)/);
|
|
65
|
-
const query = splittedPart ? splittedPart[2] : "";
|
|
66
|
-
let singlePath = splittedPart ? splittedPart[1] : part;
|
|
67
|
-
if (isAbsolutePath(singlePath) && context) {
|
|
68
|
-
singlePath = _path.default.relative(context, singlePath);
|
|
69
|
-
if (isAbsolutePath(singlePath)) {
|
|
70
|
-
// If singlePath still matches an absolute path, singlePath was on a different drive than context.
|
|
71
|
-
// In this case, we leave the path platform-specific without replacing any separators.
|
|
72
|
-
// @see https://github.com/webpack/loader-utils/pull/14
|
|
73
|
-
return singlePath + query;
|
|
74
|
-
}
|
|
75
|
-
if (isRelativePath(singlePath) === false) {
|
|
76
|
-
// Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
|
|
77
|
-
singlePath = `./${singlePath}`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return singlePath.replace(/\\/g, "/") + query;
|
|
81
|
-
}).join("!"));
|
|
46
|
+
return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
|
|
82
47
|
}
|
|
83
48
|
|
|
84
49
|
// We can't use path.win32.isAbsolute because it also matches paths starting with a forward slash
|
|
@@ -272,7 +237,7 @@ const filenameReservedRegex = /[<>:"/\\|?*]/g;
|
|
|
272
237
|
// eslint-disable-next-line no-control-regex
|
|
273
238
|
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g;
|
|
274
239
|
function escapeLocalIdent(localident) {
|
|
275
|
-
// TODO simplify
|
|
240
|
+
// TODO simplify?
|
|
276
241
|
return escape(localident
|
|
277
242
|
// For `[hash]` placeholder
|
|
278
243
|
.replace(/^((-?[0-9])|--)/, "_$1").replace(filenameReservedRegex, "-").replace(reControlChars, "-").replace(/\./g, "-"));
|
|
@@ -317,10 +282,8 @@ function defaultGetLocalIdent(loaderContext, localIdentName, localName, options)
|
|
|
317
282
|
}
|
|
318
283
|
let localIdentHash = "";
|
|
319
284
|
for (let tier = 0; localIdentHash.length < hashDigestLength; tier++) {
|
|
320
|
-
// TODO remove this in the next major release
|
|
321
|
-
const hash = loaderContext.utils && typeof loaderContext.utils.createHash === "function" ? loaderContext.utils.createHash(hashFunction) :
|
|
322
285
|
// eslint-disable-next-line no-underscore-dangle
|
|
323
|
-
loaderContext._compiler.webpack.util.createHash(hashFunction);
|
|
286
|
+
const hash = loaderContext._compiler.webpack.util.createHash(hashFunction);
|
|
324
287
|
if (hashSalt) {
|
|
325
288
|
hash.update(hashSalt);
|
|
326
289
|
}
|
|
@@ -440,7 +403,7 @@ function getValidLocalName(localName, exportLocalsConvention) {
|
|
|
440
403
|
}
|
|
441
404
|
const IS_MODULES = /\.module(s)?\.\w+$/i;
|
|
442
405
|
const IS_ICSS = /\.icss\.\w+$/i;
|
|
443
|
-
function getModulesOptions(rawOptions, exportType, loaderContext) {
|
|
406
|
+
function getModulesOptions(rawOptions, esModule, exportType, loaderContext) {
|
|
444
407
|
if (typeof rawOptions.modules === "boolean" && rawOptions.modules === false) {
|
|
445
408
|
return false;
|
|
446
409
|
}
|
|
@@ -470,6 +433,8 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
|
|
|
470
433
|
outputOptions
|
|
471
434
|
} = loaderContext._compilation;
|
|
472
435
|
const needNamedExport = exportType === "css-style-sheet" || exportType === "string";
|
|
436
|
+
const namedExport = typeof rawModulesOptions.namedExport !== "undefined" ? rawModulesOptions.namedExport : needNamedExport || esModule;
|
|
437
|
+
const exportLocalsConvention = typeof rawModulesOptions.exportLocalsConvention !== "undefined" ? rawModulesOptions.exportLocalsConvention : namedExport ? "as-is" : "camel-case-only";
|
|
473
438
|
const modulesOptions = {
|
|
474
439
|
auto,
|
|
475
440
|
mode: "local",
|
|
@@ -484,21 +449,25 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
|
|
|
484
449
|
localIdentRegExp: undefined,
|
|
485
450
|
// eslint-disable-next-line no-undefined
|
|
486
451
|
getLocalIdent: undefined,
|
|
487
|
-
|
|
488
|
-
exportLocalsConvention: (rawModulesOptions.namedExport === true || needNamedExport) && typeof rawModulesOptions.exportLocalsConvention === "undefined" ? "camelCaseOnly" : "asIs",
|
|
452
|
+
// TODO improve me and enable by default
|
|
489
453
|
exportOnlyLocals: false,
|
|
490
454
|
...rawModulesOptions,
|
|
491
|
-
|
|
455
|
+
exportLocalsConvention,
|
|
456
|
+
namedExport
|
|
492
457
|
};
|
|
493
|
-
let exportLocalsConventionType;
|
|
494
458
|
if (typeof modulesOptions.exportLocalsConvention === "string") {
|
|
495
|
-
|
|
459
|
+
// eslint-disable-next-line no-shadow
|
|
460
|
+
const {
|
|
461
|
+
exportLocalsConvention
|
|
462
|
+
} = modulesOptions;
|
|
496
463
|
modulesOptions.exportLocalsConvention = name => {
|
|
497
|
-
switch (
|
|
464
|
+
switch (exportLocalsConvention) {
|
|
465
|
+
case "camel-case":
|
|
498
466
|
case "camelCase":
|
|
499
467
|
{
|
|
500
468
|
return [name, camelCase(name)];
|
|
501
469
|
}
|
|
470
|
+
case "camel-case-only":
|
|
502
471
|
case "camelCaseOnly":
|
|
503
472
|
{
|
|
504
473
|
return camelCase(name);
|
|
@@ -507,10 +476,12 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
|
|
|
507
476
|
{
|
|
508
477
|
return [name, dashesCamelCase(name)];
|
|
509
478
|
}
|
|
479
|
+
case "dashes-only":
|
|
510
480
|
case "dashesOnly":
|
|
511
481
|
{
|
|
512
482
|
return dashesCamelCase(name);
|
|
513
483
|
}
|
|
484
|
+
case "as-is":
|
|
514
485
|
case "asIs":
|
|
515
486
|
default:
|
|
516
487
|
return name;
|
|
@@ -548,33 +519,29 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
|
|
|
548
519
|
modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath, loaderContext.resourceQuery, loaderContext.resourceFragment);
|
|
549
520
|
}
|
|
550
521
|
if (needNamedExport) {
|
|
551
|
-
if (
|
|
522
|
+
if (esModule === false) {
|
|
552
523
|
throw new Error("The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModule' option to be enabled");
|
|
553
524
|
}
|
|
554
525
|
if (modulesOptions.namedExport === false) {
|
|
555
526
|
throw new Error("The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'modules.namedExport' option to be enabled");
|
|
556
527
|
}
|
|
557
528
|
}
|
|
558
|
-
if (modulesOptions.namedExport === true) {
|
|
559
|
-
|
|
560
|
-
throw new Error("The 'modules.namedExport' option requires the 'esModule' option to be enabled");
|
|
561
|
-
}
|
|
562
|
-
if (typeof exportLocalsConventionType === "string" && exportLocalsConventionType !== "asIs" && exportLocalsConventionType !== "camelCaseOnly" && exportLocalsConventionType !== "dashesOnly") {
|
|
563
|
-
throw new Error('The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly" or "dashesOnly"');
|
|
564
|
-
}
|
|
529
|
+
if (modulesOptions.namedExport === true && esModule === false) {
|
|
530
|
+
throw new Error("The 'modules.namedExport' option requires the 'esModule' option to be enabled");
|
|
565
531
|
}
|
|
566
532
|
return modulesOptions;
|
|
567
533
|
}
|
|
568
534
|
function normalizeOptions(rawOptions, loaderContext) {
|
|
569
535
|
const exportType = typeof rawOptions.exportType === "undefined" ? "array" : rawOptions.exportType;
|
|
570
|
-
const
|
|
536
|
+
const esModule = typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule;
|
|
537
|
+
const modulesOptions = getModulesOptions(rawOptions, esModule, exportType, loaderContext);
|
|
571
538
|
return {
|
|
572
539
|
url: typeof rawOptions.url === "undefined" ? true : rawOptions.url,
|
|
573
540
|
import: typeof rawOptions.import === "undefined" ? true : rawOptions.import,
|
|
574
541
|
modules: modulesOptions,
|
|
575
542
|
sourceMap: typeof rawOptions.sourceMap === "boolean" ? rawOptions.sourceMap : loaderContext.sourceMap,
|
|
576
543
|
importLoaders: typeof rawOptions.importLoaders === "string" ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders,
|
|
577
|
-
esModule
|
|
544
|
+
esModule,
|
|
578
545
|
exportType
|
|
579
546
|
};
|
|
580
547
|
}
|
|
@@ -869,6 +836,8 @@ function convertToTemplateLiteral(str) {
|
|
|
869
836
|
function dashesCamelCase(str) {
|
|
870
837
|
return str.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
|
|
871
838
|
}
|
|
839
|
+
const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u;
|
|
840
|
+
const keywords = new Set(["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with"]);
|
|
872
841
|
function getExportCode(exports, replacements, icssPluginUsed, options, isTemplateLiteralSupported) {
|
|
873
842
|
let code = "// Exports\n";
|
|
874
843
|
if (icssPluginUsed) {
|
|
@@ -879,7 +848,7 @@ function getExportCode(exports, replacements, icssPluginUsed, options, isTemplat
|
|
|
879
848
|
for (const name of normalizedNames) {
|
|
880
849
|
const serializedValue = isTemplateLiteralSupported ? convertToTemplateLiteral(value) : JSON.stringify(value);
|
|
881
850
|
if (options.modules.namedExport) {
|
|
882
|
-
if (
|
|
851
|
+
if (!validIdentifier.test(name) || keywords.has(name)) {
|
|
883
852
|
identifierId += 1;
|
|
884
853
|
const id = `_${identifierId.toString(16)}`;
|
|
885
854
|
localsCode += `var ${id} = ${serializedValue};\n`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "css-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "css loader module for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/css-loader",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"main": "dist/cjs.js",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">= 12.
|
|
16
|
+
"node": ">= 18.12.0"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "npm run build -- -w",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"postbuild": "npm run validate:runtime",
|
|
25
25
|
"commitlint": "commitlint --from=master",
|
|
26
26
|
"security": "npm audit --production",
|
|
27
|
-
"lint:prettier": "prettier --list-different .",
|
|
27
|
+
"lint:prettier": "prettier --cache --list-different .",
|
|
28
28
|
"lint:js": "eslint --cache .",
|
|
29
|
-
"lint:spelling": "cspell \"**/*.*\"",
|
|
29
|
+
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
|
|
30
30
|
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
31
31
|
"fix:js": "npm run lint:js -- --fix",
|
|
32
32
|
"fix:prettier": "npm run lint:prettier -- --write",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
],
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@rspack/core": "0.x || 1.x",
|
|
47
|
-
"webpack": "^5.
|
|
47
|
+
"webpack": "^5.27.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"@rspack/core": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"icss-utils": "^5.1.0",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"postcss-modules-extract-imports": "^3.
|
|
61
|
-
"postcss-modules-local-by-default": "^4.0.
|
|
62
|
-
"postcss-modules-scope": "^3.
|
|
60
|
+
"postcss-modules-extract-imports": "^3.1.0",
|
|
61
|
+
"postcss-modules-local-by-default": "^4.0.5",
|
|
62
|
+
"postcss-modules-scope": "^3.2.0",
|
|
63
63
|
"postcss-modules-values": "^4.0.0",
|
|
64
64
|
"postcss-value-parser": "^4.2.0",
|
|
65
65
|
"semver": "^7.5.4"
|
|
@@ -68,38 +68,37 @@
|
|
|
68
68
|
"@babel/cli": "^7.23.4",
|
|
69
69
|
"@babel/core": "^7.23.7",
|
|
70
70
|
"@babel/preset-env": "^7.23.7",
|
|
71
|
-
"@commitlint/cli": "^
|
|
72
|
-
"@commitlint/config-conventional": "^
|
|
71
|
+
"@commitlint/cli": "^19.2.1",
|
|
72
|
+
"@commitlint/config-conventional": "^19.1.0",
|
|
73
73
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
74
|
-
"babel-jest": "^
|
|
74
|
+
"babel-jest": "^29.7.0",
|
|
75
75
|
"cross-env": "^7.0.3",
|
|
76
|
-
"cspell": "^6.
|
|
77
|
-
"del": "^
|
|
78
|
-
"del-cli": "^4.0.1",
|
|
76
|
+
"cspell": "^8.6.1",
|
|
77
|
+
"del-cli": "^5.1.0",
|
|
79
78
|
"es-check": "^7.1.0",
|
|
80
79
|
"eslint": "^8.54.0",
|
|
81
|
-
"eslint-config-prettier": "^
|
|
80
|
+
"eslint-config-prettier": "^9.1.0",
|
|
82
81
|
"eslint-plugin-import": "^2.29.0",
|
|
83
82
|
"file-loader": "^6.2.0",
|
|
84
|
-
"husky": "^
|
|
85
|
-
"jest": "^
|
|
86
|
-
"jest-environment-jsdom": "^
|
|
83
|
+
"husky": "^9.0.11",
|
|
84
|
+
"jest": "^29.7.0",
|
|
85
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
87
86
|
"less": "^4.2.0",
|
|
88
|
-
"less-loader": "^
|
|
89
|
-
"lint-staged": "^
|
|
90
|
-
"memfs": "^
|
|
87
|
+
"less-loader": "^12.2.0",
|
|
88
|
+
"lint-staged": "^15.2.2",
|
|
89
|
+
"memfs": "^4.8.1",
|
|
91
90
|
"mini-css-extract-plugin": "^2.7.5",
|
|
92
91
|
"npm-run-all": "^4.1.5",
|
|
93
|
-
"postcss-loader": "^
|
|
94
|
-
"postcss-preset-env": "^
|
|
95
|
-
"prettier": "^2.
|
|
92
|
+
"postcss-loader": "^8.1.1",
|
|
93
|
+
"postcss-preset-env": "^9.5.4",
|
|
94
|
+
"prettier": "^3.2.5",
|
|
96
95
|
"sass": "^1.69.7",
|
|
97
|
-
"sass-loader": "^
|
|
96
|
+
"sass-loader": "^14.1.1",
|
|
98
97
|
"standard-version": "^9.5.0",
|
|
99
98
|
"strip-ansi": "^6.0.0",
|
|
100
|
-
"style-loader": "^3.3.
|
|
101
|
-
"stylus": "^0.
|
|
102
|
-
"stylus-loader": "^
|
|
99
|
+
"style-loader": "^3.3.4",
|
|
100
|
+
"stylus": "^0.63.0",
|
|
101
|
+
"stylus-loader": "^8.1.0",
|
|
103
102
|
"url-loader": "^4.1.1",
|
|
104
103
|
"webpack": "^5.89.0"
|
|
105
104
|
},
|