webpack 5.14.0 → 5.18.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/bin/webpack.js +0 -0
- package/hot/lazy-compilation-node.js +38 -0
- package/hot/lazy-compilation-web.js +74 -0
- package/lib/AutomaticPrefetchPlugin.js +14 -7
- package/lib/CacheFacade.js +1 -0
- package/lib/ChunkGraph.js +132 -19
- package/lib/CodeGenerationResults.js +43 -8
- package/lib/Compilation.js +253 -149
- package/lib/Compiler.js +7 -2
- package/lib/ContextModule.js +2 -2
- package/lib/Dependency.js +1 -7
- package/lib/ExportsInfo.js +23 -5
- package/lib/ExternalModuleFactoryPlugin.js +46 -3
- package/lib/FileSystemInfo.js +192 -137
- package/lib/HotModuleReplacementPlugin.js +76 -29
- package/lib/IgnoreErrorModuleFactory.js +39 -0
- package/lib/Module.js +2 -3
- package/lib/NormalModuleFactory.js +27 -8
- package/lib/Template.js +32 -23
- package/lib/WebpackIsIncludedPlugin.js +85 -0
- package/lib/WebpackOptionsApply.js +27 -5
- package/lib/cache/PackFileCacheStrategy.js +5 -1
- package/lib/config/defaults.js +18 -18
- package/lib/config/normalization.js +44 -9
- package/lib/debug/ProfilingPlugin.js +20 -1
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDPlugin.js +6 -7
- package/lib/dependencies/CommonJsImportsParserPlugin.js +43 -1
- package/lib/dependencies/CommonJsPlugin.js +1 -6
- package/lib/dependencies/ContextDependencyHelpers.js +3 -2
- package/lib/dependencies/ExportsInfoDependency.js +0 -20
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +1 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +0 -29
- package/lib/dependencies/HarmonyImportDependency.js +0 -41
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +2 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +2 -36
- package/lib/dependencies/HarmonyModulesPlugin.js +2 -2
- package/lib/dependencies/ImportPlugin.js +1 -6
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/ModuleDecoratorDependency.js +0 -1
- package/lib/dependencies/NullDependency.js +0 -8
- package/lib/dependencies/ProvidedDependency.js +0 -1
- package/lib/dependencies/StaticExportsDependency.js +0 -12
- package/lib/dependencies/SystemPlugin.js +0 -4
- package/lib/dependencies/URLDependency.js +45 -3
- package/lib/dependencies/URLPlugin.js +33 -7
- package/lib/dependencies/WebpackIsIncludedDependency.js +80 -0
- package/lib/hmr/LazyCompilationPlugin.js +348 -0
- package/lib/hmr/lazyCompilationBackend.js +86 -0
- package/lib/javascript/JavascriptModulesPlugin.js +4 -3
- package/lib/javascript/JavascriptParser.js +20 -5
- package/lib/library/AssignLibraryPlugin.js +13 -4
- package/lib/library/EnableLibraryPlugin.js +12 -0
- package/lib/optimize/ConcatenatedModule.js +0 -12
- package/lib/optimize/InnerGraph.js +32 -0
- package/lib/optimize/SplitChunksPlugin.js +4 -1
- package/lib/serialization/ObjectMiddleware.js +7 -5
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ShareRuntimeModule.js +2 -2
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -0
- package/lib/util/MapHelpers.js +22 -0
- package/lib/util/binarySearchBounds.js +86 -0
- package/lib/util/createHash.js +13 -7
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/processAsyncTree.js +61 -0
- package/lib/util/runtime.js +12 -1
- package/package.json +3 -3
- package/schemas/WebpackOptions.json +330 -140
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +2 -1
- package/types.d.ts +320 -121
@@ -1650,18 +1650,6 @@ ${defineGetters}`
|
|
1650
1650
|
}
|
1651
1651
|
}
|
1652
1652
|
|
1653
|
-
/**
|
1654
|
-
* @param {ChunkGraph} chunkGraph the chunk graph
|
1655
|
-
* @param {DependencyTemplates} dependencyTemplates dependency templates
|
1656
|
-
* @param {RuntimeSpec} runtime the runtime
|
1657
|
-
* @returns {string} hash
|
1658
|
-
*/
|
1659
|
-
_getHashDigest(chunkGraph, dependencyTemplates, runtime) {
|
1660
|
-
const hash = chunkGraph.getModuleHash(this, runtime);
|
1661
|
-
const dtHash = dependencyTemplates.getHash();
|
1662
|
-
return `${hash}-${dtHash}`;
|
1663
|
-
}
|
1664
|
-
|
1665
1653
|
/**
|
1666
1654
|
* @param {ModuleGraph} moduleGraph the module graph
|
1667
1655
|
* @param {RuntimeSpec} runtime the runtime
|
@@ -5,9 +5,14 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { UsageState } = require("../ExportsInfo");
|
9
|
+
|
8
10
|
/** @typedef {import("estree").Node} AnyNode */
|
11
|
+
/** @typedef {import("../Dependency")} Dependency */
|
12
|
+
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
9
13
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
10
14
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
15
|
+
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
11
16
|
|
12
17
|
/** @typedef {Map<TopLevelSymbol, Set<string | TopLevelSymbol> | true>} InnerGraph */
|
13
18
|
/** @typedef {function(boolean | Set<string> | undefined): void} UsageCallback */
|
@@ -254,6 +259,33 @@ exports.tagTopLevelSymbol = (parser, name) => {
|
|
254
259
|
return fn;
|
255
260
|
};
|
256
261
|
|
262
|
+
/**
|
263
|
+
* @param {Dependency} dependency the dependency
|
264
|
+
* @param {Set<string> | boolean} usedByExports usedByExports info
|
265
|
+
* @param {ModuleGraph} moduleGraph moduleGraph
|
266
|
+
* @param {RuntimeSpec} runtime runtime
|
267
|
+
* @returns {boolean} false, when unused. Otherwise true
|
268
|
+
*/
|
269
|
+
exports.isDependencyUsedByExports = (
|
270
|
+
dependency,
|
271
|
+
usedByExports,
|
272
|
+
moduleGraph,
|
273
|
+
runtime
|
274
|
+
) => {
|
275
|
+
if (usedByExports === false) return false;
|
276
|
+
if (usedByExports !== true && usedByExports !== undefined) {
|
277
|
+
const selfModule = moduleGraph.getParentModule(dependency);
|
278
|
+
const exportsInfo = moduleGraph.getExportsInfo(selfModule);
|
279
|
+
let used = false;
|
280
|
+
for (const exportName of usedByExports) {
|
281
|
+
if (exportsInfo.getUsed(exportName, runtime) !== UsageState.Unused)
|
282
|
+
used = true;
|
283
|
+
}
|
284
|
+
if (!used) return false;
|
285
|
+
}
|
286
|
+
return true;
|
287
|
+
};
|
288
|
+
|
257
289
|
class TopLevelSymbol {
|
258
290
|
/**
|
259
291
|
* @param {string} name name of the variable
|
@@ -1298,7 +1298,10 @@ module.exports = class SplitChunksPlugin {
|
|
1298
1298
|
) {
|
1299
1299
|
continue;
|
1300
1300
|
}
|
1301
|
-
if (
|
1301
|
+
if (
|
1302
|
+
item.chunks.size > 1 &&
|
1303
|
+
chunkGraph.getNumberOfEntryModules(chunk) > 0
|
1304
|
+
) {
|
1302
1305
|
continue;
|
1303
1306
|
}
|
1304
1307
|
for (const module of item.modules) {
|
@@ -367,11 +367,13 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
367
367
|
try {
|
368
368
|
process(value);
|
369
369
|
} catch (e) {
|
370
|
-
if (
|
371
|
-
hasDebugInfoAttached
|
372
|
-
|
373
|
-
e
|
374
|
-
|
370
|
+
if (e !== NOT_SERIALIZABLE) {
|
371
|
+
if (hasDebugInfoAttached === undefined)
|
372
|
+
hasDebugInfoAttached = new WeakSet();
|
373
|
+
if (!hasDebugInfoAttached.has(e)) {
|
374
|
+
e.message += `\nwhile serializing ${stackToString(value)}`;
|
375
|
+
hasDebugInfoAttached.add(e);
|
376
|
+
}
|
375
377
|
}
|
376
378
|
throw e;
|
377
379
|
}
|
@@ -83,11 +83,11 @@ class ShareRuntimeModule extends RuntimeModule {
|
|
83
83
|
)};`,
|
84
84
|
`var uniqueName = ${JSON.stringify(uniqueName || undefined)};`,
|
85
85
|
`var register = ${runtimeTemplate.basicFunction(
|
86
|
-
"name, version, factory",
|
86
|
+
"name, version, factory, eager",
|
87
87
|
[
|
88
88
|
"var versions = scope[name] = scope[name] || {};",
|
89
89
|
"var activeVersion = versions[version];",
|
90
|
-
"if(!activeVersion || !activeVersion.loaded && uniqueName > activeVersion.from) versions[version] = { get: factory, from: uniqueName };"
|
90
|
+
"if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager };"
|
91
91
|
]
|
92
92
|
)};`,
|
93
93
|
`var initExternal = ${runtimeTemplate.basicFunction("id", [
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @template K
|
10
|
+
* @template V
|
11
|
+
* @param {Map<K, V>} map a map
|
12
|
+
* @param {K} key the key
|
13
|
+
* @param {function(): V} computer compute value
|
14
|
+
* @returns {V} value
|
15
|
+
*/
|
16
|
+
exports.provide = (map, key, computer) => {
|
17
|
+
const value = map.get(key);
|
18
|
+
if (value !== undefined) return value;
|
19
|
+
const newValue = computer();
|
20
|
+
map.set(key, newValue);
|
21
|
+
return newValue;
|
22
|
+
};
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Mikola Lysenko @mikolalysenko
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/* cspell:disable-next-line */
|
9
|
+
// Refactor: Peter Somogyvari @petermetz
|
10
|
+
|
11
|
+
const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
|
12
|
+
const code = [
|
13
|
+
"function ",
|
14
|
+
funcName,
|
15
|
+
"(a,l,h,",
|
16
|
+
extraArgs.join(","),
|
17
|
+
"){",
|
18
|
+
earlyOut ? "" : "var i=",
|
19
|
+
reversed ? "l-1" : "h+1",
|
20
|
+
";while(l<=h){var m=(l+h)>>>1,x=a[m]"
|
21
|
+
];
|
22
|
+
|
23
|
+
if (earlyOut) {
|
24
|
+
if (predicate.indexOf("c") < 0) {
|
25
|
+
code.push(";if(x===y){return m}else if(x<=y){");
|
26
|
+
} else {
|
27
|
+
code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){");
|
28
|
+
}
|
29
|
+
} else {
|
30
|
+
code.push(";if(", predicate, "){i=m;");
|
31
|
+
}
|
32
|
+
if (reversed) {
|
33
|
+
code.push("l=m+1}else{h=m-1}");
|
34
|
+
} else {
|
35
|
+
code.push("h=m-1}else{l=m+1}");
|
36
|
+
}
|
37
|
+
code.push("}");
|
38
|
+
if (earlyOut) {
|
39
|
+
code.push("return -1};");
|
40
|
+
} else {
|
41
|
+
code.push("return i};");
|
42
|
+
}
|
43
|
+
return code.join("");
|
44
|
+
};
|
45
|
+
|
46
|
+
const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => {
|
47
|
+
const arg1 = compileSearch(
|
48
|
+
"A",
|
49
|
+
"x" + predicate + "y",
|
50
|
+
reversed,
|
51
|
+
["y"],
|
52
|
+
earlyOut
|
53
|
+
);
|
54
|
+
|
55
|
+
const arg2 = compileSearch(
|
56
|
+
"P",
|
57
|
+
"c(x,y)" + predicate + "0",
|
58
|
+
reversed,
|
59
|
+
["y", "c"],
|
60
|
+
earlyOut
|
61
|
+
);
|
62
|
+
|
63
|
+
const fnHeader = "function dispatchBinarySearch";
|
64
|
+
|
65
|
+
const fnBody =
|
66
|
+
"(a,y,c,l,h){\
|
67
|
+
if(typeof(c)==='function'){\
|
68
|
+
return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)\
|
69
|
+
}else{\
|
70
|
+
return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)\
|
71
|
+
}}\
|
72
|
+
return dispatchBinarySearch";
|
73
|
+
|
74
|
+
const fnArgList = [arg1, arg2, fnHeader, suffix, fnBody, suffix];
|
75
|
+
const fnSource = fnArgList.join("");
|
76
|
+
const result = new Function(fnSource);
|
77
|
+
return result();
|
78
|
+
};
|
79
|
+
|
80
|
+
module.exports = {
|
81
|
+
ge: compileBoundsSearch(">=", false, "GE"),
|
82
|
+
gt: compileBoundsSearch(">", false, "GT"),
|
83
|
+
lt: compileBoundsSearch("<", true, "LT"),
|
84
|
+
le: compileBoundsSearch("<=", true, "LE"),
|
85
|
+
eq: compileBoundsSearch("-", true, "EQ", true)
|
86
|
+
};
|
package/lib/util/createHash.js
CHANGED
@@ -7,9 +7,11 @@
|
|
7
7
|
|
8
8
|
const Hash = require("./Hash");
|
9
9
|
|
10
|
-
const BULK_SIZE =
|
10
|
+
const BULK_SIZE = 2000;
|
11
11
|
|
12
|
-
|
12
|
+
// We are using an object instead of a Map as this will stay static during the runtime
|
13
|
+
// so access to it can be optimized by v8
|
14
|
+
const digestCaches = {};
|
13
15
|
|
14
16
|
class BulkUpdateDecorator extends Hash {
|
15
17
|
/**
|
@@ -64,11 +66,15 @@ class BulkUpdateDecorator extends Hash {
|
|
64
66
|
* @returns {string|Buffer} digest
|
65
67
|
*/
|
66
68
|
digest(encoding) {
|
67
|
-
let
|
69
|
+
let digestCache;
|
68
70
|
if (this.hash === undefined) {
|
69
71
|
// short data for hash, we can use caching
|
70
|
-
cacheKey = `${this.hashKey}-${encoding}
|
71
|
-
|
72
|
+
const cacheKey = `${this.hashKey}-${encoding}`;
|
73
|
+
digestCache = digestCaches[cacheKey];
|
74
|
+
if (digestCache === undefined) {
|
75
|
+
digestCache = digestCaches[cacheKey] = new Map();
|
76
|
+
}
|
77
|
+
const cacheEntry = digestCache.get(this.buffer);
|
72
78
|
if (cacheEntry !== undefined) return cacheEntry;
|
73
79
|
this.hash = this.hashFactory();
|
74
80
|
}
|
@@ -78,8 +84,8 @@ class BulkUpdateDecorator extends Hash {
|
|
78
84
|
const digestResult = this.hash.digest(encoding);
|
79
85
|
const result =
|
80
86
|
typeof digestResult === "string" ? digestResult : digestResult.toString();
|
81
|
-
if (
|
82
|
-
digestCache.set(
|
87
|
+
if (digestCache !== undefined) {
|
88
|
+
digestCache.set(this.buffer, result);
|
83
89
|
}
|
84
90
|
return result;
|
85
91
|
}
|
@@ -150,6 +150,8 @@ module.exports = {
|
|
150
150
|
require("../dependencies/WebAssemblyExportImportedDependency"),
|
151
151
|
"dependencies/WebAssemblyImportDependency": () =>
|
152
152
|
require("../dependencies/WebAssemblyImportDependency"),
|
153
|
+
"dependencies/WebpackIsIncludedDependency": () =>
|
154
|
+
require("../dependencies/WebpackIsIncludedDependency"),
|
153
155
|
"dependencies/WorkerDependency": () =>
|
154
156
|
require("../dependencies/WorkerDependency"),
|
155
157
|
"optimize/ConcatenatedModule": () =>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @template T
|
10
|
+
* @param {Iterable<T>} items initial items
|
11
|
+
* @param {number} concurrency number of items running in parallel
|
12
|
+
* @param {function(T, function(T): void, function(Error=): void): void} processor worker which pushes more items
|
13
|
+
* @param {function(Error=): void} callback all items processed
|
14
|
+
* @returns {void}
|
15
|
+
*/
|
16
|
+
const processAsyncTree = (items, concurrency, processor, callback) => {
|
17
|
+
const queue = Array.from(items);
|
18
|
+
if (queue.length === 0) return callback();
|
19
|
+
let processing = 0;
|
20
|
+
let finished = false;
|
21
|
+
let processScheduled = true;
|
22
|
+
|
23
|
+
const push = item => {
|
24
|
+
queue.push(item);
|
25
|
+
if (!processScheduled && processing < concurrency) {
|
26
|
+
processScheduled = true;
|
27
|
+
process.nextTick(processQueue);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
const processorCallback = err => {
|
32
|
+
processing--;
|
33
|
+
if (err && !finished) {
|
34
|
+
finished = true;
|
35
|
+
callback(err);
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
if (!processScheduled) {
|
39
|
+
processScheduled = true;
|
40
|
+
process.nextTick(processQueue);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
const processQueue = () => {
|
45
|
+
if (finished) return;
|
46
|
+
while (processing < concurrency && queue.length > 0) {
|
47
|
+
processing++;
|
48
|
+
const item = queue.pop();
|
49
|
+
processor(item, push, processorCallback);
|
50
|
+
}
|
51
|
+
processScheduled = false;
|
52
|
+
if (queue.length === 0 && processing === 0 && !finished) {
|
53
|
+
finished = true;
|
54
|
+
callback();
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
processQueue();
|
59
|
+
};
|
60
|
+
|
61
|
+
module.exports = processAsyncTree;
|
package/lib/util/runtime.js
CHANGED
@@ -54,14 +54,16 @@ exports.getEntryRuntime = (compilation, name, options) => {
|
|
54
54
|
/**
|
55
55
|
* @param {RuntimeSpec} runtime runtime
|
56
56
|
* @param {function(string): void} fn functor
|
57
|
+
* @param {boolean} deterministicOrder enforce a deterministic order
|
57
58
|
* @returns {void}
|
58
59
|
*/
|
59
|
-
exports.forEachRuntime = (runtime, fn) => {
|
60
|
+
exports.forEachRuntime = (runtime, fn, deterministicOrder = false) => {
|
60
61
|
if (runtime === undefined) {
|
61
62
|
fn(undefined);
|
62
63
|
} else if (typeof runtime === "string") {
|
63
64
|
fn(runtime);
|
64
65
|
} else {
|
66
|
+
if (deterministicOrder) runtime.sort();
|
65
67
|
for (const r of runtime) {
|
66
68
|
fn(r);
|
67
69
|
}
|
@@ -448,6 +450,15 @@ class RuntimeSpecMap {
|
|
448
450
|
this._map.set(getRuntimeKey(runtime), value);
|
449
451
|
}
|
450
452
|
|
453
|
+
provide(runtime, computer) {
|
454
|
+
const key = getRuntimeKey(runtime);
|
455
|
+
const value = this._map.get(key);
|
456
|
+
if (value !== undefined) return value;
|
457
|
+
const newValue = computer();
|
458
|
+
this._map.set(key, newValue);
|
459
|
+
return newValue;
|
460
|
+
}
|
461
|
+
|
451
462
|
delete(runtime) {
|
452
463
|
this._map.delete(getRuntimeKey(runtime));
|
453
464
|
}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.18.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
7
7
|
"dependencies": {
|
8
8
|
"@types/eslint-scope": "^3.7.0",
|
9
|
-
"@types/estree": "^0.0.
|
9
|
+
"@types/estree": "^0.0.46",
|
10
10
|
"@webassemblyjs/ast": "1.11.0",
|
11
11
|
"@webassemblyjs/wasm-edit": "1.11.0",
|
12
12
|
"@webassemblyjs/wasm-parser": "1.11.0",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"core-js": "^3.6.5",
|
50
50
|
"coveralls": "^3.1.0",
|
51
51
|
"cspell": "^4.0.63",
|
52
|
-
"css-loader": "^
|
52
|
+
"css-loader": "^5.0.1",
|
53
53
|
"date-fns": "^2.15.0",
|
54
54
|
"es5-ext": "^0.10.53",
|
55
55
|
"es6-promise-polyfill": "^1.2.0",
|