webpack 5.80.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/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 +15 -3
- package/lib/RawModule.js +8 -0
- package/lib/WebpackError.js +8 -0
- 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 +132 -73
- package/lib/css/walkCssTokens.js +27 -47
- 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 +8 -0
- 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/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/index.js +1 -0
- package/lib/javascript/JavascriptParser.js +1 -1
- package/lib/optimize/RealContentHashPlugin.js +6 -0
- package/lib/runtime/AutoPublicPathRuntimeModule.js +6 -1
- 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/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 +4 -5
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +8 -0
- package/types.d.ts +55 -22
package/lib/Module.js
CHANGED
@@ -33,6 +33,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
33
33
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
34
34
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
35
35
|
/** @typedef {import("./WebpackError")} WebpackError */
|
36
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
37
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
36
38
|
/** @typedef {import("./util/Hash")} Hash */
|
37
39
|
/** @template T @typedef {import("./util/LazySet")<T>} LazySet<T> */
|
38
40
|
/** @template T @typedef {import("./util/SortableSet")<T>} SortableSet<T> */
|
@@ -976,6 +978,9 @@ class Module extends DependenciesBlock {
|
|
976
978
|
buildDependencies
|
977
979
|
) {}
|
978
980
|
|
981
|
+
/**
|
982
|
+
* @param {ObjectSerializerContext} context context
|
983
|
+
*/
|
979
984
|
serialize(context) {
|
980
985
|
const { write } = context;
|
981
986
|
write(this.type);
|
@@ -1002,6 +1007,9 @@ class Module extends DependenciesBlock {
|
|
1002
1007
|
super.serialize(context);
|
1003
1008
|
}
|
1004
1009
|
|
1010
|
+
/**
|
1011
|
+
* @param {ObjectDeserializerContext} context context
|
1012
|
+
*/
|
1005
1013
|
deserialize(context) {
|
1006
1014
|
const { read } = context;
|
1007
1015
|
this.type = read();
|
package/lib/ModuleBuildError.js
CHANGED
@@ -9,6 +9,9 @@ const { cutOffLoaderExecution } = require("./ErrorHelpers");
|
|
9
9
|
const WebpackError = require("./WebpackError");
|
10
10
|
const makeSerializable = require("./util/makeSerializable");
|
11
11
|
|
12
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
13
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
14
|
+
|
12
15
|
class ModuleBuildError extends WebpackError {
|
13
16
|
/**
|
14
17
|
* @param {string | Error&any} err error thrown
|
@@ -55,6 +58,9 @@ class ModuleBuildError extends WebpackError {
|
|
55
58
|
this.error = err;
|
56
59
|
}
|
57
60
|
|
61
|
+
/**
|
62
|
+
* @param {ObjectSerializerContext} context context
|
63
|
+
*/
|
58
64
|
serialize(context) {
|
59
65
|
const { write } = context;
|
60
66
|
|
@@ -63,6 +69,9 @@ class ModuleBuildError extends WebpackError {
|
|
63
69
|
super.serialize(context);
|
64
70
|
}
|
65
71
|
|
72
|
+
/**
|
73
|
+
* @param {ObjectDeserializerContext} context context
|
74
|
+
*/
|
66
75
|
deserialize(context) {
|
67
76
|
const { read } = context;
|
68
77
|
|
package/lib/ModuleError.js
CHANGED
@@ -9,6 +9,9 @@ const { cleanUp } = require("./ErrorHelpers");
|
|
9
9
|
const WebpackError = require("./WebpackError");
|
10
10
|
const makeSerializable = require("./util/makeSerializable");
|
11
11
|
|
12
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
13
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
14
|
+
|
12
15
|
class ModuleError extends WebpackError {
|
13
16
|
/**
|
14
17
|
* @param {Error} err error thrown
|
@@ -39,6 +42,9 @@ class ModuleError extends WebpackError {
|
|
39
42
|
: undefined;
|
40
43
|
}
|
41
44
|
|
45
|
+
/**
|
46
|
+
* @param {ObjectSerializerContext} context context
|
47
|
+
*/
|
42
48
|
serialize(context) {
|
43
49
|
const { write } = context;
|
44
50
|
|
@@ -47,6 +53,9 @@ class ModuleError extends WebpackError {
|
|
47
53
|
super.serialize(context);
|
48
54
|
}
|
49
55
|
|
56
|
+
/**
|
57
|
+
* @param {ObjectDeserializerContext} context context
|
58
|
+
*/
|
50
59
|
deserialize(context) {
|
51
60
|
const { read } = context;
|
52
61
|
|
@@ -14,6 +14,9 @@ const memoize = require("./util/memoize");
|
|
14
14
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
15
15
|
/** @typedef {typeof import("./util/Hash")} Hash */
|
16
16
|
|
17
|
+
/** @typedef {string | RegExp | string[] | RegExp[]} Matcher */
|
18
|
+
/** @typedef {{test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
|
19
|
+
|
17
20
|
const ModuleFilenameHelpers = exports;
|
18
21
|
|
19
22
|
// TODO webpack 6: consider removing these
|
@@ -43,6 +46,12 @@ ModuleFilenameHelpers.REGEXP_HASH = /\[hash\]/gi;
|
|
43
46
|
ModuleFilenameHelpers.NAMESPACE = "[namespace]";
|
44
47
|
ModuleFilenameHelpers.REGEXP_NAMESPACE = /\[namespace\]/gi;
|
45
48
|
|
49
|
+
/**
|
50
|
+
* Returns a function that returns the part of the string after the token
|
51
|
+
* @param {() => string} strFn the function to get the string
|
52
|
+
* @param {string} token the token to search for
|
53
|
+
* @returns {() => string} a function that returns the part of the string after the token
|
54
|
+
*/
|
46
55
|
const getAfter = (strFn, token) => {
|
47
56
|
return () => {
|
48
57
|
const str = strFn();
|
@@ -51,6 +60,12 @@ const getAfter = (strFn, token) => {
|
|
51
60
|
};
|
52
61
|
};
|
53
62
|
|
63
|
+
/**
|
64
|
+
* Returns a function that returns the part of the string before the token
|
65
|
+
* @param {() => string} strFn the function to get the string
|
66
|
+
* @param {string} token the token to search for
|
67
|
+
* @returns {() => string} a function that returns the part of the string before the token
|
68
|
+
*/
|
54
69
|
const getBefore = (strFn, token) => {
|
55
70
|
return () => {
|
56
71
|
const str = strFn();
|
@@ -59,6 +74,12 @@ const getBefore = (strFn, token) => {
|
|
59
74
|
};
|
60
75
|
};
|
61
76
|
|
77
|
+
/**
|
78
|
+
* Returns a function that returns a hash of the string
|
79
|
+
* @param {() => string} strFn the function to get the string
|
80
|
+
* @param {string | Hash} hashFunction the hash function to use
|
81
|
+
* @returns {() => string} a function that returns the hash of the string
|
82
|
+
*/
|
62
83
|
const getHash = (strFn, hashFunction) => {
|
63
84
|
return () => {
|
64
85
|
const hash = createHash(hashFunction);
|
@@ -68,13 +89,35 @@ const getHash = (strFn, hashFunction) => {
|
|
68
89
|
};
|
69
90
|
};
|
70
91
|
|
92
|
+
/**
|
93
|
+
* Returns a function that returns the string with the token replaced with the replacement
|
94
|
+
* @param {string|RegExp} test A regular expression string or Regular Expression object
|
95
|
+
* @returns {RegExp} A regular expression object
|
96
|
+
* @example
|
97
|
+
* ```js
|
98
|
+
* const test = asRegExp("test");
|
99
|
+
* test.test("test"); // true
|
100
|
+
*
|
101
|
+
* const test2 = asRegExp(/test/);
|
102
|
+
* test2.test("test"); // true
|
103
|
+
* ```
|
104
|
+
*/
|
71
105
|
const asRegExp = test => {
|
72
106
|
if (typeof test === "string") {
|
107
|
+
// Escape special characters in the string to prevent them from being interpreted as special characters in a regular expression. Do this by
|
108
|
+
// adding a backslash before each special character
|
73
109
|
test = new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
74
110
|
}
|
75
111
|
return test;
|
76
112
|
};
|
77
113
|
|
114
|
+
/**
|
115
|
+
* @template T
|
116
|
+
* Returns a lazy object. The object is lazy in the sense that the properties are
|
117
|
+
* only evaluated when they are accessed. This is only obtained by setting a function as the value for each key.
|
118
|
+
* @param {Record<string, () => T>} obj the object to covert to a lazy access object
|
119
|
+
* @returns {Object} the lazy access object
|
120
|
+
*/
|
78
121
|
const lazyObject = obj => {
|
79
122
|
const newObj = {};
|
80
123
|
for (const key of Object.keys(obj)) {
|
@@ -95,7 +138,7 @@ const lazyObject = obj => {
|
|
95
138
|
return newObj;
|
96
139
|
};
|
97
140
|
|
98
|
-
const
|
141
|
+
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi;
|
99
142
|
|
100
143
|
/**
|
101
144
|
*
|
@@ -212,7 +255,7 @@ ModuleFilenameHelpers.createFilename = (
|
|
212
255
|
ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE,
|
213
256
|
"[short-identifier]"
|
214
257
|
)
|
215
|
-
.replace(
|
258
|
+
.replace(SQUARE_BRACKET_TAG_REGEXP, (match, content) => {
|
216
259
|
if (content.length + 2 === match.length) {
|
217
260
|
const replacement = replacements.get(content.toLowerCase());
|
218
261
|
if (replacement !== undefined) {
|
@@ -225,9 +268,28 @@ ModuleFilenameHelpers.createFilename = (
|
|
225
268
|
});
|
226
269
|
};
|
227
270
|
|
271
|
+
/**
|
272
|
+
* Replaces duplicate items in an array with new values generated by a callback function.
|
273
|
+
* The callback function is called with the duplicate item, the index of the duplicate item, and the number of times the item has been replaced.
|
274
|
+
* The callback function should return the new value for the duplicate item.
|
275
|
+
*
|
276
|
+
* @template T
|
277
|
+
* @param {T[]} array the array with duplicates to be replaced
|
278
|
+
* @param {(duplicateItem: T, duplicateItemIndex: number, numberOfTimesReplaced: number) => T} fn callback function to generate new values for the duplicate items
|
279
|
+
* @param {(firstElement:T, nextElement:T) => -1 | 0 | 1} [comparator] optional comparator function to sort the duplicate items
|
280
|
+
* @returns {T[]} the array with duplicates replaced
|
281
|
+
*
|
282
|
+
* @example
|
283
|
+
* ```js
|
284
|
+
* const array = ["a", "b", "c", "a", "b", "a"];
|
285
|
+
* const result = ModuleFilenameHelpers.replaceDuplicates(array, (item, index, count) => `${item}-${count}`);
|
286
|
+
* // result: ["a-1", "b-1", "c", "a-2", "b-2", "a-3"]
|
287
|
+
* ```
|
288
|
+
*/
|
228
289
|
ModuleFilenameHelpers.replaceDuplicates = (array, fn, comparator) => {
|
229
290
|
const countMap = Object.create(null);
|
230
291
|
const posMap = Object.create(null);
|
292
|
+
|
231
293
|
array.forEach((item, idx) => {
|
232
294
|
countMap[item] = countMap[item] || [];
|
233
295
|
countMap[item].push(idx);
|
@@ -248,16 +310,63 @@ ModuleFilenameHelpers.replaceDuplicates = (array, fn, comparator) => {
|
|
248
310
|
});
|
249
311
|
};
|
250
312
|
|
313
|
+
/**
|
314
|
+
* Tests if a string matches a RegExp or an array of RegExp.
|
315
|
+
*
|
316
|
+
* @param {string} str string to test
|
317
|
+
* @param {Matcher} test value which will be used to match against the string
|
318
|
+
* @returns {boolean} true, when the RegExp matches
|
319
|
+
*
|
320
|
+
* @example
|
321
|
+
* ```js
|
322
|
+
* ModuleFilenameHelpers.matchPart("foo.js", "foo"); // true
|
323
|
+
* ModuleFilenameHelpers.matchPart("foo.js", "foo.js"); // true
|
324
|
+
* ModuleFilenameHelpers.matchPart("foo.js", "foo."); // false
|
325
|
+
* ModuleFilenameHelpers.matchPart("foo.js", "foo*"); // false
|
326
|
+
* ModuleFilenameHelpers.matchPart("foo.js", "foo.*"); // true
|
327
|
+
* ModuleFilenameHelpers.matchPart("foo.js", /^foo/); // true
|
328
|
+
* ModuleFilenameHelpers.matchPart("foo.js", [/^foo/, "bar"]); // true
|
329
|
+
* ModuleFilenameHelpers.matchPart("foo.js", [/^foo/, "bar"]); // true
|
330
|
+
* ModuleFilenameHelpers.matchPart("foo.js", [/^foo/, /^bar/]); // true
|
331
|
+
* ModuleFilenameHelpers.matchPart("foo.js", [/^baz/, /^bar/]); // false
|
332
|
+
* ```
|
333
|
+
*/
|
251
334
|
ModuleFilenameHelpers.matchPart = (str, test) => {
|
252
335
|
if (!test) return true;
|
253
|
-
|
336
|
+
|
254
337
|
if (Array.isArray(test)) {
|
255
338
|
return test.map(asRegExp).some(regExp => regExp.test(str));
|
256
339
|
} else {
|
257
|
-
return test.test(str);
|
340
|
+
return asRegExp(test).test(str);
|
258
341
|
}
|
259
342
|
};
|
260
343
|
|
344
|
+
/**
|
345
|
+
* Tests if a string matches a match object. The match object can have the following properties:
|
346
|
+
* - `test`: a RegExp or an array of RegExp
|
347
|
+
* - `include`: a RegExp or an array of RegExp
|
348
|
+
* - `exclude`: a RegExp or an array of RegExp
|
349
|
+
*
|
350
|
+
* The `test` property is tested first, then `include` and then `exclude`.
|
351
|
+
*
|
352
|
+
* @param {MatchObject} obj a match object to test against the string
|
353
|
+
* @param {string} str string to test against the matching object
|
354
|
+
* @returns {boolean} true, when the object matches
|
355
|
+
* @example
|
356
|
+
* ```js
|
357
|
+
* ModuleFilenameHelpers.matchObject({ test: "foo.js" }, "foo.js"); // true
|
358
|
+
* ModuleFilenameHelpers.matchObject({ test: /^foo/ }, "foo.js"); // true
|
359
|
+
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "foo.js"); // true
|
360
|
+
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "baz.js"); // false
|
361
|
+
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "foo.js"); // true
|
362
|
+
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "bar.js"); // false
|
363
|
+
* ModuleFilenameHelpers.matchObject({ include: /^foo/ }, "foo.js"); // true
|
364
|
+
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "foo.js"); // true
|
365
|
+
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "baz.js"); // false
|
366
|
+
* ModuleFilenameHelpers.matchObject({ exclude: "foo.js" }, "foo.js"); // false
|
367
|
+
* ModuleFilenameHelpers.matchObject({ exclude: [/^foo/, "bar"] }, "foo.js"); // false
|
368
|
+
* ```
|
369
|
+
*/
|
261
370
|
ModuleFilenameHelpers.matchObject = (obj, str) => {
|
262
371
|
if (obj.test) {
|
263
372
|
if (!ModuleFilenameHelpers.matchPart(str, obj.test)) {
|
package/lib/ModuleParseError.js
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
const WebpackError = require("./WebpackError");
|
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
|
const WASM_HEADER = Buffer.from([0x00, 0x61, 0x73, 0x6d]);
|
12
15
|
|
13
16
|
class ModuleParseError extends WebpackError {
|
@@ -87,6 +90,9 @@ class ModuleParseError extends WebpackError {
|
|
87
90
|
this.error = err;
|
88
91
|
}
|
89
92
|
|
93
|
+
/**
|
94
|
+
* @param {ObjectSerializerContext} context context
|
95
|
+
*/
|
90
96
|
serialize(context) {
|
91
97
|
const { write } = context;
|
92
98
|
|
@@ -95,6 +101,9 @@ class ModuleParseError extends WebpackError {
|
|
95
101
|
super.serialize(context);
|
96
102
|
}
|
97
103
|
|
104
|
+
/**
|
105
|
+
* @param {ObjectDeserializerContext} context context
|
106
|
+
*/
|
98
107
|
deserialize(context) {
|
99
108
|
const { read } = context;
|
100
109
|
|
@@ -42,9 +42,30 @@ const WEBASSEMBLY_MODULE_TYPE_ASYNC = "webassembly/async";
|
|
42
42
|
*/
|
43
43
|
const WEBASSEMBLY_MODULE_TYPE_SYNC = "webassembly/sync";
|
44
44
|
|
45
|
+
/**
|
46
|
+
* @type {Readonly<"css">}
|
47
|
+
* This is the module type used for CSS files.
|
48
|
+
*/
|
49
|
+
const CSS_MODULE_TYPE = "css";
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @type {Readonly<"css/global">}
|
53
|
+
* This is the module type used for CSS modules files where you need to use `:local` in selector list to hash classes.
|
54
|
+
*/
|
55
|
+
const CSS_MODULE_TYPE_GLOBAL = "css/global";
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @type {Readonly<"css/module">}
|
59
|
+
* This is the module type used for CSS modules files, by default all classes are hashed.
|
60
|
+
*/
|
61
|
+
const CSS_MODULE_TYPE_MODULE = "css/module";
|
62
|
+
|
45
63
|
exports.JAVASCRIPT_MODULE_TYPE_AUTO = JAVASCRIPT_MODULE_TYPE_AUTO;
|
46
64
|
exports.JAVASCRIPT_MODULE_TYPE_DYNAMIC = JAVASCRIPT_MODULE_TYPE_DYNAMIC;
|
47
65
|
exports.JAVASCRIPT_MODULE_TYPE_ESM = JAVASCRIPT_MODULE_TYPE_ESM;
|
48
66
|
exports.JSON_MODULE_TYPE = JSON_MODULE_TYPE;
|
49
67
|
exports.WEBASSEMBLY_MODULE_TYPE_ASYNC = WEBASSEMBLY_MODULE_TYPE_ASYNC;
|
50
68
|
exports.WEBASSEMBLY_MODULE_TYPE_SYNC = WEBASSEMBLY_MODULE_TYPE_SYNC;
|
69
|
+
exports.CSS_MODULE_TYPE = CSS_MODULE_TYPE;
|
70
|
+
exports.CSS_MODULE_TYPE_GLOBAL = CSS_MODULE_TYPE_GLOBAL;
|
71
|
+
exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE;
|
package/lib/ModuleWarning.js
CHANGED
@@ -9,6 +9,9 @@ const { cleanUp } = require("./ErrorHelpers");
|
|
9
9
|
const WebpackError = require("./WebpackError");
|
10
10
|
const makeSerializable = require("./util/makeSerializable");
|
11
11
|
|
12
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
13
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
14
|
+
|
12
15
|
class ModuleWarning extends WebpackError {
|
13
16
|
/**
|
14
17
|
* @param {Error} warning error thrown
|
@@ -39,6 +42,9 @@ class ModuleWarning extends WebpackError {
|
|
39
42
|
: undefined;
|
40
43
|
}
|
41
44
|
|
45
|
+
/**
|
46
|
+
* @param {ObjectSerializerContext} context context
|
47
|
+
*/
|
42
48
|
serialize(context) {
|
43
49
|
const { write } = context;
|
44
50
|
|
@@ -47,6 +53,9 @@ class ModuleWarning extends WebpackError {
|
|
47
53
|
super.serialize(context);
|
48
54
|
}
|
49
55
|
|
56
|
+
/**
|
57
|
+
* @param {ObjectDeserializerContext} context context
|
58
|
+
*/
|
50
59
|
deserialize(context) {
|
51
60
|
const { read } = context;
|
52
61
|
|
package/lib/NormalModule.js
CHANGED
@@ -71,6 +71,8 @@ const memoize = require("./util/memoize");
|
|
71
71
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
72
72
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
73
73
|
/** @typedef {import("./logging/Logger").Logger} WebpackLogger */
|
74
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
75
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
74
76
|
/** @typedef {import("./util/Hash")} Hash */
|
75
77
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
76
78
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
@@ -1365,6 +1367,9 @@ class NormalModule extends Module {
|
|
1365
1367
|
super.updateHash(hash, context);
|
1366
1368
|
}
|
1367
1369
|
|
1370
|
+
/**
|
1371
|
+
* @param {ObjectSerializerContext} context context
|
1372
|
+
*/
|
1368
1373
|
serialize(context) {
|
1369
1374
|
const { write } = context;
|
1370
1375
|
// deserialize
|
@@ -1399,6 +1404,9 @@ class NormalModule extends Module {
|
|
1399
1404
|
return obj;
|
1400
1405
|
}
|
1401
1406
|
|
1407
|
+
/**
|
1408
|
+
* @param {ObjectDeserializerContext} context context
|
1409
|
+
*/
|
1402
1410
|
deserialize(context) {
|
1403
1411
|
const { read } = context;
|
1404
1412
|
this._source = read();
|
@@ -233,6 +233,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
233
233
|
),
|
234
234
|
generator: new HookMap(
|
235
235
|
() => new SyncHook(["generator", "generatorOptions"])
|
236
|
+
),
|
237
|
+
createModuleClass: new HookMap(
|
238
|
+
() => new SyncBailHook(["createData", "resolveData"])
|
236
239
|
)
|
237
240
|
});
|
238
241
|
this.resolverFactory = resolverFactory;
|
@@ -308,9 +311,18 @@ class NormalModuleFactory extends ModuleFactory {
|
|
308
311
|
return callback(new Error("Empty dependency (no request)"));
|
309
312
|
}
|
310
313
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
+
// TODO webpack 6 make it required and move javascript/wasm/asset properties to own module
|
315
|
+
createdModule = this.hooks.createModuleClass
|
316
|
+
.for(createData.settings.type)
|
317
|
+
.call(createData, resolveData);
|
318
|
+
|
319
|
+
if (!createdModule) {
|
320
|
+
createdModule = /** @type {Module} */ (
|
321
|
+
new NormalModule(
|
322
|
+
/** @type {NormalModuleCreateData} */ (createData)
|
323
|
+
)
|
324
|
+
);
|
325
|
+
}
|
314
326
|
}
|
315
327
|
|
316
328
|
createdModule = this.hooks.module.call(
|
package/lib/RawModule.js
CHANGED
@@ -23,6 +23,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
23
23
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
24
24
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
25
25
|
/** @typedef {import("./WebpackError")} WebpackError */
|
26
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
27
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
26
28
|
/** @typedef {import("./util/Hash")} Hash */
|
27
29
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
28
30
|
|
@@ -125,6 +127,9 @@ class RawModule extends Module {
|
|
125
127
|
super.updateHash(hash, context);
|
126
128
|
}
|
127
129
|
|
130
|
+
/**
|
131
|
+
* @param {ObjectSerializerContext} context context
|
132
|
+
*/
|
128
133
|
serialize(context) {
|
129
134
|
const { write } = context;
|
130
135
|
|
@@ -136,6 +141,9 @@ class RawModule extends Module {
|
|
136
141
|
super.serialize(context);
|
137
142
|
}
|
138
143
|
|
144
|
+
/**
|
145
|
+
* @param {ObjectDeserializerContext} context context
|
146
|
+
*/
|
139
147
|
deserialize(context) {
|
140
148
|
const { read } = context;
|
141
149
|
|
package/lib/WebpackError.js
CHANGED
@@ -11,6 +11,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
11
11
|
/** @typedef {import("./Chunk")} Chunk */
|
12
12
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
13
13
|
/** @typedef {import("./Module")} Module */
|
14
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
15
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
14
16
|
|
15
17
|
class WebpackError extends Error {
|
16
18
|
/**
|
@@ -37,6 +39,9 @@ class WebpackError extends Error {
|
|
37
39
|
return this.stack + (this.details ? `\n${this.details}` : "");
|
38
40
|
}
|
39
41
|
|
42
|
+
/**
|
43
|
+
* @param {ObjectSerializerContext} context context
|
44
|
+
*/
|
40
45
|
serialize({ write }) {
|
41
46
|
write(this.name);
|
42
47
|
write(this.message);
|
@@ -46,6 +51,9 @@ class WebpackError extends Error {
|
|
46
51
|
write(this.hideStack);
|
47
52
|
}
|
48
53
|
|
54
|
+
/**
|
55
|
+
* @param {ObjectDeserializerContext} context context
|
56
|
+
*/
|
49
57
|
deserialize({ read }) {
|
50
58
|
this.name = read();
|
51
59
|
this.message = read();
|
@@ -19,6 +19,8 @@ const makeSerializable = require("../util/makeSerializable");
|
|
19
19
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
20
20
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
21
21
|
/** @typedef {import("../WebpackError")} WebpackError */
|
22
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
23
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
22
24
|
/** @typedef {import("../util/Hash")} Hash */
|
23
25
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
24
26
|
|
@@ -122,6 +124,9 @@ class RawDataUrlModule extends Module {
|
|
122
124
|
super.updateHash(hash, context);
|
123
125
|
}
|
124
126
|
|
127
|
+
/**
|
128
|
+
* @param {ObjectSerializerContext} context context
|
129
|
+
*/
|
125
130
|
serialize(context) {
|
126
131
|
const { write } = context;
|
127
132
|
|
@@ -132,6 +137,9 @@ class RawDataUrlModule extends Module {
|
|
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
|
|
@@ -124,8 +124,11 @@ class ResolverCachePlugin {
|
|
124
124
|
const newResolveContext = {
|
125
125
|
...resolveContext,
|
126
126
|
stack: new Set(),
|
127
|
+
/** @type {LazySet<string>} */
|
127
128
|
missingDependencies: new LazySet(),
|
129
|
+
/** @type {LazySet<string>} */
|
128
130
|
fileDependencies: new LazySet(),
|
131
|
+
/** @type {LazySet<string>} */
|
129
132
|
contextDependencies: new LazySet()
|
130
133
|
};
|
131
134
|
let yieldResult;
|
@@ -327,6 +327,7 @@ const getNormalizedWebpackOptions = config => {
|
|
327
327
|
hotUpdateChunkFilename: output.hotUpdateChunkFilename,
|
328
328
|
hotUpdateGlobal: output.hotUpdateGlobal,
|
329
329
|
hotUpdateMainFilename: output.hotUpdateMainFilename,
|
330
|
+
ignoreBrowserWarnings: output.ignoreBrowserWarnings,
|
330
331
|
iife: output.iife,
|
331
332
|
importFunctionName: output.importFunctionName,
|
332
333
|
importMetaName: output.importMetaName,
|
@@ -26,6 +26,8 @@ const ContainerExposedDependency = require("./ContainerExposedDependency");
|
|
26
26
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
27
27
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
28
28
|
/** @typedef {import("../WebpackError")} WebpackError */
|
29
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
30
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
29
31
|
/** @typedef {import("../util/Hash")} Hash */
|
30
32
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
31
33
|
/** @typedef {import("./ContainerEntryDependency")} ContainerEntryDependency */
|
@@ -260,6 +262,9 @@ class ContainerEntryModule extends Module {
|
|
260
262
|
return 42;
|
261
263
|
}
|
262
264
|
|
265
|
+
/**
|
266
|
+
* @param {ObjectSerializerContext} context context
|
267
|
+
*/
|
263
268
|
serialize(context) {
|
264
269
|
const { write } = context;
|
265
270
|
write(this._name);
|
@@ -8,6 +8,9 @@
|
|
8
8
|
const ModuleDependency = require("../dependencies/ModuleDependency");
|
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 ContainerExposedDependency extends ModuleDependency {
|
12
15
|
/**
|
13
16
|
* @param {string} exposedName public name
|
@@ -33,11 +36,17 @@ class ContainerExposedDependency extends ModuleDependency {
|
|
33
36
|
return `exposed dependency ${this.exposedName}=${this.request}`;
|
34
37
|
}
|
35
38
|
|
39
|
+
/**
|
40
|
+
* @param {ObjectSerializerContext} context context
|
41
|
+
*/
|
36
42
|
serialize(context) {
|
37
43
|
context.write(this.exposedName);
|
38
44
|
super.serialize(context);
|
39
45
|
}
|
40
46
|
|
47
|
+
/**
|
48
|
+
* @param {ObjectDeserializerContext} context context
|
49
|
+
*/
|
41
50
|
deserialize(context) {
|
42
51
|
this.exposedName = context.read();
|
43
52
|
super.deserialize(context);
|
@@ -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 FallbackDependency extends Dependency {
|
12
15
|
constructor(requests) {
|
13
16
|
super();
|
@@ -29,6 +32,9 @@ class FallbackDependency extends Dependency {
|
|
29
32
|
return "esm";
|
30
33
|
}
|
31
34
|
|
35
|
+
/**
|
36
|
+
* @param {ObjectSerializerContext} context context
|
37
|
+
*/
|
32
38
|
serialize(context) {
|
33
39
|
const { write } = context;
|
34
40
|
write(this.requests);
|
@@ -24,6 +24,8 @@ const FallbackItemDependency = require("./FallbackItemDependency");
|
|
24
24
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
25
25
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
26
26
|
/** @typedef {import("../WebpackError")} WebpackError */
|
27
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
28
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
27
29
|
/** @typedef {import("../util/Hash")} Hash */
|
28
30
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
29
31
|
|
@@ -154,6 +156,9 @@ class FallbackModule extends Module {
|
|
154
156
|
return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS };
|
155
157
|
}
|
156
158
|
|
159
|
+
/**
|
160
|
+
* @param {ObjectSerializerContext} context context
|
161
|
+
*/
|
157
162
|
serialize(context) {
|
158
163
|
const { write } = context;
|
159
164
|
write(this.requests);
|
@@ -23,6 +23,8 @@ const RemoteToExternalDependency = require("./RemoteToExternalDependency");
|
|
23
23
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
24
24
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
25
25
|
/** @typedef {import("../WebpackError")} WebpackError */
|
26
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
27
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
26
28
|
/** @typedef {import("../util/Hash")} Hash */
|
27
29
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
28
30
|
|
@@ -149,6 +151,9 @@ class RemoteModule extends Module {
|
|
149
151
|
return { sources, data, runtimeRequirements: RUNTIME_REQUIREMENTS };
|
150
152
|
}
|
151
153
|
|
154
|
+
/**
|
155
|
+
* @param {ObjectSerializerContext} context context
|
156
|
+
*/
|
152
157
|
serialize(context) {
|
153
158
|
const { write } = context;
|
154
159
|
write(this.request);
|