webpack 5.101.1 → 5.101.3
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.
- package/lib/ChunkGraph.js +14 -2
- package/lib/Compilation.js +3 -25
- package/lib/ConstPlugin.js +12 -5
- package/lib/DefinePlugin.js +14 -0
- package/lib/Entrypoint.js +19 -0
- package/lib/GraphHelpers.js +11 -0
- package/lib/JavascriptMetaInfoPlugin.js +1 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +18 -1
- package/lib/dependencies/ImportMetaPlugin.js +6 -0
- package/lib/dependencies/ImportParserPlugin.js +6 -0
- package/lib/javascript/JavascriptParser.js +201 -94
- package/lib/library/ModuleLibraryPlugin.js +2 -3
- package/lib/optimize/ConcatenatedModule.js +1 -0
- package/lib/optimize/InnerGraph.js +7 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +2 -6
- package/package.json +2 -2
- package/types.d.ts +105 -11
package/lib/ChunkGraph.js
CHANGED
|
@@ -1242,7 +1242,7 @@ class ChunkGraph {
|
|
|
1242
1242
|
* @param {Chunk} chunk the chunk
|
|
1243
1243
|
* @returns {Iterable<Chunk>} iterable of chunks and include chunks from children entrypoints
|
|
1244
1244
|
*/
|
|
1245
|
-
|
|
1245
|
+
getRuntimeChunkDependentChunksIterable(chunk) {
|
|
1246
1246
|
/** @type {Set<Chunk>} */
|
|
1247
1247
|
const set = new Set();
|
|
1248
1248
|
|
|
@@ -1259,7 +1259,7 @@ class ChunkGraph {
|
|
|
1259
1259
|
|
|
1260
1260
|
let hasChildrenEntrypoint = false;
|
|
1261
1261
|
for (const child of current.childrenIterable) {
|
|
1262
|
-
if (child.
|
|
1262
|
+
if (child instanceof Entrypoint && child.dependOn(current)) {
|
|
1263
1263
|
hasChildrenEntrypoint = true;
|
|
1264
1264
|
queue.push(/** @type {Entrypoint} */ (child));
|
|
1265
1265
|
}
|
|
@@ -1277,6 +1277,18 @@ class ChunkGraph {
|
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
1279
|
}
|
|
1280
|
+
|
|
1281
|
+
for (const entrypoint of entrypoints) {
|
|
1282
|
+
const entrypointChunk = entrypoint.getEntrypointChunk();
|
|
1283
|
+
const cgc = this._getChunkGraphChunk(entrypointChunk);
|
|
1284
|
+
for (const chunkGroup of cgc.entryModules.values()) {
|
|
1285
|
+
for (const c of chunkGroup.chunks) {
|
|
1286
|
+
if (c !== chunk && c !== entrypointChunk && !c.hasRuntime()) {
|
|
1287
|
+
set.add(c);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1280
1292
|
return set;
|
|
1281
1293
|
}
|
|
1282
1294
|
|
package/lib/Compilation.js
CHANGED
|
@@ -32,7 +32,8 @@ const ErrorHelpers = require("./ErrorHelpers");
|
|
|
32
32
|
const FileSystemInfo = require("./FileSystemInfo");
|
|
33
33
|
const {
|
|
34
34
|
connectChunkGroupAndChunk,
|
|
35
|
-
connectChunkGroupParentAndChild
|
|
35
|
+
connectChunkGroupParentAndChild,
|
|
36
|
+
connectEntrypointAndDependOn
|
|
36
37
|
} = require("./GraphHelpers");
|
|
37
38
|
const {
|
|
38
39
|
makeWebpackError,
|
|
@@ -3207,7 +3208,6 @@ Remove the 'runtime' option from the entrypoint.`);
|
|
|
3207
3208
|
const referencedChunks = entry
|
|
3208
3209
|
.getEntrypointChunk()
|
|
3209
3210
|
.getAllReferencedChunks();
|
|
3210
|
-
const dependOnEntries = [];
|
|
3211
3211
|
for (const dep of dependOn) {
|
|
3212
3212
|
const dependency = this.entrypoints.get(dep);
|
|
3213
3213
|
if (!dependency) {
|
|
@@ -3225,9 +3225,7 @@ Remove the 'runtime' option from the entrypoint.`);
|
|
|
3225
3225
|
entry.setRuntimeChunk(entryChunk);
|
|
3226
3226
|
continue outer;
|
|
3227
3227
|
}
|
|
3228
|
-
|
|
3229
|
-
}
|
|
3230
|
-
for (const dependency of dependOnEntries) {
|
|
3228
|
+
connectEntrypointAndDependOn(entry, dependency);
|
|
3231
3229
|
connectChunkGroupParentAndChild(dependency, entry);
|
|
3232
3230
|
}
|
|
3233
3231
|
} else if (runtime) {
|
|
@@ -3278,26 +3276,6 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
3278
3276
|
}
|
|
3279
3277
|
this.hooks.afterOptimizeChunks.call(this.chunks, this.chunkGroups);
|
|
3280
3278
|
|
|
3281
|
-
for (const [
|
|
3282
|
-
name,
|
|
3283
|
-
{
|
|
3284
|
-
options: { dependOn }
|
|
3285
|
-
}
|
|
3286
|
-
] of this.entries) {
|
|
3287
|
-
if (dependOn) {
|
|
3288
|
-
const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
|
|
3289
|
-
for (const dep of dependOn) {
|
|
3290
|
-
const depEntry = /** @type {Entrypoint} */ (
|
|
3291
|
-
this.entrypoints.get(dep)
|
|
3292
|
-
);
|
|
3293
|
-
const runtimeChunk = depEntry.getRuntimeChunk();
|
|
3294
|
-
if (runtimeChunk) {
|
|
3295
|
-
runtimeChunk.addGroup(entry);
|
|
3296
|
-
}
|
|
3297
|
-
}
|
|
3298
|
-
}
|
|
3299
|
-
}
|
|
3300
|
-
|
|
3301
3279
|
this.hooks.optimizeTree.callAsync(this.chunks, this.modules, (err) => {
|
|
3302
3280
|
if (err) {
|
|
3303
3281
|
return finalCallback(
|
package/lib/ConstPlugin.js
CHANGED
|
@@ -180,7 +180,7 @@ class ConstPlugin {
|
|
|
180
180
|
? statement.alternate
|
|
181
181
|
: statement.consequent;
|
|
182
182
|
if (branchToRemove) {
|
|
183
|
-
this.eliminateUnusedStatement(parser, branchToRemove);
|
|
183
|
+
this.eliminateUnusedStatement(parser, branchToRemove, true);
|
|
184
184
|
}
|
|
185
185
|
return bool;
|
|
186
186
|
}
|
|
@@ -193,7 +193,7 @@ class ConstPlugin {
|
|
|
193
193
|
) {
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
|
-
this.eliminateUnusedStatement(parser, statement);
|
|
196
|
+
this.eliminateUnusedStatement(parser, statement, false);
|
|
197
197
|
return true;
|
|
198
198
|
});
|
|
199
199
|
parser.hooks.expressionConditionalOperator.tap(
|
|
@@ -509,9 +509,10 @@ class ConstPlugin {
|
|
|
509
509
|
* Eliminate an unused statement.
|
|
510
510
|
* @param {JavascriptParser} parser the parser
|
|
511
511
|
* @param {Statement} statement the statement to remove
|
|
512
|
+
* @param {boolean} alwaysInBlock whether to always generate curly brackets
|
|
512
513
|
* @returns {void}
|
|
513
514
|
*/
|
|
514
|
-
eliminateUnusedStatement(parser, statement) {
|
|
515
|
+
eliminateUnusedStatement(parser, statement, alwaysInBlock) {
|
|
515
516
|
// Before removing the unused branch, the hoisted declarations
|
|
516
517
|
// must be collected.
|
|
517
518
|
//
|
|
@@ -545,8 +546,14 @@ class ConstPlugin {
|
|
|
545
546
|
const declarations = parser.scope.isStrict
|
|
546
547
|
? getHoistedDeclarations(statement, false)
|
|
547
548
|
: getHoistedDeclarations(statement, true);
|
|
548
|
-
|
|
549
|
-
|
|
549
|
+
|
|
550
|
+
const inBlock = alwaysInBlock || statement.type === "BlockStatement";
|
|
551
|
+
|
|
552
|
+
let replacement = inBlock ? "{" : "";
|
|
553
|
+
replacement +=
|
|
554
|
+
declarations.length > 0 ? ` var ${declarations.join(", ")}; ` : "";
|
|
555
|
+
replacement += inBlock ? "}" : "";
|
|
556
|
+
|
|
550
557
|
const dep = new ConstDependency(
|
|
551
558
|
`// removed by dead control flow\n${replacement}`,
|
|
552
559
|
/** @type {Range} */ (statement.range)
|
package/lib/DefinePlugin.js
CHANGED
|
@@ -489,6 +489,13 @@ class DefinePlugin {
|
|
|
489
489
|
if (nested && !hooked.has(nested)) {
|
|
490
490
|
// only detect the same nested key once
|
|
491
491
|
hooked.add(nested);
|
|
492
|
+
parser.hooks.collectDestructuringAssignmentProperties.tap(
|
|
493
|
+
PLUGIN_NAME,
|
|
494
|
+
(expr) => {
|
|
495
|
+
const nameInfo = parser.getNameForExpression(expr);
|
|
496
|
+
if (nameInfo && nameInfo.name === nested) return true;
|
|
497
|
+
}
|
|
498
|
+
);
|
|
492
499
|
parser.hooks.expression.for(nested).tap(
|
|
493
500
|
{
|
|
494
501
|
name: PLUGIN_NAME,
|
|
@@ -687,6 +694,13 @@ class DefinePlugin {
|
|
|
687
694
|
PLUGIN_NAME,
|
|
688
695
|
withValueDependency(key, evaluateToString("object"))
|
|
689
696
|
);
|
|
697
|
+
parser.hooks.collectDestructuringAssignmentProperties.tap(
|
|
698
|
+
PLUGIN_NAME,
|
|
699
|
+
(expr) => {
|
|
700
|
+
const nameInfo = parser.getNameForExpression(expr);
|
|
701
|
+
if (nameInfo && nameInfo.name === key) return true;
|
|
702
|
+
}
|
|
703
|
+
);
|
|
690
704
|
parser.hooks.expression.for(key).tap(PLUGIN_NAME, (expr) => {
|
|
691
705
|
addValueDependency(key);
|
|
692
706
|
let strCode = stringifyObj(
|
package/lib/Entrypoint.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const ChunkGroup = require("./ChunkGroup");
|
|
9
|
+
const SortableSet = require("./util/SortableSet");
|
|
9
10
|
|
|
10
11
|
/** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescription */
|
|
11
12
|
/** @typedef {import("./Chunk")} Chunk */
|
|
@@ -38,6 +39,8 @@ class Entrypoint extends ChunkGroup {
|
|
|
38
39
|
this._entrypointChunk = undefined;
|
|
39
40
|
/** @type {boolean} */
|
|
40
41
|
this._initial = initial;
|
|
42
|
+
/** @type {SortableSet<Entrypoint>} */
|
|
43
|
+
this._dependOn = new SortableSet();
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
/**
|
|
@@ -96,6 +99,22 @@ class Entrypoint extends ChunkGroup {
|
|
|
96
99
|
if (this._entrypointChunk === oldChunk) this._entrypointChunk = newChunk;
|
|
97
100
|
return super.replaceChunk(oldChunk, newChunk);
|
|
98
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {Entrypoint} entrypoint the entrypoint
|
|
105
|
+
* @returns {void}
|
|
106
|
+
*/
|
|
107
|
+
addDependOn(entrypoint) {
|
|
108
|
+
this._dependOn.add(entrypoint);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {Entrypoint} entrypoint the entrypoint
|
|
113
|
+
* @returns {boolean} true if the entrypoint is in the dependOn set
|
|
114
|
+
*/
|
|
115
|
+
dependOn(entrypoint) {
|
|
116
|
+
return this._dependOn.has(entrypoint);
|
|
117
|
+
}
|
|
99
118
|
}
|
|
100
119
|
|
|
101
120
|
module.exports = Entrypoint;
|
package/lib/GraphHelpers.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
11
11
|
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
|
12
12
|
/** @typedef {import("./Module")} Module */
|
|
13
|
+
/** @typedef {import(".").Entrypoint} Entrypoint */
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @param {ChunkGroup} chunkGroup the ChunkGroup to connect
|
|
@@ -33,6 +34,16 @@ const connectChunkGroupParentAndChild = (parent, child) => {
|
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @param {Entrypoint} entrypoint the entrypoint
|
|
39
|
+
* @param {Entrypoint} dependOnEntrypoint the dependOnEntrypoint
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
42
|
+
const connectEntrypointAndDependOn = (entrypoint, dependOnEntrypoint) => {
|
|
43
|
+
entrypoint.addDependOn(dependOnEntrypoint);
|
|
44
|
+
};
|
|
45
|
+
|
|
36
46
|
module.exports.connectChunkGroupAndChunk = connectChunkGroupAndChunk;
|
|
37
47
|
module.exports.connectChunkGroupParentAndChild =
|
|
38
48
|
connectChunkGroupParentAndChild;
|
|
49
|
+
module.exports.connectEntrypointAndDependOn = connectEntrypointAndDependOn;
|
|
@@ -54,8 +54,7 @@ class JavascriptMetaInfoPlugin {
|
|
|
54
54
|
topLevelDeclarations = buildInfo.topLevelDeclarations = new Set();
|
|
55
55
|
}
|
|
56
56
|
for (const name of parser.scope.definitions.asSet()) {
|
|
57
|
-
|
|
58
|
-
if (freeInfo === undefined) {
|
|
57
|
+
if (parser.isVariableDefined(name)) {
|
|
59
58
|
topLevelDeclarations.add(name);
|
|
60
59
|
}
|
|
61
60
|
}
|
|
@@ -62,9 +62,12 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
62
62
|
this.dependencies.size === 1 ||
|
|
63
63
|
!runtimeTemplate.supportsDestructuring()
|
|
64
64
|
) {
|
|
65
|
+
templateInput.push(
|
|
66
|
+
"var __webpack_async_dependencies_result__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);"
|
|
67
|
+
);
|
|
65
68
|
for (const [index, importVar] of importVars.entries()) {
|
|
66
69
|
templateInput.push(
|
|
67
|
-
`${importVar} =
|
|
70
|
+
`${importVar} = __webpack_async_dependencies_result__[${index}];`
|
|
68
71
|
);
|
|
69
72
|
}
|
|
70
73
|
} else {
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
const CommentCompilationWarning = require("../CommentCompilationWarning");
|
|
9
9
|
const HotModuleReplacementPlugin = require("../HotModuleReplacementPlugin");
|
|
10
10
|
const WebpackError = require("../WebpackError");
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
VariableInfo,
|
|
13
|
+
getImportAttributes
|
|
14
|
+
} = require("../javascript/JavascriptParser");
|
|
12
15
|
const InnerGraph = require("../optimize/InnerGraph");
|
|
13
16
|
const ConstDependency = require("./ConstDependency");
|
|
14
17
|
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
|
|
@@ -211,6 +214,20 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
|
211
214
|
InnerGraph.onUsage(parser.state, (e) => (dep.usedByExports = e));
|
|
212
215
|
return true;
|
|
213
216
|
});
|
|
217
|
+
parser.hooks.collectDestructuringAssignmentProperties.tap(
|
|
218
|
+
PLUGIN_NAME,
|
|
219
|
+
(expr) => {
|
|
220
|
+
const nameInfo = parser.getNameForExpression(expr);
|
|
221
|
+
if (
|
|
222
|
+
nameInfo &&
|
|
223
|
+
nameInfo.rootInfo instanceof VariableInfo &&
|
|
224
|
+
nameInfo.rootInfo.name &&
|
|
225
|
+
parser.getTagData(nameInfo.rootInfo.name, harmonySpecifierTag)
|
|
226
|
+
) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
);
|
|
214
231
|
parser.hooks.expression
|
|
215
232
|
.for(harmonySpecifierTag)
|
|
216
233
|
.tap(PLUGIN_NAME, (expr) => {
|
|
@@ -96,6 +96,12 @@ class ImportMetaPlugin {
|
|
|
96
96
|
PLUGIN_NAME,
|
|
97
97
|
toConstantDependency(parser, JSON.stringify("object"))
|
|
98
98
|
);
|
|
99
|
+
parser.hooks.collectDestructuringAssignmentProperties.tap(
|
|
100
|
+
PLUGIN_NAME,
|
|
101
|
+
(expr) => {
|
|
102
|
+
if (expr.type === "MetaProperty") return true;
|
|
103
|
+
}
|
|
104
|
+
);
|
|
99
105
|
parser.hooks.expression
|
|
100
106
|
.for("import.meta")
|
|
101
107
|
.tap(PLUGIN_NAME, (metaProperty) => {
|
|
@@ -46,6 +46,12 @@ class ImportParserPlugin {
|
|
|
46
46
|
*/
|
|
47
47
|
const exportsFromEnumerable = (enumerable) =>
|
|
48
48
|
Array.from(enumerable, (e) => [e]);
|
|
49
|
+
parser.hooks.collectDestructuringAssignmentProperties.tap(
|
|
50
|
+
PLUGIN_NAME,
|
|
51
|
+
(expr) => {
|
|
52
|
+
if (expr.type === "ImportExpression") return true;
|
|
53
|
+
}
|
|
54
|
+
);
|
|
49
55
|
parser.hooks.importCall.tap(PLUGIN_NAME, (expr) => {
|
|
50
56
|
const param = parser.evaluateExpression(expr.source);
|
|
51
57
|
|
|
@@ -258,17 +258,42 @@ const getImportAttributes = (node) => {
|
|
|
258
258
|
return result;
|
|
259
259
|
};
|
|
260
260
|
|
|
261
|
+
/** @typedef {typeof VariableInfoFlags.Evaluated | typeof VariableInfoFlags.Free | typeof VariableInfoFlags.Normal | typeof VariableInfoFlags.Tagged} VariableInfoFlagsType */
|
|
262
|
+
|
|
263
|
+
const VariableInfoFlags = Object.freeze({
|
|
264
|
+
Evaluated: 0b000,
|
|
265
|
+
Free: 0b001,
|
|
266
|
+
Normal: 0b010,
|
|
267
|
+
Tagged: 0b100
|
|
268
|
+
});
|
|
269
|
+
|
|
261
270
|
class VariableInfo {
|
|
262
271
|
/**
|
|
263
272
|
* @param {ScopeInfo} declaredScope scope in which the variable is declared
|
|
264
|
-
* @param {string |
|
|
273
|
+
* @param {string | undefined} name which name the variable use, defined name or free name or tagged name
|
|
274
|
+
* @param {VariableInfoFlagsType} flags how the variable is created
|
|
265
275
|
* @param {TagInfo | undefined} tagInfo info about tags
|
|
266
276
|
*/
|
|
267
|
-
constructor(declaredScope,
|
|
277
|
+
constructor(declaredScope, name, flags, tagInfo) {
|
|
268
278
|
this.declaredScope = declaredScope;
|
|
269
|
-
this.
|
|
279
|
+
this.name = name;
|
|
280
|
+
this.flags = flags;
|
|
270
281
|
this.tagInfo = tagInfo;
|
|
271
282
|
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @returns {boolean} the variable is free or not
|
|
286
|
+
*/
|
|
287
|
+
isFree() {
|
|
288
|
+
return (this.flags & VariableInfoFlags.Free) > 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @returns {boolean} the variable is tagged by tagVariable or not
|
|
293
|
+
*/
|
|
294
|
+
isTagged() {
|
|
295
|
+
return (this.flags & VariableInfoFlags.Tagged) > 0;
|
|
296
|
+
}
|
|
272
297
|
}
|
|
273
298
|
|
|
274
299
|
/** @typedef {string | ScopeInfo | VariableInfo} ExportedVariableInfo */
|
|
@@ -497,6 +522,10 @@ class JavascriptParser extends Parser {
|
|
|
497
522
|
varDeclarationVar: new HookMap(() => new SyncBailHook(["declaration"])),
|
|
498
523
|
/** @type {HookMap<SyncBailHook<[Identifier], boolean | void>>} */
|
|
499
524
|
pattern: new HookMap(() => new SyncBailHook(["pattern"])),
|
|
525
|
+
/** @type {SyncBailHook<[Expression], boolean | void>} */
|
|
526
|
+
collectDestructuringAssignmentProperties: new SyncBailHook([
|
|
527
|
+
"expression"
|
|
528
|
+
]),
|
|
500
529
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
501
530
|
canRename: new HookMap(() => new SyncBailHook(["initExpression"])),
|
|
502
531
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
@@ -1426,7 +1455,7 @@ class JavascriptParser extends Parser {
|
|
|
1426
1455
|
const info = this.getVariableInfo(/** @type {Identifier} */ (expr).name);
|
|
1427
1456
|
if (
|
|
1428
1457
|
typeof info === "string" ||
|
|
1429
|
-
(info instanceof VariableInfo &&
|
|
1458
|
+
(info instanceof VariableInfo && (info.isFree() || info.isTagged()))
|
|
1430
1459
|
) {
|
|
1431
1460
|
return {
|
|
1432
1461
|
name: info,
|
|
@@ -1441,7 +1470,7 @@ class JavascriptParser extends Parser {
|
|
|
1441
1470
|
const info = this.getVariableInfo("this");
|
|
1442
1471
|
if (
|
|
1443
1472
|
typeof info === "string" ||
|
|
1444
|
-
(info instanceof VariableInfo &&
|
|
1473
|
+
(info instanceof VariableInfo && (info.isFree() || info.isTagged()))
|
|
1445
1474
|
) {
|
|
1446
1475
|
return {
|
|
1447
1476
|
name: info,
|
|
@@ -1930,6 +1959,32 @@ class JavascriptParser extends Parser {
|
|
|
1930
1959
|
}
|
|
1931
1960
|
}
|
|
1932
1961
|
|
|
1962
|
+
/**
|
|
1963
|
+
* Module pre walking iterates the scope for import entries
|
|
1964
|
+
* @param {(Statement | ModuleDeclaration)[]} statements statements
|
|
1965
|
+
*/
|
|
1966
|
+
modulePreWalkStatements(statements) {
|
|
1967
|
+
for (let index = 0, len = statements.length; index < len; index++) {
|
|
1968
|
+
const statement = statements[index];
|
|
1969
|
+
/** @type {StatementPath} */
|
|
1970
|
+
(this.statementPath).push(statement);
|
|
1971
|
+
switch (statement.type) {
|
|
1972
|
+
case "ImportDeclaration":
|
|
1973
|
+
this.modulePreWalkImportDeclaration(statement);
|
|
1974
|
+
break;
|
|
1975
|
+
case "ExportAllDeclaration":
|
|
1976
|
+
this.modulePreWalkExportAllDeclaration(statement);
|
|
1977
|
+
break;
|
|
1978
|
+
case "ExportNamedDeclaration":
|
|
1979
|
+
this.modulePreWalkExportNamedDeclaration(statement);
|
|
1980
|
+
break;
|
|
1981
|
+
}
|
|
1982
|
+
this.prevStatement =
|
|
1983
|
+
/** @type {StatementPath} */
|
|
1984
|
+
(this.statementPath).pop();
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1933
1988
|
/**
|
|
1934
1989
|
* Pre walking iterates the scope for variable declarations
|
|
1935
1990
|
* @param {(Statement | ModuleDeclaration)[]} statements statements
|
|
@@ -2050,12 +2105,6 @@ class JavascriptParser extends Parser {
|
|
|
2050
2105
|
return;
|
|
2051
2106
|
}
|
|
2052
2107
|
switch (statement.type) {
|
|
2053
|
-
case "ImportDeclaration":
|
|
2054
|
-
this.blockPreWalkImportDeclaration(statement);
|
|
2055
|
-
break;
|
|
2056
|
-
case "ExportAllDeclaration":
|
|
2057
|
-
this.blockPreWalkExportAllDeclaration(statement);
|
|
2058
|
-
break;
|
|
2059
2108
|
case "ExportDefaultDeclaration":
|
|
2060
2109
|
this.blockPreWalkExportDefaultDeclaration(statement);
|
|
2061
2110
|
break;
|
|
@@ -2562,40 +2611,54 @@ class JavascriptParser extends Parser {
|
|
|
2562
2611
|
* @param {AssignmentExpression} expression assignment expression
|
|
2563
2612
|
*/
|
|
2564
2613
|
preWalkAssignmentExpression(expression) {
|
|
2614
|
+
this.enterDestructuringAssignment(expression.left, expression.right);
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
/**
|
|
2618
|
+
* @param {Pattern} pattern pattern
|
|
2619
|
+
* @param {Expression} expression assignment expression
|
|
2620
|
+
* @returns {Expression | undefined} destructuring expression
|
|
2621
|
+
*/
|
|
2622
|
+
enterDestructuringAssignment(pattern, expression) {
|
|
2565
2623
|
if (
|
|
2566
|
-
|
|
2624
|
+
pattern.type !== "ObjectPattern" ||
|
|
2567
2625
|
!this.destructuringAssignmentProperties
|
|
2568
2626
|
) {
|
|
2569
2627
|
return;
|
|
2570
2628
|
}
|
|
2571
|
-
const keys = this._preWalkObjectPattern(expression.left);
|
|
2572
|
-
if (!keys) return;
|
|
2573
|
-
|
|
2574
|
-
// check multiple assignments
|
|
2575
|
-
if (this.destructuringAssignmentProperties.has(expression)) {
|
|
2576
|
-
const set =
|
|
2577
|
-
/** @type {Set<DestructuringAssignmentProperty>} */
|
|
2578
|
-
(this.destructuringAssignmentProperties.get(expression));
|
|
2579
|
-
this.destructuringAssignmentProperties.delete(expression);
|
|
2580
|
-
for (const id of set) keys.add(id);
|
|
2581
|
-
}
|
|
2582
2629
|
|
|
2583
|
-
|
|
2584
|
-
expression.
|
|
2585
|
-
? expression.right.argument
|
|
2586
|
-
: expression.right,
|
|
2587
|
-
keys
|
|
2588
|
-
);
|
|
2630
|
+
const expr =
|
|
2631
|
+
expression.type === "AwaitExpression" ? expression.argument : expression;
|
|
2589
2632
|
|
|
2590
|
-
|
|
2591
|
-
|
|
2633
|
+
const destructuring =
|
|
2634
|
+
expr.type === "AssignmentExpression"
|
|
2635
|
+
? this.enterDestructuringAssignment(expr.left, expr.right)
|
|
2636
|
+
: this.hooks.collectDestructuringAssignmentProperties.call(expr)
|
|
2637
|
+
? expr
|
|
2638
|
+
: undefined;
|
|
2639
|
+
|
|
2640
|
+
if (destructuring) {
|
|
2641
|
+
const keys = this._preWalkObjectPattern(pattern);
|
|
2642
|
+
if (!keys) return;
|
|
2643
|
+
|
|
2644
|
+
// check multiple assignments
|
|
2645
|
+
if (this.destructuringAssignmentProperties.has(destructuring)) {
|
|
2646
|
+
const set =
|
|
2647
|
+
/** @type {Set<DestructuringAssignmentProperty>} */
|
|
2648
|
+
(this.destructuringAssignmentProperties.get(destructuring));
|
|
2649
|
+
for (const id of keys) set.add(id);
|
|
2650
|
+
} else {
|
|
2651
|
+
this.destructuringAssignmentProperties.set(destructuring, keys);
|
|
2652
|
+
}
|
|
2592
2653
|
}
|
|
2654
|
+
|
|
2655
|
+
return destructuring;
|
|
2593
2656
|
}
|
|
2594
2657
|
|
|
2595
2658
|
/**
|
|
2596
2659
|
* @param {ImportDeclaration} statement statement
|
|
2597
2660
|
*/
|
|
2598
|
-
|
|
2661
|
+
modulePreWalkImportDeclaration(statement) {
|
|
2599
2662
|
const source = /** @type {ImportSource} */ (statement.source.value);
|
|
2600
2663
|
this.hooks.import.call(statement, source);
|
|
2601
2664
|
for (const specifier of statement.specifiers) {
|
|
@@ -2665,14 +2728,49 @@ class JavascriptParser extends Parser {
|
|
|
2665
2728
|
/**
|
|
2666
2729
|
* @param {ExportNamedDeclaration} statement statement
|
|
2667
2730
|
*/
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2731
|
+
modulePreWalkExportNamedDeclaration(statement) {
|
|
2732
|
+
if (!statement.source) return;
|
|
2733
|
+
const source = /** @type {ImportSource} */ (statement.source.value);
|
|
2734
|
+
this.hooks.exportImport.call(statement, source);
|
|
2735
|
+
if (statement.specifiers) {
|
|
2736
|
+
for (
|
|
2737
|
+
let specifierIndex = 0;
|
|
2738
|
+
specifierIndex < statement.specifiers.length;
|
|
2739
|
+
specifierIndex++
|
|
2740
|
+
) {
|
|
2741
|
+
const specifier = statement.specifiers[specifierIndex];
|
|
2742
|
+
switch (specifier.type) {
|
|
2743
|
+
case "ExportSpecifier": {
|
|
2744
|
+
const localName =
|
|
2745
|
+
/** @type {Identifier} */ (specifier.local).name ||
|
|
2746
|
+
/** @type {string} */ (
|
|
2747
|
+
/** @type {Literal} */ (specifier.local).value
|
|
2748
|
+
);
|
|
2749
|
+
const name =
|
|
2750
|
+
/** @type {Identifier} */
|
|
2751
|
+
(specifier.exported).name ||
|
|
2752
|
+
/** @type {string} */
|
|
2753
|
+
(/** @type {Literal} */ (specifier.exported).value);
|
|
2754
|
+
this.hooks.exportImportSpecifier.call(
|
|
2755
|
+
statement,
|
|
2756
|
+
source,
|
|
2757
|
+
localName,
|
|
2758
|
+
name,
|
|
2759
|
+
specifierIndex
|
|
2760
|
+
);
|
|
2761
|
+
break;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2675
2765
|
}
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
/**
|
|
2769
|
+
* @param {ExportNamedDeclaration} statement statement
|
|
2770
|
+
*/
|
|
2771
|
+
blockPreWalkExportNamedDeclaration(statement) {
|
|
2772
|
+
if (statement.source) return;
|
|
2773
|
+
this.hooks.export.call(statement);
|
|
2676
2774
|
if (
|
|
2677
2775
|
statement.declaration &&
|
|
2678
2776
|
!this.hooks.exportDeclaration.call(statement, statement.declaration)
|
|
@@ -2705,22 +2803,12 @@ class JavascriptParser extends Parser {
|
|
|
2705
2803
|
(specifier.exported).name ||
|
|
2706
2804
|
/** @type {string} */
|
|
2707
2805
|
(/** @type {Literal} */ (specifier.exported).value);
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
specifierIndex
|
|
2715
|
-
);
|
|
2716
|
-
} else {
|
|
2717
|
-
this.hooks.exportSpecifier.call(
|
|
2718
|
-
statement,
|
|
2719
|
-
localName,
|
|
2720
|
-
name,
|
|
2721
|
-
specifierIndex
|
|
2722
|
-
);
|
|
2723
|
-
}
|
|
2806
|
+
this.hooks.exportSpecifier.call(
|
|
2807
|
+
statement,
|
|
2808
|
+
localName,
|
|
2809
|
+
name,
|
|
2810
|
+
specifierIndex
|
|
2811
|
+
);
|
|
2724
2812
|
break;
|
|
2725
2813
|
}
|
|
2726
2814
|
}
|
|
@@ -2812,7 +2900,7 @@ class JavascriptParser extends Parser {
|
|
|
2812
2900
|
/**
|
|
2813
2901
|
* @param {ExportAllDeclaration} statement statement
|
|
2814
2902
|
*/
|
|
2815
|
-
|
|
2903
|
+
modulePreWalkExportAllDeclaration(statement) {
|
|
2816
2904
|
const source = /** @type {ImportSource} */ (statement.source.value);
|
|
2817
2905
|
const name = statement.exported
|
|
2818
2906
|
? /** @type {Identifier} */
|
|
@@ -2925,25 +3013,8 @@ class JavascriptParser extends Parser {
|
|
|
2925
3013
|
* @param {VariableDeclarator} declarator variable declarator
|
|
2926
3014
|
*/
|
|
2927
3015
|
preWalkVariableDeclarator(declarator) {
|
|
2928
|
-
if (
|
|
2929
|
-
|
|
2930
|
-
declarator.id.type !== "ObjectPattern" ||
|
|
2931
|
-
!this.destructuringAssignmentProperties
|
|
2932
|
-
) {
|
|
2933
|
-
return;
|
|
2934
|
-
}
|
|
2935
|
-
const keys = this._preWalkObjectPattern(declarator.id);
|
|
2936
|
-
|
|
2937
|
-
if (!keys) return;
|
|
2938
|
-
this.destructuringAssignmentProperties.set(
|
|
2939
|
-
declarator.init.type === "AwaitExpression"
|
|
2940
|
-
? declarator.init.argument
|
|
2941
|
-
: declarator.init,
|
|
2942
|
-
keys
|
|
2943
|
-
);
|
|
2944
|
-
|
|
2945
|
-
if (declarator.init.type === "AssignmentExpression") {
|
|
2946
|
-
this.preWalkAssignmentExpression(declarator.init);
|
|
3016
|
+
if (declarator.init) {
|
|
3017
|
+
this.enterDestructuringAssignment(declarator.id, declarator.init);
|
|
2947
3018
|
}
|
|
2948
3019
|
}
|
|
2949
3020
|
|
|
@@ -4053,13 +4124,13 @@ class JavascriptParser extends Parser {
|
|
|
4053
4124
|
}
|
|
4054
4125
|
tagInfo = tagInfo.next;
|
|
4055
4126
|
}
|
|
4056
|
-
if (info.
|
|
4127
|
+
if (!info.isFree() && !info.isTagged()) {
|
|
4057
4128
|
if (defined !== undefined) {
|
|
4058
4129
|
return defined();
|
|
4059
4130
|
}
|
|
4060
4131
|
return;
|
|
4061
4132
|
}
|
|
4062
|
-
name = info.
|
|
4133
|
+
name = info.name;
|
|
4063
4134
|
}
|
|
4064
4135
|
const hook = hookMap.get(name);
|
|
4065
4136
|
if (hook !== undefined) {
|
|
@@ -4543,6 +4614,7 @@ class JavascriptParser extends Parser {
|
|
|
4543
4614
|
if (this.hooks.program.call(ast, comments) === undefined) {
|
|
4544
4615
|
this.destructuringAssignmentProperties = new WeakMap();
|
|
4545
4616
|
this.detectMode(ast.body);
|
|
4617
|
+
this.modulePreWalkStatements(ast.body);
|
|
4546
4618
|
this.preWalkStatements(ast.body);
|
|
4547
4619
|
this.prevStatement = undefined;
|
|
4548
4620
|
this.blockPreWalkStatements(ast.body);
|
|
@@ -4818,25 +4890,31 @@ class JavascriptParser extends Parser {
|
|
|
4818
4890
|
* @param {string} name name
|
|
4819
4891
|
* @param {Tag} tag tag info
|
|
4820
4892
|
* @param {TagData=} data data
|
|
4893
|
+
* @param {VariableInfoFlagsType=} flags flags
|
|
4821
4894
|
*/
|
|
4822
|
-
tagVariable(name, tag, data) {
|
|
4895
|
+
tagVariable(name, tag, data, flags = VariableInfoFlags.Tagged) {
|
|
4823
4896
|
const oldInfo = this.scope.definitions.get(name);
|
|
4824
4897
|
/** @type {VariableInfo} */
|
|
4825
4898
|
let newInfo;
|
|
4826
4899
|
if (oldInfo === undefined) {
|
|
4827
|
-
newInfo = new VariableInfo(this.scope, name, {
|
|
4900
|
+
newInfo = new VariableInfo(this.scope, name, flags, {
|
|
4828
4901
|
tag,
|
|
4829
4902
|
data,
|
|
4830
4903
|
next: undefined
|
|
4831
4904
|
});
|
|
4832
4905
|
} else if (oldInfo instanceof VariableInfo) {
|
|
4833
|
-
newInfo = new VariableInfo(
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4906
|
+
newInfo = new VariableInfo(
|
|
4907
|
+
oldInfo.declaredScope,
|
|
4908
|
+
oldInfo.name,
|
|
4909
|
+
/** @type {VariableInfoFlagsType} */ (oldInfo.flags | flags),
|
|
4910
|
+
{
|
|
4911
|
+
tag,
|
|
4912
|
+
data,
|
|
4913
|
+
next: oldInfo.tagInfo
|
|
4914
|
+
}
|
|
4915
|
+
);
|
|
4838
4916
|
} else {
|
|
4839
|
-
newInfo = new VariableInfo(oldInfo,
|
|
4917
|
+
newInfo = new VariableInfo(oldInfo, name, flags, {
|
|
4840
4918
|
tag,
|
|
4841
4919
|
data,
|
|
4842
4920
|
next: undefined
|
|
@@ -4875,7 +4953,7 @@ class JavascriptParser extends Parser {
|
|
|
4875
4953
|
const info = this.scope.definitions.get(name);
|
|
4876
4954
|
if (info === undefined) return false;
|
|
4877
4955
|
if (info instanceof VariableInfo) {
|
|
4878
|
-
return info.
|
|
4956
|
+
return !info.isFree();
|
|
4879
4957
|
}
|
|
4880
4958
|
return true;
|
|
4881
4959
|
}
|
|
@@ -4904,7 +4982,12 @@ class JavascriptParser extends Parser {
|
|
|
4904
4982
|
} else {
|
|
4905
4983
|
this.scope.definitions.set(
|
|
4906
4984
|
name,
|
|
4907
|
-
new VariableInfo(
|
|
4985
|
+
new VariableInfo(
|
|
4986
|
+
this.scope,
|
|
4987
|
+
variableInfo,
|
|
4988
|
+
VariableInfoFlags.Free,
|
|
4989
|
+
undefined
|
|
4990
|
+
)
|
|
4908
4991
|
);
|
|
4909
4992
|
}
|
|
4910
4993
|
} else {
|
|
@@ -4917,7 +5000,12 @@ class JavascriptParser extends Parser {
|
|
|
4917
5000
|
* @returns {VariableInfo} variable info
|
|
4918
5001
|
*/
|
|
4919
5002
|
evaluatedVariable(tagInfo) {
|
|
4920
|
-
return new VariableInfo(
|
|
5003
|
+
return new VariableInfo(
|
|
5004
|
+
this.scope,
|
|
5005
|
+
undefined,
|
|
5006
|
+
VariableInfoFlags.Evaluated,
|
|
5007
|
+
tagInfo
|
|
5008
|
+
);
|
|
4921
5009
|
}
|
|
4922
5010
|
|
|
4923
5011
|
/**
|
|
@@ -5002,9 +5090,27 @@ class JavascriptParser extends Parser {
|
|
|
5002
5090
|
getFreeInfoFromVariable(varName) {
|
|
5003
5091
|
const info = this.getVariableInfo(varName);
|
|
5004
5092
|
let name;
|
|
5005
|
-
if (info instanceof VariableInfo) {
|
|
5006
|
-
|
|
5007
|
-
|
|
5093
|
+
if (info instanceof VariableInfo && info.name) {
|
|
5094
|
+
if (!info.isFree()) return;
|
|
5095
|
+
name = info.name;
|
|
5096
|
+
} else if (typeof info !== "string") {
|
|
5097
|
+
return;
|
|
5098
|
+
} else {
|
|
5099
|
+
name = info;
|
|
5100
|
+
}
|
|
5101
|
+
return { info, name };
|
|
5102
|
+
}
|
|
5103
|
+
|
|
5104
|
+
/**
|
|
5105
|
+
* @param {string} varName variable name
|
|
5106
|
+
* @returns {{name: string, info: VariableInfo | string} | undefined} name of the free variable and variable info for that
|
|
5107
|
+
*/
|
|
5108
|
+
getNameInfoFromVariable(varName) {
|
|
5109
|
+
const info = this.getVariableInfo(varName);
|
|
5110
|
+
let name;
|
|
5111
|
+
if (info instanceof VariableInfo && info.name) {
|
|
5112
|
+
if (!info.isFree() && !info.isTagged()) return;
|
|
5113
|
+
name = info.name;
|
|
5008
5114
|
} else if (typeof info !== "string") {
|
|
5009
5115
|
return;
|
|
5010
5116
|
} else {
|
|
@@ -5035,7 +5141,7 @@ class JavascriptParser extends Parser {
|
|
|
5035
5141
|
}
|
|
5036
5142
|
const rootName = getRootName(callee);
|
|
5037
5143
|
if (!rootName) return;
|
|
5038
|
-
const result = this.
|
|
5144
|
+
const result = this.getNameInfoFromVariable(rootName);
|
|
5039
5145
|
if (!result) return;
|
|
5040
5146
|
const { info: rootInfo, name: resolvedRoot } = result;
|
|
5041
5147
|
const calleeName = objectAndMembersToName(resolvedRoot, rootMembers);
|
|
@@ -5058,7 +5164,7 @@ class JavascriptParser extends Parser {
|
|
|
5058
5164
|
const rootName = getRootName(object);
|
|
5059
5165
|
if (!rootName) return;
|
|
5060
5166
|
|
|
5061
|
-
const result = this.
|
|
5167
|
+
const result = this.getNameInfoFromVariable(rootName);
|
|
5062
5168
|
if (!result) return;
|
|
5063
5169
|
const { info: rootInfo, name: resolvedRoot } = result;
|
|
5064
5170
|
return {
|
|
@@ -5074,7 +5180,7 @@ class JavascriptParser extends Parser {
|
|
|
5074
5180
|
}
|
|
5075
5181
|
|
|
5076
5182
|
/**
|
|
5077
|
-
* @param {
|
|
5183
|
+
* @param {Expression} expression an expression
|
|
5078
5184
|
* @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => string[]} | undefined} name info
|
|
5079
5185
|
*/
|
|
5080
5186
|
getNameForExpression(expression) {
|
|
@@ -5151,4 +5257,5 @@ module.exports.ALLOWED_MEMBER_TYPES_CALL_EXPRESSION =
|
|
|
5151
5257
|
module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
|
|
5152
5258
|
ALLOWED_MEMBER_TYPES_EXPRESSION;
|
|
5153
5259
|
module.exports.VariableInfo = VariableInfo;
|
|
5260
|
+
module.exports.VariableInfoFlags = VariableInfoFlags;
|
|
5154
5261
|
module.exports.getImportAttributes = getImportAttributes;
|
|
@@ -242,7 +242,6 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
242
242
|
{ factory, inlinedInIIFE },
|
|
243
243
|
libraryContext
|
|
244
244
|
) {
|
|
245
|
-
const result = new ConcatSource(source);
|
|
246
245
|
// Re-add `factoryExportsBinding` to the source
|
|
247
246
|
// when the module is rendered as a factory or treated as an inlined (startup) module but wrapped in an IIFE
|
|
248
247
|
if (
|
|
@@ -250,9 +249,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
250
249
|
module.buildMeta &&
|
|
251
250
|
module.buildMeta.factoryExportsBinding
|
|
252
251
|
) {
|
|
253
|
-
|
|
252
|
+
return new ConcatSource(module.buildMeta.factoryExportsBinding, source);
|
|
254
253
|
}
|
|
255
|
-
return
|
|
254
|
+
return source;
|
|
256
255
|
}
|
|
257
256
|
}
|
|
258
257
|
|
|
@@ -1722,6 +1722,7 @@ class ConcatenatedModule extends Module {
|
|
|
1722
1722
|
|
|
1723
1723
|
if (onDemandExportsGeneration.call(this)) {
|
|
1724
1724
|
/** @type {BuildMeta} */ (this.buildMeta).factoryExportsBinding =
|
|
1725
|
+
"\n// EXPORTS\n" +
|
|
1725
1726
|
`${RuntimeGlobals.definePropertyGetters}(${
|
|
1726
1727
|
this.exportsArgument
|
|
1727
1728
|
}, {${definitions.join(",")}\n});\n`;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const { UsageState } = require("../ExportsInfo");
|
|
9
|
+
const JavascriptParser = require("../javascript/JavascriptParser");
|
|
9
10
|
|
|
10
11
|
/** @typedef {import("estree").Node} AnyNode */
|
|
11
12
|
/** @typedef {import("../Dependency")} Dependency */
|
|
@@ -15,7 +16,6 @@ const { UsageState } = require("../ExportsInfo");
|
|
|
15
16
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
16
17
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
17
18
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
18
|
-
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
19
19
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
20
20
|
|
|
21
21
|
/** @typedef {Map<TopLevelSymbol | null, Set<string | TopLevelSymbol> | true | undefined>} InnerGraph */
|
|
@@ -348,7 +348,12 @@ module.exports.tagTopLevelSymbol = (parser, name) => {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
const fn = new TopLevelSymbol(name);
|
|
351
|
-
parser.tagVariable(
|
|
351
|
+
parser.tagVariable(
|
|
352
|
+
name,
|
|
353
|
+
topLevelSymbolTag,
|
|
354
|
+
fn,
|
|
355
|
+
JavascriptParser.VariableInfoFlags.Normal
|
|
356
|
+
);
|
|
352
357
|
return fn;
|
|
353
358
|
};
|
|
354
359
|
|
|
@@ -101,16 +101,12 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
101
101
|
.getTreeRuntimeRequirements(chunk)
|
|
102
102
|
.has(RuntimeGlobals.ensureChunkIncludeEntries);
|
|
103
103
|
if (includeEntries) {
|
|
104
|
-
includedChunksMessages.push("
|
|
105
|
-
for (const c of chunkGraph.
|
|
104
|
+
includedChunksMessages.push("chunks that the entrypoint depends on");
|
|
105
|
+
for (const c of chunkGraph.getRuntimeChunkDependentChunksIterable(
|
|
106
106
|
chunk
|
|
107
107
|
)) {
|
|
108
108
|
addChunk(c);
|
|
109
109
|
}
|
|
110
|
-
includedChunksMessages.push("chunks that the entrypoint depends on");
|
|
111
|
-
for (const c of chunkGraph.getChunkEntryDependOnChunksIterable(chunk)) {
|
|
112
|
-
addChunk(c);
|
|
113
|
-
}
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
112
|
for (const entrypoint of chunk.getAllReferencedAsyncEntrypoints()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack",
|
|
3
|
-
"version": "5.101.
|
|
3
|
+
"version": "5.101.3",
|
|
4
4
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
|
5
5
|
"homepage": "https://github.com/webpack/webpack",
|
|
6
6
|
"bugs": "https://github.com/webpack/webpack/issues",
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"style-loader": "^4.0.0",
|
|
181
181
|
"terser": "^5.43.1",
|
|
182
182
|
"three": "^0.179.1",
|
|
183
|
-
"tinybench": "^
|
|
183
|
+
"tinybench": "^5.0.0",
|
|
184
184
|
"toml": "^3.0.0",
|
|
185
185
|
"tooling": "webpack/tooling#v1.24.3",
|
|
186
186
|
"ts-loader": "^9.5.1",
|
package/types.d.ts
CHANGED
|
@@ -663,12 +663,12 @@ declare abstract class BasicEvaluatedExpression {
|
|
|
663
663
|
| MethodDefinition
|
|
664
664
|
| PropertyDefinition
|
|
665
665
|
| VariableDeclarator
|
|
666
|
-
| SwitchCase
|
|
667
|
-
| CatchClause
|
|
668
666
|
| ObjectPattern
|
|
669
667
|
| ArrayPattern
|
|
670
668
|
| RestElement
|
|
671
669
|
| AssignmentPattern
|
|
670
|
+
| SwitchCase
|
|
671
|
+
| CatchClause
|
|
672
672
|
| Property
|
|
673
673
|
| AssignmentProperty
|
|
674
674
|
| ClassBody
|
|
@@ -894,12 +894,12 @@ declare abstract class BasicEvaluatedExpression {
|
|
|
894
894
|
| MethodDefinition
|
|
895
895
|
| PropertyDefinition
|
|
896
896
|
| VariableDeclarator
|
|
897
|
-
| SwitchCase
|
|
898
|
-
| CatchClause
|
|
899
897
|
| ObjectPattern
|
|
900
898
|
| ArrayPattern
|
|
901
899
|
| RestElement
|
|
902
900
|
| AssignmentPattern
|
|
901
|
+
| SwitchCase
|
|
902
|
+
| CatchClause
|
|
903
903
|
| Property
|
|
904
904
|
| AssignmentProperty
|
|
905
905
|
| ClassBody
|
|
@@ -1373,7 +1373,7 @@ declare class ChunkGraph {
|
|
|
1373
1373
|
getNumberOfRuntimeModules(chunk: Chunk): number;
|
|
1374
1374
|
getChunkEntryModulesIterable(chunk: Chunk): Iterable<Module>;
|
|
1375
1375
|
getChunkEntryDependentChunksIterable(chunk: Chunk): Iterable<Chunk>;
|
|
1376
|
-
|
|
1376
|
+
getRuntimeChunkDependentChunksIterable(chunk: Chunk): Iterable<Chunk>;
|
|
1377
1377
|
hasChunkEntryDependentChunks(chunk: Chunk): boolean;
|
|
1378
1378
|
getChunkRuntimeModulesIterable(chunk: Chunk): Iterable<RuntimeModule>;
|
|
1379
1379
|
getChunkRuntimeModulesInOrder(chunk: Chunk): RuntimeModule[];
|
|
@@ -4534,6 +4534,8 @@ declare abstract class Entrypoint extends ChunkGroup {
|
|
|
4534
4534
|
* (or at least the execution of them)
|
|
4535
4535
|
*/
|
|
4536
4536
|
getEntrypointChunk(): Chunk;
|
|
4537
|
+
addDependOn(entrypoint: Entrypoint): void;
|
|
4538
|
+
dependOn(entrypoint: Entrypoint): boolean;
|
|
4537
4539
|
}
|
|
4538
4540
|
type EnumValue =
|
|
4539
4541
|
| null
|
|
@@ -6853,6 +6855,10 @@ declare class JavascriptParser extends ParserClass {
|
|
|
6853
6855
|
varDeclarationUsing: HookMap<SyncBailHook<[Identifier], boolean | void>>;
|
|
6854
6856
|
varDeclarationVar: HookMap<SyncBailHook<[Identifier], boolean | void>>;
|
|
6855
6857
|
pattern: HookMap<SyncBailHook<[Identifier], boolean | void>>;
|
|
6858
|
+
collectDestructuringAssignmentProperties: SyncBailHook<
|
|
6859
|
+
[Expression],
|
|
6860
|
+
boolean | void
|
|
6861
|
+
>;
|
|
6856
6862
|
canRename: HookMap<SyncBailHook<[Expression], boolean | void>>;
|
|
6857
6863
|
rename: HookMap<SyncBailHook<[Expression], boolean | void>>;
|
|
6858
6864
|
assign: HookMap<SyncBailHook<[AssignmentExpression], boolean | void>>;
|
|
@@ -7054,6 +7060,40 @@ declare class JavascriptParser extends ParserClass {
|
|
|
7054
7060
|
classy: ClassExpression | ClassDeclaration | MaybeNamedClassDeclaration
|
|
7055
7061
|
): void;
|
|
7056
7062
|
|
|
7063
|
+
/**
|
|
7064
|
+
* Module pre walking iterates the scope for import entries
|
|
7065
|
+
*/
|
|
7066
|
+
modulePreWalkStatements(
|
|
7067
|
+
statements: (
|
|
7068
|
+
| ImportDeclarationJavascriptParser
|
|
7069
|
+
| ExportNamedDeclarationJavascriptParser
|
|
7070
|
+
| ExportAllDeclarationJavascriptParser
|
|
7071
|
+
| FunctionDeclaration
|
|
7072
|
+
| VariableDeclaration
|
|
7073
|
+
| ClassDeclaration
|
|
7074
|
+
| ExpressionStatement
|
|
7075
|
+
| BlockStatement
|
|
7076
|
+
| StaticBlock
|
|
7077
|
+
| EmptyStatement
|
|
7078
|
+
| DebuggerStatement
|
|
7079
|
+
| WithStatement
|
|
7080
|
+
| ReturnStatement
|
|
7081
|
+
| LabeledStatement
|
|
7082
|
+
| BreakStatement
|
|
7083
|
+
| ContinueStatement
|
|
7084
|
+
| IfStatement
|
|
7085
|
+
| SwitchStatement
|
|
7086
|
+
| ThrowStatement
|
|
7087
|
+
| TryStatement
|
|
7088
|
+
| WhileStatement
|
|
7089
|
+
| DoWhileStatement
|
|
7090
|
+
| ForStatement
|
|
7091
|
+
| ForInStatement
|
|
7092
|
+
| ForOfStatement
|
|
7093
|
+
| ExportDefaultDeclaration
|
|
7094
|
+
)[]
|
|
7095
|
+
): void;
|
|
7096
|
+
|
|
7057
7097
|
/**
|
|
7058
7098
|
* Pre walking iterates the scope for variable declarations
|
|
7059
7099
|
*/
|
|
@@ -7293,13 +7333,48 @@ declare class JavascriptParser extends ParserClass {
|
|
|
7293
7333
|
): void;
|
|
7294
7334
|
blockPreWalkExpressionStatement(statement: ExpressionStatement): void;
|
|
7295
7335
|
preWalkAssignmentExpression(expression: AssignmentExpression): void;
|
|
7296
|
-
|
|
7336
|
+
enterDestructuringAssignment(
|
|
7337
|
+
pattern: Pattern,
|
|
7338
|
+
expression: Expression
|
|
7339
|
+
):
|
|
7340
|
+
| undefined
|
|
7341
|
+
| ImportExpressionImport
|
|
7342
|
+
| UnaryExpression
|
|
7343
|
+
| ArrayExpression
|
|
7344
|
+
| ArrowFunctionExpression
|
|
7345
|
+
| AssignmentExpression
|
|
7346
|
+
| AwaitExpression
|
|
7347
|
+
| BinaryExpression
|
|
7348
|
+
| SimpleCallExpression
|
|
7349
|
+
| NewExpression
|
|
7350
|
+
| ChainExpression
|
|
7351
|
+
| ClassExpression
|
|
7352
|
+
| ConditionalExpression
|
|
7353
|
+
| FunctionExpression
|
|
7354
|
+
| Identifier
|
|
7355
|
+
| SimpleLiteral
|
|
7356
|
+
| RegExpLiteral
|
|
7357
|
+
| BigIntLiteral
|
|
7358
|
+
| LogicalExpression
|
|
7359
|
+
| MemberExpression
|
|
7360
|
+
| MetaProperty
|
|
7361
|
+
| ObjectExpression
|
|
7362
|
+
| SequenceExpression
|
|
7363
|
+
| TaggedTemplateExpression
|
|
7364
|
+
| TemplateLiteral
|
|
7365
|
+
| ThisExpression
|
|
7366
|
+
| UpdateExpression
|
|
7367
|
+
| YieldExpression;
|
|
7368
|
+
modulePreWalkImportDeclaration(
|
|
7297
7369
|
statement: ImportDeclarationJavascriptParser
|
|
7298
7370
|
): void;
|
|
7299
7371
|
enterDeclaration(
|
|
7300
7372
|
declaration: Declaration,
|
|
7301
7373
|
onIdent: (ident: string, identifier: Identifier) => void
|
|
7302
7374
|
): void;
|
|
7375
|
+
modulePreWalkExportNamedDeclaration(
|
|
7376
|
+
statement: ExportNamedDeclarationJavascriptParser
|
|
7377
|
+
): void;
|
|
7303
7378
|
blockPreWalkExportNamedDeclaration(
|
|
7304
7379
|
statement: ExportNamedDeclarationJavascriptParser
|
|
7305
7380
|
): void;
|
|
@@ -7310,7 +7385,7 @@ declare class JavascriptParser extends ParserClass {
|
|
|
7310
7385
|
statement: ExportDefaultDeclaration
|
|
7311
7386
|
): void;
|
|
7312
7387
|
walkExportDefaultDeclaration(statement: ExportDefaultDeclaration): void;
|
|
7313
|
-
|
|
7388
|
+
modulePreWalkExportAllDeclaration(
|
|
7314
7389
|
statement: ExportAllDeclarationJavascriptParser
|
|
7315
7390
|
): void;
|
|
7316
7391
|
preWalkVariableDeclaration(statement: VariableDeclaration): void;
|
|
@@ -7716,7 +7791,12 @@ declare class JavascriptParser extends ParserClass {
|
|
|
7716
7791
|
unsetAsiPosition(pos: number): void;
|
|
7717
7792
|
isStatementLevelExpression(expr: Expression): boolean;
|
|
7718
7793
|
getTagData(name: string, tag: symbol): undefined | TagData;
|
|
7719
|
-
tagVariable(
|
|
7794
|
+
tagVariable(
|
|
7795
|
+
name: string,
|
|
7796
|
+
tag: symbol,
|
|
7797
|
+
data?: TagData,
|
|
7798
|
+
flags?: 0 | 1 | 2 | 4
|
|
7799
|
+
): void;
|
|
7720
7800
|
defineVariable(name: string): void;
|
|
7721
7801
|
undefineVariable(name: string): void;
|
|
7722
7802
|
isVariableDefined(name: string): boolean;
|
|
@@ -7794,6 +7874,9 @@ declare class JavascriptParser extends ParserClass {
|
|
|
7794
7874
|
getFreeInfoFromVariable(
|
|
7795
7875
|
varName: string
|
|
7796
7876
|
): undefined | { name: string; info: string | VariableInfo };
|
|
7877
|
+
getNameInfoFromVariable(
|
|
7878
|
+
varName: string
|
|
7879
|
+
): undefined | { name: string; info: string | VariableInfo };
|
|
7797
7880
|
getMemberExpressionInfo(
|
|
7798
7881
|
expression:
|
|
7799
7882
|
| ImportExpressionImport
|
|
@@ -7827,7 +7910,7 @@ declare class JavascriptParser extends ParserClass {
|
|
|
7827
7910
|
allowedTypes: number
|
|
7828
7911
|
): undefined | CallExpressionInfo | ExpressionExpressionInfo;
|
|
7829
7912
|
getNameForExpression(
|
|
7830
|
-
expression:
|
|
7913
|
+
expression: Expression
|
|
7831
7914
|
):
|
|
7832
7915
|
| undefined
|
|
7833
7916
|
| {
|
|
@@ -7842,6 +7925,12 @@ declare class JavascriptParser extends ParserClass {
|
|
|
7842
7925
|
static ALLOWED_MEMBER_TYPES_CALL_EXPRESSION: 1;
|
|
7843
7926
|
static ALLOWED_MEMBER_TYPES_EXPRESSION: 2;
|
|
7844
7927
|
static VariableInfo: typeof VariableInfo;
|
|
7928
|
+
static VariableInfoFlags: Readonly<{
|
|
7929
|
+
Evaluated: 0;
|
|
7930
|
+
Free: 1;
|
|
7931
|
+
Normal: 2;
|
|
7932
|
+
Tagged: 4;
|
|
7933
|
+
}>;
|
|
7845
7934
|
static getImportAttributes: (
|
|
7846
7935
|
node:
|
|
7847
7936
|
| ImportDeclarationJavascriptParser
|
|
@@ -16949,13 +17038,18 @@ declare interface Values {
|
|
|
16949
17038
|
declare class VariableInfo {
|
|
16950
17039
|
constructor(
|
|
16951
17040
|
declaredScope: ScopeInfo,
|
|
16952
|
-
|
|
17041
|
+
name: undefined | string,
|
|
17042
|
+
flags: VariableInfoFlagsType,
|
|
16953
17043
|
tagInfo?: TagInfo
|
|
16954
17044
|
);
|
|
16955
17045
|
declaredScope: ScopeInfo;
|
|
16956
|
-
|
|
17046
|
+
name?: string;
|
|
17047
|
+
flags: VariableInfoFlagsType;
|
|
16957
17048
|
tagInfo?: TagInfo;
|
|
17049
|
+
isFree(): boolean;
|
|
17050
|
+
isTagged(): boolean;
|
|
16958
17051
|
}
|
|
17052
|
+
type VariableInfoFlagsType = 0 | 1 | 2 | 4;
|
|
16959
17053
|
declare interface VirtualModuleConfig {
|
|
16960
17054
|
/**
|
|
16961
17055
|
* - The module type
|