@rollup/wasm-node 4.55.3 → 4.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +381 -424
- package/dist/es/shared/parseAst.js +3 -4
- package/dist/es/shared/watch.js +3 -3
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +3 -3
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -4
- package/dist/shared/rollup.js +380 -423
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +3 -3
- package/package.json +1 -1
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.56.0
|
|
4
|
+
Thu, 22 Jan 2026 05:37:20 GMT - commit 1cbac18d9fb153db123d8f266947c5a5acfa387f
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
|
|
|
42
42
|
|
|
43
43
|
const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
|
|
44
44
|
|
|
45
|
-
var version = "4.
|
|
45
|
+
var version = "4.56.0";
|
|
46
46
|
|
|
47
47
|
function ensureArray$1(items) {
|
|
48
48
|
if (Array.isArray(items)) {
|
|
@@ -6816,15 +6816,15 @@ function isCallExpressionNode(node) {
|
|
|
6816
6816
|
function isMemberExpressionNode(node) {
|
|
6817
6817
|
return node instanceof NodeBase && node.type === parseAst_js.MemberExpression;
|
|
6818
6818
|
}
|
|
6819
|
-
function isImportExpressionNode(node) {
|
|
6820
|
-
return node instanceof NodeBase && node.type === parseAst_js.ImportExpression;
|
|
6821
|
-
}
|
|
6822
6819
|
function isAwaitExpressionNode(node) {
|
|
6823
6820
|
return node instanceof NodeBase && node.type === parseAst_js.AwaitExpression;
|
|
6824
6821
|
}
|
|
6825
6822
|
function isIdentifierNode(node) {
|
|
6826
6823
|
return node instanceof NodeBase && node.type === parseAst_js.Identifier;
|
|
6827
6824
|
}
|
|
6825
|
+
function isExpressionStatementNode(node) {
|
|
6826
|
+
return node instanceof NodeBase && node.type === parseAst_js.ExpressionStatement;
|
|
6827
|
+
}
|
|
6828
6828
|
|
|
6829
6829
|
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
6830
6830
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
@@ -8982,21 +8982,6 @@ class LocalVariable extends Variable {
|
|
|
8982
8982
|
break;
|
|
8983
8983
|
node = node.parent;
|
|
8984
8984
|
}
|
|
8985
|
-
/**
|
|
8986
|
-
* import('foo').then(m => {
|
|
8987
|
-
* console.log(m.foo)
|
|
8988
|
-
* })
|
|
8989
|
-
*/
|
|
8990
|
-
if (this.kind === 'parameter' &&
|
|
8991
|
-
(isArrowFunctionExpressionNode(declaration.parent) ||
|
|
8992
|
-
isFunctionExpressionNode(declaration.parent)) &&
|
|
8993
|
-
isCallExpressionNode(declaration.parent.parent) &&
|
|
8994
|
-
isMemberExpressionNode(declaration.parent.parent.callee) &&
|
|
8995
|
-
isIdentifierNode(declaration.parent.parent.callee.property) &&
|
|
8996
|
-
declaration.parent.parent.callee.property.name === 'then' &&
|
|
8997
|
-
isImportExpressionNode(declaration.parent.parent.callee.object)) {
|
|
8998
|
-
declaration.parent.parent.callee.object.includePath(path, context);
|
|
8999
|
-
}
|
|
9000
8985
|
}
|
|
9001
8986
|
// We need to make sure we include the correct path of the init
|
|
9002
8987
|
if (path.length > 0) {
|
|
@@ -11144,6 +11129,7 @@ function getStringFromPath(path) {
|
|
|
11144
11129
|
class MemberExpression extends NodeBase {
|
|
11145
11130
|
constructor() {
|
|
11146
11131
|
super(...arguments);
|
|
11132
|
+
this.promiseHandler = null;
|
|
11147
11133
|
this.variable = null;
|
|
11148
11134
|
this.expressionsToBeDeoptimized = [];
|
|
11149
11135
|
}
|
|
@@ -11199,7 +11185,10 @@ class MemberExpression extends NodeBase {
|
|
|
11199
11185
|
}
|
|
11200
11186
|
}
|
|
11201
11187
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11202
|
-
if (this.
|
|
11188
|
+
if (this.promiseHandler) {
|
|
11189
|
+
this.promiseHandler.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11190
|
+
}
|
|
11191
|
+
else if (this.variable) {
|
|
11203
11192
|
this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11204
11193
|
}
|
|
11205
11194
|
else if (!this.isUndefined) {
|
|
@@ -11389,25 +11378,14 @@ class MemberExpression extends NodeBase {
|
|
|
11389
11378
|
this.property.include(context, includeChildrenRecursively);
|
|
11390
11379
|
}
|
|
11391
11380
|
includeCallArguments(interaction, context) {
|
|
11392
|
-
if (this.
|
|
11381
|
+
if (this.promiseHandler) {
|
|
11382
|
+
this.promiseHandler.includeCallArguments(interaction, context);
|
|
11383
|
+
}
|
|
11384
|
+
else if (this.variable) {
|
|
11393
11385
|
this.variable.includeCallArguments(interaction, context);
|
|
11394
11386
|
}
|
|
11395
11387
|
else {
|
|
11396
|
-
|
|
11397
|
-
/**
|
|
11398
|
-
* const c = await import('foo')
|
|
11399
|
-
* c.foo();
|
|
11400
|
-
*/
|
|
11401
|
-
(this.object.variable &&
|
|
11402
|
-
!this.object.variable.isReassigned &&
|
|
11403
|
-
this.object.variable instanceof LocalVariable &&
|
|
11404
|
-
isAwaitExpressionNode(this.object.variable.init) &&
|
|
11405
|
-
isImportExpressionNode(this.object.variable.init.argument))) {
|
|
11406
|
-
includeInteractionWithoutThis(interaction, context);
|
|
11407
|
-
}
|
|
11408
|
-
else {
|
|
11409
|
-
includeInteraction(interaction, context);
|
|
11410
|
-
}
|
|
11388
|
+
includeInteraction(interaction, context);
|
|
11411
11389
|
}
|
|
11412
11390
|
}
|
|
11413
11391
|
includeDestructuredIfNecessary() {
|
|
@@ -11455,7 +11433,7 @@ class MemberExpression extends NodeBase {
|
|
|
11455
11433
|
// Namespaces are not bound and should not be deoptimized
|
|
11456
11434
|
this.bound &&
|
|
11457
11435
|
propertyReadSideEffects &&
|
|
11458
|
-
!(this.variable || this.isUndefined)) {
|
|
11436
|
+
!(this.variable || this.isUndefined || this.promiseHandler)) {
|
|
11459
11437
|
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [this.propertyKey], SHARED_RECURSION_TRACKER);
|
|
11460
11438
|
this.scope.context.requestTreeshakingPass();
|
|
11461
11439
|
}
|
|
@@ -11763,8 +11741,9 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
11763
11741
|
class NamespaceVariable extends Variable {
|
|
11764
11742
|
constructor(context) {
|
|
11765
11743
|
super(context.getModuleName());
|
|
11766
|
-
this.
|
|
11744
|
+
this.areAllMembersDeoptimized = false;
|
|
11767
11745
|
this.mergedNamespaces = [];
|
|
11746
|
+
this.nonExplicitNamespacesIncluded = false;
|
|
11768
11747
|
this.referencedEarly = false;
|
|
11769
11748
|
this.references = [];
|
|
11770
11749
|
this.context = context;
|
|
@@ -11778,7 +11757,10 @@ class NamespaceVariable extends Variable {
|
|
|
11778
11757
|
if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) {
|
|
11779
11758
|
const key = path[0];
|
|
11780
11759
|
if (typeof key === 'string') {
|
|
11781
|
-
this.
|
|
11760
|
+
this.module
|
|
11761
|
+
.getExportedVariablesByName()
|
|
11762
|
+
.get(key)
|
|
11763
|
+
?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
|
|
11782
11764
|
}
|
|
11783
11765
|
else {
|
|
11784
11766
|
deoptimizeInteraction(interaction);
|
|
@@ -11789,7 +11771,13 @@ class NamespaceVariable extends Variable {
|
|
|
11789
11771
|
if (path.length > 1) {
|
|
11790
11772
|
const key = path[0];
|
|
11791
11773
|
if (typeof key === 'string') {
|
|
11792
|
-
this.
|
|
11774
|
+
this.module.getExportedVariablesByName().get(key)?.deoptimizePath(path.slice(1));
|
|
11775
|
+
}
|
|
11776
|
+
else if (!this.areAllMembersDeoptimized) {
|
|
11777
|
+
this.areAllMembersDeoptimized = true;
|
|
11778
|
+
for (const variable of this.module.getExportedVariablesByName().values()) {
|
|
11779
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
11780
|
+
}
|
|
11793
11781
|
}
|
|
11794
11782
|
}
|
|
11795
11783
|
}
|
|
@@ -11799,22 +11787,6 @@ class NamespaceVariable extends Variable {
|
|
|
11799
11787
|
}
|
|
11800
11788
|
return UnknownValue;
|
|
11801
11789
|
}
|
|
11802
|
-
getMemberVariables() {
|
|
11803
|
-
if (this.memberVariables) {
|
|
11804
|
-
return this.memberVariables;
|
|
11805
|
-
}
|
|
11806
|
-
const memberVariables = Object.create(null);
|
|
11807
|
-
const sortedExports = [...this.context.getExports(), ...this.context.getReexports()].sort();
|
|
11808
|
-
for (const name of sortedExports) {
|
|
11809
|
-
if (name[0] !== '*' && name !== this.module.info.syntheticNamedExports) {
|
|
11810
|
-
const [exportedVariable] = this.context.traceExport(name);
|
|
11811
|
-
if (exportedVariable) {
|
|
11812
|
-
memberVariables[name] = exportedVariable;
|
|
11813
|
-
}
|
|
11814
|
-
}
|
|
11815
|
-
}
|
|
11816
|
-
return (this.memberVariables = memberVariables);
|
|
11817
|
-
}
|
|
11818
11790
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11819
11791
|
const { type } = interaction;
|
|
11820
11792
|
if (path.length === 0) {
|
|
@@ -11828,13 +11800,31 @@ class NamespaceVariable extends Variable {
|
|
|
11828
11800
|
if (typeof key !== 'string') {
|
|
11829
11801
|
return true;
|
|
11830
11802
|
}
|
|
11831
|
-
const memberVariable = this.
|
|
11803
|
+
const memberVariable = this.module.getExportedVariablesByName().get(key);
|
|
11832
11804
|
return (!memberVariable ||
|
|
11833
11805
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
11834
11806
|
}
|
|
11835
11807
|
includePath(path, context) {
|
|
11836
11808
|
super.includePath(path, context);
|
|
11837
|
-
this.context
|
|
11809
|
+
this.includeMemberPath(path, context);
|
|
11810
|
+
}
|
|
11811
|
+
includeMemberPath(path, context) {
|
|
11812
|
+
if (path.length > 0) {
|
|
11813
|
+
const [name, ...remainingPath] = path;
|
|
11814
|
+
if (typeof name === 'string') {
|
|
11815
|
+
const variable = this.module.getExportedVariablesByName().get(name);
|
|
11816
|
+
if (variable) {
|
|
11817
|
+
this.context.includeVariableInModule(variable, remainingPath, context);
|
|
11818
|
+
}
|
|
11819
|
+
else {
|
|
11820
|
+
this.includeNonExplicitNamespaces();
|
|
11821
|
+
}
|
|
11822
|
+
}
|
|
11823
|
+
else if (name) {
|
|
11824
|
+
this.module.includeAllExports();
|
|
11825
|
+
this.includeNonExplicitNamespaces();
|
|
11826
|
+
}
|
|
11827
|
+
}
|
|
11838
11828
|
}
|
|
11839
11829
|
prepare(accessedGlobalsByScope) {
|
|
11840
11830
|
if (this.mergedNamespaces.length > 0) {
|
|
@@ -11843,9 +11833,9 @@ class NamespaceVariable extends Variable {
|
|
|
11843
11833
|
}
|
|
11844
11834
|
renderBlock(options) {
|
|
11845
11835
|
const { exportNamesByVariable, format, freeze, indent: t, symbols, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
|
|
11846
|
-
const memberVariables = this.
|
|
11847
|
-
const members =
|
|
11848
|
-
.filter(([
|
|
11836
|
+
const memberVariables = this.module.getExportedVariablesByName();
|
|
11837
|
+
const members = [...memberVariables.entries()]
|
|
11838
|
+
.filter(([name, variable]) => !name.startsWith('*') && variable.included)
|
|
11849
11839
|
.map(([name, variable]) => {
|
|
11850
11840
|
if (this.referencedEarly || variable.isReassigned || variable === this) {
|
|
11851
11841
|
return [
|
|
@@ -11891,8 +11881,22 @@ class NamespaceVariable extends Variable {
|
|
|
11891
11881
|
}
|
|
11892
11882
|
}
|
|
11893
11883
|
}
|
|
11884
|
+
includeNonExplicitNamespaces() {
|
|
11885
|
+
if (!this.nonExplicitNamespacesIncluded) {
|
|
11886
|
+
this.nonExplicitNamespacesIncluded = true;
|
|
11887
|
+
this.setMergedNamespaces(this.module.includeAndGetAdditionalMergedNamespaces());
|
|
11888
|
+
}
|
|
11889
|
+
}
|
|
11894
11890
|
}
|
|
11895
11891
|
NamespaceVariable.prototype.isNamespace = true;
|
|
11892
|
+
// This is a proxy that does not include the namespace object when a path is included
|
|
11893
|
+
const getDynamicNamespaceVariable = (namespace) => Object.create(namespace, {
|
|
11894
|
+
includePath: {
|
|
11895
|
+
value(path, context) {
|
|
11896
|
+
namespace.includeMemberPath(path, context);
|
|
11897
|
+
}
|
|
11898
|
+
}
|
|
11899
|
+
});
|
|
11896
11900
|
|
|
11897
11901
|
class SyntheticNamedExportVariable extends Variable {
|
|
11898
11902
|
constructor(context, name, syntheticNamespace) {
|
|
@@ -11928,7 +11932,7 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
11928
11932
|
}
|
|
11929
11933
|
includePath(path, context) {
|
|
11930
11934
|
super.includePath(path, context);
|
|
11931
|
-
this.context.includeVariableInModule(this.syntheticNamespace, path, context);
|
|
11935
|
+
this.context.includeVariableInModule(this.syntheticNamespace, [this.name, ...path], context);
|
|
11932
11936
|
}
|
|
11933
11937
|
setRenderNames(baseName, name) {
|
|
11934
11938
|
super.setRenderNames(baseName, name);
|
|
@@ -13442,6 +13446,9 @@ class AssignmentPattern extends NodeBase {
|
|
|
13442
13446
|
}
|
|
13443
13447
|
|
|
13444
13448
|
class AwaitExpression extends NodeBase {
|
|
13449
|
+
deoptimizePath(path) {
|
|
13450
|
+
this.argument.deoptimizePath(path);
|
|
13451
|
+
}
|
|
13445
13452
|
hasEffects() {
|
|
13446
13453
|
if (!this.deoptimized)
|
|
13447
13454
|
this.applyDeoptimizations();
|
|
@@ -13844,11 +13851,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
13844
13851
|
this.callee.includeCallArguments(this.interaction, context);
|
|
13845
13852
|
}
|
|
13846
13853
|
}
|
|
13847
|
-
includeNode(
|
|
13854
|
+
includeNode(_context) {
|
|
13848
13855
|
this.included = true;
|
|
13849
13856
|
if (!this.deoptimized)
|
|
13850
13857
|
this.applyDeoptimizations();
|
|
13851
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
13852
13858
|
}
|
|
13853
13859
|
initialise() {
|
|
13854
13860
|
super.initialise();
|
|
@@ -14706,95 +14712,41 @@ class ImportDefaultSpecifier extends NodeBase {
|
|
|
14706
14712
|
ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14707
14713
|
ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14708
14714
|
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
this.isAsyncUsingDeclaration = kind === 'await using';
|
|
14717
|
-
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
14718
|
-
}
|
|
14719
|
-
deoptimizePath(path) {
|
|
14720
|
-
this.id.deoptimizePath(path);
|
|
14721
|
-
}
|
|
14722
|
-
hasEffects(context) {
|
|
14723
|
-
const initEffect = this.init?.hasEffects(context);
|
|
14724
|
-
this.id.markDeclarationReached();
|
|
14725
|
-
return (initEffect ||
|
|
14726
|
-
this.isUsingDeclaration ||
|
|
14727
|
-
this.isAsyncUsingDeclaration ||
|
|
14728
|
-
this.id.hasEffects(context) ||
|
|
14729
|
-
(this.scope.context.options.treeshake
|
|
14730
|
-
.propertyReadSideEffects &&
|
|
14731
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
14715
|
+
class ObjectPromiseHandler {
|
|
14716
|
+
constructor(resolvedVariable) {
|
|
14717
|
+
this.interaction = {
|
|
14718
|
+
args: [null, resolvedVariable],
|
|
14719
|
+
type: INTERACTION_CALLED,
|
|
14720
|
+
withNew: false
|
|
14721
|
+
};
|
|
14732
14722
|
}
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
if (
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
id.include(context, includeChildrenRecursively);
|
|
14741
|
-
}
|
|
14742
|
-
else {
|
|
14743
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
14723
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
14724
|
+
deoptimizeInteraction(interaction);
|
|
14725
|
+
if (interaction.type === INTERACTION_CALLED &&
|
|
14726
|
+
path.length === 0 &&
|
|
14727
|
+
(isFunctionExpressionNode(interaction.args[1]) ||
|
|
14728
|
+
isArrowFunctionExpressionNode(interaction.args[1]))) {
|
|
14729
|
+
interaction.args[1].deoptimizeArgumentsOnInteractionAtPath(this.interaction, [], recursionTracker);
|
|
14744
14730
|
}
|
|
14745
14731
|
}
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14751
|
-
|
|
14752
|
-
|
|
14753
|
-
if (renderId) {
|
|
14754
|
-
id.render(code, options);
|
|
14755
|
-
}
|
|
14756
|
-
else {
|
|
14757
|
-
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
14758
|
-
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
14759
|
-
}
|
|
14760
|
-
if (init) {
|
|
14761
|
-
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
14762
|
-
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
14763
|
-
if (renderedVariable !== id.name) {
|
|
14764
|
-
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
14765
|
-
}
|
|
14766
|
-
}
|
|
14767
|
-
init.render(code, options, renderId ? parseAst_js.BLANK : { renderedSurroundingElement: parseAst_js.ExpressionStatement });
|
|
14768
|
-
}
|
|
14769
|
-
else if (id instanceof Identifier &&
|
|
14770
|
-
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
14771
|
-
code.appendLeft(end, `${_}=${_}void 0`);
|
|
14732
|
+
includeCallArguments(interaction, context) {
|
|
14733
|
+
// This includes the function call itself
|
|
14734
|
+
includeInteractionWithoutThis(interaction, context);
|
|
14735
|
+
if (interaction.type === INTERACTION_CALLED &&
|
|
14736
|
+
(isFunctionExpressionNode(interaction.args[1]) ||
|
|
14737
|
+
isArrowFunctionExpressionNode(interaction.args[1]))) {
|
|
14738
|
+
interaction.args[1].includeCallArguments(this.interaction, context);
|
|
14772
14739
|
}
|
|
14773
14740
|
}
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
else if (this.isAsyncUsingDeclaration) {
|
|
14782
|
-
init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context);
|
|
14783
|
-
}
|
|
14784
|
-
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
14785
|
-
const { name, variable } = id;
|
|
14786
|
-
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
14787
|
-
if (accessedVariable !== variable) {
|
|
14788
|
-
accessedVariable.forbidName(name);
|
|
14789
|
-
}
|
|
14790
|
-
}
|
|
14791
|
-
}
|
|
14792
|
-
}
|
|
14741
|
+
}
|
|
14742
|
+
class EmptyPromiseHandler {
|
|
14743
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction) {
|
|
14744
|
+
deoptimizeInteraction(interaction);
|
|
14745
|
+
}
|
|
14746
|
+
includeCallArguments(interaction, context) {
|
|
14747
|
+
includeInteractionWithoutThis(interaction, context);
|
|
14793
14748
|
}
|
|
14794
14749
|
}
|
|
14795
|
-
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14796
|
-
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
14797
|
-
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
14798
14750
|
|
|
14799
14751
|
function getChunkInfoWithPath(chunk) {
|
|
14800
14752
|
return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() };
|
|
@@ -14803,12 +14755,11 @@ class ImportExpression extends NodeBase {
|
|
|
14803
14755
|
constructor() {
|
|
14804
14756
|
super(...arguments);
|
|
14805
14757
|
this.inlineNamespace = null;
|
|
14806
|
-
this.
|
|
14807
|
-
this.accessedPropKey = new Set();
|
|
14758
|
+
this.resolution = null;
|
|
14808
14759
|
this.attributes = null;
|
|
14809
14760
|
this.mechanism = null;
|
|
14810
14761
|
this.namespaceExportName = undefined;
|
|
14811
|
-
this.
|
|
14762
|
+
this.localResolution = null;
|
|
14812
14763
|
this.resolutionString = null;
|
|
14813
14764
|
}
|
|
14814
14765
|
get shouldIncludeDynamicAttributes() {
|
|
@@ -14818,84 +14769,65 @@ class ImportExpression extends NodeBase {
|
|
|
14818
14769
|
this.flags = setFlag(this.flags, 268435456 /* Flag.shouldIncludeDynamicAttributes */, value);
|
|
14819
14770
|
}
|
|
14820
14771
|
bind() {
|
|
14821
|
-
this
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
*
|
|
14827
|
-
* 1. `const { foo } = await import('bar')`.
|
|
14828
|
-
* 2. `(await import('bar')).foo`
|
|
14829
|
-
* 3. `import('bar').then(({ foo }) => {})`
|
|
14830
|
-
*
|
|
14831
|
-
* Returns empty array if it's side-effect only import.
|
|
14832
|
-
* Returns undefined if it's not fully deterministic.
|
|
14833
|
-
*/
|
|
14834
|
-
getDeterministicImportedNames() {
|
|
14835
|
-
const parent1 = this.parent;
|
|
14836
|
-
// Side-effect only: import('bar')
|
|
14837
|
-
if (parent1 instanceof ExpressionStatement) {
|
|
14838
|
-
return parseAst_js.EMPTY_ARRAY;
|
|
14839
|
-
}
|
|
14840
|
-
if (parent1 instanceof AwaitExpression) {
|
|
14841
|
-
const parent2 = parent1.parent;
|
|
14842
|
-
// Side effect only: await import('bar')
|
|
14843
|
-
if (parent2 instanceof ExpressionStatement) {
|
|
14844
|
-
return parseAst_js.EMPTY_ARRAY;
|
|
14845
|
-
}
|
|
14846
|
-
// Case 1: const { foo } / module = await import('bar')
|
|
14847
|
-
if (parent2 instanceof VariableDeclarator) {
|
|
14848
|
-
const declaration = parent2.id;
|
|
14849
|
-
if (declaration instanceof Identifier) {
|
|
14850
|
-
return this.hasUnknownAccessedKey ? undefined : [...this.accessedPropKey];
|
|
14851
|
-
}
|
|
14852
|
-
if (declaration instanceof ObjectPattern) {
|
|
14853
|
-
return getDeterministicObjectDestructure(declaration);
|
|
14854
|
-
}
|
|
14855
|
-
}
|
|
14856
|
-
// Case 2: (await import('bar')).foo
|
|
14857
|
-
if (parent2 instanceof MemberExpression) {
|
|
14858
|
-
const id = parent2.property;
|
|
14859
|
-
if (!parent2.computed && id instanceof Identifier) {
|
|
14860
|
-
return [id.name];
|
|
14861
|
-
}
|
|
14862
|
-
}
|
|
14772
|
+
const { options, parent, resolution, source } = this;
|
|
14773
|
+
source.bind();
|
|
14774
|
+
options?.bind();
|
|
14775
|
+
// Check if we resolved to a Module without using instanceof
|
|
14776
|
+
if (typeof resolution !== 'object' || !resolution || !('namespace' in resolution)) {
|
|
14863
14777
|
return;
|
|
14864
14778
|
}
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
}
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
thenCallback instanceof FunctionExpression)) {
|
|
14887
|
-
return;
|
|
14779
|
+
// In these cases, we can track exactly what is included or deoptimized:
|
|
14780
|
+
// * import('foo'); // as statement
|
|
14781
|
+
// * await import('foo') // use as awaited expression in any way
|
|
14782
|
+
// * import('foo').then(n => {...}) // only if .then is called directly on the import()
|
|
14783
|
+
if (isExpressionStatementNode(parent) || isAwaitExpressionNode(parent)) {
|
|
14784
|
+
this.localResolution = { resolution, tracked: true };
|
|
14785
|
+
return;
|
|
14786
|
+
}
|
|
14787
|
+
if (!isMemberExpressionNode(parent)) {
|
|
14788
|
+
this.localResolution = { resolution, tracked: false };
|
|
14789
|
+
return;
|
|
14790
|
+
}
|
|
14791
|
+
let currentParent = parent;
|
|
14792
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14793
|
+
let callExpression = this;
|
|
14794
|
+
while (true) {
|
|
14795
|
+
if (currentParent.computed ||
|
|
14796
|
+
currentParent.object !== callExpression ||
|
|
14797
|
+
!isIdentifierNode(currentParent.property) ||
|
|
14798
|
+
!isCallExpressionNode(currentParent.parent)) {
|
|
14799
|
+
break;
|
|
14888
14800
|
}
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14801
|
+
const propertyName = currentParent.property.name;
|
|
14802
|
+
callExpression = currentParent.parent;
|
|
14803
|
+
if (propertyName === 'then') {
|
|
14804
|
+
const firstArgument = callExpression.arguments[0];
|
|
14805
|
+
if (firstArgument === undefined ||
|
|
14806
|
+
isFunctionExpressionNode(firstArgument) ||
|
|
14807
|
+
isArrowFunctionExpressionNode(firstArgument)) {
|
|
14808
|
+
currentParent.promiseHandler = new ObjectPromiseHandler(getDynamicNamespaceVariable(resolution.namespace));
|
|
14809
|
+
this.localResolution = { resolution, tracked: true };
|
|
14810
|
+
return;
|
|
14811
|
+
}
|
|
14892
14812
|
}
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14813
|
+
else if (propertyName === 'catch' || propertyName === 'finally') {
|
|
14814
|
+
if (isMemberExpressionNode(callExpression.parent)) {
|
|
14815
|
+
currentParent.promiseHandler = new EmptyPromiseHandler();
|
|
14816
|
+
currentParent = callExpression.parent;
|
|
14817
|
+
continue;
|
|
14818
|
+
}
|
|
14819
|
+
if (isExpressionStatementNode(callExpression.parent)) {
|
|
14820
|
+
currentParent.promiseHandler = new EmptyPromiseHandler();
|
|
14821
|
+
this.localResolution = { resolution, tracked: true };
|
|
14822
|
+
return;
|
|
14823
|
+
}
|
|
14896
14824
|
}
|
|
14897
|
-
|
|
14825
|
+
break;
|
|
14898
14826
|
}
|
|
14827
|
+
this.localResolution = { resolution, tracked: false };
|
|
14828
|
+
}
|
|
14829
|
+
deoptimizePath(path) {
|
|
14830
|
+
this.localResolution?.resolution?.namespace.deoptimizePath(path);
|
|
14899
14831
|
}
|
|
14900
14832
|
hasEffects() {
|
|
14901
14833
|
return true;
|
|
@@ -14904,30 +14836,31 @@ class ImportExpression extends NodeBase {
|
|
|
14904
14836
|
if (!this.included)
|
|
14905
14837
|
this.includeNode(context);
|
|
14906
14838
|
this.source.include(context, includeChildrenRecursively);
|
|
14907
|
-
if (this.shouldIncludeDynamicAttributes)
|
|
14839
|
+
if (this.shouldIncludeDynamicAttributes) {
|
|
14908
14840
|
this.options?.include(context, includeChildrenRecursively);
|
|
14841
|
+
}
|
|
14909
14842
|
}
|
|
14910
14843
|
includeNode(context) {
|
|
14911
14844
|
this.included = true;
|
|
14912
|
-
|
|
14845
|
+
const { localResolution, scope, shouldIncludeDynamicAttributes } = this;
|
|
14846
|
+
if (shouldIncludeDynamicAttributes) {
|
|
14913
14847
|
this.options?.includePath(UNKNOWN_PATH, context);
|
|
14914
|
-
|
|
14915
|
-
|
|
14848
|
+
}
|
|
14849
|
+
scope.context.includeDynamicImport(this);
|
|
14850
|
+
scope.addAccessedDynamicImport(this);
|
|
14851
|
+
if (localResolution) {
|
|
14852
|
+
if (localResolution.tracked) {
|
|
14853
|
+
localResolution.resolution.includeModuleInExecution();
|
|
14854
|
+
}
|
|
14855
|
+
else {
|
|
14856
|
+
localResolution.resolution.includeAllExports();
|
|
14857
|
+
}
|
|
14858
|
+
}
|
|
14916
14859
|
}
|
|
14917
14860
|
includePath(path, context) {
|
|
14918
14861
|
if (!this.included)
|
|
14919
14862
|
this.includeNode(context);
|
|
14920
|
-
|
|
14921
|
-
if (this.hasUnknownAccessedKey)
|
|
14922
|
-
return;
|
|
14923
|
-
if (path[0] === UnknownKey) {
|
|
14924
|
-
this.hasUnknownAccessedKey = true;
|
|
14925
|
-
}
|
|
14926
|
-
else if (typeof path[0] === 'string') {
|
|
14927
|
-
this.accessedPropKey.add(path[0]);
|
|
14928
|
-
}
|
|
14929
|
-
// Update included paths
|
|
14930
|
-
this.scope.context.includeDynamicImport(this);
|
|
14863
|
+
this.localResolution?.resolution?.namespace.includeMemberPath(path, context);
|
|
14931
14864
|
}
|
|
14932
14865
|
initialise() {
|
|
14933
14866
|
super.initialise();
|
|
@@ -14977,16 +14910,15 @@ class ImportExpression extends NodeBase {
|
|
|
14977
14910
|
}
|
|
14978
14911
|
}
|
|
14979
14912
|
}
|
|
14980
|
-
setExternalResolution(exportMode,
|
|
14913
|
+
setExternalResolution(exportMode, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes, ownChunk, targetChunk) {
|
|
14981
14914
|
const { format } = options;
|
|
14982
14915
|
this.inlineNamespace = null;
|
|
14983
|
-
this.resolution = resolution;
|
|
14984
14916
|
this.resolutionString = resolutionString;
|
|
14985
14917
|
this.namespaceExportName = namespaceExportName;
|
|
14986
14918
|
this.attributes = attributes;
|
|
14987
14919
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
14988
14920
|
let helper;
|
|
14989
|
-
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(
|
|
14921
|
+
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(exportMode, options, snippets, pluginDriver, ownChunk, targetChunk));
|
|
14990
14922
|
if (helper) {
|
|
14991
14923
|
accessedGlobals.push(helper);
|
|
14992
14924
|
}
|
|
@@ -14997,11 +14929,12 @@ class ImportExpression extends NodeBase {
|
|
|
14997
14929
|
setInternalResolution(inlineNamespace) {
|
|
14998
14930
|
this.inlineNamespace = inlineNamespace;
|
|
14999
14931
|
}
|
|
15000
|
-
getDynamicImportMechanismAndHelper(
|
|
14932
|
+
getDynamicImportMechanismAndHelper(exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver, ownChunk, targetChunk) {
|
|
14933
|
+
const { resolution, scope } = this;
|
|
15001
14934
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
15002
14935
|
{
|
|
15003
14936
|
chunk: getChunkInfoWithPath(ownChunk),
|
|
15004
|
-
customResolution: typeof
|
|
14937
|
+
customResolution: typeof resolution === 'string' ? resolution : null,
|
|
15005
14938
|
format,
|
|
15006
14939
|
getTargetChunkImports() {
|
|
15007
14940
|
if (targetChunk === null)
|
|
@@ -15028,15 +14961,15 @@ class ImportExpression extends NodeBase {
|
|
|
15028
14961
|
}
|
|
15029
14962
|
return chunkInfos;
|
|
15030
14963
|
},
|
|
15031
|
-
moduleId:
|
|
14964
|
+
moduleId: scope.context.module.id,
|
|
15032
14965
|
targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null,
|
|
15033
|
-
targetModuleId:
|
|
14966
|
+
targetModuleId: resolution && typeof resolution !== 'string' ? resolution.id : null
|
|
15034
14967
|
}
|
|
15035
14968
|
]);
|
|
15036
14969
|
if (mechanism) {
|
|
15037
14970
|
return { helper: null, mechanism };
|
|
15038
14971
|
}
|
|
15039
|
-
const hasDynamicTarget = !
|
|
14972
|
+
const hasDynamicTarget = !resolution || typeof resolution === 'string';
|
|
15040
14973
|
switch (format) {
|
|
15041
14974
|
case 'cjs': {
|
|
15042
14975
|
if (dynamicImportInCjs &&
|
|
@@ -15126,15 +15059,6 @@ const accessedImportGlobals = {
|
|
|
15126
15059
|
cjs: ['require'],
|
|
15127
15060
|
system: ['module']
|
|
15128
15061
|
};
|
|
15129
|
-
function getDeterministicObjectDestructure(objectPattern) {
|
|
15130
|
-
const variables = [];
|
|
15131
|
-
for (const property of objectPattern.properties) {
|
|
15132
|
-
if (property.type === 'RestElement' || property.computed || property.key.type !== 'Identifier')
|
|
15133
|
-
return;
|
|
15134
|
-
variables.push(property.key.name);
|
|
15135
|
-
}
|
|
15136
|
-
return variables;
|
|
15137
|
-
}
|
|
15138
15062
|
|
|
15139
15063
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
15140
15064
|
}
|
|
@@ -16129,7 +16053,7 @@ ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
|
16129
16053
|
|
|
16130
16054
|
class PanicError extends NodeBase {
|
|
16131
16055
|
initialise() {
|
|
16132
|
-
const id = this.scope.context.module
|
|
16056
|
+
const { id } = this.scope.context.module;
|
|
16133
16057
|
// This simulates the current nested error structure. We could also just
|
|
16134
16058
|
// replace it with a flat error.
|
|
16135
16059
|
const parseError = parseAst_js.getRollupError(parseAst_js.logParseError(this.message));
|
|
@@ -16141,7 +16065,7 @@ class PanicError extends NodeBase {
|
|
|
16141
16065
|
class ParseError extends NodeBase {
|
|
16142
16066
|
initialise() {
|
|
16143
16067
|
const pos = this.start;
|
|
16144
|
-
const id = this.scope.context.module
|
|
16068
|
+
const { id } = this.scope.context.module;
|
|
16145
16069
|
// This simulates the current nested error structure. We could also just
|
|
16146
16070
|
// replace it with a flat error.
|
|
16147
16071
|
const parseError = parseAst_js.getRollupError(parseAst_js.logParseError(this.message, pos));
|
|
@@ -16600,9 +16524,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
16600
16524
|
set hasCheckedForWarnings(value) {
|
|
16601
16525
|
this.flags = setFlag(this.flags, 134217728 /* Flag.checkedForWarnings */, value);
|
|
16602
16526
|
}
|
|
16603
|
-
bind() {
|
|
16604
|
-
super.bind();
|
|
16605
|
-
}
|
|
16606
16527
|
hasEffects(context) {
|
|
16607
16528
|
if (!this.deoptimized)
|
|
16608
16529
|
this.applyDeoptimizations();
|
|
@@ -16722,12 +16643,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
16722
16643
|
}
|
|
16723
16644
|
|
|
16724
16645
|
class ModuleScope extends ChildScope {
|
|
16725
|
-
constructor(parent, context) {
|
|
16646
|
+
constructor(parent, context, importDescriptions) {
|
|
16726
16647
|
super(parent, context);
|
|
16648
|
+
this.importDescriptions = importDescriptions;
|
|
16727
16649
|
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
16728
16650
|
}
|
|
16729
16651
|
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
16730
|
-
if (this.
|
|
16652
|
+
if (this.importDescriptions.has(identifier.name)) {
|
|
16731
16653
|
context.error(parseAst_js.logRedeclarationError(identifier.name), identifier.start);
|
|
16732
16654
|
}
|
|
16733
16655
|
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
@@ -17039,6 +16961,10 @@ class UpdateExpression extends NodeBase {
|
|
|
17039
16961
|
}
|
|
17040
16962
|
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
17041
16963
|
|
|
16964
|
+
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
16965
|
+
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
16966
|
+
}
|
|
16967
|
+
|
|
17042
16968
|
class VariableDeclaration extends NodeBase {
|
|
17043
16969
|
deoptimizePath() {
|
|
17044
16970
|
for (const declarator of this.declarations) {
|
|
@@ -17224,6 +17150,92 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
17224
17150
|
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
17225
17151
|
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
17226
17152
|
|
|
17153
|
+
class VariableDeclarator extends NodeBase {
|
|
17154
|
+
declareDeclarator(kind) {
|
|
17155
|
+
this.isUsingDeclaration = kind === 'using';
|
|
17156
|
+
this.isAsyncUsingDeclaration = kind === 'await using';
|
|
17157
|
+
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
17158
|
+
}
|
|
17159
|
+
deoptimizePath(path) {
|
|
17160
|
+
this.id.deoptimizePath(path);
|
|
17161
|
+
}
|
|
17162
|
+
hasEffects(context) {
|
|
17163
|
+
const initEffect = this.init?.hasEffects(context);
|
|
17164
|
+
this.id.markDeclarationReached();
|
|
17165
|
+
return (initEffect ||
|
|
17166
|
+
this.isUsingDeclaration ||
|
|
17167
|
+
this.isAsyncUsingDeclaration ||
|
|
17168
|
+
this.id.hasEffects(context) ||
|
|
17169
|
+
(this.scope.context.options.treeshake
|
|
17170
|
+
.propertyReadSideEffects &&
|
|
17171
|
+
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
17172
|
+
}
|
|
17173
|
+
include(context, includeChildrenRecursively) {
|
|
17174
|
+
const { id, init } = this;
|
|
17175
|
+
if (!this.included)
|
|
17176
|
+
this.includeNode(context);
|
|
17177
|
+
init?.include(context, includeChildrenRecursively);
|
|
17178
|
+
id.markDeclarationReached();
|
|
17179
|
+
if (includeChildrenRecursively) {
|
|
17180
|
+
id.include(context, includeChildrenRecursively);
|
|
17181
|
+
}
|
|
17182
|
+
else {
|
|
17183
|
+
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
17184
|
+
}
|
|
17185
|
+
}
|
|
17186
|
+
removeAnnotations(code) {
|
|
17187
|
+
this.init?.removeAnnotations(code);
|
|
17188
|
+
}
|
|
17189
|
+
render(code, options) {
|
|
17190
|
+
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
17191
|
+
const { end, id, init, start } = this;
|
|
17192
|
+
const renderId = id.included || this.isUsingDeclaration || this.isAsyncUsingDeclaration;
|
|
17193
|
+
if (renderId) {
|
|
17194
|
+
id.render(code, options);
|
|
17195
|
+
}
|
|
17196
|
+
else {
|
|
17197
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
17198
|
+
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
17199
|
+
}
|
|
17200
|
+
if (init) {
|
|
17201
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
17202
|
+
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
17203
|
+
if (renderedVariable !== id.name) {
|
|
17204
|
+
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
17205
|
+
}
|
|
17206
|
+
}
|
|
17207
|
+
init.render(code, options, renderId ? parseAst_js.BLANK : { renderedSurroundingElement: parseAst_js.ExpressionStatement });
|
|
17208
|
+
}
|
|
17209
|
+
else if (id instanceof Identifier &&
|
|
17210
|
+
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
17211
|
+
code.appendLeft(end, `${_}=${_}void 0`);
|
|
17212
|
+
}
|
|
17213
|
+
}
|
|
17214
|
+
includeNode(context) {
|
|
17215
|
+
this.included = true;
|
|
17216
|
+
const { id, init } = this;
|
|
17217
|
+
if (init) {
|
|
17218
|
+
if (this.isUsingDeclaration) {
|
|
17219
|
+
init.includePath(SYMBOL_DISPOSE_PATH, context);
|
|
17220
|
+
}
|
|
17221
|
+
else if (this.isAsyncUsingDeclaration) {
|
|
17222
|
+
init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context);
|
|
17223
|
+
}
|
|
17224
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
17225
|
+
const { name, variable } = id;
|
|
17226
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
17227
|
+
if (accessedVariable !== variable) {
|
|
17228
|
+
accessedVariable.forbidName(name);
|
|
17229
|
+
}
|
|
17230
|
+
}
|
|
17231
|
+
}
|
|
17232
|
+
}
|
|
17233
|
+
}
|
|
17234
|
+
}
|
|
17235
|
+
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
17236
|
+
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
17237
|
+
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
17238
|
+
|
|
17227
17239
|
class WhileStatement extends NodeBase {
|
|
17228
17240
|
hasEffects(context) {
|
|
17229
17241
|
if (this.test.hasEffects(context))
|
|
@@ -18504,27 +18516,26 @@ class Module {
|
|
|
18504
18516
|
this.needsExportShim = false;
|
|
18505
18517
|
this.sideEffectDependenciesByVariable = new Map();
|
|
18506
18518
|
this.sourcesWithAttributes = new Map();
|
|
18507
|
-
this.allExportNames = null;
|
|
18508
18519
|
this.allExportsIncluded = false;
|
|
18509
18520
|
this.ast = null;
|
|
18510
18521
|
this.exportAllModules = [];
|
|
18511
18522
|
this.exportAllSources = new Set();
|
|
18523
|
+
this.exportDescriptions = new Map();
|
|
18524
|
+
this.exportedVariablesByName = null;
|
|
18512
18525
|
this.exportNamesByVariable = null;
|
|
18513
18526
|
this.exportShimVariable = new ExportShimVariable(this);
|
|
18514
|
-
this.exports = new Map();
|
|
18515
18527
|
this.namespaceReexportsByName = new Map();
|
|
18516
18528
|
this.reexportDescriptions = new Map();
|
|
18517
18529
|
this.relevantDependencies = null;
|
|
18518
18530
|
this.syntheticExports = new Map();
|
|
18519
18531
|
this.syntheticNamespace = null;
|
|
18520
18532
|
this.transformDependencies = [];
|
|
18521
|
-
this.transitiveReexports = null;
|
|
18522
18533
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
18523
18534
|
this.context = options.moduleContext(id);
|
|
18524
18535
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
18525
18536
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
18526
18537
|
const module = this;
|
|
18527
|
-
const { dynamicImports, dynamicImporters, exportAllSources,
|
|
18538
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAttributes } = this;
|
|
18528
18539
|
this.info = {
|
|
18529
18540
|
ast: null,
|
|
18530
18541
|
attributes,
|
|
@@ -18543,7 +18554,7 @@ class Module {
|
|
|
18543
18554
|
return dynamicImporters.sort();
|
|
18544
18555
|
},
|
|
18545
18556
|
get exportedBindings() {
|
|
18546
|
-
const exportBindings = { '.': [...
|
|
18557
|
+
const exportBindings = { '.': [...exportDescriptions.keys()] };
|
|
18547
18558
|
for (const [name, { source }] of reexportDescriptions) {
|
|
18548
18559
|
(exportBindings[source] ??= []).push(name);
|
|
18549
18560
|
}
|
|
@@ -18554,7 +18565,7 @@ class Module {
|
|
|
18554
18565
|
},
|
|
18555
18566
|
get exports() {
|
|
18556
18567
|
return [
|
|
18557
|
-
...
|
|
18568
|
+
...exportDescriptions.keys(),
|
|
18558
18569
|
...reexportDescriptions.keys(),
|
|
18559
18570
|
...[...exportAllSources].map(() => '*')
|
|
18560
18571
|
];
|
|
@@ -18564,7 +18575,7 @@ class Module {
|
|
|
18564
18575
|
if (!module.ast) {
|
|
18565
18576
|
return null;
|
|
18566
18577
|
}
|
|
18567
|
-
return module.
|
|
18578
|
+
return module.exportDescriptions.has('default') || reexportDescriptions.has('default');
|
|
18568
18579
|
},
|
|
18569
18580
|
id,
|
|
18570
18581
|
get implicitlyLoadedAfterOneOf() {
|
|
@@ -18637,28 +18648,6 @@ class Module {
|
|
|
18637
18648
|
}
|
|
18638
18649
|
return size;
|
|
18639
18650
|
}
|
|
18640
|
-
getAllExportNames() {
|
|
18641
|
-
if (this.allExportNames) {
|
|
18642
|
-
return this.allExportNames;
|
|
18643
|
-
}
|
|
18644
|
-
this.allExportNames = new Set([...this.exports.keys(), ...this.reexportDescriptions.keys()]);
|
|
18645
|
-
for (const module of this.exportAllModules) {
|
|
18646
|
-
if (module instanceof ExternalModule) {
|
|
18647
|
-
this.allExportNames.add(`*${module.id}`);
|
|
18648
|
-
continue;
|
|
18649
|
-
}
|
|
18650
|
-
for (const name of module.getAllExportNames()) {
|
|
18651
|
-
if (name !== 'default')
|
|
18652
|
-
this.allExportNames.add(name);
|
|
18653
|
-
}
|
|
18654
|
-
}
|
|
18655
|
-
// We do not count the synthetic namespace as a regular export to hide it
|
|
18656
|
-
// from entry signatures and namespace objects
|
|
18657
|
-
if (typeof this.info.syntheticNamedExports === 'string') {
|
|
18658
|
-
this.allExportNames.delete(this.info.syntheticNamedExports);
|
|
18659
|
-
}
|
|
18660
|
-
return this.allExportNames;
|
|
18661
|
-
}
|
|
18662
18651
|
getDependenciesToBeIncluded() {
|
|
18663
18652
|
if (this.relevantDependencies)
|
|
18664
18653
|
return this.relevantDependencies;
|
|
@@ -18670,10 +18659,9 @@ class Module {
|
|
|
18670
18659
|
this.includedDynamicImporters.length > 0 ||
|
|
18671
18660
|
this.namespace.included ||
|
|
18672
18661
|
this.implicitlyLoadedAfter.size > 0) {
|
|
18673
|
-
for (const
|
|
18674
|
-
|
|
18675
|
-
|
|
18676
|
-
dependencyVariables.add(exportedVariable);
|
|
18662
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
18663
|
+
if (variable.included) {
|
|
18664
|
+
dependencyVariables.add(variable);
|
|
18677
18665
|
}
|
|
18678
18666
|
}
|
|
18679
18667
|
}
|
|
@@ -18705,18 +18693,56 @@ class Module {
|
|
|
18705
18693
|
}
|
|
18706
18694
|
return this.relevantDependencies;
|
|
18707
18695
|
}
|
|
18696
|
+
getExportedVariablesByName() {
|
|
18697
|
+
if (this.exportedVariablesByName) {
|
|
18698
|
+
return this.exportedVariablesByName;
|
|
18699
|
+
}
|
|
18700
|
+
const exportedVariablesByName = (this.exportedVariablesByName = new Map());
|
|
18701
|
+
for (const name of this.exportDescriptions.keys()) {
|
|
18702
|
+
// We do not count the synthetic namespace as a regular export to hide it
|
|
18703
|
+
// from entry signatures and namespace objects
|
|
18704
|
+
if (name !== this.info.syntheticNamedExports) {
|
|
18705
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
18706
|
+
if (exportedVariable) {
|
|
18707
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
18708
|
+
}
|
|
18709
|
+
else {
|
|
18710
|
+
return parseAst_js.error(parseAst_js.logMissingEntryExport(name, this.id));
|
|
18711
|
+
}
|
|
18712
|
+
}
|
|
18713
|
+
}
|
|
18714
|
+
for (const name of this.reexportDescriptions.keys()) {
|
|
18715
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
18716
|
+
if (exportedVariable) {
|
|
18717
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
18718
|
+
}
|
|
18719
|
+
}
|
|
18720
|
+
for (const module of this.exportAllModules) {
|
|
18721
|
+
if (module instanceof ExternalModule) {
|
|
18722
|
+
exportedVariablesByName.set(`*${module.id}`, module.getVariableForExportName('*', {
|
|
18723
|
+
importChain: [this.id]
|
|
18724
|
+
})[0]);
|
|
18725
|
+
continue;
|
|
18726
|
+
}
|
|
18727
|
+
for (const name of module.getExportedVariablesByName().keys()) {
|
|
18728
|
+
if (name !== 'default' && !exportedVariablesByName.has(name)) {
|
|
18729
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
18730
|
+
if (exportedVariable) {
|
|
18731
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
18732
|
+
}
|
|
18733
|
+
}
|
|
18734
|
+
}
|
|
18735
|
+
}
|
|
18736
|
+
return (this.exportedVariablesByName = new Map([...exportedVariablesByName].sort(sortExportedVariables)));
|
|
18737
|
+
}
|
|
18708
18738
|
getExportNamesByVariable() {
|
|
18709
18739
|
if (this.exportNamesByVariable) {
|
|
18710
18740
|
return this.exportNamesByVariable;
|
|
18711
18741
|
}
|
|
18712
18742
|
const exportNamesByVariable = new Map();
|
|
18713
|
-
for (const exportName of this.
|
|
18714
|
-
|
|
18715
|
-
if (
|
|
18716
|
-
tracedVariable = tracedVariable.getOriginalVariable();
|
|
18717
|
-
}
|
|
18718
|
-
if (!tracedVariable ||
|
|
18719
|
-
!(tracedVariable.included || tracedVariable instanceof ExternalVariable)) {
|
|
18743
|
+
for (const [exportName, variable] of this.getExportedVariablesByName().entries()) {
|
|
18744
|
+
const tracedVariable = variable instanceof ExportDefaultVariable ? variable.getOriginalVariable() : variable;
|
|
18745
|
+
if (!variable || !(variable.included || variable instanceof ExternalVariable)) {
|
|
18720
18746
|
continue;
|
|
18721
18747
|
}
|
|
18722
18748
|
const existingExportNames = exportNamesByVariable.get(tracedVariable);
|
|
@@ -18729,36 +18755,14 @@ class Module {
|
|
|
18729
18755
|
}
|
|
18730
18756
|
return (this.exportNamesByVariable = exportNamesByVariable);
|
|
18731
18757
|
}
|
|
18732
|
-
getExports() {
|
|
18733
|
-
return [...this.exports.keys()];
|
|
18734
|
-
}
|
|
18735
|
-
getReexports() {
|
|
18736
|
-
if (this.transitiveReexports) {
|
|
18737
|
-
return this.transitiveReexports;
|
|
18738
|
-
}
|
|
18739
|
-
// to avoid infinite recursion when using circular `export * from X`
|
|
18740
|
-
this.transitiveReexports = [];
|
|
18741
|
-
const reexports = new Set(this.reexportDescriptions.keys());
|
|
18742
|
-
for (const module of this.exportAllModules) {
|
|
18743
|
-
if (module instanceof ExternalModule) {
|
|
18744
|
-
reexports.add(`*${module.id}`);
|
|
18745
|
-
}
|
|
18746
|
-
else {
|
|
18747
|
-
for (const name of [...module.getReexports(), ...module.getExports()]) {
|
|
18748
|
-
if (name !== 'default')
|
|
18749
|
-
reexports.add(name);
|
|
18750
|
-
}
|
|
18751
|
-
}
|
|
18752
|
-
}
|
|
18753
|
-
return (this.transitiveReexports = [...reexports]);
|
|
18754
|
-
}
|
|
18755
18758
|
getRenderedExports() {
|
|
18756
18759
|
// only direct exports are counted here, not reexports at all
|
|
18757
18760
|
const renderedExports = [];
|
|
18758
18761
|
const removedExports = [];
|
|
18759
|
-
for (const exportName of this.
|
|
18760
|
-
|
|
18761
|
-
|
|
18762
|
+
for (const exportName of this.exportDescriptions.keys()) {
|
|
18763
|
+
(this.getExportedVariablesByName().get(exportName)?.included
|
|
18764
|
+
? renderedExports
|
|
18765
|
+
: removedExports).push(exportName);
|
|
18762
18766
|
}
|
|
18763
18767
|
return { removedExports, renderedExports };
|
|
18764
18768
|
}
|
|
@@ -18801,7 +18805,7 @@ class Module {
|
|
|
18801
18805
|
}
|
|
18802
18806
|
return [variable];
|
|
18803
18807
|
}
|
|
18804
|
-
const exportDeclaration = this.
|
|
18808
|
+
const exportDeclaration = this.exportDescriptions.get(name);
|
|
18805
18809
|
if (exportDeclaration) {
|
|
18806
18810
|
if (exportDeclaration === MISSING_EXPORT_SHIM_DESCRIPTION) {
|
|
18807
18811
|
return [this.exportShimVariable];
|
|
@@ -18852,63 +18856,29 @@ class Module {
|
|
|
18852
18856
|
if (this.ast.shouldBeIncluded(context))
|
|
18853
18857
|
this.ast.include(context, false);
|
|
18854
18858
|
}
|
|
18855
|
-
includeAllExports(
|
|
18856
|
-
if (includeNamespaceMembers) {
|
|
18857
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
18858
|
-
}
|
|
18859
|
+
includeAllExports() {
|
|
18859
18860
|
if (this.allExportsIncluded)
|
|
18860
18861
|
return;
|
|
18861
18862
|
this.allExportsIncluded = true;
|
|
18862
|
-
|
|
18863
|
-
markModuleAndImpureDependenciesAsExecuted(this);
|
|
18864
|
-
this.graph.needsTreeshakingPass = true;
|
|
18865
|
-
}
|
|
18863
|
+
this.includeModuleInExecution();
|
|
18866
18864
|
const inclusionContext = createInclusionContext();
|
|
18867
|
-
for (const
|
|
18868
|
-
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
}
|
|
18873
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18874
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18875
|
-
}
|
|
18876
|
-
}
|
|
18877
|
-
for (const name of this.getReexports()) {
|
|
18878
|
-
const [variable] = this.getVariableForExportName(name);
|
|
18879
|
-
if (variable) {
|
|
18880
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18881
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18882
|
-
if (variable instanceof ExternalVariable) {
|
|
18883
|
-
variable.module.reexported = true;
|
|
18884
|
-
}
|
|
18865
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
18866
|
+
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18867
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18868
|
+
if (variable instanceof ExternalVariable) {
|
|
18869
|
+
variable.module.reexported = true;
|
|
18885
18870
|
}
|
|
18886
18871
|
}
|
|
18887
18872
|
}
|
|
18888
18873
|
includeAllInBundle() {
|
|
18889
18874
|
this.ast.include(createInclusionContext(), true);
|
|
18890
|
-
this.includeAllExports(
|
|
18875
|
+
this.includeAllExports();
|
|
18891
18876
|
}
|
|
18892
|
-
|
|
18877
|
+
includeModuleInExecution() {
|
|
18893
18878
|
if (!this.isExecuted) {
|
|
18894
18879
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
18895
18880
|
this.graph.needsTreeshakingPass = true;
|
|
18896
18881
|
}
|
|
18897
|
-
let includeNamespaceMembers = false;
|
|
18898
|
-
const inclusionContext = createInclusionContext();
|
|
18899
|
-
for (const name of names) {
|
|
18900
|
-
const variable = this.getVariableForExportName(name)[0];
|
|
18901
|
-
if (variable) {
|
|
18902
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18903
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18904
|
-
}
|
|
18905
|
-
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
18906
|
-
includeNamespaceMembers = true;
|
|
18907
|
-
}
|
|
18908
|
-
}
|
|
18909
|
-
if (includeNamespaceMembers) {
|
|
18910
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
18911
|
-
}
|
|
18912
18882
|
}
|
|
18913
18883
|
isIncluded() {
|
|
18914
18884
|
// Modules where this.ast is missing have been loaded via this.load and are
|
|
@@ -18987,14 +18957,11 @@ class Module {
|
|
|
18987
18957
|
deoptimizationTracker: this.graph.deoptimizationTracker,
|
|
18988
18958
|
error: this.error.bind(this),
|
|
18989
18959
|
fileName, // Needed for warnings
|
|
18990
|
-
getExports: this.getExports.bind(this),
|
|
18991
18960
|
getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this),
|
|
18992
18961
|
getModuleExecIndex: () => this.execIndex,
|
|
18993
18962
|
getModuleName: this.basename.bind(this),
|
|
18994
18963
|
getNodeConstructor: (name) => nodeConstructors[name] || nodeConstructors.UnknownNode,
|
|
18995
|
-
getReexports: this.getReexports.bind(this),
|
|
18996
18964
|
importDescriptions: this.importDescriptions,
|
|
18997
|
-
includeAllExports: () => this.includeAllExports(true),
|
|
18998
18965
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
18999
18966
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
19000
18967
|
log: this.log.bind(this),
|
|
@@ -19009,7 +18976,7 @@ class Module {
|
|
|
19009
18976
|
traceVariable: this.traceVariable.bind(this),
|
|
19010
18977
|
usesTopLevelAwait: false
|
|
19011
18978
|
};
|
|
19012
|
-
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
18979
|
+
this.scope = new ModuleScope(this.graph.scope, this.astContext, this.importDescriptions);
|
|
19013
18980
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
19014
18981
|
const programParent = { context: this.astContext, type: 'Module' };
|
|
19015
18982
|
if (ast) {
|
|
@@ -19110,10 +19077,10 @@ class Module {
|
|
|
19110
19077
|
typeof argument.value === 'string') {
|
|
19111
19078
|
argument = argument.value;
|
|
19112
19079
|
}
|
|
19113
|
-
this.dynamicImports.push({ argument, id: null, node
|
|
19080
|
+
this.dynamicImports.push({ argument, id: null, node });
|
|
19114
19081
|
}
|
|
19115
19082
|
assertUniqueExportName(name, nodeStart) {
|
|
19116
|
-
if (this.
|
|
19083
|
+
if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
|
|
19117
19084
|
this.error(parseAst_js.logDuplicateExportError(name), nodeStart);
|
|
19118
19085
|
}
|
|
19119
19086
|
}
|
|
@@ -19121,7 +19088,7 @@ class Module {
|
|
|
19121
19088
|
if (node instanceof ExportDefaultDeclaration) {
|
|
19122
19089
|
// export default foo;
|
|
19123
19090
|
this.assertUniqueExportName('default', node.start);
|
|
19124
|
-
this.
|
|
19091
|
+
this.exportDescriptions.set('default', {
|
|
19125
19092
|
identifier: node.variable.getAssignedVariableName(),
|
|
19126
19093
|
localName: 'default'
|
|
19127
19094
|
});
|
|
@@ -19168,7 +19135,7 @@ class Module {
|
|
|
19168
19135
|
for (const declarator of declaration.declarations) {
|
|
19169
19136
|
for (const localName of extractAssignedNames(declarator.id)) {
|
|
19170
19137
|
this.assertUniqueExportName(localName, declarator.id.start);
|
|
19171
|
-
this.
|
|
19138
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
19172
19139
|
}
|
|
19173
19140
|
}
|
|
19174
19141
|
}
|
|
@@ -19176,7 +19143,7 @@ class Module {
|
|
|
19176
19143
|
// export function foo () {}
|
|
19177
19144
|
const localName = declaration.id.name;
|
|
19178
19145
|
this.assertUniqueExportName(localName, declaration.id.start);
|
|
19179
|
-
this.
|
|
19146
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
19180
19147
|
}
|
|
19181
19148
|
}
|
|
19182
19149
|
else {
|
|
@@ -19186,7 +19153,7 @@ class Module {
|
|
|
19186
19153
|
const localName = local.name;
|
|
19187
19154
|
const exportedName = exported instanceof Identifier ? exported.name : exported.value;
|
|
19188
19155
|
this.assertUniqueExportName(exportedName, exported.start);
|
|
19189
|
-
this.
|
|
19156
|
+
this.exportDescriptions.set(exportedName, { identifier: null, localName });
|
|
19190
19157
|
}
|
|
19191
19158
|
}
|
|
19192
19159
|
}
|
|
@@ -19360,7 +19327,7 @@ class Module {
|
|
|
19360
19327
|
return [...syntheticNamespaces, ...externalNamespaces];
|
|
19361
19328
|
}
|
|
19362
19329
|
includeDynamicImport(node) {
|
|
19363
|
-
const resolution =
|
|
19330
|
+
const { resolution } = node;
|
|
19364
19331
|
if (resolution instanceof Module) {
|
|
19365
19332
|
if (!resolution.includedDynamicImporters.includes(this)) {
|
|
19366
19333
|
resolution.includedDynamicImporters.push(this);
|
|
@@ -19370,15 +19337,6 @@ class Module {
|
|
|
19370
19337
|
resolution.includedTopLevelAwaitingDynamicImporters.add(this);
|
|
19371
19338
|
}
|
|
19372
19339
|
}
|
|
19373
|
-
const importedNames = this.options.treeshake
|
|
19374
|
-
? node.getDeterministicImportedNames()
|
|
19375
|
-
: undefined;
|
|
19376
|
-
if (importedNames) {
|
|
19377
|
-
resolution.includeExportsByNames(importedNames);
|
|
19378
|
-
}
|
|
19379
|
-
else {
|
|
19380
|
-
resolution.includeAllExports(true);
|
|
19381
|
-
}
|
|
19382
19340
|
}
|
|
19383
19341
|
}
|
|
19384
19342
|
includeVariable(variable, path, context) {
|
|
@@ -19388,21 +19346,17 @@ class Module {
|
|
|
19388
19346
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
19389
19347
|
getAndExtendSideEffectModules(variable, this);
|
|
19390
19348
|
}
|
|
19349
|
+
return;
|
|
19391
19350
|
}
|
|
19392
|
-
|
|
19393
|
-
|
|
19394
|
-
|
|
19395
|
-
|
|
19396
|
-
|
|
19397
|
-
|
|
19398
|
-
|
|
19399
|
-
|
|
19400
|
-
|
|
19401
|
-
if (!module.isExecuted) {
|
|
19402
|
-
markModuleAndImpureDependenciesAsExecuted(module);
|
|
19403
|
-
}
|
|
19404
|
-
}
|
|
19405
|
-
}
|
|
19351
|
+
this.graph.needsTreeshakingPass = true;
|
|
19352
|
+
if (!(variableModule instanceof Module)) {
|
|
19353
|
+
return;
|
|
19354
|
+
}
|
|
19355
|
+
variableModule.includeModuleInExecution();
|
|
19356
|
+
if (variableModule !== this) {
|
|
19357
|
+
const sideEffectModules = getAndExtendSideEffectModules(variable, this);
|
|
19358
|
+
for (const module of sideEffectModules) {
|
|
19359
|
+
module.includeModuleInExecution();
|
|
19406
19360
|
}
|
|
19407
19361
|
}
|
|
19408
19362
|
}
|
|
@@ -19415,7 +19369,7 @@ class Module {
|
|
|
19415
19369
|
}
|
|
19416
19370
|
shimMissingExport(name) {
|
|
19417
19371
|
this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logShimmedExport(this.id, name));
|
|
19418
|
-
this.
|
|
19372
|
+
this.exportDescriptions.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
|
|
19419
19373
|
}
|
|
19420
19374
|
tryParse() {
|
|
19421
19375
|
try {
|
|
@@ -19445,6 +19399,7 @@ function setAlternativeExporterIfCyclic(variable, importer, reexporter) {
|
|
|
19445
19399
|
}
|
|
19446
19400
|
const copyNameToModulesMap = (searchedNamesAndModules) => searchedNamesAndModules &&
|
|
19447
19401
|
new Map(Array.from(searchedNamesAndModules, ([name, modules]) => [name, new Set(modules)]));
|
|
19402
|
+
const sortExportedVariables = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
19448
19403
|
|
|
19449
19404
|
const concatSeparator = (out, next) => (next ? `${out}\n${next}` : out);
|
|
19450
19405
|
const concatDblSeparator = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
@@ -19827,6 +19782,8 @@ class Chunk {
|
|
|
19827
19782
|
includedNamespaces.add(module);
|
|
19828
19783
|
this.exports.add(module.namespace);
|
|
19829
19784
|
}
|
|
19785
|
+
// This only needs to run once
|
|
19786
|
+
break;
|
|
19830
19787
|
}
|
|
19831
19788
|
}
|
|
19832
19789
|
if (module.implicitlyLoadedAfter.size > 0) {
|
|
@@ -20464,10 +20421,11 @@ class Chunk {
|
|
|
20464
20421
|
}
|
|
20465
20422
|
const includedDynamicImports = [];
|
|
20466
20423
|
for (const module of this.orderedModules) {
|
|
20467
|
-
for (const { node
|
|
20424
|
+
for (const { node } of module.dynamicImports) {
|
|
20468
20425
|
if (!node.included) {
|
|
20469
20426
|
continue;
|
|
20470
20427
|
}
|
|
20428
|
+
const { resolution } = node;
|
|
20471
20429
|
includedDynamicImports.push(resolution instanceof Module
|
|
20472
20430
|
? {
|
|
20473
20431
|
chunk: this.chunkByModule.get(resolution),
|
|
@@ -20725,13 +20683,13 @@ class Chunk {
|
|
|
20725
20683
|
node.setInternalResolution(resolution.namespace);
|
|
20726
20684
|
}
|
|
20727
20685
|
else {
|
|
20728
|
-
node.setExternalResolution((facadeChunk || chunk).exportMode,
|
|
20686
|
+
node.setExternalResolution((facadeChunk || chunk).exportMode, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)[0], null, this, facadeChunk || chunk);
|
|
20729
20687
|
}
|
|
20730
20688
|
}
|
|
20731
20689
|
else {
|
|
20732
20690
|
const { node, resolution } = resolvedDynamicImport;
|
|
20733
20691
|
const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
|
|
20734
|
-
node.setExternalResolution('external',
|
|
20692
|
+
node.setExternalResolution('external', outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
|
|
20735
20693
|
}
|
|
20736
20694
|
}
|
|
20737
20695
|
}
|
|
@@ -20784,8 +20742,7 @@ class Chunk {
|
|
|
20784
20742
|
// when we are not preserving modules, we need to make all namespace variables available for
|
|
20785
20743
|
// rendering the namespace object
|
|
20786
20744
|
if (!this.outputOptions.preserveModules && this.includedNamespaces.has(module)) {
|
|
20787
|
-
const
|
|
20788
|
-
for (const variable of Object.values(memberVariables)) {
|
|
20745
|
+
for (const variable of module.getExportedVariablesByName().values()) {
|
|
20789
20746
|
if (variable.included) {
|
|
20790
20747
|
moduleImports.add(variable);
|
|
20791
20748
|
}
|
|
@@ -20816,8 +20773,8 @@ class Chunk {
|
|
|
20816
20773
|
module.includedDynamicImporters.some(importer => this.chunkByModule.get(importer) !== this)) {
|
|
20817
20774
|
this.ensureReexportsAreAvailableForModule(module);
|
|
20818
20775
|
}
|
|
20819
|
-
for (const { node, resolution } of module.dynamicImports) {
|
|
20820
|
-
if (
|
|
20776
|
+
for (const { node: { included, resolution } } of module.dynamicImports) {
|
|
20777
|
+
if (included &&
|
|
20821
20778
|
resolution instanceof Module &&
|
|
20822
20779
|
this.chunkByModule.get(resolution) === this &&
|
|
20823
20780
|
!this.includedNamespaces.has(resolution)) {
|
|
@@ -21048,7 +21005,7 @@ function analyzeModuleGraph(entries) {
|
|
|
21048
21005
|
staticDependencies.add(dependency);
|
|
21049
21006
|
}
|
|
21050
21007
|
}
|
|
21051
|
-
for (const { resolution } of module.dynamicImports) {
|
|
21008
|
+
for (const { node: { resolution } } of module.dynamicImports) {
|
|
21052
21009
|
if (resolution instanceof Module &&
|
|
21053
21010
|
resolution.includedDynamicImporters.length > 0 &&
|
|
21054
21011
|
!allEntriesSet.has(resolution)) {
|
|
@@ -21589,9 +21546,9 @@ function analyseModuleExecution(entryModules) {
|
|
|
21589
21546
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
21590
21547
|
dynamicImports.add(dependency);
|
|
21591
21548
|
}
|
|
21592
|
-
for (const { resolution,
|
|
21549
|
+
for (const { node: { resolution, scope } } of module.dynamicImports) {
|
|
21593
21550
|
if (resolution instanceof Module) {
|
|
21594
|
-
if (
|
|
21551
|
+
if (scope.context.usesTopLevelAwait) {
|
|
21595
21552
|
handleSyncLoadedModule(resolution, module);
|
|
21596
21553
|
}
|
|
21597
21554
|
else {
|
|
@@ -22743,14 +22700,14 @@ class ModuleLoader {
|
|
|
22743
22700
|
return loadNewModulesPromise;
|
|
22744
22701
|
}
|
|
22745
22702
|
async fetchDynamicDependencies(module, resolveDynamicImportPromises) {
|
|
22746
|
-
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([
|
|
22703
|
+
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([{ node }, resolvedId]) => {
|
|
22747
22704
|
if (resolvedId === null)
|
|
22748
22705
|
return null;
|
|
22749
22706
|
if (typeof resolvedId === 'string') {
|
|
22750
|
-
|
|
22707
|
+
node.resolution = resolvedId;
|
|
22751
22708
|
return null;
|
|
22752
22709
|
}
|
|
22753
|
-
return (
|
|
22710
|
+
return (node.resolution = await this.fetchResolvedDependency(parseAst_js.relativeId(resolvedId.id), module.id, resolvedId));
|
|
22754
22711
|
})));
|
|
22755
22712
|
for (const dependency of dependencies) {
|
|
22756
22713
|
if (dependency) {
|
|
@@ -23132,7 +23089,7 @@ class Graph {
|
|
|
23132
23089
|
timeEnd('generate module graph', 2);
|
|
23133
23090
|
timeStart('sort and bind modules', 2);
|
|
23134
23091
|
this.phase = BuildPhase.ANALYSE;
|
|
23135
|
-
this.
|
|
23092
|
+
this.sortAndBindModules();
|
|
23136
23093
|
timeEnd('sort and bind modules', 2);
|
|
23137
23094
|
timeStart('mark included statements', 2);
|
|
23138
23095
|
this.includeStatements();
|
|
@@ -23205,7 +23162,7 @@ class Graph {
|
|
|
23205
23162
|
// the TDZ detection logic
|
|
23206
23163
|
for (const module of entryModules) {
|
|
23207
23164
|
if (module.preserveSignature !== false) {
|
|
23208
|
-
module.includeAllExports(
|
|
23165
|
+
module.includeAllExports();
|
|
23209
23166
|
this.needsTreeshakingPass = true;
|
|
23210
23167
|
}
|
|
23211
23168
|
}
|
|
@@ -23227,7 +23184,7 @@ class Graph {
|
|
|
23227
23184
|
}
|
|
23228
23185
|
}
|
|
23229
23186
|
}
|
|
23230
|
-
|
|
23187
|
+
sortAndBindModules() {
|
|
23231
23188
|
const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
|
|
23232
23189
|
for (const cyclePath of cyclePaths) {
|
|
23233
23190
|
this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logCircularDependency(cyclePath));
|