@depup/webpack 5.105.4-depup.37 → 5.106.1-depup.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.
Files changed (124) hide show
  1. package/README.md +6 -3
  2. package/changes.json +50 -0
  3. package/lib/BannerPlugin.js +13 -13
  4. package/lib/Chunk.js +25 -0
  5. package/lib/ChunkGraph.js +8 -4
  6. package/lib/CleanPlugin.js +23 -20
  7. package/lib/CompatibilityPlugin.js +1 -1
  8. package/lib/Compilation.js +34 -11
  9. package/lib/Compiler.js +59 -1
  10. package/lib/CssModule.js +17 -2
  11. package/lib/Dependency.js +1 -1
  12. package/lib/DllPlugin.js +17 -17
  13. package/lib/DllReferencePlugin.js +20 -18
  14. package/lib/DotenvPlugin.js +29 -27
  15. package/lib/ExternalModule.js +39 -6
  16. package/lib/FileSystemInfo.js +3 -1
  17. package/lib/IgnorePlugin.js +12 -11
  18. package/lib/LoaderOptionsPlugin.js +17 -15
  19. package/lib/ManifestPlugin.js +27 -25
  20. package/lib/Module.js +69 -7
  21. package/lib/ModuleGraph.js +3 -0
  22. package/lib/ModuleParseError.js +1 -1
  23. package/lib/ModuleTypeConstants.js +1 -1
  24. package/lib/NormalModule.js +7 -3
  25. package/lib/NormalModuleFactory.js +20 -1
  26. package/lib/ProgressPlugin.js +39 -29
  27. package/lib/RuntimeGlobals.js +6 -0
  28. package/lib/RuntimeTemplate.js +1 -1
  29. package/lib/SourceMapDevToolPlugin.js +13 -11
  30. package/lib/TemplatedPathPlugin.js +4 -3
  31. package/lib/WatchIgnorePlugin.js +15 -13
  32. package/lib/WebpackOptionsApply.js +4 -4
  33. package/lib/asset/AssetModulesPlugin.js +50 -29
  34. package/lib/cli.js +3 -1
  35. package/lib/config/defaults.js +27 -13
  36. package/lib/config/normalization.js +3 -2
  37. package/lib/container/ContainerPlugin.js +46 -42
  38. package/lib/container/ContainerReferencePlugin.js +42 -26
  39. package/lib/container/FallbackModule.js +1 -1
  40. package/lib/container/ModuleFederationPlugin.js +17 -13
  41. package/lib/css/CssGenerator.js +306 -192
  42. package/lib/css/CssInjectStyleRuntimeModule.js +179 -0
  43. package/lib/css/CssLoadingRuntimeModule.js +1 -4
  44. package/lib/css/CssModulesPlugin.js +197 -98
  45. package/lib/css/CssParser.js +243 -134
  46. package/lib/css/walkCssTokens.js +115 -12
  47. package/lib/debug/ProfilingPlugin.js +16 -13
  48. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +20 -15
  49. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -3
  50. package/lib/dependencies/CommonJsExportRequireDependency.js +4 -2
  51. package/lib/dependencies/CommonJsExportsDependency.js +1 -1
  52. package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
  53. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
  54. package/lib/dependencies/CommonJsImportsParserPlugin.js +63 -2
  55. package/lib/dependencies/CommonJsRequireContextDependency.js +21 -0
  56. package/lib/dependencies/CommonJsRequireDependency.js +42 -1
  57. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -1
  58. package/lib/dependencies/ContextElementDependency.js +1 -1
  59. package/lib/dependencies/CssIcssExportDependency.js +211 -88
  60. package/lib/dependencies/CssIcssImportDependency.js +13 -70
  61. package/lib/dependencies/CssIcssSymbolDependency.js +19 -30
  62. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +13 -2
  63. package/lib/dependencies/HarmonyExportExpressionDependency.js +35 -5
  64. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -3
  65. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  66. package/lib/dependencies/HarmonyImportDependency.js +21 -8
  67. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -1
  68. package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
  69. package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -2
  70. package/lib/dependencies/ImportContextDependency.js +1 -1
  71. package/lib/dependencies/ImportDependency.js +16 -2
  72. package/lib/dependencies/ImportMetaPlugin.js +39 -29
  73. package/lib/dependencies/ImportParserPlugin.js +4 -5
  74. package/lib/dependencies/ImportPhase.js +65 -22
  75. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
  76. package/lib/esm/ModuleChunkFormatPlugin.js +1 -4
  77. package/lib/ids/HashedModuleIdsPlugin.js +21 -23
  78. package/lib/ids/OccurrenceChunkIdsPlugin.js +15 -11
  79. package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -11
  80. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -4
  81. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -4
  82. package/lib/javascript/EnableChunkLoadingPlugin.js +1 -2
  83. package/lib/javascript/JavascriptModulesPlugin.js +38 -12
  84. package/lib/javascript/JavascriptParser.js +5 -3
  85. package/lib/json/JsonModulesPlugin.js +28 -21
  86. package/lib/library/AssignLibraryPlugin.js +1 -1
  87. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  88. package/lib/library/ModuleLibraryPlugin.js +35 -13
  89. package/lib/library/SystemLibraryPlugin.js +1 -1
  90. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +22 -0
  91. package/lib/optimize/AggressiveSplittingPlugin.js +18 -31
  92. package/lib/optimize/ConcatenatedModule.js +4 -3
  93. package/lib/optimize/InnerGraphPlugin.js +11 -5
  94. package/lib/optimize/LimitChunkCountPlugin.js +22 -18
  95. package/lib/optimize/MergeDuplicateChunksPlugin.js +15 -12
  96. package/lib/optimize/MinChunkSizePlugin.js +20 -16
  97. package/lib/optimize/RemoveEmptyChunksPlugin.js +0 -1
  98. package/lib/rules/RuleSetCompiler.js +1 -0
  99. package/lib/schemes/HttpUriPlugin.js +20 -11
  100. package/lib/schemes/VirtualUrlPlugin.js +77 -30
  101. package/lib/serialization/FileMiddleware.js +7 -7
  102. package/lib/sharing/ConsumeSharedPlugin.js +32 -25
  103. package/lib/sharing/ProvideSharedPlugin.js +29 -25
  104. package/lib/util/{propertyName.js → property.js} +26 -1
  105. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +148 -0
  106. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +54 -0
  107. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +105 -0
  108. package/lib/wasm-async/AsyncWebAssemblyParser.js +30 -6
  109. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +26 -2
  110. package/lib/web/FetchCompileAsyncWasmPlugin.js +23 -0
  111. package/lib/web/JsonpTemplatePlugin.js +1 -0
  112. package/lib/webpack.js +34 -4
  113. package/package.json +45 -27
  114. package/schemas/WebpackOptions.check.js +1 -1
  115. package/schemas/WebpackOptions.json +82 -22
  116. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  117. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  118. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  119. package/schemas/plugins/optimize/LimitChunkCountPlugin.json +1 -1
  120. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -1
  121. package/schemas/plugins/schemes/VirtualUrlPlugin.json +8 -0
  122. package/types.d.ts +511 -114
  123. package/lib/util/create-schema-validation.js +0 -41
  124. package/lib/util/propertyAccess.js +0 -30
@@ -7,7 +7,6 @@
7
7
 
8
8
  const vm = require("vm");
9
9
  const CommentCompilationWarning = require("../CommentCompilationWarning");
10
- const CssModule = require("../CssModule");
11
10
  const ModuleDependencyWarning = require("../ModuleDependencyWarning");
12
11
  const { CSS_MODULE_TYPE_AUTO } = require("../ModuleTypeConstants");
13
12
  const Parser = require("../Parser");
@@ -34,6 +33,7 @@ const walkCssTokens = require("./walkCssTokens");
34
33
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
35
34
  /** @typedef {import("./walkCssTokens").CssTokenCallbacks} CssTokenCallbacks */
36
35
  /** @typedef {import("../../declarations/WebpackOptions").CssModuleParserOptions} CssModuleParserOptions */
36
+ /** @typedef {import("../CssModule")} CssModule */
37
37
 
38
38
  /** @typedef {[number, number]} Range */
39
39
  /** @typedef {{ line: number, column: number }} Position */
@@ -50,6 +50,8 @@ const CC_RIGHT_CURLY = "}".charCodeAt(0);
50
50
  const CC_HYPHEN_MINUS = "-".charCodeAt(0);
51
51
  const CC_TILDE = "~".charCodeAt(0);
52
52
  const CC_EQUAL = "=".charCodeAt(0);
53
+ const CC_FULL_STOP = ".".charCodeAt(0);
54
+ const CC_EXCLAMATION = "!".charCodeAt(0);
53
55
 
54
56
  // https://www.w3.org/TR/css-syntax-3/#newline
55
57
  // We don't have `preprocessing` stage, so we need specify all of them
@@ -61,7 +63,7 @@ const IMAGE_SET_FUNCTION = /^(?:-\w+-)?image-set$/i;
61
63
  const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(?:-\w+-)?keyframes$/;
62
64
  const COMPOSES_PROPERTY = /^(?:composes|compose-with)$/i;
63
65
  const IS_MODULES = /\.modules?\.[^.]+$/i;
64
- const CSS_COMMENT = /\/\*((?!\*\/).*?)\*\//g;
66
+ const CSS_COMMENT = /\/\*((?!\*\/)[\s\S]*?)\*\//g;
65
67
 
66
68
  /**
67
69
  * @param {RegExp} regexp a regexp
@@ -370,7 +372,7 @@ const GRID_AUTO_FLOW = {
370
372
  };
371
373
 
372
374
  /** @type {Record<string, number>} */
373
- const GRID_TEMPLATE_ARES = {
375
+ const GRID_TEMPLATE_AREAS = {
374
376
  // Special
375
377
  none: 1,
376
378
  ...GLOBAL_VALUES
@@ -389,7 +391,7 @@ const GRID_TEMPLATE_COLUMNS_OR_ROWS = {
389
391
 
390
392
  /** @type {Record<string, number>} */
391
393
  const GRID_TEMPLATE = {
392
- ...GRID_TEMPLATE_ARES,
394
+ ...GRID_TEMPLATE_AREAS,
393
395
  ...GRID_TEMPLATE_COLUMNS_OR_ROWS
394
396
  };
395
397
 
@@ -399,7 +401,7 @@ const GRID = {
399
401
  dense: 1,
400
402
  ...GRID_AUTO_COLUMNS_OR_ROW,
401
403
  ...GRID_AUTO_FLOW,
402
- ...GRID_TEMPLATE_ARES,
404
+ ...GRID_TEMPLATE_AREAS,
403
405
  ...GRID_TEMPLATE_COLUMNS_OR_ROWS
404
406
  };
405
407
 
@@ -511,12 +513,11 @@ const getKnownProperties = (options = {}) => {
511
513
  knownProperties.set("grid-column", GRID_AREA_OR_COLUMN_OR_ROW);
512
514
  knownProperties.set("grid-column-end", GRID_AREA_OR_COLUMN_OR_ROW);
513
515
  knownProperties.set("grid-column-start", GRID_AREA_OR_COLUMN_OR_ROW);
514
- knownProperties.set("grid-column-start", GRID_AREA_OR_COLUMN_OR_ROW);
515
516
  knownProperties.set("grid-row", GRID_AREA_OR_COLUMN_OR_ROW);
516
517
  knownProperties.set("grid-row-end", GRID_AREA_OR_COLUMN_OR_ROW);
517
518
  knownProperties.set("grid-row-start", GRID_AREA_OR_COLUMN_OR_ROW);
518
519
  knownProperties.set("grid-template", GRID_TEMPLATE);
519
- knownProperties.set("grid-template-areas", GRID_TEMPLATE_ARES);
520
+ knownProperties.set("grid-template-areas", GRID_TEMPLATE_AREAS);
520
521
  knownProperties.set("grid-template-columns", GRID_TEMPLATE_COLUMNS_OR_ROWS);
521
522
  knownProperties.set("grid-template-rows", GRID_TEMPLATE_COLUMNS_OR_ROWS);
522
523
  }
@@ -655,7 +656,6 @@ class CssParser extends Parser {
655
656
  mode === "auto" &&
656
657
  module.type === CSS_MODULE_TYPE_AUTO &&
657
658
  IS_MODULES.test(
658
- // TODO matchResource
659
659
  parseResource(/** @type {string} */ (module.getResource())).path
660
660
  )
661
661
  ) {
@@ -689,11 +689,13 @@ class CssParser extends Parser {
689
689
  let blockNestingLevel = 0;
690
690
  /** @type {0 | 1 | undefined} */
691
691
  let modeData;
692
+ /** @type {number} */
693
+ let counter = 0;
692
694
 
693
695
  /** @type {string[]} */
694
696
  let lastLocalIdentifiers = [];
695
697
 
696
- /** @typedef {{ value: string, isReference?: boolean }} IcssDefinition */
698
+ /** @typedef {{ value?: string, importName?: string, localName?: string }} IcssDefinition */
697
699
  /** @type {Map<string, IcssDefinition>} */
698
700
  const icssDefinitions = new Map();
699
701
 
@@ -1062,16 +1064,32 @@ class CssParser extends Parser {
1062
1064
 
1063
1065
  /**
1064
1066
  * @param {string} value value to resolve
1065
- * @returns {string | [string, string, boolean]} resolved reexport
1067
+ * @param {string=} localName override local name
1068
+ * @param {boolean=} isCustomProperty true when it is custom property, otherwise false
1069
+ * @returns {string | [string, string]} resolved reexport (`localName` and `importName`)
1066
1070
  */
1067
- const getReexport = (value) => {
1068
- const reexport = icssDefinitions.get(value);
1071
+ const getReexport = (value, localName, isCustomProperty) => {
1072
+ const reexport = icssDefinitions.get(
1073
+ isCustomProperty ? `--${value}` : value
1074
+ );
1069
1075
 
1070
1076
  if (reexport) {
1071
- if (reexport.isReference) {
1072
- return [value, reexport.value, true];
1077
+ if (reexport.importName) {
1078
+ return [
1079
+ reexport.localName || (isCustomProperty ? `--${value}` : value),
1080
+ reexport.importName
1081
+ ];
1082
+ }
1083
+
1084
+ if (isCustomProperty) {
1085
+ return /** @type {string} */ (reexport.value).slice(2);
1073
1086
  }
1074
- return [value, reexport.value, false];
1087
+
1088
+ return /** @type {string} */ (reexport.value);
1089
+ }
1090
+
1091
+ if (localName) {
1092
+ return [localName, value];
1075
1093
  }
1076
1094
 
1077
1095
  return value;
@@ -1105,7 +1123,7 @@ class CssParser extends Parser {
1105
1123
  if (!str) {
1106
1124
  this._emitWarning(
1107
1125
  state,
1108
- `Unexpected '${input[pos]}' at ${pos} during parsing of '${type ? ":import" : ":export"}' (expected string)`,
1126
+ `Unexpected '${input[pos]}' at ${pos} during parsing of '${type === 0 ? ":import" : ":export"}' (expected string)`,
1109
1127
  locConverter,
1110
1128
  stringStart,
1111
1129
  pos
@@ -1144,14 +1162,15 @@ class CssParser extends Parser {
1144
1162
  [0, 0],
1145
1163
  /** @type {"local" | "global"} */
1146
1164
  (mode),
1147
- value
1165
+ value,
1166
+ name
1148
1167
  );
1149
1168
  const { line: sl, column: sc } = locConverter.get(start);
1150
1169
  const { line: el, column: ec } = locConverter.get(end);
1151
1170
  dep.setLoc(sl, sc, el, ec);
1152
1171
  module.addDependency(dep);
1153
1172
 
1154
- icssDefinitions.set(name, { value, isReference: true });
1173
+ icssDefinitions.set(name, { importName: value });
1155
1174
  } else if (type === 1) {
1156
1175
  const dep = new CssIcssExportDependency(name, getReexport(value));
1157
1176
  const { line: sl, column: sc } = locConverter.get(start);
@@ -1244,6 +1263,76 @@ class CssParser extends Parser {
1244
1263
  return pos;
1245
1264
  };
1246
1265
 
1266
+ /** @typedef {{ from: string, items: ({ localName: string, importName: string })[] }} ValueAtRuleImport */
1267
+ /** @typedef {{ localName: string, value: string }} ValueAtRuleValue */
1268
+ /**
1269
+ * @param {string} str value at-rule params
1270
+ * @returns {ValueAtRuleImport | ValueAtRuleValue} parsed result
1271
+ */
1272
+ const parseValueAtRuleParams = (str) => {
1273
+ if (/from(\/\*|\s)(?:[\s\S]+)$/i.test(str)) {
1274
+ str = str.replace(CSS_COMMENT, " ").trim().replace(/;$/, "");
1275
+ const fromIdx = str.lastIndexOf("from");
1276
+ const path = str
1277
+ .slice(fromIdx + 5)
1278
+ .trim()
1279
+ .replace(/['"]/g, "");
1280
+ let content = str.slice(0, fromIdx).trim();
1281
+
1282
+ if (content.startsWith("(") && content.endsWith(")")) {
1283
+ content = content.slice(1, -1);
1284
+ }
1285
+
1286
+ return {
1287
+ from: path,
1288
+ items: content.split(",").map((item) => {
1289
+ item = item.trim();
1290
+
1291
+ if (item.includes(":")) {
1292
+ const [local, remote] = item.split(":");
1293
+
1294
+ return { localName: local.trim(), importName: remote.trim() };
1295
+ }
1296
+
1297
+ const asParts = item.split(/\s+as\s+/);
1298
+
1299
+ if (asParts.length === 2) {
1300
+ return {
1301
+ localName: asParts[1].trim(),
1302
+ importName: asParts[0].trim()
1303
+ };
1304
+ }
1305
+
1306
+ return { localName: item, importName: item };
1307
+ })
1308
+ };
1309
+ }
1310
+
1311
+ /** @type {string} */
1312
+ let localName;
1313
+ /** @type {string} */
1314
+ let value;
1315
+
1316
+ const idx = str.indexOf(":");
1317
+
1318
+ if (idx !== -1) {
1319
+ localName = str.slice(0, idx).replace(CSS_COMMENT, "").trim();
1320
+ value = str.slice(idx + 1);
1321
+ } else {
1322
+ const mask = str.replace(CSS_COMMENT, (m) => " ".repeat(m.length));
1323
+ const idx = mask.search(/\S\s/) + 1;
1324
+
1325
+ localName = str.slice(0, idx).replace(CSS_COMMENT, "").trim();
1326
+ value = str.slice(idx + (str[idx] === " " ? 1 : 0));
1327
+ }
1328
+
1329
+ if (value.length > 0 && !/^\s+$/.test(value.replace(CSS_COMMENT, ""))) {
1330
+ value = value.trim();
1331
+ }
1332
+
1333
+ return { localName, value };
1334
+ };
1335
+
1247
1336
  /**
1248
1337
  * @param {string} input input
1249
1338
  * @param {number} start name start position
@@ -1254,55 +1343,55 @@ class CssParser extends Parser {
1254
1343
  const semi = eatUntilSemi(input, end);
1255
1344
  const atRuleEnd = semi + 1;
1256
1345
  const params = input.slice(end, semi);
1257
- let [alias, request] = params.split(/\s*from\s*/);
1258
-
1259
- if (request) {
1260
- const aliases = alias
1261
- .replace(CSS_COMMENT, " ")
1262
- .trim()
1263
- .replace(/^\(\s*|\s*\)$/g, "")
1264
- .split(/\s*,\s*/);
1265
-
1266
- request = request.replace(CSS_COMMENT, "").trim();
1346
+ const parsed = parseValueAtRuleParams(params);
1267
1347
 
1268
- const isExplicitImport = request[0] === "'" || request[0] === '"';
1348
+ if (
1349
+ typeof (/** @type {ValueAtRuleImport} */ (parsed).from) !== "undefined"
1350
+ ) {
1351
+ if (/** @type {ValueAtRuleImport} */ (parsed).from.length === 0) {
1352
+ this._emitWarning(
1353
+ state,
1354
+ `Broken '@value' at-rule: ${input.slice(start, atRuleEnd)}'`,
1355
+ locConverter,
1356
+ start,
1357
+ atRuleEnd
1358
+ );
1269
1359
 
1270
- if (isExplicitImport) {
1271
- request = request.slice(1, -1);
1360
+ const dep = new ConstDependency("", [start, atRuleEnd]);
1361
+ module.addPresentationalDependency(dep);
1362
+ return atRuleEnd;
1272
1363
  }
1273
1364
 
1274
- for (const alias of aliases) {
1275
- const [name, aliasName] = alias.split(/\s+as\s+/);
1365
+ let { from, items } = /** @type {ValueAtRuleImport} */ (parsed);
1276
1366
 
1367
+ for (const { importName, localName } of items) {
1277
1368
  {
1278
- const reexport = icssDefinitions.get(request);
1369
+ const reexport = icssDefinitions.get(from);
1279
1370
 
1280
- if (reexport) {
1281
- request = reexport.value.slice(1, -1);
1371
+ if (reexport && reexport.value) {
1372
+ from = reexport.value.slice(1, -1);
1282
1373
  }
1283
1374
 
1284
1375
  const dep = new CssIcssImportDependency(
1285
- request,
1376
+ from,
1286
1377
  [0, 0],
1287
1378
  /** @type {"local" | "global"} */
1288
1379
  (mode),
1289
- name
1380
+ importName,
1381
+ localName
1290
1382
  );
1291
1383
  const { line: sl, column: sc } = locConverter.get(start);
1292
1384
  const { line: el, column: ec } = locConverter.get(end);
1293
1385
  dep.setLoc(sl, sc, el, ec);
1294
1386
  module.addDependency(dep);
1295
1387
 
1296
- icssDefinitions.set(aliasName || name, {
1297
- value: name,
1298
- isReference: true
1299
- });
1388
+ icssDefinitions.set(localName, { importName });
1300
1389
  }
1301
1390
 
1302
1391
  {
1303
1392
  const dep = new CssIcssExportDependency(
1304
- aliasName || name,
1305
- getReexport(aliasName || name),
1393
+ localName,
1394
+ getReexport(localName),
1306
1395
  undefined,
1307
1396
  false,
1308
1397
  CssIcssExportDependency.EXPORT_MODE.REPLACE
@@ -1314,9 +1403,7 @@ class CssParser extends Parser {
1314
1403
  }
1315
1404
  }
1316
1405
  } else {
1317
- const ident = walkCssTokens.eatIdentSequence(alias, 0);
1318
-
1319
- if (!ident) {
1406
+ if (/** @type {ValueAtRuleValue} */ (parsed).localName.length === 0) {
1320
1407
  this._emitWarning(
1321
1408
  state,
1322
1409
  `Broken '@value' at-rule: ${input.slice(start, atRuleEnd)}'`,
@@ -1330,33 +1417,32 @@ class CssParser extends Parser {
1330
1417
  return atRuleEnd;
1331
1418
  }
1332
1419
 
1333
- const pos = walkCssTokens.eatWhitespaceAndComments(alias, ident[1])[0];
1334
-
1335
- const name = alias.slice(ident[0], ident[1]);
1336
- let value =
1337
- alias.charCodeAt(pos) === CC_COLON
1338
- ? alias.slice(pos + 1)
1339
- : alias.slice(ident[1]);
1340
-
1341
- if (value && !/^\s+$/.test(value.replace(CSS_COMMENT, ""))) {
1342
- value = value.trim();
1343
- }
1420
+ const { localName, value } = /** @type {ValueAtRuleValue} */ (parsed);
1421
+ const { line: sl, column: sc } = locConverter.get(start);
1422
+ const { line: el, column: ec } = locConverter.get(end);
1344
1423
 
1345
1424
  if (icssDefinitions.has(value)) {
1346
1425
  const def =
1347
1426
  /** @type {IcssDefinition} */
1348
1427
  (icssDefinitions.get(value));
1349
1428
 
1350
- value = def.value;
1351
- }
1429
+ def.localName = value;
1352
1430
 
1353
- icssDefinitions.set(name, { value });
1431
+ icssDefinitions.set(localName, def);
1354
1432
 
1355
- const dep = new CssIcssExportDependency(name, value);
1356
- const { line: sl, column: sc } = locConverter.get(start);
1357
- const { line: el, column: ec } = locConverter.get(end);
1358
- dep.setLoc(sl, sc, el, ec);
1359
- module.addDependency(dep);
1433
+ const dep = new CssIcssExportDependency(
1434
+ localName,
1435
+ getReexport(value)
1436
+ );
1437
+ dep.setLoc(sl, sc, el, ec);
1438
+ module.addDependency(dep);
1439
+ } else {
1440
+ icssDefinitions.set(localName, { value });
1441
+
1442
+ const dep = new CssIcssExportDependency(localName, value);
1443
+ dep.setLoc(sl, sc, el, ec);
1444
+ module.addDependency(dep);
1445
+ }
1360
1446
  }
1361
1447
 
1362
1448
  const dep = new ConstDependency("", [start, atRuleEnd]);
@@ -1371,16 +1457,16 @@ class CssParser extends Parser {
1371
1457
  * @returns {number} position after handling
1372
1458
  */
1373
1459
  const processICSSSymbol = (name, start, end) => {
1374
- const { value, isReference } =
1460
+ const def =
1375
1461
  /** @type {IcssDefinition} */
1376
1462
  (icssDefinitions.get(name));
1377
1463
  const { line: sl, column: sc } = locConverter.get(start);
1378
1464
  const { line: el, column: ec } = locConverter.get(end);
1379
1465
  const dep = new CssIcssSymbolDependency(
1380
- name,
1381
- value,
1466
+ def.localName || name,
1382
1467
  [start, end],
1383
- isReference
1468
+ def.value,
1469
+ def.importName
1384
1470
  );
1385
1471
  dep.setLoc(sl, sc, el, ec);
1386
1472
  module.addDependency(dep);
@@ -1587,19 +1673,35 @@ class CssParser extends Parser {
1587
1673
  } else if (from[2] === false) {
1588
1674
  const { line: sl, column: sc } = locConverter.get(customIdent[0]);
1589
1675
  const { line: el, column: ec } = locConverter.get(from[1] - 1);
1590
- const dep = new CssIcssImportDependency(
1591
- path.slice(1, -1),
1592
- [customIdent[0], from[1] - 1],
1593
- /** @type {"local" | "global"} */
1594
- (mode),
1595
- identifier,
1596
- identifier,
1597
- CssIcssExportDependency.EXPORT_MODE.NONE,
1598
- CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
1599
- );
1676
+ const localName = `__ICSS_IMPORT_${counter++}__`;
1600
1677
 
1601
- dep.setLoc(sl, sc, el, ec);
1602
- module.addDependency(dep);
1678
+ {
1679
+ const dep = new CssIcssImportDependency(
1680
+ path.slice(1, -1),
1681
+ [customIdent[0], from[1] - 1],
1682
+ /** @type {"local" | "global"} */
1683
+ (mode),
1684
+ identifier,
1685
+ localName
1686
+ );
1687
+
1688
+ dep.setLoc(sl, sc, el, ec);
1689
+ module.addDependency(dep);
1690
+ }
1691
+
1692
+ {
1693
+ const dep = new CssIcssExportDependency(
1694
+ identifier,
1695
+ getReexport(identifier, localName, true),
1696
+ [customIdent[0], from[1] - 1],
1697
+ true,
1698
+ CssIcssExportDependency.EXPORT_MODE.ONCE,
1699
+ CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
1700
+ );
1701
+
1702
+ dep.setLoc(sl, sc, el, ec);
1703
+ module.addDependency(dep);
1704
+ }
1603
1705
 
1604
1706
  {
1605
1707
  const dep = new ConstDependency("", [fromWord[0], from[1]]);
@@ -1612,7 +1714,7 @@ class CssParser extends Parser {
1612
1714
  const { line: el, column: ec } = locConverter.get(customIdent[1]);
1613
1715
  const dep = new CssIcssExportDependency(
1614
1716
  identifier,
1615
- getReexport(identifier),
1717
+ getReexport(identifier, undefined, true),
1616
1718
  [customIdent[0], customIdent[1]],
1617
1719
  true,
1618
1720
  CssIcssExportDependency.EXPORT_MODE.ONCE,
@@ -1671,10 +1773,16 @@ class CssParser extends Parser {
1671
1773
  )
1672
1774
  : false;
1673
1775
 
1776
+ let afterExclamation = false;
1777
+
1674
1778
  const end = walkCssTokens.consumeUntil(
1675
1779
  input,
1676
1780
  pos,
1677
1781
  {
1782
+ delim(input, start, end) {
1783
+ afterExclamation = input.charCodeAt(start) === CC_EXCLAMATION;
1784
+ return end;
1785
+ },
1678
1786
  leftSquareBracket(input, start, end) {
1679
1787
  let i = end;
1680
1788
 
@@ -1723,6 +1831,11 @@ class CssParser extends Parser {
1723
1831
  return end;
1724
1832
  }
1725
1833
 
1834
+ if (afterExclamation) {
1835
+ afterExclamation = false;
1836
+ return end;
1837
+ }
1838
+
1726
1839
  const identifier = input.slice(start, end);
1727
1840
  const keyword = identifier.toLowerCase();
1728
1841
 
@@ -1886,15 +1999,15 @@ class CssParser extends Parser {
1886
1999
  for (const className of classNames) {
1887
2000
  const [start, end] = className;
1888
2001
  const identifier = unescapeIdentifier(input.slice(start, end));
1889
- const resolvedClassName = getReexport(identifier);
1890
2002
  const dep = new CssIcssExportDependency(
1891
2003
  lastLocalIdentifier,
1892
- resolvedClassName,
2004
+ getReexport(identifier),
1893
2005
  [start, end],
1894
- isGlobalFunction ? false : !Array.isArray(resolvedClassName),
2006
+ !isGlobalFunction,
1895
2007
  isGlobalFunction
1896
2008
  ? CssIcssExportDependency.EXPORT_MODE.APPEND
1897
- : CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
2009
+ : CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE,
2010
+ CssIcssExportDependency.EXPORT_TYPE.COMPOSES
1898
2011
  );
1899
2012
  const { line: sl, column: sc } = locConverter.get(start);
1900
2013
  const { line: el, column: ec } = locConverter.get(end);
@@ -1925,20 +2038,35 @@ class CssParser extends Parser {
1925
2038
  for (const className of classNames) {
1926
2039
  const [start, end] = className;
1927
2040
  const identifier = unescapeIdentifier(input.slice(start, end));
1928
- const dep = new CssIcssImportDependency(
1929
- request,
1930
- [start, end],
1931
- /** @type {"local" | "global"} */
1932
- (mode),
1933
- identifier,
1934
- /** @type {string} */
1935
- (lastLocalIdentifier),
1936
- CssIcssExportDependency.EXPORT_MODE.APPEND
1937
- );
1938
2041
  const { line: sl, column: sc } = locConverter.get(start);
1939
2042
  const { line: el, column: ec } = locConverter.get(end);
1940
- dep.setLoc(sl, sc, el, ec);
1941
- module.addDependency(dep);
2043
+ const localName = `__ICSS_IMPORT_${counter++}__`;
2044
+
2045
+ {
2046
+ const dep = new CssIcssImportDependency(
2047
+ request,
2048
+ [start, end],
2049
+ /** @type {"local" | "global"} */
2050
+ (mode),
2051
+ identifier,
2052
+ localName
2053
+ );
2054
+ dep.setLoc(sl, sc, el, ec);
2055
+ module.addDependency(dep);
2056
+ }
2057
+
2058
+ {
2059
+ const dep = new CssIcssExportDependency(
2060
+ lastLocalIdentifier,
2061
+ getReexport(identifier, localName),
2062
+ [start, end],
2063
+ true,
2064
+ CssIcssExportDependency.EXPORT_MODE.APPEND,
2065
+ CssIcssExportDependency.EXPORT_TYPE.COMPOSES
2066
+ );
2067
+ dep.setLoc(sl, sc, el, ec);
2068
+ module.addDependency(dep);
2069
+ }
1942
2070
  }
1943
2071
 
1944
2072
  classNames.clear();
@@ -1958,7 +2086,8 @@ class CssParser extends Parser {
1958
2086
  getReexport(identifier),
1959
2087
  [start, end],
1960
2088
  false,
1961
- CssIcssExportDependency.EXPORT_MODE.APPEND
2089
+ CssIcssExportDependency.EXPORT_MODE.APPEND,
2090
+ CssIcssExportDependency.EXPORT_TYPE.COMPOSES
1962
2091
  );
1963
2092
  const { line: sl, column: sc } = locConverter.get(start);
1964
2093
  const { line: el, column: ec } = locConverter.get(end);
@@ -2255,10 +2384,6 @@ class CssParser extends Parser {
2255
2384
  if (isModules) {
2256
2385
  const identifier = input.slice(start, end);
2257
2386
 
2258
- if (icssDefinitions.has(identifier)) {
2259
- return processICSSSymbol(identifier, start, end);
2260
- }
2261
-
2262
2387
  if (
2263
2388
  this.options.dashedIdents &&
2264
2389
  isLocalMode() &&
@@ -2267,6 +2392,10 @@ class CssParser extends Parser {
2267
2392
  return processDashedIdent(input, start, end);
2268
2393
  }
2269
2394
 
2395
+ if (icssDefinitions.has(identifier)) {
2396
+ return processICSSSymbol(identifier, start, end);
2397
+ }
2398
+
2270
2399
  switch (scope) {
2271
2400
  case CSS_MODE_IN_BLOCK: {
2272
2401
  if (isModules && !isNextRulePrelude) {
@@ -2281,7 +2410,11 @@ class CssParser extends Parser {
2281
2410
  return end;
2282
2411
  },
2283
2412
  delim: (input, start, end) => {
2284
- if (isNextRulePrelude && isLocalMode()) {
2413
+ if (
2414
+ input.charCodeAt(start) === CC_FULL_STOP &&
2415
+ isNextRulePrelude &&
2416
+ isLocalMode()
2417
+ ) {
2285
2418
  return processClassSelector(input, start, end);
2286
2419
  }
2287
2420
 
@@ -2486,13 +2619,9 @@ class CssParser extends Parser {
2486
2619
  return end;
2487
2620
  },
2488
2621
  comma: (input, start, end) => {
2489
- if (isModules) {
2490
- const popped = balanced.pop();
2491
-
2492
- if (!popped) {
2493
- // Reset stack for `:global .class :local .class-other` selector after
2494
- modeData = undefined;
2495
- }
2622
+ if (isModules && balanced.length === 0) {
2623
+ // Reset stack for `:global .class :local .class-other` selector after
2624
+ modeData = undefined;
2496
2625
  }
2497
2626
 
2498
2627
  lastTokenEndForComments = start;
@@ -2510,30 +2639,10 @@ class CssParser extends Parser {
2510
2639
  buildMeta.defaultObject = this.options.namedExports
2511
2640
  ? false
2512
2641
  : "redirect-warn";
2513
- buildMeta.exportType = this.options.exportType;
2514
-
2515
- if (!buildMeta.exportType) {
2516
- // Inherit exportType from parent module to ensure consistency.
2517
- // When a CSS file is imported with syntax like `import "./basic.css" with { type: "css" }`,
2518
- // the parent module's exportType is set to "css-style-sheet".
2519
- // Child modules imported via @import should inherit this exportType
2520
- // instead of using the default "link", ensuring that the entire
2521
- // import chain uses the same export format.
2522
- const parent = state.compilation.moduleGraph.getIssuer(module);
2523
- if (parent instanceof CssModule) {
2524
- buildMeta.exportType = /** @type {BuildMeta} */ (
2525
- parent.buildMeta
2526
- ).exportType;
2527
- }
2528
- }
2529
- if (!buildMeta.exportType) {
2530
- buildMeta.exportType = "link";
2531
- }
2532
2642
 
2533
- // TODO this.namedExports?
2534
2643
  if (
2535
- buildMeta.exportType === "text" ||
2536
- buildMeta.exportType === "css-style-sheet"
2644
+ /** @type {CssModule} */ (module).exportType === "text" ||
2645
+ /** @type {CssModule} */ (module).exportType === "css-style-sheet"
2537
2646
  ) {
2538
2647
  module.addDependency(new StaticExportsDependency(["default"], true));
2539
2648
  } else {