webpack 5.36.2 → 5.38.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/Compilation.js +45 -57
- package/lib/Compiler.js +9 -6
- 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 +4 -4
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/ExportsInfo.js +20 -13
- package/lib/FileSystemInfo.js +25 -31
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HotModuleReplacementPlugin.js +27 -32
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -3
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraphConnection.js +6 -2
- package/lib/ModuleInfoHeaderPlugin.js +2 -3
- package/lib/MultiCompiler.js +31 -27
- package/lib/NormalModule.js +42 -8
- package/lib/NormalModuleFactory.js +2 -0
- 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 +91 -47
- 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 +31 -10
- package/lib/config/normalization.js +16 -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/CreateScriptUrlDependency.js +54 -0
- 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 +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 +32 -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/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/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/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/fs.js +8 -8
- package/lib/util/identifier.js +2 -1
- package/lib/util/internalSerializables.js +2 -0
- 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/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 +10 -7
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +107 -60
- package/types.d.ts +480 -285
- package/lib/util/DataURI.js +0 -32
package/README.md
CHANGED
@@ -169,17 +169,14 @@ or are automatically applied via regex from your webpack configuration.
|
|
169
169
|
|
170
170
|
#### Transpiling
|
171
171
|
|
172
|
-
| Name |
|
173
|
-
| :--------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
174
|
-
| <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> |
|
175
|
-
|
|
176
|
-
|
|
177
|
-
| <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |
|
172
|
+
| Name | Status | Install Size | Description |
|
173
|
+
| :--------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ |
|
174
|
+
| <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a> |
|
175
|
+
| <a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg"></a> | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript |
|
176
|
+
| <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |
|
178
177
|
|
179
178
|
[babel-npm]: https://img.shields.io/npm/v/babel-loader.svg
|
180
179
|
[babel-size]: https://packagephobia.com/badge?p=babel-loader
|
181
|
-
[traceur-npm]: https://img.shields.io/npm/v/traceur-loader.svg
|
182
|
-
[traceur-size]: https://packagephobia.com/badge?p=traceur-loader
|
183
180
|
[coffee-npm]: https://img.shields.io/npm/v/coffee-loader.svg
|
184
181
|
[coffee-size]: https://packagephobia.com/badge?p=coffee-loader
|
185
182
|
[type-npm]: https://img.shields.io/npm/v/ts-loader.svg
|
package/bin/webpack.js
CHANGED
File without changes
|
package/lib/CacheFacade.js
CHANGED
@@ -90,9 +90,9 @@ class MultiItemCache {
|
|
90
90
|
* @returns {Promise<void>} promise signals when the value is stored
|
91
91
|
*/
|
92
92
|
storePromise(data) {
|
93
|
-
return Promise.all(
|
94
|
-
|
95
|
-
)
|
93
|
+
return Promise.all(this._items.map(item => item.storePromise(data))).then(
|
94
|
+
() => {}
|
95
|
+
);
|
96
96
|
}
|
97
97
|
}
|
98
98
|
|
package/lib/Chunk.js
CHANGED
@@ -547,9 +547,8 @@ class Chunk {
|
|
547
547
|
xor.add(chunkGraph.getModuleHash(m, this.runtime));
|
548
548
|
}
|
549
549
|
xor.updateHash(hash);
|
550
|
-
const entryModules =
|
551
|
-
this
|
552
|
-
);
|
550
|
+
const entryModules =
|
551
|
+
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(this);
|
553
552
|
for (const [m, chunkGroup] of entryModules) {
|
554
553
|
hash.update("entry");
|
555
554
|
hash.update(`${chunkGraph.getModuleId(m)}`);
|
@@ -568,9 +567,15 @@ class Chunk {
|
|
568
567
|
Array.from(this.groupsIterable, g => new Set(g.chunks))
|
569
568
|
);
|
570
569
|
|
571
|
-
|
570
|
+
const initialQueue = new Set(this.groupsIterable);
|
571
|
+
|
572
|
+
for (const chunkGroup of initialQueue) {
|
572
573
|
for (const child of chunkGroup.childrenIterable) {
|
573
|
-
|
574
|
+
if (child instanceof Entrypoint) {
|
575
|
+
initialQueue.add(child);
|
576
|
+
} else {
|
577
|
+
queue.add(child);
|
578
|
+
}
|
574
579
|
}
|
575
580
|
}
|
576
581
|
|
package/lib/Compilation.js
CHANGED
@@ -510,7 +510,8 @@ class Compilation {
|
|
510
510
|
* @returns {FakeHook<Pick<AsyncSeriesHook<T>, "tap" | "tapAsync" | "tapPromise" | "name">>} fake hook which redirects
|
511
511
|
*/
|
512
512
|
const createProcessAssetsHook = (name, stage, getArgs, code) => {
|
513
|
-
const errorMessage =
|
513
|
+
const errorMessage =
|
514
|
+
reason => `Can't automatically convert plugin using Compilation.hooks.${name} to Compilation.hooks.processAssets because ${reason}.
|
514
515
|
BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a single Compilation.hooks.processAssets hook.`;
|
515
516
|
const getOptions = options => {
|
516
517
|
if (typeof options === "string") options = { name: options };
|
@@ -1615,9 +1616,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1615
1616
|
let creatingModuleDuringBuildSet = undefined;
|
1616
1617
|
if (!recursive && this.buildQueue.isProcessing(originModule)) {
|
1617
1618
|
// Track build dependency
|
1618
|
-
creatingModuleDuringBuildSet =
|
1619
|
-
originModule
|
1620
|
-
);
|
1619
|
+
creatingModuleDuringBuildSet =
|
1620
|
+
this.creatingModuleDuringBuild.get(originModule);
|
1621
1621
|
if (creatingModuleDuringBuildSet === undefined) {
|
1622
1622
|
creatingModuleDuringBuildSet = new Set();
|
1623
1623
|
this.creatingModuleDuringBuild.set(
|
@@ -1746,11 +1746,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1746
1746
|
module: result
|
1747
1747
|
};
|
1748
1748
|
}
|
1749
|
-
const {
|
1750
|
-
|
1751
|
-
contextDependencies,
|
1752
|
-
missingDependencies
|
1753
|
-
} = result;
|
1749
|
+
const { fileDependencies, contextDependencies, missingDependencies } =
|
1750
|
+
result;
|
1754
1751
|
if (fileDependencies) {
|
1755
1752
|
this.fileDependencies.addAll(fileDependencies);
|
1756
1753
|
}
|
@@ -2316,7 +2313,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2316
2313
|
}
|
2317
2314
|
] of this.entries) {
|
2318
2315
|
if (dependOn && runtime) {
|
2319
|
-
const err =
|
2316
|
+
const err =
|
2317
|
+
new WebpackError(`Entrypoint '${name}' has 'dependOn' and 'runtime' specified. This is not valid.
|
2320
2318
|
Entrypoints that depend on other entrypoints do not have their own runtime.
|
2321
2319
|
They will use the runtime(s) from referenced entrypoints instead.
|
2322
2320
|
Remove the 'runtime' option from the entrypoint.`);
|
@@ -2357,11 +2355,12 @@ Remove the 'runtime' option from the entrypoint.`);
|
|
2357
2355
|
let chunk = this.namedChunks.get(runtime);
|
2358
2356
|
if (chunk) {
|
2359
2357
|
if (!runtimeChunks.has(chunk)) {
|
2360
|
-
const err =
|
2358
|
+
const err =
|
2359
|
+
new WebpackError(`Entrypoint '${name}' has a 'runtime' option which points to another entrypoint named '${runtime}'.
|
2361
2360
|
It's not valid to use other entrypoints as runtime chunk.
|
2362
2361
|
Did you mean to use 'dependOn: ${JSON.stringify(
|
2363
|
-
|
2364
|
-
|
2362
|
+
runtime
|
2363
|
+
)}' instead to allow using entrypoint '${name}' within the runtime of entrypoint '${runtime}'? For this '${runtime}' must always be loaded when '${name}' is used.
|
2365
2364
|
Or do you want to use the entrypoints '${name}' and '${runtime}' independently on the same page with a shared runtime? In this case give them both the same value for the 'runtime' option. It must be a name not already used by an entrypoint.`);
|
2366
2365
|
const entryChunk = entry.getEntrypointChunk();
|
2367
2366
|
err.chunk = entryChunk;
|
@@ -2621,12 +2620,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
2621
2620
|
_runCodeGenerationJobs(jobs, callback) {
|
2622
2621
|
let statModulesFromCache = 0;
|
2623
2622
|
let statModulesGenerated = 0;
|
2624
|
-
const {
|
2625
|
-
|
2626
|
-
moduleGraph,
|
2627
|
-
dependencyTemplates,
|
2628
|
-
runtimeTemplate
|
2629
|
-
} = this;
|
2623
|
+
const { chunkGraph, moduleGraph, dependencyTemplates, runtimeTemplate } =
|
2624
|
+
this;
|
2630
2625
|
const results = this.codeGenerationResults;
|
2631
2626
|
const errors = [];
|
2632
2627
|
asyncLib.eachLimit(
|
@@ -2773,17 +2768,15 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
2773
2768
|
chunkGraphEntries = this._getChunkGraphEntries()
|
2774
2769
|
} = {}) {
|
2775
2770
|
const context = { chunkGraph, codeGenerationResults };
|
2776
|
-
const additionalModuleRuntimeRequirements =
|
2777
|
-
.additionalModuleRuntimeRequirements;
|
2771
|
+
const additionalModuleRuntimeRequirements =
|
2772
|
+
this.hooks.additionalModuleRuntimeRequirements;
|
2778
2773
|
const runtimeRequirementInModule = this.hooks.runtimeRequirementInModule;
|
2779
2774
|
for (const module of modules) {
|
2780
2775
|
if (chunkGraph.getNumberOfModuleChunks(module) > 0) {
|
2781
2776
|
for (const runtime of chunkGraph.getModuleRuntimes(module)) {
|
2782
2777
|
let set;
|
2783
|
-
const runtimeRequirements =
|
2784
|
-
module,
|
2785
|
-
runtime
|
2786
|
-
);
|
2778
|
+
const runtimeRequirements =
|
2779
|
+
codeGenerationResults.getRuntimeRequirements(module, runtime);
|
2787
2780
|
if (runtimeRequirements && runtimeRequirements.size > 0) {
|
2788
2781
|
set = new Set(runtimeRequirements);
|
2789
2782
|
} else if (additionalModuleRuntimeRequirements.isUsed()) {
|
@@ -2823,9 +2816,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
2823
2816
|
for (const treeEntry of chunkGraphEntries) {
|
2824
2817
|
const set = new Set();
|
2825
2818
|
for (const chunk of treeEntry.getAllReferencedChunks()) {
|
2826
|
-
const runtimeRequirements =
|
2827
|
-
chunk
|
2828
|
-
);
|
2819
|
+
const runtimeRequirements =
|
2820
|
+
chunkGraph.getChunkRuntimeRequirements(chunk);
|
2829
2821
|
for (const r of runtimeRequirements) set.add(r);
|
2830
2822
|
}
|
2831
2823
|
|
@@ -3223,9 +3215,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3223
3215
|
runtime,
|
3224
3216
|
runtimeTemplate
|
3225
3217
|
});
|
3226
|
-
const moduleHashDigest = /** @type {string} */ (
|
3227
|
-
hashDigest
|
3228
|
-
)
|
3218
|
+
const moduleHashDigest = /** @type {string} */ (
|
3219
|
+
moduleHash.digest(hashDigest)
|
3220
|
+
);
|
3229
3221
|
chunkGraph.setModuleHashes(
|
3230
3222
|
module,
|
3231
3223
|
runtime,
|
@@ -3354,10 +3346,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3354
3346
|
}
|
3355
3347
|
}
|
3356
3348
|
circularRuntimeChunkInfo.sort(compareSelect(i => i.chunk, byId));
|
3357
|
-
const err =
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3349
|
+
const err =
|
3350
|
+
new WebpackError(`Circular dependency between chunks with runtime (${Array.from(
|
3351
|
+
circularRuntimeChunkInfo,
|
3352
|
+
c => c.chunk.name || c.chunk.id
|
3353
|
+
).join(", ")})
|
3361
3354
|
This prevents using hashes of each other and should be avoided.`);
|
3362
3355
|
err.chunk = circularRuntimeChunkInfo[0].chunk;
|
3363
3356
|
this.warnings.push(err);
|
@@ -3420,15 +3413,14 @@ This prevents using hashes of each other and should be avoided.`);
|
|
3420
3413
|
moduleGraph: this.moduleGraph,
|
3421
3414
|
runtimeTemplate: this.runtimeTemplate
|
3422
3415
|
});
|
3423
|
-
const chunkHashDigest = /** @type {string} */ (
|
3424
|
-
hashDigest
|
3425
|
-
)
|
3416
|
+
const chunkHashDigest = /** @type {string} */ (
|
3417
|
+
chunkHash.digest(hashDigest)
|
3418
|
+
);
|
3426
3419
|
hash.update(chunkHashDigest);
|
3427
3420
|
chunk.hash = chunkHashDigest;
|
3428
3421
|
chunk.renderedHash = chunk.hash.substr(0, hashDigestLength);
|
3429
|
-
const fullHashModules =
|
3430
|
-
chunk
|
3431
|
-
);
|
3422
|
+
const fullHashModules =
|
3423
|
+
chunkGraph.getChunkFullHashModulesIterable(chunk);
|
3432
3424
|
if (fullHashModules) {
|
3433
3425
|
fullHashChunks.add(chunk);
|
3434
3426
|
} else {
|
@@ -3459,9 +3451,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
3459
3451
|
runtime: chunk.runtime,
|
3460
3452
|
runtimeTemplate
|
3461
3453
|
});
|
3462
|
-
const moduleHashDigest = /** @type {string} */ (
|
3463
|
-
hashDigest
|
3464
|
-
)
|
3454
|
+
const moduleHashDigest = /** @type {string} */ (
|
3455
|
+
moduleHash.digest(hashDigest)
|
3456
|
+
);
|
3465
3457
|
const oldHash = chunkGraph.getModuleHash(module, chunk.runtime);
|
3466
3458
|
chunkGraph.setModuleHashes(
|
3467
3459
|
module,
|
@@ -3474,9 +3466,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
3474
3466
|
const chunkHash = createHash(hashFunction);
|
3475
3467
|
chunkHash.update(chunk.hash);
|
3476
3468
|
chunkHash.update(this.hash);
|
3477
|
-
const chunkHashDigest = /** @type {string} */ (
|
3478
|
-
hashDigest
|
3479
|
-
)
|
3469
|
+
const chunkHashDigest = /** @type {string} */ (
|
3470
|
+
chunkHash.digest(hashDigest)
|
3471
|
+
);
|
3480
3472
|
chunk.hash = chunkHashDigest;
|
3481
3473
|
chunk.renderedHash = chunk.hash.substr(0, hashDigestLength);
|
3482
3474
|
this.hooks.contentHash.call(chunk);
|
@@ -3993,8 +3985,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
3993
3985
|
* from parent (or top level compiler) and creates a child Compilation
|
3994
3986
|
*
|
3995
3987
|
* @param {string} name name of the child compiler
|
3996
|
-
* @param {OutputOptions} outputOptions // Need to convert config schema to types for this
|
3997
|
-
* @param {Array<WebpackPluginInstance | WebpackPluginFunction
|
3988
|
+
* @param {OutputOptions=} outputOptions // Need to convert config schema to types for this
|
3989
|
+
* @param {Array<WebpackPluginInstance | WebpackPluginFunction>=} plugins webpack plugins that will be applied
|
3998
3990
|
* @returns {Compiler} creates a child Compiler instance
|
3999
3991
|
*/
|
4000
3992
|
createChildCompiler(name, outputOptions, plugins) {
|
@@ -4051,11 +4043,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4051
4043
|
// Create new chunk graph, chunk and entrypoint for the build time execution
|
4052
4044
|
const chunkGraph = new ChunkGraph(this.moduleGraph);
|
4053
4045
|
const runtime = "build time";
|
4054
|
-
const {
|
4055
|
-
|
4056
|
-
hashDigest,
|
4057
|
-
hashDigestLength
|
4058
|
-
} = this.outputOptions;
|
4046
|
+
const { hashFunction, hashDigest, hashDigestLength } =
|
4047
|
+
this.outputOptions;
|
4059
4048
|
const runtimeTemplate = this.runtimeTemplate;
|
4060
4049
|
|
4061
4050
|
const chunk = new Chunk("build time chunk");
|
@@ -4151,9 +4140,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4151
4140
|
});
|
4152
4141
|
this.chunkGraph = old;
|
4153
4142
|
|
4154
|
-
const runtimeModules =
|
4155
|
-
chunk
|
4156
|
-
);
|
4143
|
+
const runtimeModules =
|
4144
|
+
chunkGraph.getChunkRuntimeModulesIterable(chunk);
|
4157
4145
|
|
4158
4146
|
// Hash runtime modules
|
4159
4147
|
for (const module of runtimeModules) {
|
package/lib/Compiler.js
CHANGED
@@ -230,6 +230,8 @@ class Compiler {
|
|
230
230
|
this.fileTimestamps = undefined;
|
231
231
|
/** @type {Map<string, FileSystemInfoEntry | "ignore" | null>} */
|
232
232
|
this.contextTimestamps = undefined;
|
233
|
+
/** @type {number} */
|
234
|
+
this.fsStartTime = undefined;
|
233
235
|
|
234
236
|
/** @type {ResolverFactory} */
|
235
237
|
this.resolverFactory = new ResolverFactory();
|
@@ -590,9 +592,8 @@ class Compiler {
|
|
590
592
|
allTargetPaths.add(targetPath);
|
591
593
|
|
592
594
|
// check if the target file has already been written by this Compiler
|
593
|
-
const targetFileGeneration =
|
594
|
-
targetPath
|
595
|
-
);
|
595
|
+
const targetFileGeneration =
|
596
|
+
this._assetEmittingWrittenFiles.get(targetPath);
|
596
597
|
|
597
598
|
// create an cache entry for this Source if not already existing
|
598
599
|
let cacheEntry = this._assetEmittingSourceCache.get(source);
|
@@ -622,7 +623,8 @@ class Compiler {
|
|
622
623
|
}
|
623
624
|
alreadyWritten();
|
624
625
|
} else {
|
625
|
-
const err =
|
626
|
+
const err =
|
627
|
+
new WebpackError(`Prevent writing to file that only differs in casing or query string from already written file.
|
626
628
|
This will lead to a race-condition and corrupted files on case-insensitive file systems.
|
627
629
|
${targetPath}
|
628
630
|
${other}`);
|
@@ -931,8 +933,8 @@ ${other}`);
|
|
931
933
|
* @param {Compilation} compilation the compilation
|
932
934
|
* @param {string} compilerName the compiler's name
|
933
935
|
* @param {number} compilerIndex the compiler's index
|
934
|
-
* @param {OutputOptions} outputOptions the output options
|
935
|
-
* @param {WebpackPluginInstance[]} plugins the plugins to apply
|
936
|
+
* @param {OutputOptions=} outputOptions the output options
|
937
|
+
* @param {WebpackPluginInstance[]=} plugins the plugins to apply
|
936
938
|
* @returns {Compiler} a child compiler
|
937
939
|
*/
|
938
940
|
createChildCompiler(
|
@@ -952,6 +954,7 @@ ${other}`);
|
|
952
954
|
childCompiler.removedFiles = this.removedFiles;
|
953
955
|
childCompiler.fileTimestamps = this.fileTimestamps;
|
954
956
|
childCompiler.contextTimestamps = this.contextTimestamps;
|
957
|
+
childCompiler.fsStartTime = this.fsStartTime;
|
955
958
|
childCompiler.cache = this.cache;
|
956
959
|
childCompiler.compilerPath = `${this.compilerPath}${compilerName}|${compilerIndex}|`;
|
957
960
|
|
@@ -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;
|
@@ -41,10 +41,10 @@ class EntryPlugin {
|
|
41
41
|
}
|
42
42
|
);
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
const { entry, options, context } = this;
|
45
|
+
const dep = EntryPlugin.createDependency(entry, options);
|
46
46
|
|
47
|
-
|
47
|
+
compiler.hooks.make.tapAsync("EntryPlugin", (compilation, callback) => {
|
48
48
|
compilation.addEntry(context, dep, options, err => {
|
49
49
|
callback(err);
|
50
50
|
});
|
@@ -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/ExportsInfo.js
CHANGED
@@ -137,18 +137,22 @@ class ExportsInfo {
|
|
137
137
|
|
138
138
|
_sortExportsMap(exports) {
|
139
139
|
if (exports.size > 1) {
|
140
|
-
const
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
)
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
140
|
+
const namesInOrder = [];
|
141
|
+
for (const entry of exports.values()) {
|
142
|
+
namesInOrder.push(entry.name);
|
143
|
+
}
|
144
|
+
namesInOrder.sort();
|
145
|
+
let i = 0;
|
146
|
+
for (const entry of exports.values()) {
|
147
|
+
const name = namesInOrder[i];
|
148
|
+
if (entry.name !== name) break;
|
149
|
+
i++;
|
150
|
+
}
|
151
|
+
for (; i < namesInOrder.length; i++) {
|
152
|
+
const name = namesInOrder[i];
|
153
|
+
const correctEntry = exports.get(name);
|
154
|
+
exports.delete(name);
|
155
|
+
exports.set(name, correctEntry);
|
152
156
|
}
|
153
157
|
}
|
154
158
|
}
|
@@ -722,7 +726,7 @@ class ExportsInfo {
|
|
722
726
|
const otherCanMangleProvide = this._otherExportsInfo.canMangleProvide;
|
723
727
|
const otherTerminalBinding = this._otherExportsInfo.terminalBinding;
|
724
728
|
const exports = [];
|
725
|
-
for (const exportInfo of this.
|
729
|
+
for (const exportInfo of this.orderedExports) {
|
726
730
|
if (
|
727
731
|
exportInfo.provided !== otherProvided ||
|
728
732
|
exportInfo.canMangleProvide !== otherCanMangleProvide ||
|
@@ -754,7 +758,9 @@ class ExportsInfo {
|
|
754
758
|
otherTerminalBinding,
|
755
759
|
exports
|
756
760
|
}) {
|
761
|
+
let wasEmpty = true;
|
757
762
|
for (const exportInfo of this._exports.values()) {
|
763
|
+
wasEmpty = false;
|
758
764
|
exportInfo.provided = otherProvided;
|
759
765
|
exportInfo.canMangleProvide = otherCanMangleProvide;
|
760
766
|
exportInfo.terminalBinding = otherTerminalBinding;
|
@@ -772,6 +778,7 @@ class ExportsInfo {
|
|
772
778
|
exportsInfo.restoreProvided(exp.exportsInfo);
|
773
779
|
}
|
774
780
|
}
|
781
|
+
if (wasEmpty) this._exportsAreOrdered = true;
|
775
782
|
}
|
776
783
|
}
|
777
784
|
|
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) {
|