webpack 5.37.0 → 5.39.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 +5 -8
- package/bin/webpack.js +20 -5
- package/lib/AsyncDependencyToInitialChunkError.js +0 -2
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +0 -2
- package/lib/Chunk.js +8 -5
- package/lib/ChunkRenderError.js +0 -2
- package/lib/CodeGenerationError.js +0 -2
- package/lib/CommentCompilationWarning.js +0 -2
- package/lib/Compilation.js +43 -55
- package/lib/Compiler.js +7 -4
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +0 -2
- package/lib/ContextModule.js +5 -4
- package/lib/ContextModuleFactory.js +3 -1
- package/lib/ContextReplacementPlugin.js +4 -3
- package/lib/DefinePlugin.js +16 -12
- package/lib/DllReferencePlugin.js +0 -2
- package/lib/EntryPlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/ExportsInfo.js +20 -13
- package/lib/FileSystemInfo.js +24 -30
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HarmonyLinkingError.js +0 -2
- package/lib/HookWebpackError.js +0 -1
- package/lib/HotModuleReplacementPlugin.js +27 -32
- package/lib/InvalidDependenciesModuleWarning.js +0 -2
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -3
- package/lib/ModuleBuildError.js +0 -2
- package/lib/ModuleDependencyError.js +0 -2
- package/lib/ModuleDependencyWarning.js +0 -2
- package/lib/ModuleError.js +0 -2
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraphConnection.js +6 -2
- package/lib/ModuleInfoHeaderPlugin.js +2 -3
- package/lib/ModuleNotFoundError.js +0 -2
- package/lib/ModuleParseError.js +0 -2
- package/lib/ModuleRestoreError.js +0 -2
- package/lib/ModuleStoreError.js +0 -2
- package/lib/ModuleWarning.js +0 -2
- package/lib/MultiCompiler.js +31 -27
- package/lib/NoModeWarning.js +0 -2
- package/lib/NormalModule.js +26 -8
- package/lib/NormalModuleFactory.js +2 -0
- package/lib/RecordIdsPlugin.js +5 -4
- package/lib/ResolverFactory.js +10 -7
- package/lib/SourceMapDevToolPlugin.js +13 -14
- package/lib/Template.js +4 -2
- package/lib/UnsupportedFeatureWarning.js +0 -2
- package/lib/WarnDeprecatedOptionPlugin.js +0 -2
- package/lib/Watching.js +91 -47
- package/lib/WebpackError.js +0 -2
- package/lib/asset/AssetGenerator.js +46 -29
- package/lib/asset/AssetModulesPlugin.js +1 -1
- package/lib/buildChunkGraph.js +21 -21
- package/lib/cache/PackFileCacheStrategy.js +12 -9
- package/lib/config/defaults.js +21 -10
- package/lib/config/normalization.js +8 -7
- package/lib/config/target.js +7 -2
- 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/ContextElementDependency.js +6 -1
- package/lib/dependencies/CriticalDependencyWarning.js +0 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +11 -13
- 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 +3 -4
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +2 -3
- package/lib/dependencies/RequireEnsureDependency.js +3 -3
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +0 -2
- package/lib/dependencies/SystemPlugin.js +0 -2
- package/lib/dependencies/WorkerDependency.js +6 -6
- package/lib/dependencies/WorkerPlugin.js +18 -19
- package/lib/errors/BuildCycleError.js +0 -1
- package/lib/hmr/LazyCompilationPlugin.js +9 -5
- 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/NodeEnvironmentPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +19 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +5 -4
- package/lib/optimize/ConcatenatedModule.js +31 -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/performance/AssetsOverSizeLimitWarning.js +0 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +0 -2
- package/lib/performance/NoAsyncChunksWarning.js +0 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +9 -8
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -3
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +38 -37
- package/lib/schemes/DataUriPlugin.js +21 -2
- package/lib/serialization/BinaryMiddleware.js +5 -3
- package/lib/serialization/FileMiddleware.js +3 -1
- package/lib/serialization/ObjectMiddleware.js +11 -7
- package/lib/stats/DefaultStatsFactoryPlugin.js +7 -7
- 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/createHash.js +5 -4
- package/lib/util/identifier.js +2 -1
- package/lib/util/serialization.js +108 -59
- package/lib/validateSchema.js +5 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +4 -4
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +0 -2
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +5 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +89 -83
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +0 -2
- 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/package.json +9 -6
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +76 -60
- package/types.d.ts +112 -262
- package/lib/util/DataURI.js +0 -32
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();
|
@@ -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 ||
|
package/lib/HookWebpackError.js
CHANGED
@@ -31,7 +31,8 @@ const {
|
|
31
31
|
keyToRuntime,
|
32
32
|
forEachRuntime,
|
33
33
|
mergeRuntimeOwned,
|
34
|
-
subtractRuntime
|
34
|
+
subtractRuntime,
|
35
|
+
intersectRuntime
|
35
36
|
} = require("./util/runtime");
|
36
37
|
|
37
38
|
/** @typedef {import("./Chunk")} Chunk */
|
@@ -87,10 +88,8 @@ class HotModuleReplacementPlugin {
|
|
87
88
|
const runtimeRequirements = [RuntimeGlobals.module];
|
88
89
|
|
89
90
|
const createAcceptHandler = (parser, ParamDependency) => {
|
90
|
-
const {
|
91
|
-
|
92
|
-
hotAcceptWithoutCallback
|
93
|
-
} = HotModuleReplacementPlugin.getParserHooks(parser);
|
91
|
+
const { hotAcceptCallback, hotAcceptWithoutCallback } =
|
92
|
+
HotModuleReplacementPlugin.getParserHooks(parser);
|
94
93
|
|
95
94
|
return expr => {
|
96
95
|
const module = parser.state.module;
|
@@ -306,9 +305,7 @@ class HotModuleReplacementPlugin {
|
|
306
305
|
}
|
307
306
|
records.chunkModuleIds = {};
|
308
307
|
for (const chunk of compilation.chunks) {
|
309
|
-
records.chunkModuleIds[
|
310
|
-
chunk.id
|
311
|
-
] = Array.from(
|
308
|
+
records.chunkModuleIds[chunk.id] = Array.from(
|
312
309
|
chunkGraph.getOrderedChunkModulesIterable(
|
313
310
|
chunk,
|
314
311
|
compareModulesById(chunkGraph)
|
@@ -341,9 +338,8 @@ class HotModuleReplacementPlugin {
|
|
341
338
|
return chunkGraph.getModuleHash(module, chunk.runtime);
|
342
339
|
}
|
343
340
|
};
|
344
|
-
const fullHashModulesInThisChunk =
|
345
|
-
chunk
|
346
|
-
);
|
341
|
+
const fullHashModulesInThisChunk =
|
342
|
+
chunkGraph.getChunkFullHashModulesSet(chunk);
|
347
343
|
if (fullHashModulesInThisChunk !== undefined) {
|
348
344
|
for (const module of fullHashModulesInThisChunk) {
|
349
345
|
fullHashModules.add(module, chunk);
|
@@ -451,16 +447,14 @@ class HotModuleReplacementPlugin {
|
|
451
447
|
allOldRuntime = mergeRuntimeOwned(allOldRuntime, runtime);
|
452
448
|
}
|
453
449
|
forEachRuntime(allOldRuntime, runtime => {
|
454
|
-
const {
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
}
|
463
|
-
);
|
450
|
+
const { path: filename, info: assetInfo } =
|
451
|
+
compilation.getPathWithInfo(
|
452
|
+
compilation.outputOptions.hotUpdateMainFilename,
|
453
|
+
{
|
454
|
+
hash: records.hash,
|
455
|
+
runtime
|
456
|
+
}
|
457
|
+
);
|
464
458
|
hotUpdateMainContentByRuntime.set(runtime, {
|
465
459
|
updatedChunkIds: new Set(),
|
466
460
|
removedChunkIds: new Set(),
|
@@ -509,16 +503,19 @@ class HotModuleReplacementPlugin {
|
|
509
503
|
);
|
510
504
|
if (currentChunk) {
|
511
505
|
chunkId = currentChunk.id;
|
512
|
-
newRuntime =
|
506
|
+
newRuntime = intersectRuntime(
|
507
|
+
currentChunk.runtime,
|
508
|
+
allOldRuntime
|
509
|
+
);
|
510
|
+
if (newRuntime === undefined) continue;
|
513
511
|
newModules = chunkGraph
|
514
512
|
.getChunkModules(currentChunk)
|
515
513
|
.filter(module => updatedModules.has(module, currentChunk));
|
516
514
|
newRuntimeModules = Array.from(
|
517
515
|
chunkGraph.getChunkRuntimeModulesIterable(currentChunk)
|
518
516
|
).filter(module => updatedModules.has(module, currentChunk));
|
519
|
-
const fullHashModules =
|
520
|
-
currentChunk
|
521
|
-
);
|
517
|
+
const fullHashModules =
|
518
|
+
chunkGraph.getChunkFullHashModulesIterable(currentChunk);
|
522
519
|
newFullHashModules =
|
523
520
|
fullHashModules &&
|
524
521
|
Array.from(fullHashModules).filter(module =>
|
@@ -631,13 +628,11 @@ class HotModuleReplacementPlugin {
|
|
631
628
|
filename = entry.filename;
|
632
629
|
assetInfo = entry.info;
|
633
630
|
} else {
|
634
|
-
({
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
entry.pathOptions
|
640
|
-
));
|
631
|
+
({ path: filename, info: assetInfo } =
|
632
|
+
compilation.getPathWithInfo(
|
633
|
+
entry.filenameTemplate,
|
634
|
+
entry.pathOptions
|
635
|
+
));
|
641
636
|
}
|
642
637
|
const source = entry.render();
|
643
638
|
compilation.additionalChunkAssets.push(filename);
|
@@ -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() {
|
package/lib/ModuleBuildError.js
CHANGED
@@ -30,8 +30,6 @@ class ModuleDependencyError extends WebpackError {
|
|
30
30
|
/** error is not (de)serialized, so it might be undefined after deserialization */
|
31
31
|
this.error = err;
|
32
32
|
|
33
|
-
Error.captureStackTrace(this, this.constructor);
|
34
|
-
|
35
33
|
if (err && /** @type {any} */ (err).hideStack) {
|
36
34
|
this.stack =
|
37
35
|
err.stack.split("\n").slice(1).join("\n") + "\n\n" + this.stack;
|
@@ -30,8 +30,6 @@ class ModuleDependencyWarning extends WebpackError {
|
|
30
30
|
/** error is not (de)serialized, so it might be undefined after deserialization */
|
31
31
|
this.error = err;
|
32
32
|
|
33
|
-
Error.captureStackTrace(this, this.constructor);
|
34
|
-
|
35
33
|
if (err && /** @type {any} */ (err).hideStack) {
|
36
34
|
this.stack =
|
37
35
|
err.stack.split("\n").slice(1).join("\n") + "\n\n" + this.stack;
|
package/lib/ModuleError.js
CHANGED
@@ -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]";
|
@@ -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/ModuleParseError.js
CHANGED
package/lib/ModuleStoreError.js
CHANGED
package/lib/ModuleWarning.js
CHANGED
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
|
|
package/lib/NoModeWarning.js
CHANGED
@@ -18,7 +18,5 @@ module.exports = class NoModeWarning extends WebpackError {
|
|
18
18
|
"Set 'mode' option to 'development' or 'production' to enable defaults for each environment.\n" +
|
19
19
|
"You can also set it to 'none' to disable any default behavior. " +
|
20
20
|
"Learn more: https://webpack.js.org/configuration/mode/";
|
21
|
-
|
22
|
-
Error.captureStackTrace(this, this.constructor);
|
23
21
|
}
|
24
22
|
};
|