webpack 5.37.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/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +2 -3
- package/lib/Compilation.js +43 -55
- package/lib/Compiler.js +4 -4
- 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/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/FileSystemInfo.js +24 -30
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HotModuleReplacementPlugin.js +20 -30
- 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 +22 -5
- 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/Watching.js +83 -46
- package/lib/asset/AssetGenerator.js +19 -23
- package/lib/buildChunkGraph.js +21 -21
- package/lib/cache/PackFileCacheStrategy.js +12 -9
- package/lib/config/defaults.js +12 -9
- package/lib/config/normalization.js +7 -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/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 +18 -19
- 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/EnsureChunkRuntimeModule.js +9 -8
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -3
- 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/identifier.js +2 -1
- 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/package.json +6 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +68 -60
- package/types.d.ts +89 -257
@@ -47,9 +47,8 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
47
47
|
chunk instanceof HotUpdateChunk ? chunk : null;
|
48
48
|
const globalObject = runtimeTemplate.outputOptions.globalObject;
|
49
49
|
const source = new ConcatSource();
|
50
|
-
const runtimeModules =
|
51
|
-
chunk
|
52
|
-
);
|
50
|
+
const runtimeModules =
|
51
|
+
chunkGraph.getChunkRuntimeModulesInOrder(chunk);
|
53
52
|
if (hotUpdateChunk) {
|
54
53
|
const hotUpdateGlobal =
|
55
54
|
runtimeTemplate.outputOptions.hotUpdateGlobal;
|
@@ -83,9 +82,8 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
83
82
|
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
84
83
|
);
|
85
84
|
if (runtimeModules.length > 0 || entries.length > 0) {
|
86
|
-
const strictBailout =
|
87
|
-
renderContext
|
88
|
-
);
|
85
|
+
const strictBailout =
|
86
|
+
hooks.strictRuntimeBailout.call(renderContext);
|
89
87
|
const runtime = new ConcatSource(
|
90
88
|
(runtimeTemplate.supportsArrowFunction()
|
91
89
|
? "__webpack_require__ =>"
|
@@ -51,9 +51,8 @@ class CommonJsChunkFormatPlugin {
|
|
51
51
|
source.add(`exports.modules = `);
|
52
52
|
source.add(modules);
|
53
53
|
source.add(";\n");
|
54
|
-
const runtimeModules =
|
55
|
-
chunk
|
56
|
-
);
|
54
|
+
const runtimeModules =
|
55
|
+
chunkGraph.getChunkRuntimeModulesInOrder(chunk);
|
57
56
|
if (runtimeModules.length > 0) {
|
58
57
|
source.add("exports.runtime =\n");
|
59
58
|
source.add(
|
@@ -180,7 +180,9 @@ class JavascriptGenerator extends Generator {
|
|
180
180
|
* @returns {void}
|
181
181
|
*/
|
182
182
|
sourceDependency(module, dependency, initFragments, source, generateContext) {
|
183
|
-
const constructor = /** @type {new (...args: any[]) => Dependency} */ (
|
183
|
+
const constructor = /** @type {new (...args: any[]) => Dependency} */ (
|
184
|
+
dependency.constructor
|
185
|
+
);
|
184
186
|
const template = generateContext.dependencyTemplates.get(constructor);
|
185
187
|
if (!template) {
|
186
188
|
throw new Error(
|
@@ -228,10 +228,11 @@ class JavascriptModulesPlugin {
|
|
228
228
|
chunk instanceof HotUpdateChunk ? chunk : null;
|
229
229
|
|
230
230
|
let render;
|
231
|
-
const filenameTemplate =
|
232
|
-
|
233
|
-
|
234
|
-
|
231
|
+
const filenameTemplate =
|
232
|
+
JavascriptModulesPlugin.getChunkFilenameTemplate(
|
233
|
+
chunk,
|
234
|
+
outputOptions
|
235
|
+
);
|
235
236
|
if (hotUpdateChunk) {
|
236
237
|
render = () =>
|
237
238
|
this.renderChunk(
|
@@ -394,9 +395,8 @@ class JavascriptModulesPlugin {
|
|
394
395
|
compilation.hooks.executeModule.tap(
|
395
396
|
"JavascriptModulesPlugin",
|
396
397
|
(options, context) => {
|
397
|
-
const source =
|
398
|
-
"javascript"
|
399
|
-
);
|
398
|
+
const source =
|
399
|
+
options.codeGenerationResult.sources.get("javascript");
|
400
400
|
if (source === undefined) return;
|
401
401
|
const { module, moduleObject } = options;
|
402
402
|
const code = source.source();
|
@@ -468,12 +468,8 @@ class JavascriptModulesPlugin {
|
|
468
468
|
* @returns {Source} the newly generated source from rendering
|
469
469
|
*/
|
470
470
|
renderModule(module, renderContext, hooks, factory) {
|
471
|
-
const {
|
472
|
-
|
473
|
-
chunkGraph,
|
474
|
-
runtimeTemplate,
|
475
|
-
codeGenerationResults
|
476
|
-
} = renderContext;
|
471
|
+
const { chunk, chunkGraph, runtimeTemplate, codeGenerationResults } =
|
472
|
+
renderContext;
|
477
473
|
try {
|
478
474
|
const moduleSource = codeGenerationResults.getSource(
|
479
475
|
module,
|
@@ -699,9 +695,8 @@ class JavascriptModulesPlugin {
|
|
699
695
|
);
|
700
696
|
}
|
701
697
|
|
702
|
-
const runtimeModules =
|
703
|
-
chunk
|
704
|
-
);
|
698
|
+
const runtimeModules =
|
699
|
+
renderContext.chunkGraph.getChunkRuntimeModulesInOrder(chunk);
|
705
700
|
|
706
701
|
if (runtimeModules.length > 0) {
|
707
702
|
source.add(
|
@@ -985,9 +980,8 @@ class JavascriptModulesPlugin {
|
|
985
980
|
if (chunkGraph.getNumberOfEntryModules(chunk) > 0) {
|
986
981
|
/** @type {string[]} */
|
987
982
|
const buf2 = [];
|
988
|
-
const runtimeRequirements =
|
989
|
-
chunk
|
990
|
-
);
|
983
|
+
const runtimeRequirements =
|
984
|
+
chunkGraph.getTreeRuntimeRequirements(chunk);
|
991
985
|
buf2.push("// Load entry module and return exports");
|
992
986
|
let i = chunkGraph.getNumberOfEntryModules(chunk);
|
993
987
|
for (const [
|
@@ -1044,10 +1038,8 @@ class JavascriptModulesPlugin {
|
|
1044
1038
|
}
|
1045
1039
|
i--;
|
1046
1040
|
const moduleId = chunkGraph.getModuleId(entryModule);
|
1047
|
-
const entryRuntimeRequirements =
|
1048
|
-
entryModule,
|
1049
|
-
chunk.runtime
|
1050
|
-
);
|
1041
|
+
const entryRuntimeRequirements =
|
1042
|
+
chunkGraph.getModuleRuntimeRequirements(entryModule, chunk.runtime);
|
1051
1043
|
let moduleIdExpr = JSON.stringify(moduleId);
|
1052
1044
|
if (runtimeRequirements.has(RuntimeGlobals.entryModuleId)) {
|
1053
1045
|
moduleIdExpr = `${RuntimeGlobals.entryModuleId} = ${moduleIdExpr}`;
|
@@ -3336,8 +3336,10 @@ class JavascriptParser extends Parser {
|
|
3336
3336
|
if (expr.superClass && !this.isPure(expr.superClass, expr.range[0])) {
|
3337
3337
|
return false;
|
3338
3338
|
}
|
3339
|
-
const items =
|
3340
|
-
|
3339
|
+
const items =
|
3340
|
+
/** @type {(MethodDefinitionNode | PropertyDefinitionNode)[]} */ (
|
3341
|
+
expr.body.body
|
3342
|
+
);
|
3341
3343
|
return items.every(
|
3342
3344
|
item =>
|
3343
3345
|
(!item.computed ||
|
@@ -3623,10 +3625,8 @@ class JavascriptParser extends Parser {
|
|
3623
3625
|
let callee = object.callee;
|
3624
3626
|
let rootMembers = EMPTY_ARRAY;
|
3625
3627
|
if (callee.type === "MemberExpression") {
|
3626
|
-
({
|
3627
|
-
|
3628
|
-
members: rootMembers
|
3629
|
-
} = this.extractMemberExpressionChain(callee));
|
3628
|
+
({ object: callee, members: rootMembers } =
|
3629
|
+
this.extractMemberExpressionChain(callee));
|
3630
3630
|
}
|
3631
3631
|
const rootName = getRootName(callee);
|
3632
3632
|
if (!rootName) return undefined;
|
@@ -3729,5 +3729,7 @@ class JavascriptParser extends Parser {
|
|
3729
3729
|
|
3730
3730
|
module.exports = JavascriptParser;
|
3731
3731
|
module.exports.ALLOWED_MEMBER_TYPES_ALL = ALLOWED_MEMBER_TYPES_ALL;
|
3732
|
-
module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
|
3733
|
-
|
3732
|
+
module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
|
3733
|
+
ALLOWED_MEMBER_TYPES_EXPRESSION;
|
3734
|
+
module.exports.ALLOWED_MEMBER_TYPES_CALL_EXPRESSION =
|
3735
|
+
ALLOWED_MEMBER_TYPES_CALL_EXPRESSION;
|
@@ -24,8 +24,10 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
|
24
24
|
/** @typedef {import("../util/Hash")} Hash */
|
25
25
|
/** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
|
26
26
|
|
27
|
-
const KEYWORD_REGEX =
|
28
|
-
const
|
27
|
+
const KEYWORD_REGEX =
|
28
|
+
/^(await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/;
|
29
|
+
const IDENTIFIER_REGEX =
|
30
|
+
/^[\p{L}\p{Nl}$_][\p{L}\p{Nl}$\p{Mn}\p{Mc}\p{Nd}\p{Pc}]*$/iu;
|
29
31
|
|
30
32
|
/**
|
31
33
|
* Validates the library name by checking for keywords and valid characters
|
@@ -70,11 +70,12 @@ class NodeWatchFileSystem {
|
|
70
70
|
}
|
71
71
|
this.watcher.once("aggregated", (changes, removals) => {
|
72
72
|
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
73
|
+
const fs = this.inputFileSystem;
|
73
74
|
for (const item of changes) {
|
74
|
-
|
75
|
+
fs.purge(item);
|
75
76
|
}
|
76
77
|
for (const item of removals) {
|
77
|
-
|
78
|
+
fs.purge(item);
|
78
79
|
}
|
79
80
|
}
|
80
81
|
const times = this.watcher.getTimeInfoEntries();
|
@@ -99,10 +100,24 @@ class NodeWatchFileSystem {
|
|
99
100
|
}
|
100
101
|
},
|
101
102
|
getAggregatedRemovals: () => {
|
102
|
-
|
103
|
+
const items = this.watcher && this.watcher.aggregatedRemovals;
|
104
|
+
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
|
105
|
+
const fs = this.inputFileSystem;
|
106
|
+
for (const item of items) {
|
107
|
+
fs.purge(item);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
return items;
|
103
111
|
},
|
104
112
|
getAggregatedChanges: () => {
|
105
|
-
|
113
|
+
const items = this.watcher && this.watcher.aggregatedChanges;
|
114
|
+
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
|
115
|
+
const fs = this.inputFileSystem;
|
116
|
+
for (const item of items) {
|
117
|
+
fs.purge(item);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
return items;
|
106
121
|
},
|
107
122
|
getFileTimeInfoEntries: () => {
|
108
123
|
if (this.watcher) {
|
@@ -109,10 +109,11 @@ class AggressiveSplittingPlugin {
|
|
109
109
|
// Precompute stuff
|
110
110
|
const nameToModuleMap = new Map();
|
111
111
|
const moduleToNameMap = new Map();
|
112
|
-
const makePathsRelative =
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
const makePathsRelative =
|
113
|
+
identifierUtils.makePathsRelative.bindContextCache(
|
114
|
+
compiler.context,
|
115
|
+
compiler.root
|
116
|
+
);
|
116
117
|
for (const m of compilation.modules) {
|
117
118
|
const name = makePathsRelative(m.identifier());
|
118
119
|
nameToModuleMap.set(name, m);
|
@@ -381,10 +381,9 @@ const getFinalBinding = (
|
|
381
381
|
}
|
382
382
|
const directExport = info.exportMap && info.exportMap.get(exportId);
|
383
383
|
if (directExport) {
|
384
|
-
const usedName = /** @type {string[]} */ (
|
385
|
-
exportName,
|
386
|
-
|
387
|
-
));
|
384
|
+
const usedName = /** @type {string[]} */ (
|
385
|
+
exportsInfo.getUsedName(exportName, runtime)
|
386
|
+
);
|
388
387
|
if (!usedName) {
|
389
388
|
return {
|
390
389
|
info,
|
@@ -443,10 +442,9 @@ const getFinalBinding = (
|
|
443
442
|
);
|
444
443
|
}
|
445
444
|
if (info.namespaceExportSymbol) {
|
446
|
-
const usedName = /** @type {string[]} */ (
|
447
|
-
exportName,
|
448
|
-
|
449
|
-
));
|
445
|
+
const usedName = /** @type {string[]} */ (
|
446
|
+
exportsInfo.getUsedName(exportName, runtime)
|
447
|
+
);
|
450
448
|
return {
|
451
449
|
info,
|
452
450
|
rawName: info.namespaceObjectName,
|
@@ -462,10 +460,9 @@ const getFinalBinding = (
|
|
462
460
|
}
|
463
461
|
|
464
462
|
case "external": {
|
465
|
-
const used = /** @type {string[]} */ (
|
466
|
-
exportName,
|
467
|
-
|
468
|
-
));
|
463
|
+
const used = /** @type {string[]} */ (
|
464
|
+
exportsInfo.getUsedName(exportName, runtime)
|
465
|
+
);
|
469
466
|
if (!used) {
|
470
467
|
return {
|
471
468
|
info,
|
@@ -883,8 +880,9 @@ class ConcatenatedModule extends Module {
|
|
883
880
|
})
|
884
881
|
.map(connection => ({
|
885
882
|
connection,
|
886
|
-
sourceOrder: /** @type {HarmonyImportDependency} */ (
|
887
|
-
.
|
883
|
+
sourceOrder: /** @type {HarmonyImportDependency} */ (
|
884
|
+
connection.dependency
|
885
|
+
).sourceOrder
|
888
886
|
}));
|
889
887
|
references.sort(
|
890
888
|
concatComparators(bySourceOrder, keepOriginalOrder(references))
|
@@ -1162,13 +1160,11 @@ class ConcatenatedModule extends Module {
|
|
1162
1160
|
true
|
1163
1161
|
);
|
1164
1162
|
if (!binding.ids) continue;
|
1165
|
-
const {
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
"name" in binding ? binding.name : ""
|
1171
|
-
);
|
1163
|
+
const { usedNames, alreadyCheckedScopes } =
|
1164
|
+
getUsedNamesInScopeInfo(
|
1165
|
+
binding.info.module.identifier(),
|
1166
|
+
"name" in binding ? binding.name : ""
|
1167
|
+
);
|
1172
1168
|
for (const expr of getSuperClassExpressions(reference.from)) {
|
1173
1169
|
if (
|
1174
1170
|
expr.range[0] <= reference.identifier.range[0] &&
|
@@ -1361,9 +1357,9 @@ class ConcatenatedModule extends Module {
|
|
1361
1357
|
/** @type {Set<string>} */
|
1362
1358
|
const unusedExports = new Set();
|
1363
1359
|
|
1364
|
-
const rootInfo = /** @type {ConcatenatedModuleInfo} */ (
|
1365
|
-
this.rootModule
|
1366
|
-
)
|
1360
|
+
const rootInfo = /** @type {ConcatenatedModuleInfo} */ (
|
1361
|
+
moduleToInfoMap.get(this.rootModule)
|
1362
|
+
);
|
1367
1363
|
const strictHarmonyModule = rootInfo.module.buildMeta.strictHarmonyModule;
|
1368
1364
|
const exportsInfo = moduleGraph.getExportsInfo(rootInfo.module);
|
1369
1365
|
for (const exportInfo of exportsInfo.orderedExports) {
|
@@ -1531,9 +1527,8 @@ ${defineGetters}`
|
|
1531
1527
|
)}\n`
|
1532
1528
|
);
|
1533
1529
|
runtimeRequirements.add(RuntimeGlobals.require);
|
1534
|
-
const {
|
1535
|
-
|
1536
|
-
} = /** @type {ExternalModuleInfo | ReferenceToModuleInfo} */ (rawInfo);
|
1530
|
+
const { runtimeCondition } =
|
1531
|
+
/** @type {ExternalModuleInfo | ReferenceToModuleInfo} */ (rawInfo);
|
1537
1532
|
const condition = runtimeTemplate.runtimeConditionExpression({
|
1538
1533
|
chunkGraph,
|
1539
1534
|
runtimeCondition,
|
@@ -68,9 +68,8 @@ class FlagIncludedChunksPlugin {
|
|
68
68
|
|
69
69
|
for (const chunkA of chunks) {
|
70
70
|
const chunkAHash = chunkModulesHash.get(chunkA);
|
71
|
-
const chunkAModulesCount =
|
72
|
-
chunkA
|
73
|
-
);
|
71
|
+
const chunkAModulesCount =
|
72
|
+
chunkGraph.getNumberOfChunkModules(chunkA);
|
74
73
|
if (chunkAModulesCount === 0) continue;
|
75
74
|
let bestModule = undefined;
|
76
75
|
for (const module of chunkGraph.getChunkModulesIterable(chunkA)) {
|
@@ -88,9 +87,8 @@ class FlagIncludedChunksPlugin {
|
|
88
87
|
// skip if we find ourselves
|
89
88
|
if (chunkA === chunkB) continue;
|
90
89
|
|
91
|
-
const chunkBModulesCount =
|
92
|
-
chunkB
|
93
|
-
);
|
90
|
+
const chunkBModulesCount =
|
91
|
+
chunkGraph.getNumberOfChunkModules(chunkB);
|
94
92
|
|
95
93
|
// ids for empty chunks are not included
|
96
94
|
if (chunkBModulesCount === 0) continue;
|
@@ -103,10 +103,9 @@ exports.addUsage = (state, symbol, usage) => {
|
|
103
103
|
*/
|
104
104
|
exports.addVariableUsage = (parser, name, usage) => {
|
105
105
|
const symbol =
|
106
|
-
/** @type {TopLevelSymbol} */ (
|
107
|
-
name,
|
108
|
-
|
109
|
-
)) || exports.tagTopLevelSymbol(parser, name);
|
106
|
+
/** @type {TopLevelSymbol} */ (
|
107
|
+
parser.getTagData(name, topLevelSymbolTag)
|
108
|
+
) || exports.tagTopLevelSymbol(parser, name);
|
110
109
|
if (symbol) {
|
111
110
|
exports.addUsage(parser.state, symbol, usage);
|
112
111
|
}
|
@@ -179,9 +178,9 @@ exports.inferDependencyUsage = state => {
|
|
179
178
|
|
180
179
|
/** @type {Map<Dependency, true | Set<string>>} */
|
181
180
|
for (const [symbol, callbacks] of usageCallbackMap) {
|
182
|
-
const usage = /** @type {true | Set<string> | undefined} */ (
|
183
|
-
symbol
|
184
|
-
)
|
181
|
+
const usage = /** @type {true | Set<string> | undefined} */ (
|
182
|
+
innerGraph.get(symbol)
|
183
|
+
);
|
185
184
|
for (const callback of callbacks) {
|
186
185
|
callback(usage === undefined ? false : usage);
|
187
186
|
}
|
@@ -249,10 +248,9 @@ exports.tagTopLevelSymbol = (parser, name) => {
|
|
249
248
|
|
250
249
|
parser.defineVariable(name);
|
251
250
|
|
252
|
-
const existingTag = /** @type {TopLevelSymbol} */ (
|
253
|
-
name,
|
254
|
-
|
255
|
-
));
|
251
|
+
const existingTag = /** @type {TopLevelSymbol} */ (
|
252
|
+
parser.getTagData(name, topLevelSymbolTag)
|
253
|
+
);
|
256
254
|
if (existingTag) {
|
257
255
|
return existingTag;
|
258
256
|
}
|
@@ -300,7 +300,9 @@ class InnerGraphPlugin {
|
|
300
300
|
parser.hooks.expression
|
301
301
|
.for(topLevelSymbolTag)
|
302
302
|
.tap("InnerGraphPlugin", () => {
|
303
|
-
const topLevelSymbol = /** @type {TopLevelSymbol} */ (
|
303
|
+
const topLevelSymbol = /** @type {TopLevelSymbol} */ (
|
304
|
+
parser.currentTagData
|
305
|
+
);
|
304
306
|
const currentTopLevelSymbol = InnerGraph.getTopLevelSymbol(
|
305
307
|
parser.state
|
306
308
|
);
|
@@ -316,9 +316,8 @@ class ModuleConcatenationPlugin {
|
|
316
316
|
}
|
317
317
|
} else {
|
318
318
|
statsEmptyConfigurations++;
|
319
|
-
const optimizationBailouts =
|
320
|
-
currentRoot
|
321
|
-
);
|
319
|
+
const optimizationBailouts =
|
320
|
+
moduleGraph.getOptimizationBailout(currentRoot);
|
322
321
|
for (const warning of currentConfiguration.getWarningsSorted()) {
|
323
322
|
optimizationBailouts.push(
|
324
323
|
formatBailoutWarning(warning[0], warning[1])
|
@@ -574,20 +573,18 @@ class ModuleConcatenationPlugin {
|
|
574
573
|
|
575
574
|
const moduleGraph = compilation.moduleGraph;
|
576
575
|
|
577
|
-
const incomingConnections =
|
578
|
-
module
|
579
|
-
);
|
576
|
+
const incomingConnections =
|
577
|
+
moduleGraph.getIncomingConnectionsByOriginModule(module);
|
580
578
|
|
581
579
|
const incomingConnectionsFromNonModules =
|
582
580
|
incomingConnections.get(null) || incomingConnections.get(undefined);
|
583
581
|
if (incomingConnectionsFromNonModules) {
|
584
|
-
const activeNonModulesConnections =
|
585
|
-
connection => {
|
582
|
+
const activeNonModulesConnections =
|
583
|
+
incomingConnectionsFromNonModules.filter(connection => {
|
586
584
|
// We are not interested in inactive connections
|
587
585
|
// or connections without dependency
|
588
586
|
return connection.isActive(runtime) || connection.dependency;
|
589
|
-
}
|
590
|
-
);
|
587
|
+
});
|
591
588
|
if (activeNonModulesConnections.length > 0) {
|
592
589
|
const problem = requestShortener => {
|
593
590
|
const importingExplanations = new Set(
|
@@ -194,24 +194,22 @@ class RealContentHashPlugin {
|
|
194
194
|
cacheAnalyse.getLazyHashedEtag(source),
|
195
195
|
Array.from(hashes).join("|")
|
196
196
|
);
|
197
|
-
[
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
197
|
+
[asset.referencedHashes, asset.ownHashes] =
|
198
|
+
await cacheAnalyse.providePromise(name, etag, () => {
|
199
|
+
const referencedHashes = new Set();
|
200
|
+
let ownHashes = new Set();
|
201
|
+
const inContent = content.match(hashRegExp);
|
202
|
+
if (inContent) {
|
203
|
+
for (const hash of inContent) {
|
204
|
+
if (hashes.has(hash)) {
|
205
|
+
ownHashes.add(hash);
|
206
|
+
continue;
|
207
|
+
}
|
208
|
+
referencedHashes.add(hash);
|
209
209
|
}
|
210
|
-
referencedHashes.add(hash);
|
211
210
|
}
|
212
|
-
|
213
|
-
|
214
|
-
});
|
211
|
+
return [referencedHashes, ownHashes];
|
212
|
+
});
|
215
213
|
})
|
216
214
|
);
|
217
215
|
const getDependencies = hash => {
|
@@ -86,11 +86,12 @@ class SideEffectsFlagPlugin {
|
|
86
86
|
if (module.factoryMeta === undefined) {
|
87
87
|
module.factoryMeta = {};
|
88
88
|
}
|
89
|
-
const hasSideEffects =
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
const hasSideEffects =
|
90
|
+
SideEffectsFlagPlugin.moduleHasSideEffects(
|
91
|
+
resolveData.relativePath,
|
92
|
+
sideEffects,
|
93
|
+
cache
|
94
|
+
);
|
94
95
|
module.factoryMeta.sideEffectFree = !hasSideEffects;
|
95
96
|
}
|
96
97
|
}
|
@@ -162,7 +162,10 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
162
162
|
|
163
163
|
const defaultGetName = /** @type {GetName} */ (() => {});
|
164
164
|
|
165
|
-
const deterministicGroupingForModules =
|
165
|
+
const deterministicGroupingForModules =
|
166
|
+
/** @type {function(DeterministicGroupingOptionsForModule): DeterministicGroupingGroupedItemsForModule[]} */ (
|
167
|
+
deterministicGrouping
|
168
|
+
);
|
166
169
|
|
167
170
|
/** @type {WeakMap<Module, string>} */
|
168
171
|
const getKeyCache = new WeakMap();
|
@@ -173,9 +176,11 @@ const getKeyCache = new WeakMap();
|
|
173
176
|
* @returns {string} hashed filename
|
174
177
|
*/
|
175
178
|
const hashFilename = (name, outputOptions) => {
|
176
|
-
const digest = /** @type {string} */ (
|
177
|
-
.
|
178
|
-
|
179
|
+
const digest = /** @type {string} */ (
|
180
|
+
createHash(outputOptions.hashFunction)
|
181
|
+
.update(name)
|
182
|
+
.digest(outputOptions.hashDigest)
|
183
|
+
);
|
179
184
|
return digest.slice(0, 8);
|
180
185
|
};
|
181
186
|
|
@@ -939,10 +944,8 @@ module.exports = class SplitChunksPlugin {
|
|
939
944
|
const getCombinations = key => getCombinationsFactory()(key);
|
940
945
|
|
941
946
|
const getExportsCombinationsFactory = memoize(() => {
|
942
|
-
const {
|
943
|
-
|
944
|
-
singleChunkSets
|
945
|
-
} = getExportsChunkSetsInGraph();
|
947
|
+
const { chunkSetsInGraph, singleChunkSets } =
|
948
|
+
getExportsChunkSetsInGraph();
|
946
949
|
return createGetCombinations(
|
947
950
|
chunkSetsInGraph,
|
948
951
|
singleChunkSets,
|
@@ -1182,13 +1185,8 @@ module.exports = class SplitChunksPlugin {
|
|
1182
1185
|
chunkCombination instanceof Chunk ? 1 : chunkCombination.size;
|
1183
1186
|
if (count < cacheGroup.minChunks) continue;
|
1184
1187
|
// Select chunks by configuration
|
1185
|
-
const {
|
1186
|
-
|
1187
|
-
key: selectedChunksKey
|
1188
|
-
} = getSelectedChunks(
|
1189
|
-
chunkCombination,
|
1190
|
-
cacheGroup.chunksFilter
|
1191
|
-
);
|
1188
|
+
const { chunks: selectedChunks, key: selectedChunksKey } =
|
1189
|
+
getSelectedChunks(chunkCombination, cacheGroup.chunksFilter);
|
1192
1190
|
|
1193
1191
|
addModuleToChunksInfoMap(
|
1194
1192
|
cacheGroup,
|
@@ -26,14 +26,15 @@ class EnsureChunkRuntimeModule extends RuntimeModule {
|
|
26
26
|
`${handlers} = {};`,
|
27
27
|
"// This file contains only the entry chunk.",
|
28
28
|
"// The chunk loading function for additional chunks",
|
29
|
-
`${
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
`${RuntimeGlobals.ensureChunk} = ${runtimeTemplate.basicFunction(
|
30
|
+
"chunkId",
|
31
|
+
[
|
32
|
+
`return Promise.all(Object.keys(${handlers}).reduce(${runtimeTemplate.basicFunction(
|
33
|
+
"promises, key",
|
34
|
+
[`${handlers}[key](chunkId, promises);`, "return promises;"]
|
35
|
+
)}, []));`
|
36
|
+
]
|
37
|
+
)};`
|
37
38
|
]);
|
38
39
|
} else {
|
39
40
|
// There ensureChunk is used somewhere in the tree, so we need an empty requireEnsure
|
@@ -65,9 +65,8 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
|
|
65
65
|
} = outputOptions;
|
66
66
|
const fn = RuntimeGlobals.loadScript;
|
67
67
|
|
68
|
-
const { createScript } =
|
69
|
-
compilation
|
70
|
-
);
|
68
|
+
const { createScript } =
|
69
|
+
LoadScriptRuntimeModule.getCompilationHooks(compilation);
|
71
70
|
|
72
71
|
const code = Template.asString([
|
73
72
|
"script = document.createElement('script');",
|