webpack 5.36.0 → 5.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +5 -8
- package/bin/webpack.js +0 -0
- package/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +10 -5
- package/lib/ChunkGraph.js +58 -35
- package/lib/Compilation.js +116 -98
- package/lib/Compiler.js +31 -17
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ContextModule.js +3 -3
- package/lib/ContextReplacementPlugin.js +4 -3
- package/lib/DefinePlugin.js +16 -12
- package/lib/EntryPlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/FileSystemInfo.js +25 -31
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HotModuleReplacementPlugin.js +20 -30
- package/lib/InitFragment.js +21 -6
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -3
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraph.js +2 -2
- package/lib/ModuleGraphConnection.js +6 -2
- package/lib/ModuleInfoHeaderPlugin.js +2 -3
- package/lib/MultiCompiler.js +31 -27
- package/lib/NormalModule.js +38 -7
- package/lib/NormalModuleFactory.js +27 -23
- package/lib/RecordIdsPlugin.js +5 -4
- package/lib/ResolverFactory.js +10 -7
- package/lib/RuntimeGlobals.js +7 -0
- package/lib/RuntimePlugin.js +19 -1
- package/lib/SourceMapDevToolPlugin.js +14 -15
- package/lib/Template.js +4 -2
- package/lib/Watching.js +83 -46
- package/lib/WebpackOptionsApply.js +1 -0
- package/lib/asset/AssetGenerator.js +19 -23
- package/lib/buildChunkGraph.js +28 -23
- package/lib/cache/PackFileCacheStrategy.js +77 -13
- package/lib/config/defaults.js +24 -10
- package/lib/config/normalization.js +17 -7
- package/lib/debug/ProfilingPlugin.js +4 -3
- package/lib/dependencies/AMDRequireDependency.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -3
- package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -4
- package/lib/dependencies/CommonJsPlugin.js +8 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +10 -8
- package/lib/dependencies/CreateScriptUrlDependency.js +54 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +11 -13
- package/lib/dependencies/HarmonyExportInitFragment.js +47 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +2 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -11
- package/lib/dependencies/ImportDependency.js +3 -3
- package/lib/dependencies/ImportParserPlugin.js +2 -4
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +2 -3
- package/lib/dependencies/RequireEnsureDependency.js +3 -3
- package/lib/dependencies/WorkerDependency.js +6 -6
- package/lib/dependencies/WorkerPlugin.js +47 -20
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/ids/HashedModuleIdsPlugin.js +3 -3
- package/lib/ids/OccurrenceModuleIdsPlugin.js +2 -3
- package/lib/index.js +5 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -6
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -3
- package/lib/javascript/JavascriptGenerator.js +3 -1
- package/lib/javascript/JavascriptModulesPlugin.js +15 -23
- package/lib/javascript/JavascriptParser.js +10 -8
- package/lib/library/AssignLibraryPlugin.js +4 -2
- package/lib/node/NodeWatchFileSystem.js +19 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +5 -4
- package/lib/optimize/ConcatenatedModule.js +22 -27
- package/lib/optimize/FlagIncludedChunksPlugin.js +4 -6
- package/lib/optimize/InnerGraph.js +9 -11
- package/lib/optimize/InnerGraphPlugin.js +3 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +7 -10
- package/lib/optimize/RealContentHashPlugin.js +14 -16
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -5
- package/lib/optimize/SplitChunksPlugin.js +13 -15
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +61 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +9 -8
- package/lib/runtime/LoadScriptRuntimeModule.js +12 -5
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +38 -37
- package/lib/serialization/BinaryMiddleware.js +2 -3
- package/lib/serialization/FileMiddleware.js +3 -1
- package/lib/serialization/ObjectMiddleware.js +11 -7
- package/lib/stats/DefaultStatsFactoryPlugin.js +2 -3
- package/lib/stats/DefaultStatsPrinterPlugin.js +11 -9
- package/lib/stats/StatsFactory.js +2 -1
- package/lib/stats/StatsPrinter.js +3 -3
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/cleverMerge.js +3 -1
- package/lib/util/comparators.js +13 -13
- package/lib/util/fs.js +8 -8
- package/lib/util/identifier.js +2 -1
- package/lib/util/internalSerializables.js +2 -0
- package/lib/validateSchema.js +5 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +4 -4
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +5 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +89 -83
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyParser.js +6 -5
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -4
- package/lib/webpack.js +11 -7
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +13 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +14 -4
- package/package.json +9 -6
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +103 -60
- package/types.d.ts +463 -280
@@ -7,7 +7,8 @@
|
|
7
7
|
|
8
8
|
/** @typedef {import("./Module")} Module */
|
9
9
|
|
10
|
-
const MODULE_REFERENCE_REGEXP =
|
10
|
+
const MODULE_REFERENCE_REGEXP =
|
11
|
+
/^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_directImport)?(?:_asiSafe(\d))?__$/;
|
11
12
|
|
12
13
|
const DEFAULT_EXPORT = "__WEBPACK_DEFAULT_EXPORT__";
|
13
14
|
const NAMESPACE_OBJECT_EXPORT = "__WEBPACK_NAMESPACE_OBJECT__";
|
package/lib/ContextModule.js
CHANGED
@@ -1016,9 +1016,9 @@ module.exports = webpackEmptyAsyncContext;`;
|
|
1016
1016
|
this.getSource(this.getSourceString(this.options.mode, context))
|
1017
1017
|
);
|
1018
1018
|
const set = new Set();
|
1019
|
-
const allDeps = /** @type {ContextElementDependency[]} */ (
|
1020
|
-
this.blocks.map(b => b.dependencies[0])
|
1021
|
-
)
|
1019
|
+
const allDeps = /** @type {ContextElementDependency[]} */ (
|
1020
|
+
this.dependencies.concat(this.blocks.map(b => b.dependencies[0]))
|
1021
|
+
);
|
1022
1022
|
set.add(RuntimeGlobals.module);
|
1023
1023
|
set.add(RuntimeGlobals.hasOwnProperty);
|
1024
1024
|
if (allDeps.length > 0) {
|
@@ -104,9 +104,10 @@ class ContextReplacementPlugin {
|
|
104
104
|
result.regExp = newContentRegExp;
|
105
105
|
}
|
106
106
|
if (typeof newContentCreateContextMap === "function") {
|
107
|
-
result.resolveDependencies =
|
108
|
-
|
109
|
-
|
107
|
+
result.resolveDependencies =
|
108
|
+
createResolveDependenciesFromContextMap(
|
109
|
+
newContentCreateContextMap
|
110
|
+
);
|
110
111
|
}
|
111
112
|
if (typeof newContentCallback === "function") {
|
112
113
|
const origResource = result.resource;
|
package/lib/DefinePlugin.js
CHANGED
@@ -89,9 +89,9 @@ class RuntimeValue {
|
|
89
89
|
module: parser.state.module,
|
90
90
|
key,
|
91
91
|
get version() {
|
92
|
-
return /** @type {string} */ (
|
93
|
-
VALUE_DEP_PREFIX + key
|
94
|
-
)
|
92
|
+
return /** @type {string} */ (
|
93
|
+
valueCacheVersions.get(VALUE_DEP_PREFIX + key)
|
94
|
+
);
|
95
95
|
}
|
96
96
|
});
|
97
97
|
}
|
@@ -286,11 +286,13 @@ class DefinePlugin {
|
|
286
286
|
);
|
287
287
|
const { runtimeTemplate } = compilation;
|
288
288
|
|
289
|
-
const mainValue = /** @type {Set<string>} */ (
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
289
|
+
const mainValue = /** @type {Set<string>} */ (
|
290
|
+
provide(
|
291
|
+
compilation.valueCacheVersions,
|
292
|
+
VALUE_DEP_MAIN,
|
293
|
+
() => new Set()
|
294
|
+
)
|
295
|
+
);
|
294
296
|
|
295
297
|
/**
|
296
298
|
* Handler
|
@@ -313,10 +315,12 @@ class DefinePlugin {
|
|
313
315
|
);
|
314
316
|
};
|
315
317
|
|
316
|
-
const withValueDependency =
|
317
|
-
|
318
|
-
|
319
|
-
|
318
|
+
const withValueDependency =
|
319
|
+
(key, fn) =>
|
320
|
+
(...args) => {
|
321
|
+
addValueDependency(key);
|
322
|
+
return fn(...args);
|
323
|
+
};
|
320
324
|
|
321
325
|
/**
|
322
326
|
* Walk definitions
|
package/lib/EntryPlugin.js
CHANGED
@@ -17,7 +17,7 @@ class EntryPlugin {
|
|
17
17
|
*
|
18
18
|
* @param {string} context context path
|
19
19
|
* @param {string} entry entry path
|
20
|
-
* @param {EntryOptions | string} options entry options (passing a string is deprecated)
|
20
|
+
* @param {EntryOptions | string=} options entry options (passing a string is deprecated)
|
21
21
|
*/
|
22
22
|
constructor(context, entry, options) {
|
23
23
|
this.context = context;
|
@@ -91,7 +91,9 @@ class EvalSourceMapDevToolPlugin {
|
|
91
91
|
} else if (m instanceof ConcatenatedModule) {
|
92
92
|
const concatModule = /** @type {ConcatenatedModule} */ (m);
|
93
93
|
if (concatModule.rootModule instanceof NormalModule) {
|
94
|
-
const module = /** @type {NormalModule} */ (
|
94
|
+
const module = /** @type {NormalModule} */ (
|
95
|
+
concatModule.rootModule
|
96
|
+
);
|
95
97
|
if (!matchModule(module.resource)) {
|
96
98
|
return result(source);
|
97
99
|
}
|
package/lib/FileSystemInfo.js
CHANGED
@@ -1160,12 +1160,8 @@ class FileSystemInfo {
|
|
1160
1160
|
* @returns {void}
|
1161
1161
|
*/
|
1162
1162
|
resolveBuildDependencies(context, deps, callback) {
|
1163
|
-
const {
|
1164
|
-
|
1165
|
-
resolveEsm,
|
1166
|
-
resolveCjs,
|
1167
|
-
resolveCjsAsChild
|
1168
|
-
} = this._createBuildDependenciesResolvers();
|
1163
|
+
const { resolveContext, resolveEsm, resolveCjs, resolveCjsAsChild } =
|
1164
|
+
this._createBuildDependenciesResolvers();
|
1169
1165
|
|
1170
1166
|
/** @type {Set<string>} */
|
1171
1167
|
const files = new Set();
|
@@ -1472,7 +1468,7 @@ class FileSystemInfo {
|
|
1472
1468
|
}
|
1473
1469
|
} else if (supportsEsm && /\.m?js$/.test(path)) {
|
1474
1470
|
if (!this._warnAboutExperimentalEsmTracking) {
|
1475
|
-
this.logger.
|
1471
|
+
this.logger.log(
|
1476
1472
|
"Node.js doesn't offer a (nice) way to introspect the ESM dependency graph yet.\n" +
|
1477
1473
|
"Until a full solution is available webpack uses an experimental ESM tracking based on parsing.\n" +
|
1478
1474
|
"As best effort webpack parses the ESM files to guess dependencies. But this can lead to expensive and incorrect tracking."
|
@@ -1547,9 +1543,8 @@ class FileSystemInfo {
|
|
1547
1543
|
break;
|
1548
1544
|
}
|
1549
1545
|
case RBDT_DIRECTORY_DEPENDENCIES: {
|
1550
|
-
const match =
|
1551
|
-
path
|
1552
|
-
);
|
1546
|
+
const match =
|
1547
|
+
/(^.+[\\/]node_modules[\\/](?:@[^\\/]+[\\/])?[^\\/]+)/.exec(path);
|
1553
1548
|
const packagePath = match ? match[1] : path;
|
1554
1549
|
const packageJson = join(this.fs, packagePath, "package.json");
|
1555
1550
|
this.fs.readFile(packageJson, (err, content) => {
|
@@ -1637,12 +1632,8 @@ class FileSystemInfo {
|
|
1637
1632
|
* @returns {void}
|
1638
1633
|
*/
|
1639
1634
|
checkResolveResultsValid(resolveResults, callback) {
|
1640
|
-
const {
|
1641
|
-
|
1642
|
-
resolveCjsAsChild,
|
1643
|
-
resolveEsm,
|
1644
|
-
resolveContext
|
1645
|
-
} = this._createBuildDependenciesResolvers();
|
1635
|
+
const { resolveCjs, resolveCjsAsChild, resolveEsm, resolveContext } =
|
1636
|
+
this._createBuildDependenciesResolvers();
|
1646
1637
|
asyncLib.eachLimit(
|
1647
1638
|
resolveResults,
|
1648
1639
|
20,
|
@@ -1844,11 +1835,12 @@ class FileSystemInfo {
|
|
1844
1835
|
unsharedManagedFiles
|
1845
1836
|
);
|
1846
1837
|
}
|
1847
|
-
const unsharedManagedContexts =
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1838
|
+
const unsharedManagedContexts =
|
1839
|
+
this._managedContextsOptimization.optimize(
|
1840
|
+
managedContexts,
|
1841
|
+
undefined,
|
1842
|
+
children
|
1843
|
+
);
|
1852
1844
|
if (managedContexts.size !== 0) {
|
1853
1845
|
snapshot.setManagedContexts(managedContexts);
|
1854
1846
|
this._managedContextsOptimization.storeUnsharedSnapshot(
|
@@ -1856,11 +1848,12 @@ class FileSystemInfo {
|
|
1856
1848
|
unsharedManagedContexts
|
1857
1849
|
);
|
1858
1850
|
}
|
1859
|
-
const unsharedManagedMissing =
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1851
|
+
const unsharedManagedMissing =
|
1852
|
+
this._managedMissingOptimization.optimize(
|
1853
|
+
managedMissing,
|
1854
|
+
undefined,
|
1855
|
+
children
|
1856
|
+
);
|
1864
1857
|
if (managedMissing.size !== 0) {
|
1865
1858
|
snapshot.setManagedMissing(managedMissing);
|
1866
1859
|
this._managedMissingOptimization.storeUnsharedSnapshot(
|
@@ -2064,11 +2057,12 @@ class FileSystemInfo {
|
|
2064
2057
|
}
|
2065
2058
|
break;
|
2066
2059
|
case 1:
|
2067
|
-
unsharedContextTimestamps =
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2060
|
+
unsharedContextTimestamps =
|
2061
|
+
this._contextTimestampsOptimization.optimize(
|
2062
|
+
capturedDirectories,
|
2063
|
+
startTime,
|
2064
|
+
children
|
2065
|
+
);
|
2072
2066
|
for (const path of capturedDirectories) {
|
2073
2067
|
const cache = this._contextTimestamps.get(path);
|
2074
2068
|
if (cache !== undefined) {
|
@@ -225,7 +225,8 @@ class FlagDependencyExportsPlugin {
|
|
225
225
|
}
|
226
226
|
|
227
227
|
if (exports) {
|
228
|
-
const nestedExportsInfo =
|
228
|
+
const nestedExportsInfo =
|
229
|
+
exportInfo.createNestedExportsInfo();
|
229
230
|
mergeExports(nestedExportsInfo, exports);
|
230
231
|
}
|
231
232
|
|
@@ -247,12 +248,12 @@ class FlagDependencyExportsPlugin {
|
|
247
248
|
const target = exportInfo.getTarget(moduleGraph);
|
248
249
|
let targetExportsInfo = undefined;
|
249
250
|
if (target) {
|
250
|
-
const targetModuleExportsInfo =
|
251
|
-
target.module
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
251
|
+
const targetModuleExportsInfo =
|
252
|
+
moduleGraph.getExportsInfo(target.module);
|
253
|
+
targetExportsInfo =
|
254
|
+
targetModuleExportsInfo.getNestedExportsInfo(
|
255
|
+
target.export
|
256
|
+
);
|
256
257
|
// add dependency for this module
|
257
258
|
const set = dependencies.get(target.module);
|
258
259
|
if (set === undefined) {
|
@@ -201,10 +201,8 @@ class FlagDependencyUsagePlugin {
|
|
201
201
|
if (oldReferencedExports === EXPORTS_OBJECT_REFERENCED) {
|
202
202
|
continue;
|
203
203
|
}
|
204
|
-
const referencedExports =
|
205
|
-
dep,
|
206
|
-
runtime
|
207
|
-
);
|
204
|
+
const referencedExports =
|
205
|
+
compilation.getDependencyReferencedExports(dep, runtime);
|
208
206
|
if (
|
209
207
|
oldReferencedExports === undefined ||
|
210
208
|
oldReferencedExports === NO_EXPORTS_REFERENCED ||
|
@@ -87,10 +87,8 @@ class HotModuleReplacementPlugin {
|
|
87
87
|
const runtimeRequirements = [RuntimeGlobals.module];
|
88
88
|
|
89
89
|
const createAcceptHandler = (parser, ParamDependency) => {
|
90
|
-
const {
|
91
|
-
|
92
|
-
hotAcceptWithoutCallback
|
93
|
-
} = HotModuleReplacementPlugin.getParserHooks(parser);
|
90
|
+
const { hotAcceptCallback, hotAcceptWithoutCallback } =
|
91
|
+
HotModuleReplacementPlugin.getParserHooks(parser);
|
94
92
|
|
95
93
|
return expr => {
|
96
94
|
const module = parser.state.module;
|
@@ -306,9 +304,7 @@ class HotModuleReplacementPlugin {
|
|
306
304
|
}
|
307
305
|
records.chunkModuleIds = {};
|
308
306
|
for (const chunk of compilation.chunks) {
|
309
|
-
records.chunkModuleIds[
|
310
|
-
chunk.id
|
311
|
-
] = Array.from(
|
307
|
+
records.chunkModuleIds[chunk.id] = Array.from(
|
312
308
|
chunkGraph.getOrderedChunkModulesIterable(
|
313
309
|
chunk,
|
314
310
|
compareModulesById(chunkGraph)
|
@@ -341,9 +337,8 @@ class HotModuleReplacementPlugin {
|
|
341
337
|
return chunkGraph.getModuleHash(module, chunk.runtime);
|
342
338
|
}
|
343
339
|
};
|
344
|
-
const fullHashModulesInThisChunk =
|
345
|
-
chunk
|
346
|
-
);
|
340
|
+
const fullHashModulesInThisChunk =
|
341
|
+
chunkGraph.getChunkFullHashModulesSet(chunk);
|
347
342
|
if (fullHashModulesInThisChunk !== undefined) {
|
348
343
|
for (const module of fullHashModulesInThisChunk) {
|
349
344
|
fullHashModules.add(module, chunk);
|
@@ -451,16 +446,14 @@ class HotModuleReplacementPlugin {
|
|
451
446
|
allOldRuntime = mergeRuntimeOwned(allOldRuntime, runtime);
|
452
447
|
}
|
453
448
|
forEachRuntime(allOldRuntime, runtime => {
|
454
|
-
const {
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
}
|
463
|
-
);
|
449
|
+
const { path: filename, info: assetInfo } =
|
450
|
+
compilation.getPathWithInfo(
|
451
|
+
compilation.outputOptions.hotUpdateMainFilename,
|
452
|
+
{
|
453
|
+
hash: records.hash,
|
454
|
+
runtime
|
455
|
+
}
|
456
|
+
);
|
464
457
|
hotUpdateMainContentByRuntime.set(runtime, {
|
465
458
|
updatedChunkIds: new Set(),
|
466
459
|
removedChunkIds: new Set(),
|
@@ -516,9 +509,8 @@ class HotModuleReplacementPlugin {
|
|
516
509
|
newRuntimeModules = Array.from(
|
517
510
|
chunkGraph.getChunkRuntimeModulesIterable(currentChunk)
|
518
511
|
).filter(module => updatedModules.has(module, currentChunk));
|
519
|
-
const fullHashModules =
|
520
|
-
currentChunk
|
521
|
-
);
|
512
|
+
const fullHashModules =
|
513
|
+
chunkGraph.getChunkFullHashModulesIterable(currentChunk);
|
522
514
|
newFullHashModules =
|
523
515
|
fullHashModules &&
|
524
516
|
Array.from(fullHashModules).filter(module =>
|
@@ -631,13 +623,11 @@ class HotModuleReplacementPlugin {
|
|
631
623
|
filename = entry.filename;
|
632
624
|
assetInfo = entry.info;
|
633
625
|
} else {
|
634
|
-
({
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
entry.pathOptions
|
640
|
-
));
|
626
|
+
({ path: filename, info: assetInfo } =
|
627
|
+
compilation.getPathWithInfo(
|
628
|
+
entry.filenameTemplate,
|
629
|
+
entry.pathOptions
|
630
|
+
));
|
641
631
|
}
|
642
632
|
const source = entry.render();
|
643
633
|
compilation.additionalChunkAssets.push(filename);
|
package/lib/InitFragment.js
CHANGED
@@ -73,13 +73,25 @@ class InitFragment {
|
|
73
73
|
// Deduplicate fragments. If a fragment has no key, it is always included.
|
74
74
|
const keyedFragments = new Map();
|
75
75
|
for (const [fragment] of sortedFragments) {
|
76
|
-
if (typeof fragment.
|
76
|
+
if (typeof fragment.mergeAll === "function") {
|
77
|
+
if (!fragment.key) {
|
78
|
+
throw new Error(
|
79
|
+
`InitFragment with mergeAll function must have a valid key: ${fragment.constructor.name}`
|
80
|
+
);
|
81
|
+
}
|
82
|
+
const oldValue = keyedFragments.get(fragment.key);
|
83
|
+
if (oldValue === undefined) {
|
84
|
+
keyedFragments.set(fragment.key, fragment);
|
85
|
+
} else if (Array.isArray(oldValue)) {
|
86
|
+
oldValue.push(fragment);
|
87
|
+
} else {
|
88
|
+
keyedFragments.set(fragment.key, [oldValue, fragment]);
|
89
|
+
}
|
90
|
+
continue;
|
91
|
+
} else if (typeof fragment.merge === "function") {
|
77
92
|
const oldValue = keyedFragments.get(fragment.key);
|
78
93
|
if (oldValue !== undefined) {
|
79
|
-
keyedFragments.set(
|
80
|
-
fragment.key || Symbol(),
|
81
|
-
fragment.merge(oldValue)
|
82
|
-
);
|
94
|
+
keyedFragments.set(fragment.key, fragment.merge(oldValue));
|
83
95
|
continue;
|
84
96
|
}
|
85
97
|
}
|
@@ -88,7 +100,10 @@ class InitFragment {
|
|
88
100
|
|
89
101
|
const concatSource = new ConcatSource();
|
90
102
|
const endContents = [];
|
91
|
-
for (
|
103
|
+
for (let fragment of keyedFragments.values()) {
|
104
|
+
if (Array.isArray(fragment)) {
|
105
|
+
fragment = fragment[0].mergeAll(fragment);
|
106
|
+
}
|
92
107
|
concatSource.add(fragment.getContent(generateContext));
|
93
108
|
const endContent = fragment.getEndContent(generateContext);
|
94
109
|
if (endContent) {
|
@@ -34,7 +34,8 @@ class JavascriptMetaInfoPlugin {
|
|
34
34
|
let topLevelDeclarations =
|
35
35
|
parser.state.module.buildInfo.topLevelDeclarations;
|
36
36
|
if (topLevelDeclarations === undefined) {
|
37
|
-
topLevelDeclarations =
|
37
|
+
topLevelDeclarations =
|
38
|
+
parser.state.module.buildInfo.topLevelDeclarations = new Set();
|
38
39
|
}
|
39
40
|
for (const name of parser.scope.definitions.asSet()) {
|
40
41
|
const freeInfo = parser.getFreeInfoFromVariable(name);
|
package/lib/MainTemplate.js
CHANGED
@@ -239,9 +239,8 @@ class MainTemplate {
|
|
239
239
|
"chunkIdExpression"
|
240
240
|
]),
|
241
241
|
get jsonpScript() {
|
242
|
-
const hooks =
|
243
|
-
compilation
|
244
|
-
);
|
242
|
+
const hooks =
|
243
|
+
getLoadScriptRuntimeModule().getCompilationHooks(compilation);
|
245
244
|
return hooks.createScript;
|
246
245
|
},
|
247
246
|
get linkPrefetch() {
|
@@ -12,14 +12,16 @@ const ModuleFilenameHelpers = exports;
|
|
12
12
|
|
13
13
|
// TODO webpack 6: consider removing these
|
14
14
|
ModuleFilenameHelpers.ALL_LOADERS_RESOURCE = "[all-loaders][resource]";
|
15
|
-
ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE =
|
15
|
+
ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE =
|
16
|
+
/\[all-?loaders\]\[resource\]/gi;
|
16
17
|
ModuleFilenameHelpers.LOADERS_RESOURCE = "[loaders][resource]";
|
17
18
|
ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE = /\[loaders\]\[resource\]/gi;
|
18
19
|
ModuleFilenameHelpers.RESOURCE = "[resource]";
|
19
20
|
ModuleFilenameHelpers.REGEXP_RESOURCE = /\[resource\]/gi;
|
20
21
|
ModuleFilenameHelpers.ABSOLUTE_RESOURCE_PATH = "[absolute-resource-path]";
|
21
22
|
// cSpell:words olute
|
22
|
-
ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH =
|
23
|
+
ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH =
|
24
|
+
/\[abs(olute)?-?resource-?path\]/gi;
|
23
25
|
ModuleFilenameHelpers.RESOURCE_PATH = "[resource-path]";
|
24
26
|
ModuleFilenameHelpers.REGEXP_RESOURCE_PATH = /\[resource-?path\]/gi;
|
25
27
|
ModuleFilenameHelpers.ALL_LOADERS = "[all-loaders]";
|
package/lib/ModuleGraph.js
CHANGED
@@ -25,7 +25,7 @@ const WeakTupleMap = require("./util/WeakTupleMap");
|
|
25
25
|
* @returns {string}
|
26
26
|
*/
|
27
27
|
|
28
|
-
const
|
28
|
+
const EMPTY_SET = new Set();
|
29
29
|
|
30
30
|
/**
|
31
31
|
* @param {SortableSet<ModuleGraphConnection>} set input
|
@@ -396,7 +396,7 @@ class ModuleGraph {
|
|
396
396
|
*/
|
397
397
|
getOutgoingConnections(module) {
|
398
398
|
const connections = this._getModuleGraphModule(module).outgoingConnections;
|
399
|
-
return connections === undefined ?
|
399
|
+
return connections === undefined ? EMPTY_SET : connections;
|
400
400
|
}
|
401
401
|
|
402
402
|
/**
|
@@ -183,5 +183,9 @@ class ModuleGraphConnection {
|
|
183
183
|
|
184
184
|
module.exports = ModuleGraphConnection;
|
185
185
|
module.exports.addConnectionStates = addConnectionStates;
|
186
|
-
module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
|
187
|
-
|
186
|
+
module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
|
187
|
+
TRANSITIVE_ONLY
|
188
|
+
);
|
189
|
+
module.exports.CIRCULAR_CONNECTION = /** @type {typeof CIRCULAR_CONNECTION} */ (
|
190
|
+
CIRCULAR_CONNECTION
|
191
|
+
);
|
@@ -222,9 +222,8 @@ class ModuleInfoHeaderPlugin {
|
|
222
222
|
)}`
|
223
223
|
) + "\n"
|
224
224
|
);
|
225
|
-
const optimizationBailout =
|
226
|
-
module
|
227
|
-
);
|
225
|
+
const optimizationBailout =
|
226
|
+
moduleGraph.getOptimizationBailout(module);
|
228
227
|
if (optimizationBailout) {
|
229
228
|
for (const text of optimizationBailout) {
|
230
229
|
let code;
|
package/lib/MultiCompiler.js
CHANGED
@@ -318,16 +318,17 @@ module.exports = class MultiCompiler {
|
|
318
318
|
* @returns {SetupResult[]} result of setup
|
319
319
|
*/
|
320
320
|
_runGraph(setup, run, callback) {
|
321
|
-
/** @typedef {{ compiler: Compiler, result: Stats, state: "pending" | "blocked" | "queued" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
|
321
|
+
/** @typedef {{ compiler: Compiler, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
|
322
322
|
|
323
323
|
// State transitions for nodes:
|
324
324
|
// -> blocked (initial)
|
325
|
-
// blocked ->
|
326
|
-
// queued ->
|
325
|
+
// blocked -> starting [running++] (when all parents done)
|
326
|
+
// queued -> starting [running++] (when processing the queue)
|
327
|
+
// starting -> running (when run has been called)
|
327
328
|
// running -> done [running--] (when compilation is done)
|
328
329
|
// done -> pending (when invalidated from file change)
|
329
|
-
// pending -> blocked (when invalidated from aggregated changes)
|
330
|
-
// done -> blocked (when invalidated, from parent invalidation)
|
330
|
+
// pending -> blocked [add to queue] (when invalidated from aggregated changes)
|
331
|
+
// done -> blocked [add to queue] (when invalidated, from parent invalidation)
|
331
332
|
// running -> running-outdated (when invalidated, either from change or parent invalidation)
|
332
333
|
// running-outdated -> blocked [running--] (when compilation is done)
|
333
334
|
|
@@ -351,6 +352,7 @@ module.exports = class MultiCompiler {
|
|
351
352
|
parent.children.push(node);
|
352
353
|
}
|
353
354
|
}
|
355
|
+
/** @type {ArrayQueue<Node>} */
|
354
356
|
const queue = new ArrayQueue();
|
355
357
|
for (const node of nodes) {
|
356
358
|
if (node.parents.length === 0) {
|
@@ -388,13 +390,13 @@ module.exports = class MultiCompiler {
|
|
388
390
|
if (node.state === "running") {
|
389
391
|
node.state = "done";
|
390
392
|
for (const child of node.children) {
|
391
|
-
|
393
|
+
if (child.state === "blocked") queue.enqueue(child);
|
392
394
|
}
|
393
395
|
} else if (node.state === "running-outdated") {
|
394
396
|
node.state = "blocked";
|
395
|
-
|
397
|
+
queue.enqueue(node);
|
396
398
|
}
|
397
|
-
|
399
|
+
processQueue();
|
398
400
|
};
|
399
401
|
/**
|
400
402
|
* @param {Node} node node
|
@@ -433,20 +435,9 @@ module.exports = class MultiCompiler {
|
|
433
435
|
if (node.state === "pending") {
|
434
436
|
node.state = "blocked";
|
435
437
|
}
|
436
|
-
|
437
|
-
processQueue();
|
438
|
-
};
|
439
|
-
/**
|
440
|
-
* @param {Node} node node
|
441
|
-
* @returns {void}
|
442
|
-
*/
|
443
|
-
const checkUnblocked = node => {
|
444
|
-
if (
|
445
|
-
node.state === "blocked" &&
|
446
|
-
node.parents.every(p => p.state === "done")
|
447
|
-
) {
|
448
|
-
node.state = "queued";
|
438
|
+
if (node.state === "blocked") {
|
449
439
|
queue.enqueue(node);
|
440
|
+
processQueue();
|
450
441
|
}
|
451
442
|
};
|
452
443
|
|
@@ -457,20 +448,33 @@ module.exports = class MultiCompiler {
|
|
457
448
|
node.compiler,
|
458
449
|
i,
|
459
450
|
nodeDone.bind(null, node),
|
460
|
-
() => node.state !== "
|
451
|
+
() => node.state !== "starting" && node.state !== "running",
|
461
452
|
() => nodeChange(node),
|
462
453
|
() => nodeInvalid(node)
|
463
454
|
)
|
464
455
|
);
|
465
456
|
});
|
457
|
+
let processing = true;
|
466
458
|
const processQueue = () => {
|
459
|
+
if (processing) return;
|
460
|
+
processing = true;
|
461
|
+
process.nextTick(processQueueWorker);
|
462
|
+
};
|
463
|
+
const processQueueWorker = () => {
|
467
464
|
while (running < parallelism && queue.length > 0 && !errored) {
|
468
465
|
const node = queue.dequeue();
|
469
|
-
if (
|
470
|
-
|
471
|
-
|
472
|
-
|
466
|
+
if (
|
467
|
+
node.state === "queued" ||
|
468
|
+
(node.state === "blocked" &&
|
469
|
+
node.parents.every(p => p.state === "done"))
|
470
|
+
) {
|
471
|
+
running++;
|
472
|
+
node.state = "starting";
|
473
|
+
run(node.compiler, nodeDone.bind(null, node));
|
474
|
+
node.state = "running";
|
475
|
+
}
|
473
476
|
}
|
477
|
+
processing = false;
|
474
478
|
if (
|
475
479
|
!errored &&
|
476
480
|
running === 0 &&
|
@@ -489,7 +493,7 @@ module.exports = class MultiCompiler {
|
|
489
493
|
}
|
490
494
|
}
|
491
495
|
};
|
492
|
-
|
496
|
+
processQueueWorker();
|
493
497
|
return setupResults;
|
494
498
|
}
|
495
499
|
|