webpack 5.105.4 → 5.106.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 +3 -6
- package/lib/BannerPlugin.js +13 -13
- package/lib/Chunk.js +25 -0
- package/lib/ChunkGraph.js +8 -4
- package/lib/CleanPlugin.js +23 -20
- package/lib/CompatibilityPlugin.js +1 -1
- package/lib/Compilation.js +34 -11
- package/lib/Compiler.js +59 -1
- package/lib/CssModule.js +17 -2
- package/lib/Dependency.js +1 -1
- package/lib/DllPlugin.js +17 -17
- package/lib/DllReferencePlugin.js +20 -18
- package/lib/DotenvPlugin.js +29 -27
- package/lib/ExternalModule.js +39 -6
- package/lib/FileSystemInfo.js +3 -1
- package/lib/IgnorePlugin.js +12 -11
- package/lib/LoaderOptionsPlugin.js +17 -15
- package/lib/ManifestPlugin.js +27 -25
- package/lib/Module.js +69 -4
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleParseError.js +1 -1
- package/lib/ModuleTypeConstants.js +1 -1
- package/lib/NormalModule.js +7 -3
- package/lib/NormalModuleFactory.js +20 -1
- package/lib/ProgressPlugin.js +39 -29
- package/lib/RuntimeGlobals.js +6 -0
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +13 -11
- package/lib/TemplatedPathPlugin.js +4 -3
- package/lib/WatchIgnorePlugin.js +15 -13
- package/lib/WebpackOptionsApply.js +4 -4
- package/lib/asset/AssetModulesPlugin.js +50 -29
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +27 -13
- package/lib/config/normalization.js +3 -2
- package/lib/container/ContainerPlugin.js +46 -42
- package/lib/container/ContainerReferencePlugin.js +42 -26
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +17 -13
- package/lib/css/CssGenerator.js +306 -192
- package/lib/css/CssInjectStyleRuntimeModule.js +179 -0
- package/lib/css/CssLoadingRuntimeModule.js +1 -4
- package/lib/css/CssModulesPlugin.js +197 -98
- package/lib/css/CssParser.js +231 -134
- package/lib/css/walkCssTokens.js +115 -12
- package/lib/debug/ProfilingPlugin.js +16 -13
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +20 -15
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -2
- package/lib/dependencies/CommonJsExportsDependency.js +1 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +63 -2
- package/lib/dependencies/CommonJsRequireContextDependency.js +21 -0
- package/lib/dependencies/CommonJsRequireDependency.js +42 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +210 -87
- package/lib/dependencies/CssIcssImportDependency.js +13 -70
- package/lib/dependencies/CssIcssSymbolDependency.js +19 -30
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +13 -2
- package/lib/dependencies/HarmonyExportExpressionDependency.js +28 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -3
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +21 -8
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -2
- package/lib/dependencies/ImportContextDependency.js +1 -1
- package/lib/dependencies/ImportDependency.js +16 -2
- package/lib/dependencies/ImportMetaPlugin.js +39 -29
- package/lib/dependencies/ImportParserPlugin.js +4 -5
- package/lib/dependencies/ImportPhase.js +65 -22
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +1 -4
- package/lib/ids/HashedModuleIdsPlugin.js +21 -23
- package/lib/ids/OccurrenceChunkIdsPlugin.js +15 -11
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -11
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -4
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -4
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -2
- package/lib/javascript/JavascriptModulesPlugin.js +38 -12
- package/lib/javascript/JavascriptParser.js +5 -3
- package/lib/json/JsonModulesPlugin.js +28 -21
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +35 -13
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +22 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +18 -31
- package/lib/optimize/ConcatenatedModule.js +4 -3
- package/lib/optimize/InnerGraphPlugin.js +11 -5
- package/lib/optimize/LimitChunkCountPlugin.js +22 -18
- package/lib/optimize/MergeDuplicateChunksPlugin.js +15 -12
- package/lib/optimize/MinChunkSizePlugin.js +20 -16
- package/lib/optimize/RemoveEmptyChunksPlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +20 -11
- package/lib/schemes/VirtualUrlPlugin.js +77 -30
- package/lib/serialization/FileMiddleware.js +7 -7
- package/lib/sharing/ConsumeSharedPlugin.js +32 -25
- package/lib/sharing/ProvideSharedPlugin.js +29 -25
- package/lib/util/{propertyName.js → property.js} +26 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +148 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +54 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +105 -0
- package/lib/wasm-async/AsyncWebAssemblyParser.js +30 -6
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +26 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +23 -0
- package/lib/web/JsonpTemplatePlugin.js +1 -0
- package/lib/webpack.js +34 -4
- package/package.json +18 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +82 -22
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +8 -0
- package/types.d.ts +511 -114
- package/lib/util/create-schema-validation.js +0 -41
- package/lib/util/propertyAccess.js +0 -30
package/lib/css/CssParser.js
CHANGED
|
@@ -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,7 @@ 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);
|
|
53
54
|
|
|
54
55
|
// https://www.w3.org/TR/css-syntax-3/#newline
|
|
55
56
|
// We don't have `preprocessing` stage, so we need specify all of them
|
|
@@ -61,7 +62,7 @@ const IMAGE_SET_FUNCTION = /^(?:-\w+-)?image-set$/i;
|
|
|
61
62
|
const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(?:-\w+-)?keyframes$/;
|
|
62
63
|
const COMPOSES_PROPERTY = /^(?:composes|compose-with)$/i;
|
|
63
64
|
const IS_MODULES = /\.modules?\.[^.]+$/i;
|
|
64
|
-
const CSS_COMMENT = /\/\*((?!\*\/)
|
|
65
|
+
const CSS_COMMENT = /\/\*((?!\*\/)[\s\S]*?)\*\//g;
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
* @param {RegExp} regexp a regexp
|
|
@@ -370,7 +371,7 @@ const GRID_AUTO_FLOW = {
|
|
|
370
371
|
};
|
|
371
372
|
|
|
372
373
|
/** @type {Record<string, number>} */
|
|
373
|
-
const
|
|
374
|
+
const GRID_TEMPLATE_AREAS = {
|
|
374
375
|
// Special
|
|
375
376
|
none: 1,
|
|
376
377
|
...GLOBAL_VALUES
|
|
@@ -389,7 +390,7 @@ const GRID_TEMPLATE_COLUMNS_OR_ROWS = {
|
|
|
389
390
|
|
|
390
391
|
/** @type {Record<string, number>} */
|
|
391
392
|
const GRID_TEMPLATE = {
|
|
392
|
-
...
|
|
393
|
+
...GRID_TEMPLATE_AREAS,
|
|
393
394
|
...GRID_TEMPLATE_COLUMNS_OR_ROWS
|
|
394
395
|
};
|
|
395
396
|
|
|
@@ -399,7 +400,7 @@ const GRID = {
|
|
|
399
400
|
dense: 1,
|
|
400
401
|
...GRID_AUTO_COLUMNS_OR_ROW,
|
|
401
402
|
...GRID_AUTO_FLOW,
|
|
402
|
-
...
|
|
403
|
+
...GRID_TEMPLATE_AREAS,
|
|
403
404
|
...GRID_TEMPLATE_COLUMNS_OR_ROWS
|
|
404
405
|
};
|
|
405
406
|
|
|
@@ -511,12 +512,11 @@ const getKnownProperties = (options = {}) => {
|
|
|
511
512
|
knownProperties.set("grid-column", GRID_AREA_OR_COLUMN_OR_ROW);
|
|
512
513
|
knownProperties.set("grid-column-end", GRID_AREA_OR_COLUMN_OR_ROW);
|
|
513
514
|
knownProperties.set("grid-column-start", GRID_AREA_OR_COLUMN_OR_ROW);
|
|
514
|
-
knownProperties.set("grid-column-start", GRID_AREA_OR_COLUMN_OR_ROW);
|
|
515
515
|
knownProperties.set("grid-row", GRID_AREA_OR_COLUMN_OR_ROW);
|
|
516
516
|
knownProperties.set("grid-row-end", GRID_AREA_OR_COLUMN_OR_ROW);
|
|
517
517
|
knownProperties.set("grid-row-start", GRID_AREA_OR_COLUMN_OR_ROW);
|
|
518
518
|
knownProperties.set("grid-template", GRID_TEMPLATE);
|
|
519
|
-
knownProperties.set("grid-template-areas",
|
|
519
|
+
knownProperties.set("grid-template-areas", GRID_TEMPLATE_AREAS);
|
|
520
520
|
knownProperties.set("grid-template-columns", GRID_TEMPLATE_COLUMNS_OR_ROWS);
|
|
521
521
|
knownProperties.set("grid-template-rows", GRID_TEMPLATE_COLUMNS_OR_ROWS);
|
|
522
522
|
}
|
|
@@ -655,7 +655,6 @@ class CssParser extends Parser {
|
|
|
655
655
|
mode === "auto" &&
|
|
656
656
|
module.type === CSS_MODULE_TYPE_AUTO &&
|
|
657
657
|
IS_MODULES.test(
|
|
658
|
-
// TODO matchResource
|
|
659
658
|
parseResource(/** @type {string} */ (module.getResource())).path
|
|
660
659
|
)
|
|
661
660
|
) {
|
|
@@ -689,11 +688,13 @@ class CssParser extends Parser {
|
|
|
689
688
|
let blockNestingLevel = 0;
|
|
690
689
|
/** @type {0 | 1 | undefined} */
|
|
691
690
|
let modeData;
|
|
691
|
+
/** @type {number} */
|
|
692
|
+
let counter = 0;
|
|
692
693
|
|
|
693
694
|
/** @type {string[]} */
|
|
694
695
|
let lastLocalIdentifiers = [];
|
|
695
696
|
|
|
696
|
-
/** @typedef {{ value
|
|
697
|
+
/** @typedef {{ value?: string, importName?: string, localName?: string }} IcssDefinition */
|
|
697
698
|
/** @type {Map<string, IcssDefinition>} */
|
|
698
699
|
const icssDefinitions = new Map();
|
|
699
700
|
|
|
@@ -1062,16 +1063,32 @@ class CssParser extends Parser {
|
|
|
1062
1063
|
|
|
1063
1064
|
/**
|
|
1064
1065
|
* @param {string} value value to resolve
|
|
1065
|
-
* @
|
|
1066
|
+
* @param {string=} localName override local name
|
|
1067
|
+
* @param {boolean=} isCustomProperty true when it is custom property, otherwise false
|
|
1068
|
+
* @returns {string | [string, string]} resolved reexport (`localName` and `importName`)
|
|
1066
1069
|
*/
|
|
1067
|
-
const getReexport = (value) => {
|
|
1068
|
-
const reexport = icssDefinitions.get(
|
|
1070
|
+
const getReexport = (value, localName, isCustomProperty) => {
|
|
1071
|
+
const reexport = icssDefinitions.get(
|
|
1072
|
+
isCustomProperty ? `--${value}` : value
|
|
1073
|
+
);
|
|
1069
1074
|
|
|
1070
1075
|
if (reexport) {
|
|
1071
|
-
if (reexport.
|
|
1072
|
-
return [
|
|
1076
|
+
if (reexport.importName) {
|
|
1077
|
+
return [
|
|
1078
|
+
reexport.localName || (isCustomProperty ? `--${value}` : value),
|
|
1079
|
+
reexport.importName
|
|
1080
|
+
];
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
if (isCustomProperty) {
|
|
1084
|
+
return /** @type {string} */ (reexport.value).slice(2);
|
|
1073
1085
|
}
|
|
1074
|
-
|
|
1086
|
+
|
|
1087
|
+
return /** @type {string} */ (reexport.value);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
if (localName) {
|
|
1091
|
+
return [localName, value];
|
|
1075
1092
|
}
|
|
1076
1093
|
|
|
1077
1094
|
return value;
|
|
@@ -1105,7 +1122,7 @@ class CssParser extends Parser {
|
|
|
1105
1122
|
if (!str) {
|
|
1106
1123
|
this._emitWarning(
|
|
1107
1124
|
state,
|
|
1108
|
-
`Unexpected '${input[pos]}' at ${pos} during parsing of '${type ? ":import" : ":export"}' (expected string)`,
|
|
1125
|
+
`Unexpected '${input[pos]}' at ${pos} during parsing of '${type === 0 ? ":import" : ":export"}' (expected string)`,
|
|
1109
1126
|
locConverter,
|
|
1110
1127
|
stringStart,
|
|
1111
1128
|
pos
|
|
@@ -1144,14 +1161,15 @@ class CssParser extends Parser {
|
|
|
1144
1161
|
[0, 0],
|
|
1145
1162
|
/** @type {"local" | "global"} */
|
|
1146
1163
|
(mode),
|
|
1147
|
-
value
|
|
1164
|
+
value,
|
|
1165
|
+
name
|
|
1148
1166
|
);
|
|
1149
1167
|
const { line: sl, column: sc } = locConverter.get(start);
|
|
1150
1168
|
const { line: el, column: ec } = locConverter.get(end);
|
|
1151
1169
|
dep.setLoc(sl, sc, el, ec);
|
|
1152
1170
|
module.addDependency(dep);
|
|
1153
1171
|
|
|
1154
|
-
icssDefinitions.set(name, {
|
|
1172
|
+
icssDefinitions.set(name, { importName: value });
|
|
1155
1173
|
} else if (type === 1) {
|
|
1156
1174
|
const dep = new CssIcssExportDependency(name, getReexport(value));
|
|
1157
1175
|
const { line: sl, column: sc } = locConverter.get(start);
|
|
@@ -1244,6 +1262,76 @@ class CssParser extends Parser {
|
|
|
1244
1262
|
return pos;
|
|
1245
1263
|
};
|
|
1246
1264
|
|
|
1265
|
+
/** @typedef {{ from: string, items: ({ localName: string, importName: string })[] }} ValueAtRuleImport */
|
|
1266
|
+
/** @typedef {{ localName: string, value: string }} ValueAtRuleValue */
|
|
1267
|
+
/**
|
|
1268
|
+
* @param {string} str value at-rule params
|
|
1269
|
+
* @returns {ValueAtRuleImport | ValueAtRuleValue} parsed result
|
|
1270
|
+
*/
|
|
1271
|
+
const parseValueAtRuleParams = (str) => {
|
|
1272
|
+
if (/from(\/\*|\s)(?:[\s\S]+)$/i.test(str)) {
|
|
1273
|
+
str = str.replace(CSS_COMMENT, " ").trim().replace(/;$/, "");
|
|
1274
|
+
const fromIdx = str.lastIndexOf("from");
|
|
1275
|
+
const path = str
|
|
1276
|
+
.slice(fromIdx + 5)
|
|
1277
|
+
.trim()
|
|
1278
|
+
.replace(/['"]/g, "");
|
|
1279
|
+
let content = str.slice(0, fromIdx).trim();
|
|
1280
|
+
|
|
1281
|
+
if (content.startsWith("(") && content.endsWith(")")) {
|
|
1282
|
+
content = content.slice(1, -1);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
return {
|
|
1286
|
+
from: path,
|
|
1287
|
+
items: content.split(",").map((item) => {
|
|
1288
|
+
item = item.trim();
|
|
1289
|
+
|
|
1290
|
+
if (item.includes(":")) {
|
|
1291
|
+
const [local, remote] = item.split(":");
|
|
1292
|
+
|
|
1293
|
+
return { localName: local.trim(), importName: remote.trim() };
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
const asParts = item.split(/\s+as\s+/);
|
|
1297
|
+
|
|
1298
|
+
if (asParts.length === 2) {
|
|
1299
|
+
return {
|
|
1300
|
+
localName: asParts[1].trim(),
|
|
1301
|
+
importName: asParts[0].trim()
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
return { localName: item, importName: item };
|
|
1306
|
+
})
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/** @type {string} */
|
|
1311
|
+
let localName;
|
|
1312
|
+
/** @type {string} */
|
|
1313
|
+
let value;
|
|
1314
|
+
|
|
1315
|
+
const idx = str.indexOf(":");
|
|
1316
|
+
|
|
1317
|
+
if (idx !== -1) {
|
|
1318
|
+
localName = str.slice(0, idx).replace(CSS_COMMENT, "").trim();
|
|
1319
|
+
value = str.slice(idx + 1);
|
|
1320
|
+
} else {
|
|
1321
|
+
const mask = str.replace(CSS_COMMENT, (m) => " ".repeat(m.length));
|
|
1322
|
+
const idx = mask.search(/\S\s/) + 1;
|
|
1323
|
+
|
|
1324
|
+
localName = str.slice(0, idx).replace(CSS_COMMENT, "").trim();
|
|
1325
|
+
value = str.slice(idx + (str[idx] === " " ? 1 : 0));
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
if (value.length > 0 && !/^\s+$/.test(value.replace(CSS_COMMENT, ""))) {
|
|
1329
|
+
value = value.trim();
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
return { localName, value };
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1247
1335
|
/**
|
|
1248
1336
|
* @param {string} input input
|
|
1249
1337
|
* @param {number} start name start position
|
|
@@ -1254,55 +1342,55 @@ class CssParser extends Parser {
|
|
|
1254
1342
|
const semi = eatUntilSemi(input, end);
|
|
1255
1343
|
const atRuleEnd = semi + 1;
|
|
1256
1344
|
const params = input.slice(end, semi);
|
|
1257
|
-
|
|
1345
|
+
const parsed = parseValueAtRuleParams(params);
|
|
1258
1346
|
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
.
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1347
|
+
if (
|
|
1348
|
+
typeof (/** @type {ValueAtRuleImport} */ (parsed).from) !== "undefined"
|
|
1349
|
+
) {
|
|
1350
|
+
if (/** @type {ValueAtRuleImport} */ (parsed).from.length === 0) {
|
|
1351
|
+
this._emitWarning(
|
|
1352
|
+
state,
|
|
1353
|
+
`Broken '@value' at-rule: ${input.slice(start, atRuleEnd)}'`,
|
|
1354
|
+
locConverter,
|
|
1355
|
+
start,
|
|
1356
|
+
atRuleEnd
|
|
1357
|
+
);
|
|
1269
1358
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1359
|
+
const dep = new ConstDependency("", [start, atRuleEnd]);
|
|
1360
|
+
module.addPresentationalDependency(dep);
|
|
1361
|
+
return atRuleEnd;
|
|
1272
1362
|
}
|
|
1273
1363
|
|
|
1274
|
-
|
|
1275
|
-
const [name, aliasName] = alias.split(/\s+as\s+/);
|
|
1364
|
+
let { from, items } = /** @type {ValueAtRuleImport} */ (parsed);
|
|
1276
1365
|
|
|
1366
|
+
for (const { importName, localName } of items) {
|
|
1277
1367
|
{
|
|
1278
|
-
const reexport = icssDefinitions.get(
|
|
1368
|
+
const reexport = icssDefinitions.get(from);
|
|
1279
1369
|
|
|
1280
|
-
if (reexport) {
|
|
1281
|
-
|
|
1370
|
+
if (reexport && reexport.value) {
|
|
1371
|
+
from = reexport.value.slice(1, -1);
|
|
1282
1372
|
}
|
|
1283
1373
|
|
|
1284
1374
|
const dep = new CssIcssImportDependency(
|
|
1285
|
-
|
|
1375
|
+
from,
|
|
1286
1376
|
[0, 0],
|
|
1287
1377
|
/** @type {"local" | "global"} */
|
|
1288
1378
|
(mode),
|
|
1289
|
-
|
|
1379
|
+
importName,
|
|
1380
|
+
localName
|
|
1290
1381
|
);
|
|
1291
1382
|
const { line: sl, column: sc } = locConverter.get(start);
|
|
1292
1383
|
const { line: el, column: ec } = locConverter.get(end);
|
|
1293
1384
|
dep.setLoc(sl, sc, el, ec);
|
|
1294
1385
|
module.addDependency(dep);
|
|
1295
1386
|
|
|
1296
|
-
icssDefinitions.set(
|
|
1297
|
-
value: name,
|
|
1298
|
-
isReference: true
|
|
1299
|
-
});
|
|
1387
|
+
icssDefinitions.set(localName, { importName });
|
|
1300
1388
|
}
|
|
1301
1389
|
|
|
1302
1390
|
{
|
|
1303
1391
|
const dep = new CssIcssExportDependency(
|
|
1304
|
-
|
|
1305
|
-
getReexport(
|
|
1392
|
+
localName,
|
|
1393
|
+
getReexport(localName),
|
|
1306
1394
|
undefined,
|
|
1307
1395
|
false,
|
|
1308
1396
|
CssIcssExportDependency.EXPORT_MODE.REPLACE
|
|
@@ -1314,9 +1402,7 @@ class CssParser extends Parser {
|
|
|
1314
1402
|
}
|
|
1315
1403
|
}
|
|
1316
1404
|
} else {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
if (!ident) {
|
|
1405
|
+
if (/** @type {ValueAtRuleValue} */ (parsed).localName.length === 0) {
|
|
1320
1406
|
this._emitWarning(
|
|
1321
1407
|
state,
|
|
1322
1408
|
`Broken '@value' at-rule: ${input.slice(start, atRuleEnd)}'`,
|
|
@@ -1330,33 +1416,32 @@ class CssParser extends Parser {
|
|
|
1330
1416
|
return atRuleEnd;
|
|
1331
1417
|
}
|
|
1332
1418
|
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
const
|
|
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
|
-
}
|
|
1419
|
+
const { localName, value } = /** @type {ValueAtRuleValue} */ (parsed);
|
|
1420
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
|
1421
|
+
const { line: el, column: ec } = locConverter.get(end);
|
|
1344
1422
|
|
|
1345
1423
|
if (icssDefinitions.has(value)) {
|
|
1346
1424
|
const def =
|
|
1347
1425
|
/** @type {IcssDefinition} */
|
|
1348
1426
|
(icssDefinitions.get(value));
|
|
1349
1427
|
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1428
|
+
def.localName = value;
|
|
1352
1429
|
|
|
1353
|
-
|
|
1430
|
+
icssDefinitions.set(localName, def);
|
|
1354
1431
|
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1432
|
+
const dep = new CssIcssExportDependency(
|
|
1433
|
+
localName,
|
|
1434
|
+
getReexport(value)
|
|
1435
|
+
);
|
|
1436
|
+
dep.setLoc(sl, sc, el, ec);
|
|
1437
|
+
module.addDependency(dep);
|
|
1438
|
+
} else {
|
|
1439
|
+
icssDefinitions.set(localName, { value });
|
|
1440
|
+
|
|
1441
|
+
const dep = new CssIcssExportDependency(localName, value);
|
|
1442
|
+
dep.setLoc(sl, sc, el, ec);
|
|
1443
|
+
module.addDependency(dep);
|
|
1444
|
+
}
|
|
1360
1445
|
}
|
|
1361
1446
|
|
|
1362
1447
|
const dep = new ConstDependency("", [start, atRuleEnd]);
|
|
@@ -1371,16 +1456,16 @@ class CssParser extends Parser {
|
|
|
1371
1456
|
* @returns {number} position after handling
|
|
1372
1457
|
*/
|
|
1373
1458
|
const processICSSSymbol = (name, start, end) => {
|
|
1374
|
-
const
|
|
1459
|
+
const def =
|
|
1375
1460
|
/** @type {IcssDefinition} */
|
|
1376
1461
|
(icssDefinitions.get(name));
|
|
1377
1462
|
const { line: sl, column: sc } = locConverter.get(start);
|
|
1378
1463
|
const { line: el, column: ec } = locConverter.get(end);
|
|
1379
1464
|
const dep = new CssIcssSymbolDependency(
|
|
1380
|
-
name,
|
|
1381
|
-
value,
|
|
1465
|
+
def.localName || name,
|
|
1382
1466
|
[start, end],
|
|
1383
|
-
|
|
1467
|
+
def.value,
|
|
1468
|
+
def.importName
|
|
1384
1469
|
);
|
|
1385
1470
|
dep.setLoc(sl, sc, el, ec);
|
|
1386
1471
|
module.addDependency(dep);
|
|
@@ -1587,19 +1672,35 @@ class CssParser extends Parser {
|
|
|
1587
1672
|
} else if (from[2] === false) {
|
|
1588
1673
|
const { line: sl, column: sc } = locConverter.get(customIdent[0]);
|
|
1589
1674
|
const { line: el, column: ec } = locConverter.get(from[1] - 1);
|
|
1590
|
-
const
|
|
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
|
-
);
|
|
1675
|
+
const localName = `__ICSS_IMPORT_${counter++}__`;
|
|
1600
1676
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1677
|
+
{
|
|
1678
|
+
const dep = new CssIcssImportDependency(
|
|
1679
|
+
path.slice(1, -1),
|
|
1680
|
+
[customIdent[0], from[1] - 1],
|
|
1681
|
+
/** @type {"local" | "global"} */
|
|
1682
|
+
(mode),
|
|
1683
|
+
identifier,
|
|
1684
|
+
localName
|
|
1685
|
+
);
|
|
1686
|
+
|
|
1687
|
+
dep.setLoc(sl, sc, el, ec);
|
|
1688
|
+
module.addDependency(dep);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
{
|
|
1692
|
+
const dep = new CssIcssExportDependency(
|
|
1693
|
+
identifier,
|
|
1694
|
+
getReexport(identifier, localName, true),
|
|
1695
|
+
[customIdent[0], from[1] - 1],
|
|
1696
|
+
true,
|
|
1697
|
+
CssIcssExportDependency.EXPORT_MODE.ONCE,
|
|
1698
|
+
CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
|
|
1699
|
+
);
|
|
1700
|
+
|
|
1701
|
+
dep.setLoc(sl, sc, el, ec);
|
|
1702
|
+
module.addDependency(dep);
|
|
1703
|
+
}
|
|
1603
1704
|
|
|
1604
1705
|
{
|
|
1605
1706
|
const dep = new ConstDependency("", [fromWord[0], from[1]]);
|
|
@@ -1612,7 +1713,7 @@ class CssParser extends Parser {
|
|
|
1612
1713
|
const { line: el, column: ec } = locConverter.get(customIdent[1]);
|
|
1613
1714
|
const dep = new CssIcssExportDependency(
|
|
1614
1715
|
identifier,
|
|
1615
|
-
getReexport(identifier),
|
|
1716
|
+
getReexport(identifier, undefined, true),
|
|
1616
1717
|
[customIdent[0], customIdent[1]],
|
|
1617
1718
|
true,
|
|
1618
1719
|
CssIcssExportDependency.EXPORT_MODE.ONCE,
|
|
@@ -1886,15 +1987,15 @@ class CssParser extends Parser {
|
|
|
1886
1987
|
for (const className of classNames) {
|
|
1887
1988
|
const [start, end] = className;
|
|
1888
1989
|
const identifier = unescapeIdentifier(input.slice(start, end));
|
|
1889
|
-
const resolvedClassName = getReexport(identifier);
|
|
1890
1990
|
const dep = new CssIcssExportDependency(
|
|
1891
1991
|
lastLocalIdentifier,
|
|
1892
|
-
|
|
1992
|
+
getReexport(identifier),
|
|
1893
1993
|
[start, end],
|
|
1894
|
-
isGlobalFunction
|
|
1994
|
+
!isGlobalFunction,
|
|
1895
1995
|
isGlobalFunction
|
|
1896
1996
|
? CssIcssExportDependency.EXPORT_MODE.APPEND
|
|
1897
|
-
: CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
|
|
1997
|
+
: CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE,
|
|
1998
|
+
CssIcssExportDependency.EXPORT_TYPE.COMPOSES
|
|
1898
1999
|
);
|
|
1899
2000
|
const { line: sl, column: sc } = locConverter.get(start);
|
|
1900
2001
|
const { line: el, column: ec } = locConverter.get(end);
|
|
@@ -1925,20 +2026,35 @@ class CssParser extends Parser {
|
|
|
1925
2026
|
for (const className of classNames) {
|
|
1926
2027
|
const [start, end] = className;
|
|
1927
2028
|
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
2029
|
const { line: sl, column: sc } = locConverter.get(start);
|
|
1939
2030
|
const { line: el, column: ec } = locConverter.get(end);
|
|
1940
|
-
|
|
1941
|
-
|
|
2031
|
+
const localName = `__ICSS_IMPORT_${counter++}__`;
|
|
2032
|
+
|
|
2033
|
+
{
|
|
2034
|
+
const dep = new CssIcssImportDependency(
|
|
2035
|
+
request,
|
|
2036
|
+
[start, end],
|
|
2037
|
+
/** @type {"local" | "global"} */
|
|
2038
|
+
(mode),
|
|
2039
|
+
identifier,
|
|
2040
|
+
localName
|
|
2041
|
+
);
|
|
2042
|
+
dep.setLoc(sl, sc, el, ec);
|
|
2043
|
+
module.addDependency(dep);
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
{
|
|
2047
|
+
const dep = new CssIcssExportDependency(
|
|
2048
|
+
lastLocalIdentifier,
|
|
2049
|
+
getReexport(identifier, localName),
|
|
2050
|
+
[start, end],
|
|
2051
|
+
true,
|
|
2052
|
+
CssIcssExportDependency.EXPORT_MODE.APPEND,
|
|
2053
|
+
CssIcssExportDependency.EXPORT_TYPE.COMPOSES
|
|
2054
|
+
);
|
|
2055
|
+
dep.setLoc(sl, sc, el, ec);
|
|
2056
|
+
module.addDependency(dep);
|
|
2057
|
+
}
|
|
1942
2058
|
}
|
|
1943
2059
|
|
|
1944
2060
|
classNames.clear();
|
|
@@ -1958,7 +2074,8 @@ class CssParser extends Parser {
|
|
|
1958
2074
|
getReexport(identifier),
|
|
1959
2075
|
[start, end],
|
|
1960
2076
|
false,
|
|
1961
|
-
CssIcssExportDependency.EXPORT_MODE.APPEND
|
|
2077
|
+
CssIcssExportDependency.EXPORT_MODE.APPEND,
|
|
2078
|
+
CssIcssExportDependency.EXPORT_TYPE.COMPOSES
|
|
1962
2079
|
);
|
|
1963
2080
|
const { line: sl, column: sc } = locConverter.get(start);
|
|
1964
2081
|
const { line: el, column: ec } = locConverter.get(end);
|
|
@@ -2255,10 +2372,6 @@ class CssParser extends Parser {
|
|
|
2255
2372
|
if (isModules) {
|
|
2256
2373
|
const identifier = input.slice(start, end);
|
|
2257
2374
|
|
|
2258
|
-
if (icssDefinitions.has(identifier)) {
|
|
2259
|
-
return processICSSSymbol(identifier, start, end);
|
|
2260
|
-
}
|
|
2261
|
-
|
|
2262
2375
|
if (
|
|
2263
2376
|
this.options.dashedIdents &&
|
|
2264
2377
|
isLocalMode() &&
|
|
@@ -2267,6 +2380,10 @@ class CssParser extends Parser {
|
|
|
2267
2380
|
return processDashedIdent(input, start, end);
|
|
2268
2381
|
}
|
|
2269
2382
|
|
|
2383
|
+
if (icssDefinitions.has(identifier)) {
|
|
2384
|
+
return processICSSSymbol(identifier, start, end);
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2270
2387
|
switch (scope) {
|
|
2271
2388
|
case CSS_MODE_IN_BLOCK: {
|
|
2272
2389
|
if (isModules && !isNextRulePrelude) {
|
|
@@ -2281,7 +2398,11 @@ class CssParser extends Parser {
|
|
|
2281
2398
|
return end;
|
|
2282
2399
|
},
|
|
2283
2400
|
delim: (input, start, end) => {
|
|
2284
|
-
if (
|
|
2401
|
+
if (
|
|
2402
|
+
input.charCodeAt(start) === CC_FULL_STOP &&
|
|
2403
|
+
isNextRulePrelude &&
|
|
2404
|
+
isLocalMode()
|
|
2405
|
+
) {
|
|
2285
2406
|
return processClassSelector(input, start, end);
|
|
2286
2407
|
}
|
|
2287
2408
|
|
|
@@ -2486,13 +2607,9 @@ class CssParser extends Parser {
|
|
|
2486
2607
|
return end;
|
|
2487
2608
|
},
|
|
2488
2609
|
comma: (input, start, end) => {
|
|
2489
|
-
if (isModules) {
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
if (!popped) {
|
|
2493
|
-
// Reset stack for `:global .class :local .class-other` selector after
|
|
2494
|
-
modeData = undefined;
|
|
2495
|
-
}
|
|
2610
|
+
if (isModules && balanced.length === 0) {
|
|
2611
|
+
// Reset stack for `:global .class :local .class-other` selector after
|
|
2612
|
+
modeData = undefined;
|
|
2496
2613
|
}
|
|
2497
2614
|
|
|
2498
2615
|
lastTokenEndForComments = start;
|
|
@@ -2510,30 +2627,10 @@ class CssParser extends Parser {
|
|
|
2510
2627
|
buildMeta.defaultObject = this.options.namedExports
|
|
2511
2628
|
? false
|
|
2512
2629
|
: "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
2630
|
|
|
2533
|
-
// TODO this.namedExports?
|
|
2534
2631
|
if (
|
|
2535
|
-
|
|
2536
|
-
|
|
2632
|
+
/** @type {CssModule} */ (module).exportType === "text" ||
|
|
2633
|
+
/** @type {CssModule} */ (module).exportType === "css-style-sheet"
|
|
2537
2634
|
) {
|
|
2538
2635
|
module.addDependency(new StaticExportsDependency(["default"], true));
|
|
2539
2636
|
} else {
|