webpack 5.83.1 → 5.85.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/README.md +2 -2
- package/lib/AsyncDependenciesBlock.js +2 -2
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +4 -0
- package/lib/CacheFacade.js +4 -0
- package/lib/ChunkGroup.js +5 -1
- package/lib/CleanPlugin.js +30 -7
- package/lib/CompatibilityPlugin.js +4 -3
- package/lib/Compilation.js +3 -3
- package/lib/Compiler.js +1 -1
- package/lib/ContextModule.js +3 -3
- package/lib/ContextModuleFactory.js +1 -1
- package/lib/DefinePlugin.js +11 -2
- package/lib/DllEntryPlugin.js +5 -0
- package/lib/DllModule.js +1 -1
- package/lib/DllModuleFactory.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/HookWebpackError.js +1 -1
- package/lib/IgnoreErrorModuleFactory.js +1 -1
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -9
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleTypeConstants.js +2 -1
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/NormalModuleReplacementPlugin.js +4 -2
- package/lib/NullFactory.js +1 -1
- package/lib/PrefetchPlugin.js +4 -0
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/RuntimeModule.js +5 -5
- package/lib/RuntimePlugin.js +4 -0
- package/lib/RuntimeTemplate.js +7 -7
- package/lib/SelfModuleFactory.js +12 -0
- package/lib/SourceMapDevToolPlugin.js +9 -2
- package/lib/Template.js +3 -2
- package/lib/UseStrictPlugin.js +4 -0
- package/lib/WarnDeprecatedOptionPlugin.js +7 -0
- package/lib/WatchIgnorePlugin.js +4 -0
- package/lib/WebpackOptionsApply.js +2 -1
- package/lib/asset/AssetGenerator.js +7 -2
- package/lib/asset/AssetModulesPlugin.js +7 -1
- package/lib/asset/AssetParser.js +4 -1
- package/lib/asset/RawDataUrlModule.js +5 -3
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +7 -1
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +240 -73
- package/lib/config/normalization.js +104 -71
- package/lib/config/target.js +37 -10
- package/lib/container/ContainerEntryModule.js +4 -0
- package/lib/container/ContainerEntryModuleFactory.js +1 -1
- package/lib/container/FallbackDependency.js +7 -0
- package/lib/container/FallbackItemDependency.js +3 -0
- package/lib/container/FallbackModule.js +5 -1
- package/lib/container/FallbackModuleFactory.js +1 -1
- package/lib/container/RemoteModule.js +4 -0
- package/lib/container/RemoteRuntimeModule.js +2 -1
- package/lib/container/RemoteToExternalDependency.js +3 -0
- package/lib/css/CssParser.js +168 -73
- package/lib/debug/ProfilingPlugin.js +11 -0
- package/lib/dependencies/AMDDefineDependency.js +12 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -2
- package/lib/dependencies/AMDPlugin.js +7 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +5 -0
- package/lib/dependencies/AMDRequireContextDependency.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -2
- package/lib/dependencies/AMDRequireDependency.js +8 -1
- package/lib/dependencies/AMDRequireItemDependency.js +6 -0
- package/lib/dependencies/CachedConstDependency.js +6 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +11 -0
- package/lib/dependencies/CommonJsExportsDependency.js +8 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +2 -2
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -1
- package/lib/dependencies/CommonJsPlugin.js +28 -12
- package/lib/dependencies/CommonJsRequireContextDependency.js +8 -0
- package/lib/dependencies/CommonJsRequireDependency.js +7 -0
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
- package/lib/dependencies/ConstDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CreateScriptUrlDependency.js +2 -1
- package/lib/dependencies/CriticalDependencyWarning.js +3 -0
- package/lib/dependencies/CssImportDependency.js +2 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +12 -2
- package/lib/dependencies/DelegatedSourceDependency.js +3 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +2 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +16 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
- package/lib/dependencies/HarmonyExportHeaderDependency.js +5 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyExports.js +3 -1
- package/lib/dependencies/HarmonyImportDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +18 -5
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +6 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +86 -6
- package/lib/dependencies/HarmonyModulesPlugin.js +12 -0
- package/lib/dependencies/ImportContextDependency.js +6 -0
- package/lib/dependencies/ImportDependency.js +2 -1
- package/lib/dependencies/ImportEagerDependency.js +2 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +32 -13
- package/lib/dependencies/ImportMetaContextPlugin.js +7 -0
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
- package/lib/dependencies/ImportParserPlugin.js +5 -0
- package/lib/dependencies/ImportPlugin.js +7 -0
- package/lib/dependencies/ImportWeakDependency.js +2 -1
- package/lib/dependencies/LocalModule.js +16 -0
- package/lib/dependencies/LocalModuleDependency.js +7 -0
- package/lib/dependencies/LocalModulesHelpers.js +18 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
- package/lib/dependencies/PrefetchDependency.js +3 -0
- package/lib/dependencies/ProvidedDependency.js +2 -1
- package/lib/dependencies/PureExpressionDependency.js +2 -1
- package/lib/dependencies/RequireContextDependency.js +6 -0
- package/lib/dependencies/RequireContextPlugin.js +7 -0
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +4 -0
- package/lib/dependencies/RequireEnsureDependency.js +8 -2
- package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +14 -0
- package/lib/dependencies/RequireHeaderDependency.js +5 -1
- package/lib/dependencies/RequireIncludeDependency.js +5 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireIncludePlugin.js +14 -0
- package/lib/dependencies/RequireResolveContextDependency.js +8 -0
- package/lib/dependencies/RequireResolveDependency.js +6 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +4 -0
- package/lib/dependencies/SystemPlugin.js +10 -1
- package/lib/dependencies/URLDependency.js +3 -2
- package/lib/dependencies/URLPlugin.js +7 -5
- package/lib/dependencies/UnsupportedDependency.js +5 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +6 -0
- package/lib/dependencies/WebpackIsIncludedDependency.js +5 -0
- package/lib/dependencies/WorkerDependency.js +2 -1
- package/lib/dependencies/WorkerPlugin.js +30 -3
- package/lib/dependencies/getFunctionExpression.js +7 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +15 -7
- package/lib/esm/ModuleChunkLoadingPlugin.js +9 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +14 -9
- package/lib/hmr/LazyCompilationPlugin.js +1 -1
- package/lib/ids/ChunkModuleIdRangePlugin.js +11 -0
- package/lib/ids/DeterministicChunkIdsPlugin.js +11 -2
- package/lib/ids/DeterministicModuleIdsPlugin.js +11 -7
- package/lib/ids/HashedModuleIdsPlugin.js +8 -1
- package/lib/ids/IdHelpers.js +6 -0
- package/lib/ids/NamedChunkIdsPlugin.js +13 -1
- package/lib/ids/NamedModuleIdsPlugin.js +14 -3
- package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -2
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +3 -3
- package/lib/javascript/BasicEvaluatedExpression.js +11 -1
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +4 -0
- package/lib/javascript/JavascriptModulesPlugin.js +36 -31
- package/lib/javascript/JavascriptParser.js +586 -192
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonGenerator.js +7 -5
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +4 -0
- package/lib/library/AssignLibraryPlugin.js +6 -4
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +6 -3
- package/lib/library/SystemLibraryPlugin.js +1 -0
- package/lib/library/UmdLibraryPlugin.js +4 -0
- package/lib/node/CommonJsChunkLoadingPlugin.js +17 -2
- package/lib/node/NodeTemplatePlugin.js +10 -2
- package/lib/node/NodeWatchFileSystem.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +6 -3
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +19 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +6 -3
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +5 -1
- package/lib/runtime/BaseUriRuntimeModule.js +5 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +3 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +35 -16
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +5 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +15 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +4 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +8 -5
- package/lib/serialization/ArraySerializer.js +22 -6
- package/lib/serialization/BinaryMiddleware.js +21 -0
- package/lib/serialization/DateObjectSerializer.js +15 -4
- package/lib/serialization/ErrorObjectSerializer.js +20 -8
- package/lib/serialization/FileMiddleware.js +17 -0
- package/lib/serialization/MapObjectSerializer.js +24 -8
- package/lib/serialization/NullPrototypeObjectSerializer.js +25 -8
- package/lib/serialization/ObjectMiddleware.js +23 -0
- package/lib/serialization/PlainObjectSerializer.js +23 -12
- package/lib/serialization/RegExpObjectSerializer.js +16 -5
- package/lib/serialization/SetObjectSerializer.js +21 -6
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -1
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/makeSerializable.js +7 -0
- package/lib/util/serialization.js +10 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +9 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +13 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +19 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +3 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +25 -1
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +14 -5
- package/lib/wasm-sync/WebAssemblyGenerator.js +18 -5
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +12 -1
- package/lib/wasm-sync/WebAssemblyParser.js +9 -2
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +9 -0
- package/lib/web/FetchCompileWasmPlugin.js +19 -2
- package/lib/web/JsonpChunkLoadingPlugin.js +9 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +9 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -2
- package/package.json +3 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +12 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
- package/types.d.ts +655 -290
package/README.md
CHANGED
@@ -32,8 +32,8 @@
|
|
32
32
|
<a href="https://github.com/webpack/webpack/graphs/contributors">
|
33
33
|
<img src="https://img.shields.io/github/contributors/webpack/webpack.svg">
|
34
34
|
</a>
|
35
|
-
<a href="https://
|
36
|
-
<img src="https://
|
35
|
+
<a href="https://github.com/webpack/webpack/discussions">
|
36
|
+
<img src="https://img.shields.io/github/discussions/webpack/webpack">
|
37
37
|
</a>
|
38
38
|
<a href="https://twitter.com/Webpack">
|
39
39
|
<img src="https://img.shields.io/twitter/follow/Webpack?style=social">
|
@@ -39,14 +39,14 @@ class AsyncDependenciesBlock extends DependenciesBlock {
|
|
39
39
|
}
|
40
40
|
|
41
41
|
/**
|
42
|
-
* @returns {string} The name of the chunk
|
42
|
+
* @returns {string | undefined} The name of the chunk
|
43
43
|
*/
|
44
44
|
get chunkName() {
|
45
45
|
return this.groupOptions.name;
|
46
46
|
}
|
47
47
|
|
48
48
|
/**
|
49
|
-
* @param {string} value The new chunk name
|
49
|
+
* @param {string | undefined} value The new chunk name
|
50
50
|
* @returns {void}
|
51
51
|
*/
|
52
52
|
set chunkName(value) {
|
package/lib/BannerPlugin.js
CHANGED
package/lib/CacheFacade.js
CHANGED
@@ -55,6 +55,10 @@ class MultiItemCache {
|
|
55
55
|
* @returns {Promise<T>} promise with the data
|
56
56
|
*/
|
57
57
|
getPromise() {
|
58
|
+
/**
|
59
|
+
* @param {number} i index
|
60
|
+
* @returns {Promise<T>} promise with the data
|
61
|
+
*/
|
58
62
|
const next = i => {
|
59
63
|
return this._items[i].getPromise().then(result => {
|
60
64
|
if (result !== undefined) return result;
|
package/lib/ChunkGroup.js
CHANGED
@@ -353,7 +353,7 @@ class ChunkGroup {
|
|
353
353
|
}
|
354
354
|
|
355
355
|
/**
|
356
|
-
* @returns {Array} an array containing the blocks
|
356
|
+
* @returns {Array<AsyncDependenciesBlock>} an array containing the blocks
|
357
357
|
*/
|
358
358
|
getBlocks() {
|
359
359
|
return this._blocks.getFromCache(getArray);
|
@@ -363,6 +363,10 @@ class ChunkGroup {
|
|
363
363
|
return this._blocks.size;
|
364
364
|
}
|
365
365
|
|
366
|
+
/**
|
367
|
+
* @param {AsyncDependenciesBlock} block block
|
368
|
+
* @returns {boolean} true, if block exists
|
369
|
+
*/
|
366
370
|
hasBlock(block) {
|
367
371
|
return this._blocks.has(block);
|
368
372
|
}
|
package/lib/CleanPlugin.js
CHANGED
@@ -78,7 +78,8 @@ const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
|
|
78
78
|
directories,
|
79
79
|
10,
|
80
80
|
(directory, callback) => {
|
81
|
-
|
81
|
+
/** @type {NonNullable<OutputFileSystem["readdir"]>} */
|
82
|
+
(fs.readdir)(join(fs, outputPath, directory), (err, entries) => {
|
82
83
|
if (err) {
|
83
84
|
if (err.code === "ENOENT") return callback();
|
84
85
|
if (err.code === "ENOTDIR") {
|
@@ -128,7 +129,8 @@ const getDiffToOldAssets = (currentAssets, oldAssets) => {
|
|
128
129
|
*/
|
129
130
|
const doStat = (fs, filename, callback) => {
|
130
131
|
if ("lstat" in fs) {
|
131
|
-
|
132
|
+
/** @type {NonNullable<OutputFileSystem["lstat"]>} */
|
133
|
+
(fs.lstat)(filename, callback);
|
132
134
|
} else {
|
133
135
|
fs.stat(filename, callback);
|
134
136
|
}
|
@@ -145,6 +147,9 @@ const doStat = (fs, filename, callback) => {
|
|
145
147
|
* @returns {void}
|
146
148
|
*/
|
147
149
|
const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
150
|
+
/**
|
151
|
+
* @param {string} msg message
|
152
|
+
*/
|
148
153
|
const log = msg => {
|
149
154
|
if (dry) {
|
150
155
|
logger.info(msg);
|
@@ -165,6 +170,10 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
165
170
|
jobs,
|
166
171
|
10,
|
167
172
|
({ type, filename, parent }, push, callback) => {
|
173
|
+
/**
|
174
|
+
* @param {Error & { code?: string }} err error
|
175
|
+
* @returns {void}
|
176
|
+
*/
|
168
177
|
const handleError = err => {
|
169
178
|
if (err.code === "ENOENT") {
|
170
179
|
log(`${filename} was removed during cleaning by something else`);
|
@@ -195,7 +204,9 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
195
204
|
});
|
196
205
|
return callback();
|
197
206
|
}
|
198
|
-
|
207
|
+
|
208
|
+
/** @type {NonNullable<OutputFileSystem["readdir"]>} */
|
209
|
+
(fs.readdir)(path, (err, entries) => {
|
199
210
|
if (err) return handleError(err);
|
200
211
|
/** @type {Job} */
|
201
212
|
const deleteJob = {
|
@@ -317,9 +328,17 @@ class CleanPlugin {
|
|
317
328
|
typeof keep === "function"
|
318
329
|
? keep
|
319
330
|
: typeof keep === "string"
|
320
|
-
?
|
331
|
+
? /**
|
332
|
+
* @param {string} path path
|
333
|
+
* @returns {boolean} true, if the path should be kept
|
334
|
+
*/
|
335
|
+
path => path.startsWith(keep)
|
321
336
|
: typeof keep === "object" && keep.test
|
322
|
-
?
|
337
|
+
? /**
|
338
|
+
* @param {string} path path
|
339
|
+
* @returns {boolean} true, if the path should be kept
|
340
|
+
*/
|
341
|
+
path => keep.test(path)
|
323
342
|
: () => false;
|
324
343
|
|
325
344
|
// We assume that no external modification happens while the compiler is active
|
@@ -371,6 +390,10 @@ class CleanPlugin {
|
|
371
390
|
|
372
391
|
const outputPath = compilation.getPath(compiler.outputPath, {});
|
373
392
|
|
393
|
+
/**
|
394
|
+
* @param {string} path path
|
395
|
+
* @returns {boolean} true, if needs to be kept
|
396
|
+
*/
|
374
397
|
const isKept = path => {
|
375
398
|
const result = hooks.keep.call(path);
|
376
399
|
if (result !== undefined) return result;
|
@@ -378,7 +401,7 @@ class CleanPlugin {
|
|
378
401
|
};
|
379
402
|
|
380
403
|
/**
|
381
|
-
* @param {Error=} err err
|
404
|
+
* @param {(Error | null)=} err err
|
382
405
|
* @param {Set<string>=} diff diff
|
383
406
|
*/
|
384
407
|
const diffCallback = (err, diff) => {
|
@@ -392,7 +415,7 @@ class CleanPlugin {
|
|
392
415
|
outputPath,
|
393
416
|
dry,
|
394
417
|
logger,
|
395
|
-
diff,
|
418
|
+
/** @type {Set<string>} */ (diff),
|
396
419
|
isKept,
|
397
420
|
(err, keptAssets) => {
|
398
421
|
if (err) {
|
@@ -10,6 +10,7 @@ const {
|
|
10
10
|
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
11
11
|
JAVASCRIPT_MODULE_TYPE_ESM
|
12
12
|
} = require("./ModuleTypeConstants");
|
13
|
+
const RuntimeGlobals = require("./RuntimeGlobals");
|
13
14
|
const ConstDependency = require("./dependencies/ConstDependency");
|
14
15
|
|
15
16
|
/** @typedef {import("./Compiler")} Compiler */
|
@@ -79,7 +80,7 @@ class CompatibilityPlugin {
|
|
79
80
|
if (
|
80
81
|
statement.type === "FunctionDeclaration" &&
|
81
82
|
statement.id &&
|
82
|
-
statement.id.name ===
|
83
|
+
statement.id.name === RuntimeGlobals.require
|
83
84
|
) {
|
84
85
|
const newName = `__nested_webpack_require_${statement.range[0]}__`;
|
85
86
|
parser.tagVariable(
|
@@ -98,7 +99,7 @@ class CompatibilityPlugin {
|
|
98
99
|
}
|
99
100
|
});
|
100
101
|
parser.hooks.pattern
|
101
|
-
.for(
|
102
|
+
.for(RuntimeGlobals.require)
|
102
103
|
.tap(PLUGIN_NAME, pattern => {
|
103
104
|
const newName = `__nested_webpack_require_${pattern.range[0]}__`;
|
104
105
|
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
|
@@ -112,7 +113,7 @@ class CompatibilityPlugin {
|
|
112
113
|
return true;
|
113
114
|
});
|
114
115
|
parser.hooks.pattern
|
115
|
-
.for(
|
116
|
+
.for(RuntimeGlobals.exports)
|
116
117
|
.tap(PLUGIN_NAME, pattern => {
|
117
118
|
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
|
118
119
|
name: "__nested_webpack_exports__",
|
package/lib/Compilation.js
CHANGED
@@ -681,7 +681,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
681
681
|
optimizeChunkModules: new AsyncSeriesBailHook(["chunks", "modules"]),
|
682
682
|
/** @type {SyncHook<[Iterable<Chunk>, Iterable<Module>]>} */
|
683
683
|
afterOptimizeChunkModules: new SyncHook(["chunks", "modules"]),
|
684
|
-
/** @type {SyncBailHook<[], boolean>} */
|
684
|
+
/** @type {SyncBailHook<[], boolean | undefined>} */
|
685
685
|
shouldRecord: new SyncBailHook([]),
|
686
686
|
|
687
687
|
/** @type {SyncHook<[Chunk, Set<string>, RuntimeRequirementsContext]>} */
|
@@ -5024,13 +5024,13 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5024
5024
|
};
|
5025
5025
|
const interceptModuleExecution = (__webpack_require__[
|
5026
5026
|
RuntimeGlobals.interceptModuleExecution.replace(
|
5027
|
-
|
5027
|
+
`${RuntimeGlobals.require}.`,
|
5028
5028
|
""
|
5029
5029
|
)
|
5030
5030
|
] = []);
|
5031
5031
|
const moduleCache = (__webpack_require__[
|
5032
5032
|
RuntimeGlobals.moduleCache.replace(
|
5033
|
-
|
5033
|
+
`${RuntimeGlobals.require}.`,
|
5034
5034
|
""
|
5035
5035
|
)
|
5036
5036
|
] = {});
|
package/lib/Compiler.js
CHANGED
@@ -126,7 +126,7 @@ class Compiler {
|
|
126
126
|
/** @type {SyncHook<[]>} */
|
127
127
|
initialize: new SyncHook([]),
|
128
128
|
|
129
|
-
/** @type {SyncBailHook<[Compilation], boolean>} */
|
129
|
+
/** @type {SyncBailHook<[Compilation], boolean | undefined>} */
|
130
130
|
shouldEmit: new SyncBailHook(["compilation"]),
|
131
131
|
/** @type {AsyncSeriesHook<[Stats]>} */
|
132
132
|
done: new AsyncSeriesHook(["stats"]),
|
package/lib/ContextModule.js
CHANGED
@@ -640,7 +640,7 @@ class ContextModule extends Module {
|
|
640
640
|
|
641
641
|
getReturn(type, asyncModule) {
|
642
642
|
if (type === 9) {
|
643
|
-
return
|
643
|
+
return `${RuntimeGlobals.require}(id)`;
|
644
644
|
}
|
645
645
|
return `${RuntimeGlobals.createFakeNamespaceObject}(id, ${type}${
|
646
646
|
asyncModule ? " | 16" : ""
|
@@ -799,7 +799,7 @@ module.exports = webpackAsyncContext;`;
|
|
799
799
|
? `${arrow ? "id =>" : "function(id)"} {
|
800
800
|
${this.getReturnModuleObjectSource(fakeMap)}
|
801
801
|
}`
|
802
|
-
:
|
802
|
+
: RuntimeGlobals.require;
|
803
803
|
return `var map = ${JSON.stringify(map, null, "\t")};
|
804
804
|
${this.getFakeMapInitStatement(fakeMap)}
|
805
805
|
|
@@ -850,7 +850,7 @@ module.exports = webpackAsyncContext;`;
|
|
850
850
|
? `${arrow ? "id =>" : "function(id)"} {
|
851
851
|
${this.getReturnModuleObjectSource(fakeMap, true)};
|
852
852
|
}`
|
853
|
-
:
|
853
|
+
: RuntimeGlobals.require;
|
854
854
|
|
855
855
|
return `var map = ${JSON.stringify(map, null, "\t")};
|
856
856
|
${this.getFakeMapInitStatement(fakeMap)}
|
@@ -80,7 +80,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
80
80
|
|
81
81
|
/**
|
82
82
|
* @param {ModuleFactoryCreateData} data data object
|
83
|
-
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
83
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
84
84
|
* @returns {void}
|
85
85
|
*/
|
86
86
|
create(data, callback) {
|
package/lib/DefinePlugin.js
CHANGED
@@ -463,7 +463,7 @@ class DefinePlugin {
|
|
463
463
|
});
|
464
464
|
parser.hooks.expression.for(key).tap(PLUGIN_NAME, expr => {
|
465
465
|
addValueDependency(originalKey);
|
466
|
-
|
466
|
+
let strCode = toCode(
|
467
467
|
code,
|
468
468
|
parser,
|
469
469
|
compilation.valueCacheVersions,
|
@@ -473,6 +473,11 @@ class DefinePlugin {
|
|
473
473
|
!parser.isAsiPosition(expr.range[0]),
|
474
474
|
parser.destructuringAssignmentPropertiesFor(expr)
|
475
475
|
);
|
476
|
+
|
477
|
+
if (parser.scope.inShorthand) {
|
478
|
+
strCode = parser.scope.inShorthand + ":" + strCode;
|
479
|
+
}
|
480
|
+
|
476
481
|
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
|
477
482
|
return toConstantDependency(parser, strCode, [
|
478
483
|
RuntimeGlobals.require
|
@@ -564,7 +569,7 @@ class DefinePlugin {
|
|
564
569
|
);
|
565
570
|
parser.hooks.expression.for(key).tap(PLUGIN_NAME, expr => {
|
566
571
|
addValueDependency(key);
|
567
|
-
|
572
|
+
let strCode = stringifyObj(
|
568
573
|
obj,
|
569
574
|
parser,
|
570
575
|
compilation.valueCacheVersions,
|
@@ -575,6 +580,10 @@ class DefinePlugin {
|
|
575
580
|
parser.destructuringAssignmentPropertiesFor(expr)
|
576
581
|
);
|
577
582
|
|
583
|
+
if (parser.scope.inShorthand) {
|
584
|
+
strCode = parser.scope.inShorthand + ":" + strCode;
|
585
|
+
}
|
586
|
+
|
578
587
|
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
|
579
588
|
return toConstantDependency(parser, strCode, [
|
580
589
|
RuntimeGlobals.require
|
package/lib/DllEntryPlugin.js
CHANGED
@@ -10,6 +10,11 @@ const DllEntryDependency = require("./dependencies/DllEntryDependency");
|
|
10
10
|
const EntryDependency = require("./dependencies/EntryDependency");
|
11
11
|
|
12
12
|
class DllEntryPlugin {
|
13
|
+
/**
|
14
|
+
* @param {string} context context
|
15
|
+
* @param {string[]} entries entry names
|
16
|
+
* @param {TODO} options options
|
17
|
+
*/
|
13
18
|
constructor(context, entries, options) {
|
14
19
|
this.context = context;
|
15
20
|
this.entries = entries;
|
package/lib/DllModule.js
CHANGED
package/lib/DllModuleFactory.js
CHANGED
@@ -19,7 +19,7 @@ class DllModuleFactory extends ModuleFactory {
|
|
19
19
|
}
|
20
20
|
/**
|
21
21
|
* @param {ModuleFactoryCreateData} data data object
|
22
|
-
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
22
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
23
23
|
* @returns {void}
|
24
24
|
*/
|
25
25
|
create(data, callback) {
|
@@ -48,7 +48,9 @@ class EvalSourceMapDevToolPlugin {
|
|
48
48
|
options = inputOptions;
|
49
49
|
}
|
50
50
|
this.sourceMapComment =
|
51
|
-
options.append
|
51
|
+
options.append && typeof options.append !== "function"
|
52
|
+
? options.append
|
53
|
+
: "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
|
52
54
|
this.moduleFilenameTemplate =
|
53
55
|
options.moduleFilenameTemplate ||
|
54
56
|
"webpack://[namespace]/[resource-path]?[hash]";
|
package/lib/HookWebpackError.js
CHANGED
@@ -26,7 +26,7 @@ class IgnoreErrorModuleFactory extends ModuleFactory {
|
|
26
26
|
|
27
27
|
/**
|
28
28
|
* @param {ModuleFactoryCreateData} data data object
|
29
|
-
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
29
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
30
30
|
* @returns {void}
|
31
31
|
*/
|
32
32
|
create(data, callback) {
|
package/lib/MainTemplate.js
CHANGED
@@ -306,8 +306,8 @@ class MainTemplate {
|
|
306
306
|
|
307
307
|
Object.defineProperty(MainTemplate.prototype, "requireFn", {
|
308
308
|
get: util.deprecate(
|
309
|
-
() =>
|
310
|
-
|
309
|
+
() => RuntimeGlobals.require,
|
310
|
+
`MainTemplate.requireFn is deprecated (use "${RuntimeGlobals.require}")`,
|
311
311
|
"DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE_FN"
|
312
312
|
)
|
313
313
|
});
|
package/lib/Module.js
CHANGED
@@ -131,13 +131,13 @@ const deprecatedNeedRebuild = util.deprecate(
|
|
131
131
|
class Module extends DependenciesBlock {
|
132
132
|
/**
|
133
133
|
* @param {ModuleTypes | ""} type the module type, when deserializing the type is not known and is an empty string
|
134
|
-
* @param {string=} context an optional context
|
135
|
-
* @param {string=} layer an optional layer in which the module is
|
134
|
+
* @param {(string | null)=} context an optional context
|
135
|
+
* @param {(string | null)=} layer an optional layer in which the module is
|
136
136
|
*/
|
137
137
|
constructor(type, context = null, layer = null) {
|
138
138
|
super();
|
139
139
|
|
140
|
-
/** @type {ModuleTypes
|
140
|
+
/** @type {ModuleTypes} */
|
141
141
|
this.type = type;
|
142
142
|
/** @type {string | null} */
|
143
143
|
this.context = context;
|
@@ -151,7 +151,7 @@ class Module extends DependenciesBlock {
|
|
151
151
|
this.debugId = debugId++;
|
152
152
|
|
153
153
|
// Info from Factory
|
154
|
-
/** @type {ResolveOptions} */
|
154
|
+
/** @type {ResolveOptions | undefined} */
|
155
155
|
this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
|
156
156
|
/** @type {object | undefined} */
|
157
157
|
this.factoryMeta = undefined;
|
@@ -167,9 +167,9 @@ class Module extends DependenciesBlock {
|
|
167
167
|
this._warnings = undefined;
|
168
168
|
/** @type {WebpackError[] | undefined} */
|
169
169
|
this._errors = undefined;
|
170
|
-
/** @type {BuildMeta} */
|
170
|
+
/** @type {BuildMeta | undefined} */
|
171
171
|
this.buildMeta = undefined;
|
172
|
-
/** @type {Record<string, any>} */
|
172
|
+
/** @type {Record<string, any> | undefined} */
|
173
173
|
this.buildInfo = undefined;
|
174
174
|
/** @type {Dependency[] | undefined} */
|
175
175
|
this.presentationalDependencies = undefined;
|
@@ -331,6 +331,10 @@ class Module extends DependenciesBlock {
|
|
331
331
|
);
|
332
332
|
}
|
333
333
|
|
334
|
+
/**
|
335
|
+
* @param {Chunk} chunk the chunk
|
336
|
+
* @returns {boolean} true, when the module was added
|
337
|
+
*/
|
334
338
|
addChunk(chunk) {
|
335
339
|
const chunkGraph = ChunkGraph.getChunkGraphForModule(
|
336
340
|
this,
|
@@ -342,6 +346,10 @@ class Module extends DependenciesBlock {
|
|
342
346
|
return true;
|
343
347
|
}
|
344
348
|
|
349
|
+
/**
|
350
|
+
* @param {Chunk} chunk the chunk
|
351
|
+
* @returns {void}
|
352
|
+
*/
|
345
353
|
removeChunk(chunk) {
|
346
354
|
return ChunkGraph.getChunkGraphForModule(
|
347
355
|
this,
|
@@ -350,6 +358,10 @@ class Module extends DependenciesBlock {
|
|
350
358
|
).disconnectChunkAndModule(chunk, this);
|
351
359
|
}
|
352
360
|
|
361
|
+
/**
|
362
|
+
* @param {Chunk} chunk the chunk
|
363
|
+
* @returns {boolean} true, when the module is in the chunk
|
364
|
+
*/
|
353
365
|
isInChunk(chunk) {
|
354
366
|
return ChunkGraph.getChunkGraphForModule(
|
355
367
|
this,
|
@@ -435,7 +447,7 @@ class Module extends DependenciesBlock {
|
|
435
447
|
case "namespace":
|
436
448
|
return "namespace";
|
437
449
|
case "default":
|
438
|
-
switch (this.buildMeta.defaultObject) {
|
450
|
+
switch (/** @type {BuildMeta} */ (this.buildMeta).defaultObject) {
|
439
451
|
case "redirect":
|
440
452
|
return "default-with-named";
|
441
453
|
case "redirect-warn":
|
@@ -447,7 +459,7 @@ class Module extends DependenciesBlock {
|
|
447
459
|
if (strict) return "default-with-named";
|
448
460
|
// Try to figure out value of __esModule by following reexports
|
449
461
|
const handleDefault = () => {
|
450
|
-
switch (this.buildMeta.defaultObject) {
|
462
|
+
switch (/** @type {BuildMeta} */ (this.buildMeta).defaultObject) {
|
451
463
|
case "redirect":
|
452
464
|
case "redirect-warn":
|
453
465
|
return "default-with-named";
|
@@ -664,7 +676,7 @@ class Module extends DependenciesBlock {
|
|
664
676
|
] of moduleGraph.getIncomingConnectionsByOriginModule(this)) {
|
665
677
|
if (!connections.some(c => c.isTargetActive(chunk.runtime))) continue;
|
666
678
|
for (const originChunk of chunkGraph.getModuleChunksIterable(
|
667
|
-
fromModule
|
679
|
+
/** @type {Module} */ (fromModule)
|
668
680
|
)) {
|
669
681
|
// return true if module this is not reachable from originChunk when ignoring chunk
|
670
682
|
if (!this.isAccessibleInChunk(chunkGraph, originChunk, chunk))
|
package/lib/ModuleFactory.js
CHANGED
@@ -38,7 +38,7 @@ class ModuleFactory {
|
|
38
38
|
/**
|
39
39
|
* @abstract
|
40
40
|
* @param {ModuleFactoryCreateData} data data object
|
41
|
-
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
41
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
42
42
|
* @returns {void}
|
43
43
|
*/
|
44
44
|
create(data, callback) {
|
@@ -135,7 +135,8 @@ const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY = "lazy-compilation-proxy";
|
|
135
135
|
/** @typedef {"css" | "css/global" | "css/module"} CSSModuleTypes */
|
136
136
|
/** @typedef {"asset" | "asset/inline" | "asset/resource" | "asset/source" | "asset/raw-data-url"} AssetModuleTypes */
|
137
137
|
/** @typedef {"runtime" | "fallback-module" | "remote-module" | "provide-module" | "consume-shared-module" | "lazy-compilation-proxy"} WebpackModuleTypes */
|
138
|
-
/** @typedef {
|
138
|
+
/** @typedef {string} UnknownModuleTypes */
|
139
|
+
/** @typedef {JavaScriptModuleTypes | JSONModuleType | WebAssemblyModuleTypes | CSSModuleTypes | AssetModuleTypes | WebpackModuleTypes | UnknownModuleTypes} ModuleTypes */
|
139
140
|
|
140
141
|
exports.ASSET_MODULE_TYPE = ASSET_MODULE_TYPE;
|
141
142
|
exports.ASSET_MODULE_TYPE_RAW_DATA_URL = ASSET_MODULE_TYPE_RAW_DATA_URL;
|
@@ -753,7 +753,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
753
753
|
|
754
754
|
/**
|
755
755
|
* @param {ModuleFactoryCreateData} data data object
|
756
|
-
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
756
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
757
757
|
* @returns {void}
|
758
758
|
*/
|
759
759
|
create(data, callback) {
|
@@ -43,7 +43,9 @@ class NormalModuleReplacementPlugin {
|
|
43
43
|
});
|
44
44
|
nmf.hooks.afterResolve.tap("NormalModuleReplacementPlugin", result => {
|
45
45
|
const createData = result.createData;
|
46
|
-
if (
|
46
|
+
if (
|
47
|
+
resourceRegExp.test(/** @type {string} */ (createData.resource))
|
48
|
+
) {
|
47
49
|
if (typeof newResource === "function") {
|
48
50
|
newResource(result);
|
49
51
|
} else {
|
@@ -56,7 +58,7 @@ class NormalModuleReplacementPlugin {
|
|
56
58
|
} else {
|
57
59
|
createData.resource = join(
|
58
60
|
fs,
|
59
|
-
dirname(fs, createData.resource),
|
61
|
+
dirname(fs, /** @type {string} */ (createData.resource)),
|
60
62
|
newResource
|
61
63
|
);
|
62
64
|
}
|
package/lib/NullFactory.js
CHANGED
@@ -13,7 +13,7 @@ const ModuleFactory = require("./ModuleFactory");
|
|
13
13
|
class NullFactory extends ModuleFactory {
|
14
14
|
/**
|
15
15
|
* @param {ModuleFactoryCreateData} data data object
|
16
|
-
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
16
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
17
17
|
* @returns {void}
|
18
18
|
*/
|
19
19
|
create(data, callback) {
|
package/lib/PrefetchPlugin.js
CHANGED
@@ -10,6 +10,10 @@ const PrefetchDependency = require("./dependencies/PrefetchDependency");
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
|
12
12
|
class PrefetchPlugin {
|
13
|
+
/**
|
14
|
+
* @param {string} context context or request if context is not set
|
15
|
+
* @param {string} [request] request
|
16
|
+
*/
|
13
17
|
constructor(context, request) {
|
14
18
|
if (request) {
|
15
19
|
this.context = context;
|
package/lib/RecordIdsPlugin.js
CHANGED
@@ -69,7 +69,7 @@ class RecordIdsPlugin {
|
|
69
69
|
compilation.hooks.recordModules.tap(
|
70
70
|
"RecordIdsPlugin",
|
71
71
|
/**
|
72
|
-
* @param {Module
|
72
|
+
* @param {Iterable<Module>} modules the modules array
|
73
73
|
* @param {Records} records the records object
|
74
74
|
* @returns {void}
|
75
75
|
*/
|
@@ -92,7 +92,7 @@ class RecordIdsPlugin {
|
|
92
92
|
compilation.hooks.reviveModules.tap(
|
93
93
|
"RecordIdsPlugin",
|
94
94
|
/**
|
95
|
-
* @param {Module
|
95
|
+
* @param {Iterable<Module>} modules the modules array
|
96
96
|
* @param {Records} records the records object
|
97
97
|
* @returns {void}
|
98
98
|
*/
|
@@ -166,7 +166,7 @@ class RecordIdsPlugin {
|
|
166
166
|
compilation.hooks.recordChunks.tap(
|
167
167
|
"RecordIdsPlugin",
|
168
168
|
/**
|
169
|
-
* @param {Chunk
|
169
|
+
* @param {Iterable<Chunk>} chunks the chunks array
|
170
170
|
* @param {Records} records the records object
|
171
171
|
* @returns {void}
|
172
172
|
*/
|
@@ -192,7 +192,7 @@ class RecordIdsPlugin {
|
|
192
192
|
compilation.hooks.reviveChunks.tap(
|
193
193
|
"RecordIdsPlugin",
|
194
194
|
/**
|
195
|
-
* @param {Chunk
|
195
|
+
* @param {Iterable<Chunk>} chunks the chunks array
|
196
196
|
* @param {Records} records the records object
|
197
197
|
* @returns {void}
|
198
198
|
*/
|
package/lib/RuntimeModule.js
CHANGED
@@ -38,15 +38,15 @@ class RuntimeModule extends Module {
|
|
38
38
|
this.stage = stage;
|
39
39
|
this.buildMeta = {};
|
40
40
|
this.buildInfo = {};
|
41
|
-
/** @type {Compilation} */
|
41
|
+
/** @type {Compilation | undefined} */
|
42
42
|
this.compilation = undefined;
|
43
|
-
/** @type {Chunk} */
|
43
|
+
/** @type {Chunk | undefined} */
|
44
44
|
this.chunk = undefined;
|
45
|
-
/** @type {ChunkGraph} */
|
45
|
+
/** @type {ChunkGraph | undefined} */
|
46
46
|
this.chunkGraph = undefined;
|
47
47
|
this.fullHash = false;
|
48
48
|
this.dependentHash = false;
|
49
|
-
/** @type {string} */
|
49
|
+
/** @type {string | undefined} */
|
50
50
|
this._cachedGeneratedCode = undefined;
|
51
51
|
}
|
52
52
|
|
@@ -117,7 +117,7 @@ class RuntimeModule extends Module {
|
|
117
117
|
hash.update(this.getGeneratedCode());
|
118
118
|
}
|
119
119
|
} catch (err) {
|
120
|
-
hash.update(err.message);
|
120
|
+
hash.update(/** @type {Error} */ (err).message);
|
121
121
|
}
|
122
122
|
super.updateHash(hash, context);
|
123
123
|
}
|
package/lib/RuntimePlugin.js
CHANGED
@@ -99,6 +99,10 @@ class RuntimePlugin {
|
|
99
99
|
apply(compiler) {
|
100
100
|
compiler.hooks.compilation.tap("RuntimePlugin", compilation => {
|
101
101
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
102
|
+
/**
|
103
|
+
* @param {Chunk} chunk chunk
|
104
|
+
* @returns {boolean} true, when chunk loading is disabled for the chunk
|
105
|
+
*/
|
102
106
|
const isChunkLoadingDisabledForChunk = chunk => {
|
103
107
|
const options = chunk.getEntryOptions();
|
104
108
|
const chunkLoading =
|