webpack 5.105.0 → 5.105.1
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 +2 -2
- package/lib/AsyncDependenciesBlock.js +5 -2
- package/lib/AsyncDependencyToInitialChunkError.js +2 -0
- package/lib/BannerPlugin.js +3 -1
- package/lib/Chunk.js +4 -4
- package/lib/ChunkRenderError.js +7 -2
- package/lib/Compilation.js +4 -0
- package/lib/Compiler.js +1 -1
- package/lib/DefinePlugin.js +12 -7
- package/lib/DynamicEntryPlugin.js +7 -1
- package/lib/ExternalModuleFactoryPlugin.js +9 -2
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/IgnoreWarningsPlugin.js +5 -2
- package/lib/ManifestPlugin.js +4 -0
- package/lib/ModuleError.js +2 -0
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/NormalModule.js +2 -0
- package/lib/UnsupportedFeatureWarning.js +2 -0
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +9 -0
- package/lib/asset/AssetParser.js +4 -0
- package/lib/container/ContainerEntryDependency.js +3 -0
- package/lib/container/ContainerEntryModule.js +3 -0
- package/lib/container/ContainerExposedDependency.js +1 -0
- package/lib/container/FallbackDependency.js +1 -0
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +2 -0
- package/lib/container/ModuleFederationPlugin.js +1 -1
- package/lib/container/RemoteModule.js +5 -0
- package/lib/dependencies/CssIcssExportDependency.js +2 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependency.js +1 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +14 -11
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
- package/lib/electron/ElectronTargetPlugin.js +3 -1
- package/lib/ids/ChunkModuleIdRangePlugin.js +7 -7
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
- package/lib/ids/HashedModuleIdsPlugin.js +3 -8
- package/lib/ids/NamedChunkIdsPlugin.js +7 -5
- package/lib/ids/NamedModuleIdsPlugin.js +1 -0
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +3 -3
- package/lib/ids/SyncModuleIdsPlugin.js +25 -19
- package/lib/index.js +2 -2
- package/lib/json/JsonGenerator.js +1 -0
- package/lib/json/JsonParser.js +3 -2
- package/lib/logging/Logger.js +9 -5
- package/lib/logging/createConsoleLogger.js +2 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +5 -4
- package/lib/node/NodeEnvironmentPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/NodeTemplatePlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +3 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +5 -0
- package/lib/optimize/LimitChunkCountPlugin.js +3 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -1
- package/lib/optimize/RealContentHashPlugin.js +2 -0
- package/lib/optimize/RuntimeChunkPlugin.js +3 -5
- package/lib/optimize/SplitChunksPlugin.js +9 -2
- package/lib/performance/SizeLimitsPlugin.js +6 -6
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
- package/lib/rules/RuleSetCompiler.js +4 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +12 -13
- package/lib/schemes/VirtualUrlPlugin.js +21 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +6 -0
- package/lib/url/URLParserPlugin.js +1 -0
- package/lib/util/hash/BatchedHash.js +1 -0
- package/lib/util/hash/BulkUpdateHash.js +1 -0
- package/lib/util/hash/wasm-hash.js +2 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
- package/lib/webpack.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
- package/package.json +15 -10
- package/schemas/WebpackOptions.json +50 -50
- package/schemas/plugins/BannerPlugin.json +2 -2
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ManifestPlugin.json +3 -3
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +104 -47
|
@@ -81,6 +81,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
|
81
81
|
*/
|
|
82
82
|
constructor(options) {
|
|
83
83
|
this.options = options;
|
|
84
|
+
/** @type {ExportPresenceMode} */
|
|
84
85
|
this.exportPresenceMode =
|
|
85
86
|
options.importExportsPresence !== undefined
|
|
86
87
|
? ExportPresenceModes.fromUserOption(options.importExportsPresence)
|
|
@@ -107,7 +108,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
|
107
108
|
parser.getTagData(harmonySettings.name, harmonySpecifierGuardTag)
|
|
108
109
|
);
|
|
109
110
|
return data && data.guards && data.guards.has(getMembersKey(ids))
|
|
110
|
-
?
|
|
111
|
+
? ExportPresenceModes.NONE
|
|
111
112
|
: this.exportPresenceMode;
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -651,17 +652,19 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
|
651
652
|
}
|
|
652
653
|
};
|
|
653
654
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
655
|
+
if (this.exportPresenceMode !== ExportPresenceModes.NONE) {
|
|
656
|
+
parser.hooks.collectGuards.tap(PLUGIN_NAME, (expression) => {
|
|
657
|
+
if (parser.scope.isAsmJs) return;
|
|
658
|
+
/** @type {Guards} */
|
|
659
|
+
const guards = new Map();
|
|
660
|
+
collect(expression, guards, true);
|
|
659
661
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
662
|
+
if (guards.size === 0) return;
|
|
663
|
+
return (walk) => {
|
|
664
|
+
withGuards(guards, walk);
|
|
665
|
+
};
|
|
666
|
+
});
|
|
667
|
+
}
|
|
665
668
|
}
|
|
666
669
|
};
|
|
667
670
|
|
|
@@ -13,7 +13,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
13
13
|
|
|
14
14
|
class RequireEnsureDependenciesBlock extends AsyncDependenciesBlock {
|
|
15
15
|
/**
|
|
16
|
-
* @param {GroupOptions | null} chunkName chunk name
|
|
16
|
+
* @param {GroupOptions | string | null} chunkName chunk name
|
|
17
17
|
* @param {(DependencyLocation | null)=} loc location info
|
|
18
18
|
*/
|
|
19
19
|
constructor(chunkName, loc) {
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
const ExternalsPlugin = require("../ExternalsPlugin");
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../Compiler")} Compiler */
|
|
11
|
+
/** @typedef {"main" | "preload" | "renderer"} ElectronContext */
|
|
11
12
|
|
|
12
13
|
class ElectronTargetPlugin {
|
|
13
14
|
/**
|
|
14
|
-
* @param {
|
|
15
|
+
* @param {ElectronContext=} context in main, preload or renderer context?
|
|
15
16
|
*/
|
|
16
17
|
constructor(context) {
|
|
18
|
+
/** @type {ElectronContext | undefined} */
|
|
17
19
|
this._context = context;
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -30,6 +30,7 @@ class ChunkModuleIdRangePlugin {
|
|
|
30
30
|
* @param {ChunkModuleIdRangePluginOptions} options options object
|
|
31
31
|
*/
|
|
32
32
|
constructor(options) {
|
|
33
|
+
/** @type {ChunkModuleIdRangePluginOptions} */
|
|
33
34
|
this.options = options;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -39,27 +40,26 @@ class ChunkModuleIdRangePlugin {
|
|
|
39
40
|
* @returns {void}
|
|
40
41
|
*/
|
|
41
42
|
apply(compiler) {
|
|
42
|
-
const options = this.options;
|
|
43
43
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
44
44
|
const moduleGraph = compilation.moduleGraph;
|
|
45
45
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, (modules) => {
|
|
46
46
|
const chunkGraph = compilation.chunkGraph;
|
|
47
47
|
const chunk = find(
|
|
48
48
|
compilation.chunks,
|
|
49
|
-
(chunk) => chunk.name === options.name
|
|
49
|
+
(chunk) => chunk.name === this.options.name
|
|
50
50
|
);
|
|
51
51
|
if (!chunk) {
|
|
52
52
|
throw new Error(
|
|
53
|
-
`${PLUGIN_NAME}: Chunk with name '${options.name}"' was not found`
|
|
53
|
+
`${PLUGIN_NAME}: Chunk with name '${this.options.name}"' was not found`
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** @type {Module[]} */
|
|
58
58
|
let chunkModules;
|
|
59
|
-
if (options.order) {
|
|
59
|
+
if (this.options.order) {
|
|
60
60
|
/** @type {ModuleComparator} */
|
|
61
61
|
let cmpFn;
|
|
62
|
-
switch (options.order) {
|
|
62
|
+
switch (this.options.order) {
|
|
63
63
|
case "index":
|
|
64
64
|
case "preOrderIndex":
|
|
65
65
|
cmpFn = compareModulesByPreOrderIndexOrIdentifier(moduleGraph);
|
|
@@ -78,13 +78,13 @@ class ChunkModuleIdRangePlugin {
|
|
|
78
78
|
.sort(compareModulesByPreOrderIndexOrIdentifier(moduleGraph));
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
let currentId = options.start || 0;
|
|
81
|
+
let currentId = this.options.start || 0;
|
|
82
82
|
for (let i = 0; i < chunkModules.length; i++) {
|
|
83
83
|
const m = chunkModules[i];
|
|
84
84
|
if (m.needId && chunkGraph.getModuleId(m) === null) {
|
|
85
85
|
chunkGraph.setModuleId(m, currentId++);
|
|
86
86
|
}
|
|
87
|
-
if (options.end && currentId > options.end) break;
|
|
87
|
+
if (this.options.end && currentId > this.options.end) break;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
});
|
|
@@ -53,7 +53,6 @@ class HashedModuleIdsPlugin {
|
|
|
53
53
|
* @returns {void}
|
|
54
54
|
*/
|
|
55
55
|
apply(compiler) {
|
|
56
|
-
const options = this.options;
|
|
57
56
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
58
57
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
59
58
|
const chunkGraph = compilation.chunkGraph;
|
|
@@ -67,14 +66,10 @@ class HashedModuleIdsPlugin {
|
|
|
67
66
|
);
|
|
68
67
|
for (const module of modulesInNaturalOrder) {
|
|
69
68
|
const ident = getFullModuleName(module, context, compiler.root);
|
|
70
|
-
const hash = createHash(
|
|
71
|
-
/** @type {NonNullable<HashedModuleIdsPluginOptions["hashFunction"]>} */ (
|
|
72
|
-
options.hashFunction
|
|
73
|
-
)
|
|
74
|
-
);
|
|
69
|
+
const hash = createHash(this.options.hashFunction);
|
|
75
70
|
hash.update(ident || "");
|
|
76
|
-
const hashId = hash.digest(options.hashDigest);
|
|
77
|
-
let len = options.hashDigestLength;
|
|
71
|
+
const hashId = hash.digest(this.options.hashDigest);
|
|
72
|
+
let len = this.options.hashDigestLength;
|
|
78
73
|
while (usedIds.has(hashId.slice(0, len))) {
|
|
79
74
|
/** @type {number} */ (len)++;
|
|
80
75
|
}
|
|
@@ -28,9 +28,9 @@ class NamedChunkIdsPlugin {
|
|
|
28
28
|
/**
|
|
29
29
|
* @param {NamedChunkIdsPluginOptions=} options options
|
|
30
30
|
*/
|
|
31
|
-
constructor(options) {
|
|
32
|
-
|
|
33
|
-
this.
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
/** @type {NamedChunkIdsPluginOptions} */
|
|
33
|
+
this.options = options;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -43,8 +43,10 @@ class NamedChunkIdsPlugin {
|
|
|
43
43
|
const hashFunction = compilation.outputOptions.hashFunction;
|
|
44
44
|
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
45
45
|
const chunkGraph = compilation.chunkGraph;
|
|
46
|
-
const context = this.
|
|
47
|
-
|
|
46
|
+
const context = this.options.context
|
|
47
|
+
? this.options.context
|
|
48
|
+
: compiler.context;
|
|
49
|
+
const delimiter = this.options.delimiter || "-";
|
|
48
50
|
|
|
49
51
|
const unnamedChunks = assignNames(
|
|
50
52
|
[...chunks].filter((chunk) => {
|
|
@@ -30,6 +30,7 @@ class OccurrenceChunkIdsPlugin {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(options = {}) {
|
|
32
32
|
validate(options);
|
|
33
|
+
/** @type {OccurrenceChunkIdsPluginOptions} */
|
|
33
34
|
this.options = options;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -39,7 +40,6 @@ class OccurrenceChunkIdsPlugin {
|
|
|
39
40
|
* @returns {void}
|
|
40
41
|
*/
|
|
41
42
|
apply(compiler) {
|
|
42
|
-
const prioritiseInitial = this.options.prioritiseInitial;
|
|
43
43
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
44
44
|
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
45
45
|
const chunkGraph = compilation.chunkGraph;
|
|
@@ -61,7 +61,7 @@ class OccurrenceChunkIdsPlugin {
|
|
|
61
61
|
|
|
62
62
|
/** @type {Chunk[]} */
|
|
63
63
|
const chunksInOccurrenceOrder = [...chunks].sort((a, b) => {
|
|
64
|
-
if (prioritiseInitial) {
|
|
64
|
+
if (this.options.prioritiseInitial) {
|
|
65
65
|
const aEntryOccurs =
|
|
66
66
|
/** @type {number} */
|
|
67
67
|
(occursInInitialChunksMap.get(a));
|
|
@@ -35,6 +35,7 @@ class OccurrenceModuleIdsPlugin {
|
|
|
35
35
|
*/
|
|
36
36
|
constructor(options = {}) {
|
|
37
37
|
validate(options);
|
|
38
|
+
/** @type {OccurrenceModuleIdsPluginOptions} */
|
|
38
39
|
this.options = options;
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -44,7 +45,6 @@ class OccurrenceModuleIdsPlugin {
|
|
|
44
45
|
* @returns {void}
|
|
45
46
|
*/
|
|
46
47
|
apply(compiler) {
|
|
47
|
-
const prioritiseInitial = this.options.prioritiseInitial;
|
|
48
48
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
49
49
|
const moduleGraph = compilation.moduleGraph;
|
|
50
50
|
|
|
@@ -115,7 +115,7 @@ class OccurrenceModuleIdsPlugin {
|
|
|
115
115
|
return sum;
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
if (prioritiseInitial) {
|
|
118
|
+
if (this.options.prioritiseInitial) {
|
|
119
119
|
for (const m of modulesInOccurrenceOrder) {
|
|
120
120
|
const result =
|
|
121
121
|
countOccursInEntry(m) +
|
|
@@ -138,7 +138,7 @@ class OccurrenceModuleIdsPlugin {
|
|
|
138
138
|
);
|
|
139
139
|
|
|
140
140
|
modulesInOccurrenceOrder.sort((a, b) => {
|
|
141
|
-
if (prioritiseInitial) {
|
|
141
|
+
if (this.options.prioritiseInitial) {
|
|
142
142
|
const aEntryOccurs =
|
|
143
143
|
/** @type {number} */
|
|
144
144
|
(occursInInitialChunksMap.get(a));
|
|
@@ -29,14 +29,9 @@ class SyncModuleIdsPlugin {
|
|
|
29
29
|
/**
|
|
30
30
|
* @param {SyncModuleIdsPluginOptions} options options
|
|
31
31
|
*/
|
|
32
|
-
constructor(
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
this._test = test || (() => true);
|
|
36
|
-
const readAndWrite = !mode || mode === "merge" || mode === "update";
|
|
37
|
-
this._read = readAndWrite || mode === "read";
|
|
38
|
-
this._write = readAndWrite || mode === "create";
|
|
39
|
-
this._prune = mode === "update";
|
|
32
|
+
constructor(options) {
|
|
33
|
+
/** @type {SyncModuleIdsPluginOptions} */
|
|
34
|
+
this.options = options;
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
/**
|
|
@@ -48,12 +43,22 @@ class SyncModuleIdsPlugin {
|
|
|
48
43
|
/** @type {Map<string, ModuleId>} */
|
|
49
44
|
let data;
|
|
50
45
|
let dataChanged = false;
|
|
51
|
-
|
|
46
|
+
|
|
47
|
+
const readAndWrite =
|
|
48
|
+
!this.options.mode ||
|
|
49
|
+
this.options.mode === "merge" ||
|
|
50
|
+
this.options.mode === "update";
|
|
51
|
+
|
|
52
|
+
const needRead = readAndWrite || this.options.mode === "read";
|
|
53
|
+
const needWrite = readAndWrite || this.options.mode === "create";
|
|
54
|
+
const needPrune = this.options.mode === "update";
|
|
55
|
+
|
|
56
|
+
if (needRead) {
|
|
52
57
|
compiler.hooks.readRecords.tapAsync(plugin, (callback) => {
|
|
53
58
|
const fs =
|
|
54
59
|
/** @type {IntermediateFileSystem} */
|
|
55
60
|
(compiler.intermediateFileSystem);
|
|
56
|
-
fs.readFile(this.
|
|
61
|
+
fs.readFile(this.options.path, (err, buffer) => {
|
|
57
62
|
if (err) {
|
|
58
63
|
if (err.code !== "ENOENT") {
|
|
59
64
|
return callback(err);
|
|
@@ -72,7 +77,7 @@ class SyncModuleIdsPlugin {
|
|
|
72
77
|
});
|
|
73
78
|
});
|
|
74
79
|
}
|
|
75
|
-
if (
|
|
80
|
+
if (needWrite) {
|
|
76
81
|
compiler.hooks.emitRecords.tapAsync(plugin, (callback) => {
|
|
77
82
|
if (!data || !dataChanged) return callback();
|
|
78
83
|
/** @type {JSONContent} */
|
|
@@ -84,19 +89,20 @@ class SyncModuleIdsPlugin {
|
|
|
84
89
|
const fs =
|
|
85
90
|
/** @type {IntermediateFileSystem} */
|
|
86
91
|
(compiler.intermediateFileSystem);
|
|
87
|
-
fs.writeFile(this.
|
|
92
|
+
fs.writeFile(this.options.path, JSON.stringify(json), callback);
|
|
88
93
|
});
|
|
89
94
|
}
|
|
90
95
|
compiler.hooks.thisCompilation.tap(plugin, (compilation) => {
|
|
91
96
|
const associatedObjectForCache = compiler.root;
|
|
92
|
-
const context = this.
|
|
93
|
-
|
|
97
|
+
const context = this.options.context || compiler.context;
|
|
98
|
+
const test = this.options.test || (() => true);
|
|
99
|
+
if (needRead) {
|
|
94
100
|
compilation.hooks.reviveModules.tap(plugin, (_1, _2) => {
|
|
95
101
|
if (!data) return;
|
|
96
102
|
const { chunkGraph } = compilation;
|
|
97
103
|
const [usedIds, modules] = getUsedModuleIdsAndModules(
|
|
98
104
|
compilation,
|
|
99
|
-
|
|
105
|
+
test
|
|
100
106
|
);
|
|
101
107
|
for (const module of modules) {
|
|
102
108
|
const name = module.libIdent({
|
|
@@ -108,7 +114,7 @@ class SyncModuleIdsPlugin {
|
|
|
108
114
|
const idAsString = `${id}`;
|
|
109
115
|
if (usedIds.has(idAsString)) {
|
|
110
116
|
const err = new WebpackError(
|
|
111
|
-
`SyncModuleIdsPlugin: Unable to restore id '${id}' from '${this.
|
|
117
|
+
`SyncModuleIdsPlugin: Unable to restore id '${id}' from '${this.options.path}' as it's already used.`
|
|
112
118
|
);
|
|
113
119
|
err.module = module;
|
|
114
120
|
compilation.errors.push(err);
|
|
@@ -118,17 +124,17 @@ class SyncModuleIdsPlugin {
|
|
|
118
124
|
}
|
|
119
125
|
});
|
|
120
126
|
}
|
|
121
|
-
if (
|
|
127
|
+
if (needWrite) {
|
|
122
128
|
compilation.hooks.recordModules.tap(plugin, (modules) => {
|
|
123
129
|
const { chunkGraph } = compilation;
|
|
124
130
|
let oldData = data;
|
|
125
131
|
if (!oldData) {
|
|
126
132
|
oldData = data = new Map();
|
|
127
|
-
} else if (
|
|
133
|
+
} else if (needPrune) {
|
|
128
134
|
data = new Map();
|
|
129
135
|
}
|
|
130
136
|
for (const module of modules) {
|
|
131
|
-
if (
|
|
137
|
+
if (test(module)) {
|
|
132
138
|
const name = module.libIdent({
|
|
133
139
|
context,
|
|
134
140
|
associatedObjectForCache
|
package/lib/index.js
CHANGED
|
@@ -33,8 +33,8 @@ const memoize = require("./util/memoize");
|
|
|
33
33
|
/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
|
|
34
34
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} Configuration */
|
|
35
35
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
|
|
36
|
-
/** @typedef {import("
|
|
37
|
-
/** @typedef {import("
|
|
36
|
+
/** @typedef {import("./webpack").WebpackPluginFunction} WebpackPluginFunction */
|
|
37
|
+
/** @typedef {import("./webpack").WebpackPluginInstance} WebpackPluginInstance */
|
|
38
38
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
39
39
|
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
|
40
40
|
/** @typedef {import("./Compilation").Asset} Asset */
|
package/lib/json/JsonParser.js
CHANGED
|
@@ -31,9 +31,10 @@ class JsonParser extends Parser {
|
|
|
31
31
|
/**
|
|
32
32
|
* @param {JsonModulesPluginParserOptions} options parser options
|
|
33
33
|
*/
|
|
34
|
-
constructor(options) {
|
|
34
|
+
constructor(options = {}) {
|
|
35
35
|
super();
|
|
36
|
-
|
|
36
|
+
/** @type {JsonModulesPluginParserOptions} */
|
|
37
|
+
this.options = options;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
package/lib/logging/Logger.js
CHANGED
|
@@ -37,14 +37,18 @@ const TIMERS_SYMBOL = Symbol("webpack logger times");
|
|
|
37
37
|
const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times");
|
|
38
38
|
|
|
39
39
|
/** @typedef {EXPECTED_ANY[]} Args */
|
|
40
|
+
/** @typedef {(type: LogTypeEnum, args?: Args) => void} LogFn */
|
|
41
|
+
/** @typedef {(name: string | (() => string)) => WebpackLogger} GetChildLogger */
|
|
40
42
|
|
|
41
43
|
class WebpackLogger {
|
|
42
44
|
/**
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {
|
|
45
|
+
* @param {LogFn} log log function
|
|
46
|
+
* @param {GetChildLogger} getChildLogger function to create child logger
|
|
45
47
|
*/
|
|
46
48
|
constructor(log, getChildLogger) {
|
|
49
|
+
/** @type {LogFn} */
|
|
47
50
|
this[LOG_SYMBOL] = log;
|
|
51
|
+
/** @type {GetChildLogger} */
|
|
48
52
|
this.getChildLogger = getChildLogger;
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -84,11 +88,11 @@ class WebpackLogger {
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
|
-
* @param {
|
|
91
|
+
* @param {boolean=} condition condition
|
|
88
92
|
* @param {Args} args args
|
|
89
93
|
*/
|
|
90
|
-
assert(
|
|
91
|
-
if (!
|
|
94
|
+
assert(condition, ...args) {
|
|
95
|
+
if (!condition) {
|
|
92
96
|
this[LOG_SYMBOL](LogType.error, args);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -100,7 +100,8 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
100
100
|
*/
|
|
101
101
|
const logger = (name, type, args) => {
|
|
102
102
|
/**
|
|
103
|
-
* @
|
|
103
|
+
* @template T
|
|
104
|
+
* @returns {[string?, ...T[]]} labeled args
|
|
104
105
|
*/
|
|
105
106
|
const labeledArgs = () => {
|
|
106
107
|
if (Array.isArray(args)) {
|
|
@@ -24,7 +24,8 @@ class CommonJsChunkLoadingPlugin {
|
|
|
24
24
|
* @param {CommonJsChunkLoadingPluginOptions=} options options
|
|
25
25
|
*/
|
|
26
26
|
constructor(options = {}) {
|
|
27
|
-
|
|
27
|
+
/** @type {CommonJsChunkLoadingPluginOptions} */
|
|
28
|
+
this.options = options;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -33,15 +34,15 @@ class CommonJsChunkLoadingPlugin {
|
|
|
33
34
|
* @returns {void}
|
|
34
35
|
*/
|
|
35
36
|
apply(compiler) {
|
|
36
|
-
const ChunkLoadingRuntimeModule = this.
|
|
37
|
+
const ChunkLoadingRuntimeModule = this.options.asyncChunkLoading
|
|
37
38
|
? require("./ReadFileChunkLoadingRuntimeModule")
|
|
38
39
|
: require("./RequireChunkLoadingRuntimeModule");
|
|
39
|
-
const chunkLoadingValue = this.
|
|
40
|
+
const chunkLoadingValue = this.options.asyncChunkLoading
|
|
40
41
|
? "async-node"
|
|
41
42
|
: "require";
|
|
42
43
|
new StartupChunkDependenciesPlugin({
|
|
43
44
|
chunkLoading: chunkLoadingValue,
|
|
44
|
-
asyncChunkLoading: this.
|
|
45
|
+
asyncChunkLoading: this.options.asyncChunkLoading
|
|
45
46
|
}).apply(compiler);
|
|
46
47
|
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
47
48
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
|
@@ -87,7 +87,15 @@ class NodeTargetPlugin {
|
|
|
87
87
|
* @returns {void}
|
|
88
88
|
*/
|
|
89
89
|
apply(compiler) {
|
|
90
|
-
new ExternalsPlugin(
|
|
90
|
+
new ExternalsPlugin((dependency) => {
|
|
91
|
+
// When `require` node.js built-in modules with module output
|
|
92
|
+
// we should still emit `createRequire` for compatibility
|
|
93
|
+
if (dependency.category === "commonjs") {
|
|
94
|
+
return "node-commonjs";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return this.type;
|
|
98
|
+
}, builtins).apply(compiler);
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
101
|
|
|
@@ -9,6 +9,7 @@ const util = require("util");
|
|
|
9
9
|
const Watchpack = require("watchpack");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */
|
|
12
|
+
/** @typedef {import("watchpack").WatchOptions} WatchOptions */
|
|
12
13
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
13
14
|
/** @typedef {import("../util/fs").WatchMethod} WatchMethod */
|
|
14
15
|
/** @typedef {import("../util/fs").Changes} Changes */
|
|
@@ -19,7 +20,9 @@ class NodeWatchFileSystem {
|
|
|
19
20
|
* @param {InputFileSystem} inputFileSystem input filesystem
|
|
20
21
|
*/
|
|
21
22
|
constructor(inputFileSystem) {
|
|
23
|
+
/** @type {InputFileSystem} */
|
|
22
24
|
this.inputFileSystem = inputFileSystem;
|
|
25
|
+
/** @type {WatchOptions} */
|
|
23
26
|
this.watcherOptions = {
|
|
24
27
|
aggregateTimeout: 0
|
|
25
28
|
};
|
|
@@ -30,6 +30,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(runtimeRequirements) {
|
|
32
32
|
super("readFile chunk loading", RuntimeModule.STAGE_ATTACH);
|
|
33
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
33
34
|
this.runtimeRequirements = runtimeRequirements;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -30,6 +30,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(runtimeRequirements) {
|
|
32
32
|
super("require chunk loading", RuntimeModule.STAGE_ATTACH);
|
|
33
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
33
34
|
this.runtimeRequirements = runtimeRequirements;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -64,16 +64,21 @@ class AggressiveSplittingPlugin {
|
|
|
64
64
|
constructor(options = {}) {
|
|
65
65
|
validate(options);
|
|
66
66
|
|
|
67
|
+
/** @type {AggressiveSplittingPluginOptions} */
|
|
67
68
|
this.options = options;
|
|
69
|
+
|
|
68
70
|
if (typeof this.options.minSize !== "number") {
|
|
69
71
|
this.options.minSize = 30 * 1024;
|
|
70
72
|
}
|
|
73
|
+
|
|
71
74
|
if (typeof this.options.maxSize !== "number") {
|
|
72
75
|
this.options.maxSize = 50 * 1024;
|
|
73
76
|
}
|
|
77
|
+
|
|
74
78
|
if (typeof this.options.chunkOverhead !== "number") {
|
|
75
79
|
this.options.chunkOverhead = 0;
|
|
76
80
|
}
|
|
81
|
+
|
|
77
82
|
if (typeof this.options.entryChunkMultiplicator !== "number") {
|
|
78
83
|
this.options.entryChunkMultiplicator = 1;
|
|
79
84
|
}
|
|
@@ -57,9 +57,10 @@ class LimitChunkCountPlugin {
|
|
|
57
57
|
/**
|
|
58
58
|
* @param {LimitChunkCountPluginOptions=} options options object
|
|
59
59
|
*/
|
|
60
|
-
constructor(options) {
|
|
60
|
+
constructor(options = { maxChunks: 1 }) {
|
|
61
61
|
validate(options);
|
|
62
|
-
|
|
62
|
+
/** @type {LimitChunkCountPluginOptions} */
|
|
63
|
+
this.options = options;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -27,10 +27,11 @@ const PLUGIN_NAME = "MergeDuplicateChunksPlugin";
|
|
|
27
27
|
|
|
28
28
|
class MergeDuplicateChunksPlugin {
|
|
29
29
|
/**
|
|
30
|
-
* @param {MergeDuplicateChunksPluginOptions} options options object
|
|
30
|
+
* @param {MergeDuplicateChunksPluginOptions=} options options object
|
|
31
31
|
*/
|
|
32
32
|
constructor(options = { stage: STAGE_BASIC }) {
|
|
33
33
|
validate(options);
|
|
34
|
+
/** @type {MergeDuplicateChunksPluginOptions} */
|
|
34
35
|
this.options = options;
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -148,7 +148,9 @@ class RealContentHashPlugin {
|
|
|
148
148
|
* @param {RealContentHashPluginOptions} options options
|
|
149
149
|
*/
|
|
150
150
|
constructor({ hashFunction, hashDigest }) {
|
|
151
|
+
/** @type {HashFunction} */
|
|
151
152
|
this._hashFunction = hashFunction;
|
|
153
|
+
/** @type {HashDigest} */
|
|
152
154
|
this._hashDigest = hashDigest;
|
|
153
155
|
}
|
|
154
156
|
|