webpack 5.99.5 → 5.99.7
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 +1 -1
- package/lib/APIPlugin.js +2 -2
- package/lib/AutomaticPrefetchPlugin.js +21 -22
- package/lib/BannerPlugin.js +31 -35
- package/lib/Cache.js +1 -1
- package/lib/Chunk.js +12 -9
- package/lib/CleanPlugin.js +5 -3
- package/lib/Compilation.js +45 -35
- package/lib/Compiler.js +6 -4
- package/lib/ContextExclusionPlugin.js +4 -2
- package/lib/ContextModule.js +2 -1
- package/lib/ContextReplacementPlugin.js +5 -3
- package/lib/DelegatedPlugin.js +4 -2
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllPlugin.js +5 -3
- package/lib/DllReferencePlugin.js +56 -60
- package/lib/DynamicEntryPlugin.js +4 -2
- package/lib/EntryOptionPlugin.js +3 -1
- package/lib/EntryPlugin.js +4 -2
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/EvalDevToolModulePlugin.js +9 -7
- package/lib/EvalSourceMapDevToolPlugin.js +137 -138
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FlagDependencyExportsPlugin.js +2 -1
- package/lib/HotModuleReplacementPlugin.js +3 -3
- package/lib/IgnorePlugin.js +6 -4
- package/lib/IgnoreWarningsPlugin.js +4 -2
- package/lib/LibManifestPlugin.js +3 -4
- package/lib/LoaderOptionsPlugin.js +4 -2
- package/lib/LoaderTargetPlugin.js +4 -2
- package/lib/Module.js +29 -14
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +15 -10
- package/lib/ModuleInfoHeaderPlugin.js +11 -12
- package/lib/MultiCompiler.js +5 -3
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NormalModule.js +6 -2
- package/lib/NormalModuleReplacementPlugin.js +33 -36
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +5 -3
- package/lib/ProgressPlugin.js +23 -26
- package/lib/RecordIdsPlugin.js +73 -103
- package/lib/RuntimePlugin.js +34 -32
- package/lib/SourceMapDevToolPlugin.js +8 -6
- package/lib/Template.js +1 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
- package/lib/WarnNoModeSetPlugin.js +3 -1
- package/lib/WatchIgnorePlugin.js +3 -1
- package/lib/WebpackError.js +11 -3
- package/lib/WebpackOptionsApply.js +22 -5
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/buildChunkGraph.js +7 -2
- package/lib/cache/IdleFileCachePlugin.js +12 -13
- package/lib/cache/MemoryCachePlugin.js +2 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +10 -7
- package/lib/cache/PackFileCacheStrategy.js +13 -21
- package/lib/cache/ResolverCachePlugin.js +22 -22
- package/lib/cli.js +8 -4
- package/lib/config/defaults.js +2 -2
- package/lib/config/normalization.js +9 -3
- package/lib/config/target.js +6 -6
- package/lib/container/ContainerReferencePlugin.js +24 -26
- package/lib/container/ModuleFederationPlugin.js +2 -1
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssModulesPlugin.js +6 -4
- package/lib/css/CssParser.js +1 -1
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CssIcssImportDependency.js +3 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -1
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +5 -3
- package/lib/dependencies/LocalModulesHelpers.js +1 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
- package/lib/dependencies/RequireResolveDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingPlugin.js +76 -57
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +11 -9
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/LazyCompilationPlugin.js +17 -18
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +48 -49
- package/lib/ids/HashedModuleIdsPlugin.js +4 -2
- package/lib/ids/NamedChunkIdsPlugin.js +6 -4
- package/lib/ids/NamedModuleIdsPlugin.js +6 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
- package/lib/index.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +2 -2
- package/lib/javascript/JavascriptParser.js +670 -688
- package/lib/library/EnableLibraryPlugin.js +15 -2
- package/lib/library/ModuleLibraryPlugin.js +66 -43
- package/lib/logging/createConsoleLogger.js +0 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +71 -75
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/node/NodeTemplatePlugin.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +3 -3
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
- package/lib/optimize/ConcatenatedModule.js +12 -15
- package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +15 -16
- package/lib/optimize/MinChunkSizePlugin.js +4 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
- package/lib/optimize/RealContentHashPlugin.js +4 -2
- package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
- package/lib/optimize/RuntimeChunkPlugin.js +17 -18
- package/lib/optimize/SplitChunksPlugin.js +9 -6
- package/lib/performance/SizeLimitsPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -4
- package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
- package/lib/schemes/DataUriPlugin.js +5 -3
- package/lib/schemes/FileUriPlugin.js +5 -3
- package/lib/schemes/HttpUriPlugin.js +32 -39
- package/lib/serialization/AggregateErrorSerializer.js +42 -0
- package/lib/serialization/BinaryMiddleware.js +22 -38
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/FileMiddleware.js +29 -33
- package/lib/serialization/ObjectMiddleware.js +42 -30
- package/lib/serialization/Serializer.js +29 -18
- package/lib/serialization/SerializerMiddleware.js +105 -72
- package/lib/serialization/SingleItemMiddleware.js +4 -5
- package/lib/sharing/ProvideSharedPlugin.js +6 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +128 -57
- package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +486 -334
- package/lib/stats/StatsFactory.js +47 -10
- package/lib/stats/StatsPrinter.js +52 -31
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/TupleQueue.js +9 -7
- package/lib/util/TupleSet.js +37 -18
- package/lib/util/WeakTupleMap.js +50 -37
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +1 -1
- package/lib/util/concatenate.js +4 -2
- package/lib/util/createHash.js +1 -1
- package/lib/util/fs.js +1 -1
- package/lib/util/makeSerializable.js +1 -1
- package/lib/util/runtime.js +1 -0
- package/lib/util/serialization.js +50 -42
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/web/FetchCompileWasmPlugin.js +2 -2
- package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
- package/lib/webpack.js +1 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
- package/package.json +4 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +24 -2
- package/types.d.ts +273 -128
@@ -12,6 +12,11 @@
|
|
12
12
|
/** @type {WeakMap<Compiler, Set<LibraryType>>} */
|
13
13
|
const enabledTypes = new WeakMap();
|
14
14
|
|
15
|
+
/**
|
16
|
+
* @typedef {object} EnableLibraryPluginOptions
|
17
|
+
* @property {() => void=} additionalApply function that runs when applying the current plugin.
|
18
|
+
*/
|
19
|
+
|
15
20
|
/**
|
16
21
|
* @param {Compiler} compiler the compiler instance
|
17
22
|
* @returns {Set<LibraryType>} enabled types
|
@@ -28,9 +33,13 @@ const getEnabledTypes = compiler => {
|
|
28
33
|
class EnableLibraryPlugin {
|
29
34
|
/**
|
30
35
|
* @param {LibraryType} type library type that should be available
|
36
|
+
* @param {EnableLibraryPluginOptions} options options of EnableLibraryPlugin
|
31
37
|
*/
|
32
|
-
constructor(type) {
|
38
|
+
constructor(type, options = {}) {
|
39
|
+
/** @type {LibraryType} */
|
33
40
|
this.type = type;
|
41
|
+
/** @type {EnableLibraryPluginOptions} */
|
42
|
+
this.options = options;
|
34
43
|
}
|
35
44
|
|
36
45
|
/**
|
@@ -67,13 +76,17 @@ class EnableLibraryPlugin {
|
|
67
76
|
* @returns {void}
|
68
77
|
*/
|
69
78
|
apply(compiler) {
|
70
|
-
const { type } = this;
|
79
|
+
const { type, options } = this;
|
71
80
|
|
72
81
|
// Only enable once
|
73
82
|
const enabled = getEnabledTypes(compiler);
|
74
83
|
if (enabled.has(type)) return;
|
75
84
|
enabled.add(type);
|
76
85
|
|
86
|
+
if (typeof options.additionalApply === "function") {
|
87
|
+
options.additionalApply();
|
88
|
+
}
|
89
|
+
|
77
90
|
if (typeof type === "string") {
|
78
91
|
const enableExportProperty = () => {
|
79
92
|
const ExportPropertyTemplatePlugin = require("./ExportPropertyLibraryPlugin");
|
@@ -39,6 +39,8 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
|
39
39
|
* @property {string | string[]=} export
|
40
40
|
*/
|
41
41
|
|
42
|
+
const PLUGIN_NAME = "ModuleLibraryPlugin";
|
43
|
+
|
42
44
|
/**
|
43
45
|
* @typedef {ModuleLibraryPluginParsed} T
|
44
46
|
* @extends {AbstractLibraryPlugin<ModuleLibraryPluginParsed>}
|
@@ -62,34 +64,31 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
62
64
|
apply(compiler) {
|
63
65
|
super.apply(compiler);
|
64
66
|
|
65
|
-
compiler.hooks.
|
67
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
66
68
|
const { exportsDefinitions } =
|
67
69
|
ConcatenatedModule.getCompilationHooks(compilation);
|
68
|
-
exportsDefinitions.tap(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if (connection.originModule) {
|
77
|
-
return false;
|
78
|
-
}
|
70
|
+
exportsDefinitions.tap(PLUGIN_NAME, (definitions, module) => {
|
71
|
+
// If we have connections not all modules were concatenated, so we need the wrapper
|
72
|
+
const connections =
|
73
|
+
compilation.moduleGraph.getIncomingConnections(module);
|
74
|
+
|
75
|
+
for (const connection of connections) {
|
76
|
+
if (connection.originModule) {
|
77
|
+
return false;
|
79
78
|
}
|
79
|
+
}
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
81
|
+
// Runtime and splitting chunks now requires the wrapper too
|
82
|
+
for (const chunk of compilation.chunkGraph.getModuleChunksIterable(
|
83
|
+
module
|
84
|
+
)) {
|
85
|
+
if (!chunk.hasRuntime()) {
|
86
|
+
return false;
|
88
87
|
}
|
89
|
-
|
90
|
-
return true;
|
91
88
|
}
|
92
|
-
|
89
|
+
|
90
|
+
return true;
|
91
|
+
});
|
93
92
|
});
|
94
93
|
}
|
95
94
|
|
@@ -121,11 +120,11 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
121
120
|
renderStartup(
|
122
121
|
source,
|
123
122
|
module,
|
124
|
-
{ moduleGraph, chunk },
|
123
|
+
{ moduleGraph, chunk, codeGenerationResults },
|
125
124
|
{ options, compilation }
|
126
125
|
) {
|
127
126
|
const result = new ConcatSource(source);
|
128
|
-
const
|
127
|
+
const exportsInfo = options.export
|
129
128
|
? [
|
130
129
|
moduleGraph.getExportInfo(
|
131
130
|
module,
|
@@ -136,7 +135,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
136
135
|
const definitions =
|
137
136
|
/** @type {BuildMeta} */
|
138
137
|
(module.buildMeta).exportsFinalName || {};
|
138
|
+
/** @type {string[]} */
|
139
139
|
const shortHandedExports = [];
|
140
|
+
/** @type {[string, string][]} */
|
140
141
|
const exports = [];
|
141
142
|
const isAsync = moduleGraph.isAsync(module);
|
142
143
|
|
@@ -146,7 +147,11 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
146
147
|
);
|
147
148
|
}
|
148
149
|
|
149
|
-
|
150
|
+
const varType = compilation.outputOptions.environment.const
|
151
|
+
? "const"
|
152
|
+
: "var";
|
153
|
+
|
154
|
+
for (const exportInfo of exportsInfo) {
|
150
155
|
if (!exportInfo.provided) continue;
|
151
156
|
|
152
157
|
let shouldContinue = false;
|
@@ -159,6 +164,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
159
164
|
for (const reexportInfo of exp.orderedExports) {
|
160
165
|
if (
|
161
166
|
reexportInfo.provided === false &&
|
167
|
+
reexportInfo.name !== "default" &&
|
162
168
|
reexportInfo.name === /** @type {string[]} */ (reexport.export)[0]
|
163
169
|
) {
|
164
170
|
shouldContinue = true;
|
@@ -168,32 +174,51 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
168
174
|
|
169
175
|
if (shouldContinue) continue;
|
170
176
|
|
171
|
-
const
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
+
const originalName = exportInfo.name;
|
178
|
+
const usedName =
|
179
|
+
/** @type {string} */
|
180
|
+
(exportInfo.getUsedName(originalName, chunk.runtime));
|
181
|
+
/** @type {string | undefined} */
|
182
|
+
const definition = definitions[usedName];
|
177
183
|
const finalName =
|
178
184
|
definition ||
|
179
|
-
`${RuntimeGlobals.exports}${Template.toIdentifier(
|
185
|
+
`${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`;
|
180
186
|
|
181
187
|
if (!definition) {
|
182
188
|
result.add(
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
])}\n`
|
189
|
+
`${varType} ${finalName} = ${RuntimeGlobals.exports}${propertyAccess([
|
190
|
+
usedName
|
191
|
+
])};\n`
|
187
192
|
);
|
188
193
|
}
|
189
194
|
|
190
|
-
if (
|
191
|
-
|
195
|
+
if (
|
196
|
+
finalName &&
|
197
|
+
(finalName.includes(".") ||
|
198
|
+
finalName.includes("[") ||
|
199
|
+
finalName.includes("("))
|
200
|
+
) {
|
201
|
+
if (exportInfo.isReexport()) {
|
202
|
+
const { data } = codeGenerationResults.get(module, chunk.runtime);
|
203
|
+
const topLevelDeclarations =
|
204
|
+
(data && data.get("topLevelDeclarations")) ||
|
205
|
+
(module.buildInfo && module.buildInfo.topLevelDeclarations);
|
206
|
+
|
207
|
+
if (topLevelDeclarations && topLevelDeclarations.has(originalName)) {
|
208
|
+
const name = `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`;
|
209
|
+
result.add(`${varType} ${name} = ${finalName};\n`);
|
210
|
+
shortHandedExports.push(`${name} as ${originalName}`);
|
211
|
+
} else {
|
212
|
+
exports.push([originalName, finalName]);
|
213
|
+
}
|
214
|
+
} else {
|
215
|
+
exports.push([originalName, finalName]);
|
216
|
+
}
|
192
217
|
} else {
|
193
218
|
shortHandedExports.push(
|
194
|
-
definition && finalName ===
|
219
|
+
definition && finalName === originalName
|
195
220
|
? finalName
|
196
|
-
: `${finalName} as ${
|
221
|
+
: `${finalName} as ${originalName}`
|
197
222
|
);
|
198
223
|
}
|
199
224
|
}
|
@@ -203,9 +228,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
203
228
|
}
|
204
229
|
|
205
230
|
for (const [exportName, final] of exports) {
|
206
|
-
result.add(
|
207
|
-
`export ${compilation.outputOptions.environment.const ? "const" : "var"} ${exportName} = ${final};\n`
|
208
|
-
);
|
231
|
+
result.add(`export ${varType} ${exportName} = ${final};\n`);
|
209
232
|
}
|
210
233
|
|
211
234
|
return result;
|
@@ -13,12 +13,14 @@ const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenc
|
|
13
13
|
|
14
14
|
/**
|
15
15
|
* @typedef {object} CommonJsChunkLoadingPluginOptions
|
16
|
-
* @property {boolean}
|
16
|
+
* @property {boolean=} asyncChunkLoading enable async chunk loading
|
17
17
|
*/
|
18
18
|
|
19
|
+
const PLUGIN_NAME = "CommonJsChunkLoadingPlugin";
|
20
|
+
|
19
21
|
class CommonJsChunkLoadingPlugin {
|
20
22
|
/**
|
21
|
-
* @param {CommonJsChunkLoadingPluginOptions}
|
23
|
+
* @param {CommonJsChunkLoadingPluginOptions=} options options
|
22
24
|
*/
|
23
25
|
constructor(options = {}) {
|
24
26
|
this._asyncChunkLoading = options.asyncChunkLoading;
|
@@ -40,81 +42,75 @@ class CommonJsChunkLoadingPlugin {
|
|
40
42
|
chunkLoading: chunkLoadingValue,
|
41
43
|
asyncChunkLoading: this._asyncChunkLoading
|
42
44
|
}).apply(compiler);
|
43
|
-
compiler.hooks.thisCompilation.tap(
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
const
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
compilation.addRuntimeModule(
|
71
|
-
chunk,
|
72
|
-
new ChunkLoadingRuntimeModule(set)
|
73
|
-
);
|
74
|
-
};
|
45
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
46
|
+
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
47
|
+
/**
|
48
|
+
* @param {Chunk} chunk chunk
|
49
|
+
* @returns {boolean} true, if wasm loading is enabled for the chunk
|
50
|
+
*/
|
51
|
+
const isEnabledForChunk = chunk => {
|
52
|
+
const options = chunk.getEntryOptions();
|
53
|
+
const chunkLoading =
|
54
|
+
options && options.chunkLoading !== undefined
|
55
|
+
? options.chunkLoading
|
56
|
+
: globalChunkLoading;
|
57
|
+
return chunkLoading === chunkLoadingValue;
|
58
|
+
};
|
59
|
+
const onceForChunkSet = new WeakSet();
|
60
|
+
/**
|
61
|
+
* @param {Chunk} chunk chunk
|
62
|
+
* @param {Set<string>} set runtime requirements
|
63
|
+
*/
|
64
|
+
const handler = (chunk, set) => {
|
65
|
+
if (onceForChunkSet.has(chunk)) return;
|
66
|
+
onceForChunkSet.add(chunk);
|
67
|
+
if (!isEnabledForChunk(chunk)) return;
|
68
|
+
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
69
|
+
set.add(RuntimeGlobals.hasOwnProperty);
|
70
|
+
compilation.addRuntimeModule(chunk, new ChunkLoadingRuntimeModule(set));
|
71
|
+
};
|
75
72
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
73
|
+
compilation.hooks.runtimeRequirementInTree
|
74
|
+
.for(RuntimeGlobals.ensureChunkHandlers)
|
75
|
+
.tap(PLUGIN_NAME, handler);
|
76
|
+
compilation.hooks.runtimeRequirementInTree
|
77
|
+
.for(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
78
|
+
.tap(PLUGIN_NAME, handler);
|
79
|
+
compilation.hooks.runtimeRequirementInTree
|
80
|
+
.for(RuntimeGlobals.hmrDownloadManifest)
|
81
|
+
.tap(PLUGIN_NAME, handler);
|
82
|
+
compilation.hooks.runtimeRequirementInTree
|
83
|
+
.for(RuntimeGlobals.baseURI)
|
84
|
+
.tap(PLUGIN_NAME, handler);
|
85
|
+
compilation.hooks.runtimeRequirementInTree
|
86
|
+
.for(RuntimeGlobals.externalInstallChunk)
|
87
|
+
.tap(PLUGIN_NAME, handler);
|
88
|
+
compilation.hooks.runtimeRequirementInTree
|
89
|
+
.for(RuntimeGlobals.onChunksLoaded)
|
90
|
+
.tap(PLUGIN_NAME, handler);
|
94
91
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
);
|
92
|
+
compilation.hooks.runtimeRequirementInTree
|
93
|
+
.for(RuntimeGlobals.ensureChunkHandlers)
|
94
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
95
|
+
if (!isEnabledForChunk(chunk)) return;
|
96
|
+
set.add(RuntimeGlobals.getChunkScriptFilename);
|
97
|
+
});
|
98
|
+
compilation.hooks.runtimeRequirementInTree
|
99
|
+
.for(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
100
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
101
|
+
if (!isEnabledForChunk(chunk)) return;
|
102
|
+
set.add(RuntimeGlobals.getChunkUpdateScriptFilename);
|
103
|
+
set.add(RuntimeGlobals.moduleCache);
|
104
|
+
set.add(RuntimeGlobals.hmrModuleData);
|
105
|
+
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
106
|
+
});
|
107
|
+
compilation.hooks.runtimeRequirementInTree
|
108
|
+
.for(RuntimeGlobals.hmrDownloadManifest)
|
109
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
110
|
+
if (!isEnabledForChunk(chunk)) return;
|
111
|
+
set.add(RuntimeGlobals.getUpdateManifestFilename);
|
112
|
+
});
|
113
|
+
});
|
118
114
|
}
|
119
115
|
}
|
120
116
|
|
@@ -20,6 +20,8 @@ const nodeConsole = require("./nodeConsole");
|
|
20
20
|
* @property {InfrastructureLogging} infrastructureLogging infrastructure logging options
|
21
21
|
*/
|
22
22
|
|
23
|
+
const PLUGIN_NAME = "NodeEnvironmentPlugin";
|
24
|
+
|
23
25
|
class NodeEnvironmentPlugin {
|
24
26
|
/**
|
25
27
|
* @param {NodeEnvironmentPluginOptions} options options
|
@@ -55,7 +57,7 @@ class NodeEnvironmentPlugin {
|
|
55
57
|
compiler.outputFileSystem = fs;
|
56
58
|
compiler.intermediateFileSystem = fs;
|
57
59
|
compiler.watchFileSystem = new NodeWatchFileSystem(inputFileSystem);
|
58
|
-
compiler.hooks.beforeRun.tap(
|
60
|
+
compiler.hooks.beforeRun.tap(PLUGIN_NAME, compiler => {
|
59
61
|
if (
|
60
62
|
compiler.inputFileSystem === inputFileSystem &&
|
61
63
|
inputFileSystem.purge
|
@@ -12,12 +12,12 @@ const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin
|
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @typedef {object} NodeTemplatePluginOptions
|
15
|
-
* @property {boolean}
|
15
|
+
* @property {boolean=} asyncChunkLoading enable async chunk loading
|
16
16
|
*/
|
17
17
|
|
18
18
|
class NodeTemplatePlugin {
|
19
19
|
/**
|
20
|
-
* @param {NodeTemplatePluginOptions}
|
20
|
+
* @param {NodeTemplatePluginOptions=} options options object
|
21
21
|
*/
|
22
22
|
constructor(options = {}) {
|
23
23
|
this._options = options;
|
@@ -15,14 +15,14 @@ const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRun
|
|
15
15
|
|
16
16
|
/**
|
17
17
|
* @typedef {object} ReadFileCompileAsyncWasmPluginOptions
|
18
|
-
* @property {boolean}
|
18
|
+
* @property {boolean=} import use import?
|
19
19
|
*/
|
20
20
|
|
21
21
|
const PLUGIN_NAME = "ReadFileCompileAsyncWasmPlugin";
|
22
22
|
|
23
23
|
class ReadFileCompileAsyncWasmPlugin {
|
24
24
|
/**
|
25
|
-
* @param {ReadFileCompileAsyncWasmPluginOptions}
|
25
|
+
* @param {ReadFileCompileAsyncWasmPluginOptions=} options options object
|
26
26
|
*/
|
27
27
|
constructor({ import: useImport = false } = {}) {
|
28
28
|
this._import = useImport;
|
@@ -15,8 +15,8 @@ const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRunt
|
|
15
15
|
|
16
16
|
/**
|
17
17
|
* @typedef {object} ReadFileCompileWasmPluginOptions
|
18
|
-
* @property {boolean}
|
19
|
-
* @property {boolean}
|
18
|
+
* @property {boolean=} mangleImports mangle imports
|
19
|
+
* @property {boolean=} import use import?
|
20
20
|
*/
|
21
21
|
|
22
22
|
// TODO webpack 6 remove
|
@@ -25,7 +25,7 @@ const PLUGIN_NAME = "ReadFileCompileWasmPlugin";
|
|
25
25
|
|
26
26
|
class ReadFileCompileWasmPlugin {
|
27
27
|
/**
|
28
|
-
* @param {ReadFileCompileWasmPluginOptions}
|
28
|
+
* @param {ReadFileCompileWasmPluginOptions=} options options object
|
29
29
|
*/
|
30
30
|
constructor(options = {}) {
|
31
31
|
this.options = options;
|
@@ -17,7 +17,7 @@ const { STAGE_ADVANCED } = require("../OptimizationStages");
|
|
17
17
|
|
18
18
|
class AggressiveMergingPlugin {
|
19
19
|
/**
|
20
|
-
* @param {AggressiveMergingPluginOptions=}
|
20
|
+
* @param {AggressiveMergingPluginOptions=} options options object
|
21
21
|
*/
|
22
22
|
constructor(options) {
|
23
23
|
if (
|