webpack 5.79.0 → 5.81.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +3 -0
- package/lib/AsyncDependenciesBlock.js +8 -0
- package/lib/CodeGenerationResults.js +2 -2
- package/lib/Compilation.js +2 -2
- package/lib/ContextModule.js +8 -0
- package/lib/CssModule.js +137 -0
- package/lib/DefinePlugin.js +81 -44
- package/lib/DelegatedModule.js +5 -0
- package/lib/DependenciesBlock.js +8 -0
- package/lib/Dependency.js +8 -0
- package/lib/DllModule.js +8 -0
- package/lib/ExportsInfo.js +3 -0
- package/lib/ExternalModule.js +8 -0
- package/lib/FileSystemInfo.js +8 -0
- package/lib/LoaderOptionsPlugin.js +12 -2
- package/lib/Module.js +8 -0
- package/lib/ModuleBuildError.js +9 -0
- package/lib/ModuleError.js +9 -0
- package/lib/ModuleFilenameHelpers.js +113 -4
- package/lib/ModuleParseError.js +9 -0
- package/lib/ModuleTypeConstants.js +21 -0
- package/lib/ModuleWarning.js +9 -0
- package/lib/NormalModule.js +8 -0
- package/lib/NormalModuleFactory.js +26 -4
- package/lib/RawModule.js +8 -0
- package/lib/WarnCaseSensitiveModulesPlugin.js +12 -0
- package/lib/WebpackError.js +8 -0
- package/lib/asset/AssetGenerator.js +11 -3
- package/lib/asset/RawDataUrlModule.js +8 -0
- package/lib/cache/ResolverCachePlugin.js +3 -0
- package/lib/config/normalization.js +1 -0
- package/lib/container/ContainerEntryModule.js +5 -0
- package/lib/container/ContainerExposedDependency.js +9 -0
- package/lib/container/FallbackDependency.js +6 -0
- package/lib/container/FallbackModule.js +5 -0
- package/lib/container/RemoteModule.js +5 -0
- package/lib/css/CssModulesPlugin.js +91 -50
- package/lib/css/CssParser.js +226 -72
- package/lib/css/walkCssTokens.js +152 -117
- package/lib/dependencies/AMDDefineDependency.js +8 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +8 -0
- package/lib/dependencies/AMDRequireContextDependency.js +9 -0
- package/lib/dependencies/AMDRequireDependency.js +8 -0
- package/lib/dependencies/CachedConstDependency.js +8 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +9 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +8 -0
- package/lib/dependencies/CommonJsExportsDependency.js +8 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +65 -3
- package/lib/dependencies/CommonJsFullRequireDependency.js +8 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +9 -0
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
- package/lib/dependencies/ConstDependency.js +8 -0
- package/lib/dependencies/ContextDependency.js +8 -0
- package/lib/dependencies/ContextElementDependency.js +8 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +8 -0
- package/lib/dependencies/CssExportDependency.js +8 -0
- package/lib/dependencies/CssImportDependency.js +52 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +8 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +8 -0
- package/lib/dependencies/CssUrlDependency.js +38 -18
- package/lib/dependencies/DllEntryDependency.js +9 -0
- package/lib/dependencies/ExportsInfoDependency.js +5 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +8 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +8 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
- package/lib/dependencies/HarmonyExportHeaderDependency.js +8 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +14 -0
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +8 -0
- package/lib/dependencies/HarmonyImportDependency.js +8 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +8 -0
- package/lib/dependencies/ImportContextDependency.js +9 -0
- package/lib/dependencies/ImportDependency.js +8 -0
- package/lib/dependencies/ImportMetaPlugin.js +56 -26
- package/lib/dependencies/ImportParserPlugin.js +17 -1
- package/lib/dependencies/JsonExportsDependency.js +8 -0
- package/lib/dependencies/LocalModuleDependency.js +8 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +8 -0
- package/lib/dependencies/ModuleDependency.js +8 -0
- package/lib/dependencies/ProvidedDependency.js +8 -0
- package/lib/dependencies/PureExpressionDependency.js +8 -0
- package/lib/dependencies/RequireEnsureDependency.js +8 -0
- package/lib/dependencies/RequireHeaderDependency.js +5 -0
- package/lib/dependencies/RequireResolveContextDependency.js +9 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +5 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +8 -0
- package/lib/dependencies/StaticExportsDependency.js +8 -0
- package/lib/dependencies/URLDependency.js +8 -0
- package/lib/dependencies/UnsupportedDependency.js +8 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +8 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +8 -0
- package/lib/dependencies/WorkerDependency.js +8 -0
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/index.js +1 -0
- package/lib/javascript/JavascriptParser.js +14 -4
- package/lib/optimize/RealContentHashPlugin.js +6 -0
- package/lib/runtime/AutoPublicPathRuntimeModule.js +6 -1
- package/lib/schemes/DataUriPlugin.js +12 -3
- package/lib/serialization/ObjectMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +8 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -3
- package/lib/sharing/ProvideSharedDependency.js +6 -0
- package/lib/sharing/ProvideSharedModule.js +5 -0
- package/lib/sharing/ShareRuntimeModule.js +7 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +98 -25
- package/lib/stats/DefaultStatsPresetPlugin.js +9 -0
- package/lib/stats/DefaultStatsPrinterPlugin.js +4 -0
- package/lib/util/LazySet.js +10 -2
- package/lib/util/MapHelpers.js +19 -5
- package/lib/util/binarySearchBounds.js +49 -0
- package/lib/util/internalSerializables.js +1 -0
- package/lib/util/semver.js +1 -1
- package/package.json +19 -22
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +16 -0
- package/types.d.ts +108 -39
@@ -16,11 +16,36 @@ const DynamicExports = require("./DynamicExports");
|
|
16
16
|
const HarmonyExports = require("./HarmonyExports");
|
17
17
|
const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
|
18
18
|
|
19
|
+
/** @typedef {import("estree").AssignmentExpression} AssignmentExpression */
|
20
|
+
/** @typedef {import("estree").CallExpression} CallExpression */
|
19
21
|
/** @typedef {import("estree").Expression} ExpressionNode */
|
22
|
+
/** @typedef {import("estree").Expression} Expression */
|
23
|
+
/** @typedef {import("estree").Super} Super */
|
24
|
+
|
20
25
|
/** @typedef {import("../NormalModule")} NormalModule */
|
21
26
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
22
27
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
28
|
+
/** @typedef {import("./CommonJsDependencyHelpers").CommonJSDependencyBaseKeywords} CommonJSDependencyBaseKeywords */
|
23
29
|
|
30
|
+
/**
|
31
|
+
* This function takes a generic expression and detects whether it is an ObjectExpression.
|
32
|
+
* This is used in the context of parsing CommonJS exports to get the value of the property descriptor
|
33
|
+
* when the `exports` object is assigned to `Object.defineProperty`.
|
34
|
+
*
|
35
|
+
* In CommonJS modules, the `exports` object can be assigned to `Object.defineProperty` and therefore
|
36
|
+
* webpack has to detect this case and get the value key of the property descriptor. See the following example
|
37
|
+
* for more information: https://astexplorer.net/#/gist/83ce51a4e96e59d777df315a6d111da6/8058ead48a1bb53c097738225db0967ef7f70e57
|
38
|
+
*
|
39
|
+
* This would be an example of a CommonJS module that exports an object with a property descriptor:
|
40
|
+
* ```js
|
41
|
+
* Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
+
* exports.foo = void 0;
|
43
|
+
* exports.foo = "bar";
|
44
|
+
* ```
|
45
|
+
*
|
46
|
+
* @param {TODO} expr expression
|
47
|
+
* @returns {Expression} returns the value of property descriptor
|
48
|
+
*/
|
24
49
|
const getValueOfPropertyDescription = expr => {
|
25
50
|
if (expr.type !== "ObjectExpression") return;
|
26
51
|
for (const property of expr.properties) {
|
@@ -31,6 +56,15 @@ const getValueOfPropertyDescription = expr => {
|
|
31
56
|
}
|
32
57
|
};
|
33
58
|
|
59
|
+
/**
|
60
|
+
* The purpose of this function is to check whether an expression is a truthy literal or not. This is
|
61
|
+
* useful when parsing CommonJS exports, because CommonJS modules can export any value, including falsy
|
62
|
+
* values like `null` and `false`. However, exports should only be created if the exported value is truthy.
|
63
|
+
*
|
64
|
+
* @param {Expression} expr expression being checked
|
65
|
+
* @returns {boolean} true, when the expression is a truthy literal
|
66
|
+
*
|
67
|
+
*/
|
34
68
|
const isTruthyLiteral = expr => {
|
35
69
|
switch (expr.type) {
|
36
70
|
case "Literal":
|
@@ -41,6 +75,14 @@ const isTruthyLiteral = expr => {
|
|
41
75
|
return false;
|
42
76
|
};
|
43
77
|
|
78
|
+
/**
|
79
|
+
* The purpose of this function is to check whether an expression is a falsy literal or not. This is
|
80
|
+
* useful when parsing CommonJS exports, because CommonJS modules can export any value, including falsy
|
81
|
+
* values like `null` and `false`. However, exports should only be created if the exported value is truthy.
|
82
|
+
*
|
83
|
+
* @param {Expression} expr expression being checked
|
84
|
+
* @returns {boolean} true, when the expression is a falsy literal
|
85
|
+
*/
|
44
86
|
const isFalsyLiteral = expr => {
|
45
87
|
switch (expr.type) {
|
46
88
|
case "Literal":
|
@@ -97,6 +139,13 @@ class CommonJsExportsParserPlugin {
|
|
97
139
|
const enableStructuredExports = () => {
|
98
140
|
DynamicExports.enable(parser.state);
|
99
141
|
};
|
142
|
+
|
143
|
+
/**
|
144
|
+
* @param {boolean} topLevel true, when the export is on top level
|
145
|
+
* @param {string[]} members members of the export
|
146
|
+
* @param {Expression} valueExpr expression for the value
|
147
|
+
* @returns {void}
|
148
|
+
*/
|
100
149
|
const checkNamespace = (topLevel, members, valueExpr) => {
|
101
150
|
if (!DynamicExports.isEnabled(parser.state)) return;
|
102
151
|
if (members.length > 0 && members[0] === "__esModule") {
|
@@ -126,6 +175,13 @@ class CommonJsExportsParserPlugin {
|
|
126
175
|
.tap("CommonJsPlugin", evaluateToString("object"));
|
127
176
|
|
128
177
|
// exporting //
|
178
|
+
|
179
|
+
/**
|
180
|
+
* @param {AssignmentExpression} expr expression
|
181
|
+
* @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
|
182
|
+
* @param {string[]} members members of the export
|
183
|
+
* @returns {boolean} true, when the expression was handled
|
184
|
+
*/
|
129
185
|
const handleAssignExport = (expr, base, members) => {
|
130
186
|
if (HarmonyExports.isEnabled(parser.state)) return;
|
131
187
|
// Handle reexporting
|
@@ -192,9 +248,7 @@ class CommonJsExportsParserPlugin {
|
|
192
248
|
parser.hooks.call
|
193
249
|
.for("Object.defineProperty")
|
194
250
|
.tap("CommonJsExportsParserPlugin", expression => {
|
195
|
-
const expr = /** @type {
|
196
|
-
expression
|
197
|
-
);
|
251
|
+
const expr = /** @type {CallExpression} */ (expression);
|
198
252
|
if (!parser.isStatementLevelExpression(expr)) return;
|
199
253
|
if (expr.arguments.length !== 3) return;
|
200
254
|
if (expr.arguments[0].type === "SpreadElement") return;
|
@@ -233,6 +287,14 @@ class CommonJsExportsParserPlugin {
|
|
233
287
|
});
|
234
288
|
|
235
289
|
// Self reference //
|
290
|
+
|
291
|
+
/**
|
292
|
+
* @param {Expression | Super} expr expression
|
293
|
+
* @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
|
294
|
+
* @param {string[]} members members of the export
|
295
|
+
* @param {CallExpression} call call expression
|
296
|
+
* @returns {boolean} true, when the expression was handled
|
297
|
+
*/
|
236
298
|
const handleAccessExport = (expr, base, members, call = undefined) => {
|
237
299
|
if (HarmonyExports.isEnabled(parser.state)) return;
|
238
300
|
if (members.length === 0) {
|
@@ -16,6 +16,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
16
16
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
17
17
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
18
18
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
19
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
20
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
19
21
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
20
22
|
|
21
23
|
class CommonJsFullRequireDependency extends ModuleDependency {
|
@@ -51,6 +53,9 @@ class CommonJsFullRequireDependency extends ModuleDependency {
|
|
51
53
|
return [this.names];
|
52
54
|
}
|
53
55
|
|
56
|
+
/**
|
57
|
+
* @param {ObjectSerializerContext} context context
|
58
|
+
*/
|
54
59
|
serialize(context) {
|
55
60
|
const { write } = context;
|
56
61
|
write(this.names);
|
@@ -59,6 +64,9 @@ class CommonJsFullRequireDependency extends ModuleDependency {
|
|
59
64
|
super.serialize(context);
|
60
65
|
}
|
61
66
|
|
67
|
+
/**
|
68
|
+
* @param {ObjectDeserializerContext} context context
|
69
|
+
*/
|
62
70
|
deserialize(context) {
|
63
71
|
const { read } = context;
|
64
72
|
this.names = read();
|
@@ -9,6 +9,9 @@ const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
const ContextDependency = require("./ContextDependency");
|
10
10
|
const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
|
11
11
|
|
12
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
13
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
14
|
+
|
12
15
|
class CommonJsRequireContextDependency extends ContextDependency {
|
13
16
|
constructor(options, range, valueRange, inShorthand, context) {
|
14
17
|
super(options, context);
|
@@ -23,6 +26,9 @@ class CommonJsRequireContextDependency extends ContextDependency {
|
|
23
26
|
return "cjs require context";
|
24
27
|
}
|
25
28
|
|
29
|
+
/**
|
30
|
+
* @param {ObjectSerializerContext} context context
|
31
|
+
*/
|
26
32
|
serialize(context) {
|
27
33
|
const { write } = context;
|
28
34
|
|
@@ -33,6 +39,9 @@ class CommonJsRequireContextDependency extends ContextDependency {
|
|
33
39
|
super.serialize(context);
|
34
40
|
}
|
35
41
|
|
42
|
+
/**
|
43
|
+
* @param {ObjectDeserializerContext} context context
|
44
|
+
*/
|
36
45
|
deserialize(context) {
|
37
46
|
const { read } = context;
|
38
47
|
|
@@ -17,6 +17,8 @@ const NullDependency = require("./NullDependency");
|
|
17
17
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
18
18
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
19
19
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
20
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
21
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
20
22
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
21
23
|
|
22
24
|
class CommonJsSelfReferenceDependency extends NullDependency {
|
@@ -53,6 +55,9 @@ class CommonJsSelfReferenceDependency extends NullDependency {
|
|
53
55
|
return [this.call ? this.names.slice(0, -1) : this.names];
|
54
56
|
}
|
55
57
|
|
58
|
+
/**
|
59
|
+
* @param {ObjectSerializerContext} context context
|
60
|
+
*/
|
56
61
|
serialize(context) {
|
57
62
|
const { write } = context;
|
58
63
|
write(this.range);
|
@@ -62,6 +67,9 @@ class CommonJsSelfReferenceDependency extends NullDependency {
|
|
62
67
|
super.serialize(context);
|
63
68
|
}
|
64
69
|
|
70
|
+
/**
|
71
|
+
* @param {ObjectDeserializerContext} context context
|
72
|
+
*/
|
65
73
|
deserialize(context) {
|
66
74
|
const { read } = context;
|
67
75
|
this.range = read();
|
@@ -15,6 +15,8 @@ const NullDependency = require("./NullDependency");
|
|
15
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
16
16
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
17
17
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
18
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
19
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
18
20
|
/** @typedef {import("../util/Hash")} Hash */
|
19
21
|
|
20
22
|
class ConstDependency extends NullDependency {
|
@@ -61,6 +63,9 @@ class ConstDependency extends NullDependency {
|
|
61
63
|
return false;
|
62
64
|
}
|
63
65
|
|
66
|
+
/**
|
67
|
+
* @param {ObjectSerializerContext} context context
|
68
|
+
*/
|
64
69
|
serialize(context) {
|
65
70
|
const { write } = context;
|
66
71
|
write(this.expression);
|
@@ -69,6 +74,9 @@ class ConstDependency extends NullDependency {
|
|
69
74
|
super.serialize(context);
|
70
75
|
}
|
71
76
|
|
77
|
+
/**
|
78
|
+
* @param {ObjectDeserializerContext} context context
|
79
|
+
*/
|
72
80
|
deserialize(context) {
|
73
81
|
const { read } = context;
|
74
82
|
this.expression = read();
|
@@ -14,6 +14,8 @@ const memoize = require("../util/memoize");
|
|
14
14
|
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
15
15
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
16
|
/** @typedef {import("../WebpackError")} WebpackError */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
18
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
17
19
|
|
18
20
|
const getCriticalDependencyWarning = memoize(() =>
|
19
21
|
require("./CriticalDependencyWarning")
|
@@ -115,6 +117,9 @@ class ContextDependency extends Dependency {
|
|
115
117
|
return warnings;
|
116
118
|
}
|
117
119
|
|
120
|
+
/**
|
121
|
+
* @param {ObjectSerializerContext} context context
|
122
|
+
*/
|
118
123
|
serialize(context) {
|
119
124
|
const { write } = context;
|
120
125
|
|
@@ -132,6 +137,9 @@ class ContextDependency extends Dependency {
|
|
132
137
|
super.serialize(context);
|
133
138
|
}
|
134
139
|
|
140
|
+
/**
|
141
|
+
* @param {ObjectDeserializerContext} context context
|
142
|
+
*/
|
135
143
|
deserialize(context) {
|
136
144
|
const { read } = context;
|
137
145
|
|
@@ -11,6 +11,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
11
11
|
|
12
12
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
13
13
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
14
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
15
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
14
16
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
15
17
|
|
16
18
|
class ContextElementDependency extends ModuleDependency {
|
@@ -68,6 +70,9 @@ class ContextElementDependency extends ModuleDependency {
|
|
68
70
|
: Dependency.EXPORTS_OBJECT_REFERENCED;
|
69
71
|
}
|
70
72
|
|
73
|
+
/**
|
74
|
+
* @param {ObjectSerializerContext} context context
|
75
|
+
*/
|
71
76
|
serialize(context) {
|
72
77
|
const { write } = context;
|
73
78
|
write(this._typePrefix);
|
@@ -76,6 +81,9 @@ class ContextElementDependency extends ModuleDependency {
|
|
76
81
|
super.serialize(context);
|
77
82
|
}
|
78
83
|
|
84
|
+
/**
|
85
|
+
* @param {ObjectDeserializerContext} context context
|
86
|
+
*/
|
79
87
|
deserialize(context) {
|
80
88
|
const { read } = context;
|
81
89
|
this._typePrefix = read();
|
@@ -12,6 +12,8 @@ const NullDependency = require("./NullDependency");
|
|
12
12
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
13
13
|
/** @typedef {import("../Dependency")} Dependency */
|
14
14
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
15
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
15
17
|
|
16
18
|
class CreateScriptUrlDependency extends NullDependency {
|
17
19
|
/**
|
@@ -26,12 +28,18 @@ class CreateScriptUrlDependency extends NullDependency {
|
|
26
28
|
return "create script url";
|
27
29
|
}
|
28
30
|
|
31
|
+
/**
|
32
|
+
* @param {ObjectSerializerContext} context context
|
33
|
+
*/
|
29
34
|
serialize(context) {
|
30
35
|
const { write } = context;
|
31
36
|
write(this.range);
|
32
37
|
super.serialize(context);
|
33
38
|
}
|
34
39
|
|
40
|
+
/**
|
41
|
+
* @param {ObjectDeserializerContext} context context
|
42
|
+
*/
|
35
43
|
deserialize(context) {
|
36
44
|
const { read } = context;
|
37
45
|
this.range = read();
|
@@ -13,6 +13,8 @@ const NullDependency = require("./NullDependency");
|
|
13
13
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
14
14
|
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
15
15
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
16
18
|
|
17
19
|
class CssExportDependency extends NullDependency {
|
18
20
|
/**
|
@@ -47,6 +49,9 @@ class CssExportDependency extends NullDependency {
|
|
47
49
|
};
|
48
50
|
}
|
49
51
|
|
52
|
+
/**
|
53
|
+
* @param {ObjectSerializerContext} context context
|
54
|
+
*/
|
50
55
|
serialize(context) {
|
51
56
|
const { write } = context;
|
52
57
|
write(this.name);
|
@@ -54,6 +59,9 @@ class CssExportDependency extends NullDependency {
|
|
54
59
|
super.serialize(context);
|
55
60
|
}
|
56
61
|
|
62
|
+
/**
|
63
|
+
* @param {ObjectDeserializerContext} context context
|
64
|
+
*/
|
57
65
|
deserialize(context) {
|
58
66
|
const { read } = context;
|
59
67
|
this.name = read();
|
@@ -17,19 +17,27 @@ const ModuleDependency = require("./ModuleDependency");
|
|
17
17
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
18
18
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
19
19
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
20
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
21
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
20
22
|
/** @typedef {import("../util/Hash")} Hash */
|
21
23
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
22
24
|
|
23
25
|
class CssImportDependency extends ModuleDependency {
|
24
26
|
/**
|
27
|
+
* Example of dependency:
|
28
|
+
*
|
29
|
+
* \@import url("landscape.css") layer(forms) screen and (orientation: landscape) screen and (orientation: landscape);
|
30
|
+
*
|
25
31
|
* @param {string} request request
|
26
32
|
* @param {[number, number]} range range of the argument
|
33
|
+
* @param {string | undefined} layer layer
|
27
34
|
* @param {string | undefined} supports list of supports conditions
|
28
35
|
* @param {string | undefined} media list of media conditions
|
29
36
|
*/
|
30
|
-
constructor(request, range, supports, media) {
|
37
|
+
constructor(request, range, layer, supports, media) {
|
31
38
|
super(request);
|
32
39
|
this.range = range;
|
40
|
+
this.layer = layer;
|
33
41
|
this.supports = supports;
|
34
42
|
this.media = media;
|
35
43
|
}
|
@@ -42,6 +50,27 @@ class CssImportDependency extends ModuleDependency {
|
|
42
50
|
return "css-import";
|
43
51
|
}
|
44
52
|
|
53
|
+
/**
|
54
|
+
* @returns {string | null} an identifier to merge equal requests
|
55
|
+
*/
|
56
|
+
getResourceIdentifier() {
|
57
|
+
let str = `context${this._context || ""}|module${this.request}`;
|
58
|
+
|
59
|
+
if (this.layer) {
|
60
|
+
str += `|layer${this.layer}`;
|
61
|
+
}
|
62
|
+
|
63
|
+
if (this.supports) {
|
64
|
+
str += `|supports${this.supports}`;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (this.media) {
|
68
|
+
str += `|media${this.media}`;
|
69
|
+
}
|
70
|
+
|
71
|
+
return str;
|
72
|
+
}
|
73
|
+
|
45
74
|
/**
|
46
75
|
* @param {string} context context directory
|
47
76
|
* @returns {Module} a module
|
@@ -49,6 +78,28 @@ class CssImportDependency extends ModuleDependency {
|
|
49
78
|
createIgnoredModule(context) {
|
50
79
|
return null;
|
51
80
|
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* @param {ObjectSerializerContext} context context
|
84
|
+
*/
|
85
|
+
serialize(context) {
|
86
|
+
const { write } = context;
|
87
|
+
write(this.layer);
|
88
|
+
write(this.supports);
|
89
|
+
write(this.media);
|
90
|
+
super.serialize(context);
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* @param {ObjectDeserializerContext} context context
|
95
|
+
*/
|
96
|
+
deserialize(context) {
|
97
|
+
const { read } = context;
|
98
|
+
this.layer = read();
|
99
|
+
this.supports = read();
|
100
|
+
this.media = read();
|
101
|
+
super.deserialize(context);
|
102
|
+
}
|
52
103
|
}
|
53
104
|
|
54
105
|
CssImportDependency.Template = class CssImportDependencyTemplate extends (
|
@@ -13,6 +13,8 @@ const NullDependency = require("./NullDependency");
|
|
13
13
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
14
14
|
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
15
15
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
16
18
|
|
17
19
|
class CssLocalIdentifierDependency extends NullDependency {
|
18
20
|
/**
|
@@ -49,6 +51,9 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
49
51
|
};
|
50
52
|
}
|
51
53
|
|
54
|
+
/**
|
55
|
+
* @param {ObjectSerializerContext} context context
|
56
|
+
*/
|
52
57
|
serialize(context) {
|
53
58
|
const { write } = context;
|
54
59
|
write(this.name);
|
@@ -57,6 +62,9 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
57
62
|
super.serialize(context);
|
58
63
|
}
|
59
64
|
|
65
|
+
/**
|
66
|
+
* @param {ObjectDeserializerContext} context context
|
67
|
+
*/
|
60
68
|
deserialize(context) {
|
61
69
|
const { read } = context;
|
62
70
|
this.name = read();
|
@@ -14,6 +14,8 @@ const CssLocalIdentifierDependency = require("./CssLocalIdentifierDependency");
|
|
14
14
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
15
15
|
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
16
16
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
18
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
17
19
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
18
20
|
|
19
21
|
class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
|
@@ -64,12 +66,18 @@ class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
|
|
64
66
|
return [[this.name]];
|
65
67
|
}
|
66
68
|
|
69
|
+
/**
|
70
|
+
* @param {ObjectSerializerContext} context context
|
71
|
+
*/
|
67
72
|
serialize(context) {
|
68
73
|
const { write } = context;
|
69
74
|
write(this.declaredSet);
|
70
75
|
super.serialize(context);
|
71
76
|
}
|
72
77
|
|
78
|
+
/**
|
79
|
+
* @param {ObjectDeserializerContext} context context
|
80
|
+
*/
|
73
81
|
deserialize(context) {
|
74
82
|
const { read } = context;
|
75
83
|
this.declaredSet = read();
|
@@ -18,6 +18,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
18
18
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
19
19
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
20
20
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
21
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
22
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
21
23
|
/** @typedef {import("../util/Hash")} Hash */
|
22
24
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
23
25
|
|
@@ -27,12 +29,12 @@ class CssUrlDependency extends ModuleDependency {
|
|
27
29
|
/**
|
28
30
|
* @param {string} request request
|
29
31
|
* @param {[number, number]} range range of the argument
|
30
|
-
* @param {string
|
32
|
+
* @param {"string" | "url"} urlType dependency type e.g. url() or string
|
31
33
|
*/
|
32
|
-
constructor(request, range,
|
34
|
+
constructor(request, range, urlType) {
|
33
35
|
super(request);
|
34
36
|
this.range = range;
|
35
|
-
this.
|
37
|
+
this.urlType = urlType;
|
36
38
|
}
|
37
39
|
|
38
40
|
get type() {
|
@@ -52,15 +54,21 @@ class CssUrlDependency extends ModuleDependency {
|
|
52
54
|
return new RawDataUrlModule("data:,", `ignored-asset`, `(ignored asset)`);
|
53
55
|
}
|
54
56
|
|
57
|
+
/**
|
58
|
+
* @param {ObjectSerializerContext} context context
|
59
|
+
*/
|
55
60
|
serialize(context) {
|
56
61
|
const { write } = context;
|
57
|
-
write(this.
|
62
|
+
write(this.urlType);
|
58
63
|
super.serialize(context);
|
59
64
|
}
|
60
65
|
|
66
|
+
/**
|
67
|
+
* @param {ObjectDeserializerContext} context context
|
68
|
+
*/
|
61
69
|
deserialize(context) {
|
62
70
|
const { read } = context;
|
63
|
-
this.
|
71
|
+
this.urlType = read();
|
64
72
|
super.deserialize(context);
|
65
73
|
}
|
66
74
|
}
|
@@ -108,22 +116,34 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
|
108
116
|
apply(
|
109
117
|
dependency,
|
110
118
|
source,
|
111
|
-
{
|
119
|
+
{ moduleGraph, runtimeTemplate, codeGenerationResults }
|
112
120
|
) {
|
113
121
|
const dep = /** @type {CssUrlDependency} */ (dependency);
|
114
122
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
let newValue;
|
124
|
+
|
125
|
+
switch (dep.urlType) {
|
126
|
+
case "string":
|
127
|
+
newValue = cssEscapeString(
|
128
|
+
runtimeTemplate.assetUrl({
|
129
|
+
publicPath: "",
|
130
|
+
module: moduleGraph.getModule(dep),
|
131
|
+
codeGenerationResults
|
132
|
+
})
|
133
|
+
);
|
134
|
+
break;
|
135
|
+
case "url":
|
136
|
+
newValue = `url(${cssEscapeString(
|
137
|
+
runtimeTemplate.assetUrl({
|
138
|
+
publicPath: "",
|
139
|
+
module: moduleGraph.getModule(dep),
|
140
|
+
codeGenerationResults
|
141
|
+
})
|
142
|
+
)})`;
|
143
|
+
break;
|
144
|
+
}
|
145
|
+
|
146
|
+
source.replace(dep.range[0], dep.range[1] - 1, newValue);
|
127
147
|
}
|
128
148
|
};
|
129
149
|
|
@@ -8,6 +8,9 @@
|
|
8
8
|
const Dependency = require("../Dependency");
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
10
10
|
|
11
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
12
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
13
|
+
|
11
14
|
class DllEntryDependency extends Dependency {
|
12
15
|
constructor(dependencies, name) {
|
13
16
|
super();
|
@@ -20,6 +23,9 @@ class DllEntryDependency extends Dependency {
|
|
20
23
|
return "dll entry";
|
21
24
|
}
|
22
25
|
|
26
|
+
/**
|
27
|
+
* @param {ObjectSerializerContext} context context
|
28
|
+
*/
|
23
29
|
serialize(context) {
|
24
30
|
const { write } = context;
|
25
31
|
|
@@ -29,6 +35,9 @@ class DllEntryDependency extends Dependency {
|
|
29
35
|
super.serialize(context);
|
30
36
|
}
|
31
37
|
|
38
|
+
/**
|
39
|
+
* @param {ObjectDeserializerContext} context context
|
40
|
+
*/
|
32
41
|
deserialize(context) {
|
33
42
|
const { read } = context;
|
34
43
|
|
@@ -16,6 +16,8 @@ const NullDependency = require("./NullDependency");
|
|
16
16
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
17
17
|
/** @typedef {import("../Module")} Module */
|
18
18
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
19
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
20
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
19
21
|
/** @typedef {import("../util/Hash")} Hash */
|
20
22
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
21
23
|
|
@@ -89,6 +91,9 @@ class ExportsInfoDependency extends NullDependency {
|
|
89
91
|
this.property = property;
|
90
92
|
}
|
91
93
|
|
94
|
+
/**
|
95
|
+
* @param {ObjectSerializerContext} context context
|
96
|
+
*/
|
92
97
|
serialize(context) {
|
93
98
|
const { write } = context;
|
94
99
|
write(this.range);
|
@@ -13,6 +13,8 @@ const NullDependency = require("./NullDependency");
|
|
13
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
14
14
|
/** @typedef {import("../Dependency")} Dependency */
|
15
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
16
18
|
/** @typedef {import("./HarmonyAcceptImportDependency")} HarmonyAcceptImportDependency */
|
17
19
|
|
18
20
|
class HarmonyAcceptDependency extends NullDependency {
|
@@ -32,6 +34,9 @@ class HarmonyAcceptDependency extends NullDependency {
|
|
32
34
|
return "accepted harmony modules";
|
33
35
|
}
|
34
36
|
|
37
|
+
/**
|
38
|
+
* @param {ObjectSerializerContext} context context
|
39
|
+
*/
|
35
40
|
serialize(context) {
|
36
41
|
const { write } = context;
|
37
42
|
write(this.range);
|
@@ -40,6 +45,9 @@ class HarmonyAcceptDependency extends NullDependency {
|
|
40
45
|
super.serialize(context);
|
41
46
|
}
|
42
47
|
|
48
|
+
/**
|
49
|
+
* @param {ObjectDeserializerContext} context context
|
50
|
+
*/
|
43
51
|
deserialize(context) {
|
44
52
|
const { read } = context;
|
45
53
|
this.range = read();
|