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
package/lib/RuntimePlugin.js
CHANGED
@@ -101,13 +101,15 @@ const TREE_DEPENDENCIES = {
|
|
101
101
|
[RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty]
|
102
102
|
};
|
103
103
|
|
104
|
+
const PLUGIN_NAME = "RuntimePlugin";
|
105
|
+
|
104
106
|
class RuntimePlugin {
|
105
107
|
/**
|
106
108
|
* @param {Compiler} compiler the Compiler
|
107
109
|
* @returns {void}
|
108
110
|
*/
|
109
111
|
apply(compiler) {
|
110
|
-
compiler.hooks.compilation.tap(
|
112
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
111
113
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
112
114
|
/**
|
113
115
|
* @param {Chunk} chunk chunk
|
@@ -128,12 +130,12 @@ class RuntimePlugin {
|
|
128
130
|
for (const req of GLOBALS_ON_REQUIRE) {
|
129
131
|
compilation.hooks.runtimeRequirementInModule
|
130
132
|
.for(req)
|
131
|
-
.tap(
|
133
|
+
.tap(PLUGIN_NAME, (module, set) => {
|
132
134
|
set.add(RuntimeGlobals.requireScope);
|
133
135
|
});
|
134
136
|
compilation.hooks.runtimeRequirementInTree
|
135
137
|
.for(req)
|
136
|
-
.tap(
|
138
|
+
.tap(PLUGIN_NAME, (module, set) => {
|
137
139
|
set.add(RuntimeGlobals.requireScope);
|
138
140
|
});
|
139
141
|
}
|
@@ -142,7 +144,7 @@ class RuntimePlugin {
|
|
142
144
|
TREE_DEPENDENCIES[/** @type {keyof TREE_DEPENDENCIES} */ (req)];
|
143
145
|
compilation.hooks.runtimeRequirementInTree
|
144
146
|
.for(req)
|
145
|
-
.tap(
|
147
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
146
148
|
for (const dep of deps) set.add(dep);
|
147
149
|
});
|
148
150
|
}
|
@@ -151,13 +153,13 @@ class RuntimePlugin {
|
|
151
153
|
MODULE_DEPENDENCIES[/** @type {keyof MODULE_DEPENDENCIES} */ (req)];
|
152
154
|
compilation.hooks.runtimeRequirementInModule
|
153
155
|
.for(req)
|
154
|
-
.tap(
|
156
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
155
157
|
for (const dep of deps) set.add(dep);
|
156
158
|
});
|
157
159
|
}
|
158
160
|
compilation.hooks.runtimeRequirementInTree
|
159
161
|
.for(RuntimeGlobals.definePropertyGetters)
|
160
|
-
.tap(
|
162
|
+
.tap(PLUGIN_NAME, chunk => {
|
161
163
|
compilation.addRuntimeModule(
|
162
164
|
chunk,
|
163
165
|
new DefinePropertyGettersRuntimeModule()
|
@@ -166,7 +168,7 @@ class RuntimePlugin {
|
|
166
168
|
});
|
167
169
|
compilation.hooks.runtimeRequirementInTree
|
168
170
|
.for(RuntimeGlobals.makeNamespaceObject)
|
169
|
-
.tap(
|
171
|
+
.tap(PLUGIN_NAME, chunk => {
|
170
172
|
compilation.addRuntimeModule(
|
171
173
|
chunk,
|
172
174
|
new MakeNamespaceObjectRuntimeModule()
|
@@ -175,7 +177,7 @@ class RuntimePlugin {
|
|
175
177
|
});
|
176
178
|
compilation.hooks.runtimeRequirementInTree
|
177
179
|
.for(RuntimeGlobals.createFakeNamespaceObject)
|
178
|
-
.tap(
|
180
|
+
.tap(PLUGIN_NAME, chunk => {
|
179
181
|
compilation.addRuntimeModule(
|
180
182
|
chunk,
|
181
183
|
new CreateFakeNamespaceObjectRuntimeModule()
|
@@ -184,7 +186,7 @@ class RuntimePlugin {
|
|
184
186
|
});
|
185
187
|
compilation.hooks.runtimeRequirementInTree
|
186
188
|
.for(RuntimeGlobals.hasOwnProperty)
|
187
|
-
.tap(
|
189
|
+
.tap(PLUGIN_NAME, chunk => {
|
188
190
|
compilation.addRuntimeModule(
|
189
191
|
chunk,
|
190
192
|
new HasOwnPropertyRuntimeModule()
|
@@ -193,7 +195,7 @@ class RuntimePlugin {
|
|
193
195
|
});
|
194
196
|
compilation.hooks.runtimeRequirementInTree
|
195
197
|
.for(RuntimeGlobals.compatGetDefaultExport)
|
196
|
-
.tap(
|
198
|
+
.tap(PLUGIN_NAME, chunk => {
|
197
199
|
compilation.addRuntimeModule(
|
198
200
|
chunk,
|
199
201
|
new CompatGetDefaultExportRuntimeModule()
|
@@ -202,13 +204,13 @@ class RuntimePlugin {
|
|
202
204
|
});
|
203
205
|
compilation.hooks.runtimeRequirementInTree
|
204
206
|
.for(RuntimeGlobals.runtimeId)
|
205
|
-
.tap(
|
207
|
+
.tap(PLUGIN_NAME, chunk => {
|
206
208
|
compilation.addRuntimeModule(chunk, new RuntimeIdRuntimeModule());
|
207
209
|
return true;
|
208
210
|
});
|
209
211
|
compilation.hooks.runtimeRequirementInTree
|
210
212
|
.for(RuntimeGlobals.publicPath)
|
211
|
-
.tap(
|
213
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
212
214
|
const { outputOptions } = compilation;
|
213
215
|
const { publicPath: globalPublicPath, scriptType } = outputOptions;
|
214
216
|
const entryOptions = chunk.getEntryOptions();
|
@@ -237,19 +239,19 @@ class RuntimePlugin {
|
|
237
239
|
});
|
238
240
|
compilation.hooks.runtimeRequirementInTree
|
239
241
|
.for(RuntimeGlobals.global)
|
240
|
-
.tap(
|
242
|
+
.tap(PLUGIN_NAME, chunk => {
|
241
243
|
compilation.addRuntimeModule(chunk, new GlobalRuntimeModule());
|
242
244
|
return true;
|
243
245
|
});
|
244
246
|
compilation.hooks.runtimeRequirementInTree
|
245
247
|
.for(RuntimeGlobals.asyncModule)
|
246
|
-
.tap(
|
248
|
+
.tap(PLUGIN_NAME, chunk => {
|
247
249
|
compilation.addRuntimeModule(chunk, new AsyncModuleRuntimeModule());
|
248
250
|
return true;
|
249
251
|
});
|
250
252
|
compilation.hooks.runtimeRequirementInTree
|
251
253
|
.for(RuntimeGlobals.systemContext)
|
252
|
-
.tap(
|
254
|
+
.tap(PLUGIN_NAME, chunk => {
|
253
255
|
const entryOptions = chunk.getEntryOptions();
|
254
256
|
const libraryType =
|
255
257
|
entryOptions && entryOptions.library !== undefined
|
@@ -267,7 +269,7 @@ class RuntimePlugin {
|
|
267
269
|
});
|
268
270
|
compilation.hooks.runtimeRequirementInTree
|
269
271
|
.for(RuntimeGlobals.getChunkScriptFilename)
|
270
|
-
.tap(
|
272
|
+
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
271
273
|
if (
|
272
274
|
typeof compilation.outputOptions.chunkFilename === "string" &&
|
273
275
|
/\[(full)?hash(:\d+)?\]/.test(
|
@@ -297,7 +299,7 @@ class RuntimePlugin {
|
|
297
299
|
});
|
298
300
|
compilation.hooks.runtimeRequirementInTree
|
299
301
|
.for(RuntimeGlobals.getChunkCssFilename)
|
300
|
-
.tap(
|
302
|
+
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
301
303
|
if (
|
302
304
|
typeof compilation.outputOptions.cssChunkFilename === "string" &&
|
303
305
|
/\[(full)?hash(:\d+)?\]/.test(
|
@@ -322,7 +324,7 @@ class RuntimePlugin {
|
|
322
324
|
});
|
323
325
|
compilation.hooks.runtimeRequirementInTree
|
324
326
|
.for(RuntimeGlobals.getChunkUpdateScriptFilename)
|
325
|
-
.tap(
|
327
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
326
328
|
if (
|
327
329
|
/\[(full)?hash(:\d+)?\]/.test(
|
328
330
|
/** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
|
@@ -346,7 +348,7 @@ class RuntimePlugin {
|
|
346
348
|
});
|
347
349
|
compilation.hooks.runtimeRequirementInTree
|
348
350
|
.for(RuntimeGlobals.getUpdateManifestFilename)
|
349
|
-
.tap(
|
351
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
350
352
|
if (
|
351
353
|
/\[(full)?hash(:\d+)?\]/.test(
|
352
354
|
/** @type {NonNullable<OutputNormalized["hotUpdateMainFilename"]>} */
|
@@ -368,7 +370,7 @@ class RuntimePlugin {
|
|
368
370
|
});
|
369
371
|
compilation.hooks.runtimeRequirementInTree
|
370
372
|
.for(RuntimeGlobals.ensureChunk)
|
371
|
-
.tap(
|
373
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
372
374
|
const hasAsyncChunks = chunk.hasAsyncChunks();
|
373
375
|
if (hasAsyncChunks) {
|
374
376
|
set.add(RuntimeGlobals.ensureChunkHandlers);
|
@@ -381,18 +383,18 @@ class RuntimePlugin {
|
|
381
383
|
});
|
382
384
|
compilation.hooks.runtimeRequirementInTree
|
383
385
|
.for(RuntimeGlobals.ensureChunkIncludeEntries)
|
384
|
-
.tap(
|
386
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
385
387
|
set.add(RuntimeGlobals.ensureChunkHandlers);
|
386
388
|
});
|
387
389
|
compilation.hooks.runtimeRequirementInTree
|
388
390
|
.for(RuntimeGlobals.shareScopeMap)
|
389
|
-
.tap(
|
391
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
390
392
|
compilation.addRuntimeModule(chunk, new ShareRuntimeModule());
|
391
393
|
return true;
|
392
394
|
});
|
393
395
|
compilation.hooks.runtimeRequirementInTree
|
394
396
|
.for(RuntimeGlobals.loadScript)
|
395
|
-
.tap(
|
397
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
396
398
|
const withCreateScriptUrl = Boolean(
|
397
399
|
compilation.outputOptions.trustedTypes
|
398
400
|
);
|
@@ -408,7 +410,7 @@ class RuntimePlugin {
|
|
408
410
|
});
|
409
411
|
compilation.hooks.runtimeRequirementInTree
|
410
412
|
.for(RuntimeGlobals.createScript)
|
411
|
-
.tap(
|
413
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
412
414
|
if (compilation.outputOptions.trustedTypes) {
|
413
415
|
set.add(RuntimeGlobals.getTrustedTypesPolicy);
|
414
416
|
}
|
@@ -417,7 +419,7 @@ class RuntimePlugin {
|
|
417
419
|
});
|
418
420
|
compilation.hooks.runtimeRequirementInTree
|
419
421
|
.for(RuntimeGlobals.createScriptUrl)
|
420
|
-
.tap(
|
422
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
421
423
|
if (compilation.outputOptions.trustedTypes) {
|
422
424
|
set.add(RuntimeGlobals.getTrustedTypesPolicy);
|
423
425
|
}
|
@@ -429,7 +431,7 @@ class RuntimePlugin {
|
|
429
431
|
});
|
430
432
|
compilation.hooks.runtimeRequirementInTree
|
431
433
|
.for(RuntimeGlobals.getTrustedTypesPolicy)
|
432
|
-
.tap(
|
434
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
433
435
|
compilation.addRuntimeModule(
|
434
436
|
chunk,
|
435
437
|
new GetTrustedTypesPolicyRuntimeModule(set)
|
@@ -438,13 +440,13 @@ class RuntimePlugin {
|
|
438
440
|
});
|
439
441
|
compilation.hooks.runtimeRequirementInTree
|
440
442
|
.for(RuntimeGlobals.relativeUrl)
|
441
|
-
.tap(
|
443
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
442
444
|
compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
|
443
445
|
return true;
|
444
446
|
});
|
445
447
|
compilation.hooks.runtimeRequirementInTree
|
446
448
|
.for(RuntimeGlobals.onChunksLoaded)
|
447
|
-
.tap(
|
449
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
448
450
|
compilation.addRuntimeModule(
|
449
451
|
chunk,
|
450
452
|
new OnChunksLoadedRuntimeModule()
|
@@ -453,7 +455,7 @@ class RuntimePlugin {
|
|
453
455
|
});
|
454
456
|
compilation.hooks.runtimeRequirementInTree
|
455
457
|
.for(RuntimeGlobals.baseURI)
|
456
|
-
.tap(
|
458
|
+
.tap(PLUGIN_NAME, chunk => {
|
457
459
|
if (isChunkLoadingDisabledForChunk(chunk)) {
|
458
460
|
compilation.addRuntimeModule(chunk, new BaseUriRuntimeModule());
|
459
461
|
return true;
|
@@ -461,13 +463,13 @@ class RuntimePlugin {
|
|
461
463
|
});
|
462
464
|
compilation.hooks.runtimeRequirementInTree
|
463
465
|
.for(RuntimeGlobals.scriptNonce)
|
464
|
-
.tap(
|
466
|
+
.tap(PLUGIN_NAME, chunk => {
|
465
467
|
compilation.addRuntimeModule(chunk, new NonceRuntimeModule());
|
466
468
|
return true;
|
467
469
|
});
|
468
470
|
// TODO webpack 6: remove CompatRuntimeModule
|
469
471
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
470
|
-
|
472
|
+
PLUGIN_NAME,
|
471
473
|
(chunk, set) => {
|
472
474
|
const { mainTemplate } = compilation;
|
473
475
|
if (
|
@@ -481,7 +483,7 @@ class RuntimePlugin {
|
|
481
483
|
}
|
482
484
|
);
|
483
485
|
JavascriptModulesPlugin.getCompilationHooks(compilation).chunkHash.tap(
|
484
|
-
|
486
|
+
PLUGIN_NAME,
|
485
487
|
(chunk, hash, { chunkGraph }) => {
|
486
488
|
const xor = new StringXor();
|
487
489
|
for (const m of chunkGraph.getChunkRuntimeModulesIterable(chunk)) {
|
@@ -131,9 +131,11 @@ const getTaskForFile = (
|
|
131
131
|
};
|
132
132
|
};
|
133
133
|
|
134
|
+
const PLUGIN_NAME = "SourceMapDevToolPlugin";
|
135
|
+
|
134
136
|
class SourceMapDevToolPlugin {
|
135
137
|
/**
|
136
|
-
* @param {SourceMapDevToolPluginOptions}
|
138
|
+
* @param {SourceMapDevToolPluginOptions=} options options object
|
137
139
|
* @throws {Error} throws error, if got more than 1 arguments
|
138
140
|
*/
|
139
141
|
constructor(options = {}) {
|
@@ -178,18 +180,18 @@ class SourceMapDevToolPlugin {
|
|
178
180
|
options
|
179
181
|
);
|
180
182
|
|
181
|
-
compiler.hooks.compilation.tap(
|
183
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
182
184
|
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
|
183
185
|
|
184
186
|
compilation.hooks.processAssets.tapAsync(
|
185
187
|
{
|
186
|
-
name:
|
188
|
+
name: PLUGIN_NAME,
|
187
189
|
stage: Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
|
188
190
|
additionalAssets: true
|
189
191
|
},
|
190
192
|
(assets, callback) => {
|
191
193
|
const chunkGraph = compilation.chunkGraph;
|
192
|
-
const cache = compilation.getCache(
|
194
|
+
const cache = compilation.getCache(PLUGIN_NAME);
|
193
195
|
/** @type {Map<string | Module, string>} */
|
194
196
|
const moduleToSourceNameMapping = new Map();
|
195
197
|
const reportProgress =
|
@@ -552,12 +554,12 @@ class SourceMapDevToolPlugin {
|
|
552
554
|
} else {
|
553
555
|
if (currentSourceMappingURLComment === false) {
|
554
556
|
throw new Error(
|
555
|
-
|
557
|
+
`${PLUGIN_NAME}: append can't be false when no filename is provided`
|
556
558
|
);
|
557
559
|
}
|
558
560
|
if (typeof currentSourceMappingURLComment === "function") {
|
559
561
|
throw new Error(
|
560
|
-
|
562
|
+
`${PLUGIN_NAME}: append can't be a function when no filename is provided`
|
561
563
|
);
|
562
564
|
}
|
563
565
|
/**
|
package/lib/Template.js
CHANGED
@@ -11,6 +11,8 @@ const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
|
|
11
11
|
/** @typedef {import("./Module")} Module */
|
12
12
|
/** @typedef {import("./NormalModule")} NormalModule */
|
13
13
|
|
14
|
+
const PLUGIN_NAME = "WarnCaseSensitiveModulesPlugin";
|
15
|
+
|
14
16
|
class WarnCaseSensitiveModulesPlugin {
|
15
17
|
/**
|
16
18
|
* Apply the plugin
|
@@ -18,47 +20,44 @@ class WarnCaseSensitiveModulesPlugin {
|
|
18
20
|
* @returns {void}
|
19
21
|
*/
|
20
22
|
apply(compiler) {
|
21
|
-
compiler.hooks.compilation.tap(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
const
|
27
|
-
for (const module of compilation.modules) {
|
28
|
-
const identifier = module.identifier();
|
23
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
24
|
+
compilation.hooks.seal.tap(PLUGIN_NAME, () => {
|
25
|
+
/** @type {Map<string, Map<string, Module>>} */
|
26
|
+
const moduleWithoutCase = new Map();
|
27
|
+
for (const module of compilation.modules) {
|
28
|
+
const identifier = module.identifier();
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
// Ignore `data:` URLs, because it's not a real path
|
31
|
+
if (
|
32
|
+
/** @type {NormalModule} */
|
33
|
+
(module).resourceResolveData !== undefined &&
|
34
|
+
/** @type {NormalModule} */
|
35
|
+
(module).resourceResolveData.encodedContent !== undefined
|
36
|
+
) {
|
37
|
+
continue;
|
38
|
+
}
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
46
|
-
map.set(identifier, module);
|
40
|
+
const lowerIdentifier = identifier.toLowerCase();
|
41
|
+
let map = moduleWithoutCase.get(lowerIdentifier);
|
42
|
+
if (map === undefined) {
|
43
|
+
map = new Map();
|
44
|
+
moduleWithoutCase.set(lowerIdentifier, map);
|
47
45
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
)
|
56
|
-
|
57
|
-
|
46
|
+
map.set(identifier, module);
|
47
|
+
}
|
48
|
+
for (const pair of moduleWithoutCase) {
|
49
|
+
const map = pair[1];
|
50
|
+
if (map.size > 1) {
|
51
|
+
compilation.warnings.push(
|
52
|
+
new CaseSensitiveModulesWarning(
|
53
|
+
map.values(),
|
54
|
+
compilation.moduleGraph
|
55
|
+
)
|
56
|
+
);
|
58
57
|
}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
);
|
58
|
+
}
|
59
|
+
});
|
60
|
+
});
|
62
61
|
}
|
63
62
|
}
|
64
63
|
|
@@ -9,6 +9,8 @@ const NoModeWarning = require("./NoModeWarning");
|
|
9
9
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
|
12
|
+
const PLUGIN_NAME = "WarnNoModeSetPlugin";
|
13
|
+
|
12
14
|
class WarnNoModeSetPlugin {
|
13
15
|
/**
|
14
16
|
* Apply the plugin
|
@@ -16,7 +18,7 @@ class WarnNoModeSetPlugin {
|
|
16
18
|
* @returns {void}
|
17
19
|
*/
|
18
20
|
apply(compiler) {
|
19
|
-
compiler.hooks.thisCompilation.tap(
|
21
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
20
22
|
compilation.warnings.push(new NoModeWarning());
|
21
23
|
});
|
22
24
|
}
|
package/lib/WatchIgnorePlugin.js
CHANGED
@@ -125,6 +125,8 @@ class IgnoringWatchFileSystem {
|
|
125
125
|
}
|
126
126
|
}
|
127
127
|
|
128
|
+
const PLUGIN_NAME = "WatchIgnorePlugin";
|
129
|
+
|
128
130
|
class WatchIgnorePlugin {
|
129
131
|
/**
|
130
132
|
* @param {WatchIgnorePluginOptions} options options
|
@@ -140,7 +142,7 @@ class WatchIgnorePlugin {
|
|
140
142
|
* @returns {void}
|
141
143
|
*/
|
142
144
|
apply(compiler) {
|
143
|
-
compiler.hooks.afterEnvironment.tap(
|
145
|
+
compiler.hooks.afterEnvironment.tap(PLUGIN_NAME, () => {
|
144
146
|
compiler.watchFileSystem = new IgnoringWatchFileSystem(
|
145
147
|
/** @type {WatchFileSystem} */
|
146
148
|
(compiler.watchFileSystem),
|
package/lib/WebpackError.js
CHANGED
@@ -18,9 +18,11 @@ class WebpackError extends Error {
|
|
18
18
|
/**
|
19
19
|
* Creates an instance of WebpackError.
|
20
20
|
* @param {string=} message error message
|
21
|
+
* @param {{ cause?: unknown }} options error options
|
21
22
|
*/
|
22
|
-
constructor(message) {
|
23
|
-
|
23
|
+
constructor(message, options = {}) {
|
24
|
+
// @ts-expect-error ES2018 doesn't `Error.cause`, but it can be used by developers
|
25
|
+
super(message, options);
|
24
26
|
|
25
27
|
/** @type {string=} */
|
26
28
|
this.details = undefined;
|
@@ -37,7 +39,11 @@ class WebpackError extends Error {
|
|
37
39
|
}
|
38
40
|
|
39
41
|
[inspect]() {
|
40
|
-
return
|
42
|
+
return (
|
43
|
+
this.stack +
|
44
|
+
(this.details ? `\n${this.details}` : "") +
|
45
|
+
(this.cause ? `\n${this.cause}` : "")
|
46
|
+
);
|
41
47
|
}
|
42
48
|
|
43
49
|
/**
|
@@ -47,6 +53,7 @@ class WebpackError extends Error {
|
|
47
53
|
write(this.name);
|
48
54
|
write(this.message);
|
49
55
|
write(this.stack);
|
56
|
+
write(this.cause);
|
50
57
|
write(this.details);
|
51
58
|
write(this.loc);
|
52
59
|
write(this.hideStack);
|
@@ -59,6 +66,7 @@ class WebpackError extends Error {
|
|
59
66
|
this.name = read();
|
60
67
|
this.message = read();
|
61
68
|
this.stack = read();
|
69
|
+
this.cause = read();
|
62
70
|
this.details = read();
|
63
71
|
this.loc = read();
|
64
72
|
this.hideStack = read();
|
@@ -48,6 +48,7 @@ const WorkerPlugin = require("./dependencies/WorkerPlugin");
|
|
48
48
|
|
49
49
|
const InferAsyncModulesPlugin = require("./async-modules/InferAsyncModulesPlugin");
|
50
50
|
|
51
|
+
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
|
51
52
|
const JavascriptMetaInfoPlugin = require("./JavascriptMetaInfoPlugin");
|
52
53
|
const DefaultStatsFactoryPlugin = require("./stats/DefaultStatsFactoryPlugin");
|
53
54
|
const DefaultStatsPresetPlugin = require("./stats/DefaultStatsPresetPlugin");
|
@@ -62,6 +63,8 @@ const { cleverMerge } = require("./util/cleverMerge");
|
|
62
63
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
63
64
|
/** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
64
65
|
|
66
|
+
const CLASS_NAME = "WebpackOptionsApply";
|
67
|
+
|
65
68
|
class WebpackOptionsApply extends OptionsApply {
|
66
69
|
constructor() {
|
67
70
|
super();
|
@@ -236,9 +239,24 @@ class WebpackOptionsApply extends OptionsApply {
|
|
236
239
|
(options.output.enabledLibraryTypes);
|
237
240
|
|
238
241
|
if (enabledLibraryTypes.length > 0) {
|
242
|
+
let once = true;
|
239
243
|
for (const type of enabledLibraryTypes) {
|
240
244
|
const EnableLibraryPlugin = require("./library/EnableLibraryPlugin");
|
241
|
-
new EnableLibraryPlugin(type
|
245
|
+
new EnableLibraryPlugin(type, {
|
246
|
+
// eslint-disable-next-line no-loop-func
|
247
|
+
additionalApply: () => {
|
248
|
+
if (!once) return;
|
249
|
+
once = false;
|
250
|
+
// We rely on `exportInfo` to generate the `export statement` in certain library bundles.
|
251
|
+
// Therefore, we ignore the disabling of `optimization.providedExport` and continue to apply `FlagDependencyExportsPlugin`.
|
252
|
+
if (
|
253
|
+
["module", "commonjs-static", "modern-module"].includes(type) &&
|
254
|
+
!options.optimization.providedExports
|
255
|
+
) {
|
256
|
+
new FlagDependencyExportsPlugin().apply(compiler);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
}).apply(compiler);
|
242
260
|
}
|
243
261
|
}
|
244
262
|
|
@@ -458,7 +476,6 @@ class WebpackOptionsApply extends OptionsApply {
|
|
458
476
|
).apply(compiler);
|
459
477
|
}
|
460
478
|
if (options.optimization.providedExports) {
|
461
|
-
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
|
462
479
|
new FlagDependencyExportsPlugin().apply(compiler);
|
463
480
|
}
|
464
481
|
if (options.optimization.usedExports) {
|
@@ -749,7 +766,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
749
766
|
}
|
750
767
|
compiler.resolverFactory.hooks.resolveOptions
|
751
768
|
.for("normal")
|
752
|
-
.tap(
|
769
|
+
.tap(CLASS_NAME, resolveOptions => {
|
753
770
|
resolveOptions = cleverMerge(options.resolve, resolveOptions);
|
754
771
|
resolveOptions.fileSystem =
|
755
772
|
/** @type {InputFileSystem} */
|
@@ -758,7 +775,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
758
775
|
});
|
759
776
|
compiler.resolverFactory.hooks.resolveOptions
|
760
777
|
.for("context")
|
761
|
-
.tap(
|
778
|
+
.tap(CLASS_NAME, resolveOptions => {
|
762
779
|
resolveOptions = cleverMerge(options.resolve, resolveOptions);
|
763
780
|
resolveOptions.fileSystem =
|
764
781
|
/** @type {InputFileSystem} */
|
@@ -768,7 +785,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
768
785
|
});
|
769
786
|
compiler.resolverFactory.hooks.resolveOptions
|
770
787
|
.for("loader")
|
771
|
-
.tap(
|
788
|
+
.tap(CLASS_NAME, resolveOptions => {
|
772
789
|
resolveOptions = cleverMerge(options.resolveLoader, resolveOptions);
|
773
790
|
resolveOptions.fileSystem =
|
774
791
|
/** @type {InputFileSystem} */
|
@@ -10,6 +10,8 @@ const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency
|
|
10
10
|
/** @typedef {import("../Compiler")} Compiler */
|
11
11
|
/** @typedef {import("../Module")} Module */
|
12
12
|
|
13
|
+
const PLUGIN_NAME = "InferAsyncModulesPlugin";
|
14
|
+
|
13
15
|
class InferAsyncModulesPlugin {
|
14
16
|
/**
|
15
17
|
* Apply the plugin
|
@@ -17,37 +19,34 @@ class InferAsyncModulesPlugin {
|
|
17
19
|
* @returns {void}
|
18
20
|
*/
|
19
21
|
apply(compiler) {
|
20
|
-
compiler.hooks.compilation.tap(
|
22
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
21
23
|
const { moduleGraph } = compilation;
|
22
|
-
compilation.hooks.finishModules.tap(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if (module.buildMeta && module.buildMeta.async) {
|
29
|
-
queue.add(module);
|
30
|
-
}
|
24
|
+
compilation.hooks.finishModules.tap(PLUGIN_NAME, modules => {
|
25
|
+
/** @type {Set<Module>} */
|
26
|
+
const queue = new Set();
|
27
|
+
for (const module of modules) {
|
28
|
+
if (module.buildMeta && module.buildMeta.async) {
|
29
|
+
queue.add(module);
|
31
30
|
}
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
)
|
45
|
-
|
46
|
-
}
|
31
|
+
}
|
32
|
+
for (const module of queue) {
|
33
|
+
moduleGraph.setAsync(module);
|
34
|
+
for (const [
|
35
|
+
originModule,
|
36
|
+
connections
|
37
|
+
] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
|
38
|
+
if (
|
39
|
+
connections.some(
|
40
|
+
c =>
|
41
|
+
c.dependency instanceof HarmonyImportDependency &&
|
42
|
+
c.isTargetActive(undefined)
|
43
|
+
)
|
44
|
+
) {
|
45
|
+
queue.add(/** @type {Module} */ (originModule));
|
47
46
|
}
|
48
47
|
}
|
49
48
|
}
|
50
|
-
);
|
49
|
+
});
|
51
50
|
});
|
52
51
|
}
|
53
52
|
}
|