@rollup/wasm-node 4.55.2 → 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 +394 -434
- 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 +393 -433
- 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) {
|
|
@@ -10310,7 +10295,7 @@ class ExpressionStatement extends NodeBase {
|
|
|
10310
10295
|
render(code, options) {
|
|
10311
10296
|
super.render(code, options);
|
|
10312
10297
|
if (code.original[this.end - 1] !== ';') {
|
|
10313
|
-
code.
|
|
10298
|
+
code.appendLeft(this.end, ';');
|
|
10314
10299
|
}
|
|
10315
10300
|
}
|
|
10316
10301
|
shouldBeIncluded(context) {
|
|
@@ -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
|
}
|
|
@@ -15490,9 +15414,9 @@ class JSXElement extends JSXElementBase {
|
|
|
15490
15414
|
}
|
|
15491
15415
|
renderAutomaticMode(code, options) {
|
|
15492
15416
|
const { snippets: { getPropertyAccess }, useOriginalName } = options;
|
|
15493
|
-
const { closingElement, end, factoryVariable, openingElement: { end:
|
|
15417
|
+
const { closingElement, end, factoryVariable, openingElement: { end: openingEnd, selfClosing } } = this;
|
|
15494
15418
|
let { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd } = this.renderAttributes(code, options, factoryVariable.getName(getPropertyAccess, useOriginalName), true);
|
|
15495
|
-
const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren(code, options,
|
|
15419
|
+
const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren(code, options, openingEnd);
|
|
15496
15420
|
if (firstChild) {
|
|
15497
15421
|
code.prependRight(firstChild.start, `children: ${hasMultipleChildren ? '[' : ''}`);
|
|
15498
15422
|
if (!inObject) {
|
|
@@ -15504,16 +15428,21 @@ class JSXElement extends JSXElementBase {
|
|
|
15504
15428
|
code.appendLeft(previousEnd, ']');
|
|
15505
15429
|
}
|
|
15506
15430
|
}
|
|
15507
|
-
|
|
15431
|
+
// This ensures that attributesEnd never corresponds to this.end. This is
|
|
15432
|
+
// important because we must never use code.move with this.end as target.
|
|
15433
|
+
// Otherwise, this would interfere with parent elements that try to append
|
|
15434
|
+
// code to this.end, which would appear BEFORE the moved code.
|
|
15435
|
+
const attributesEnd = firstChild ? childrenEnd : previousEnd;
|
|
15436
|
+
this.wrapAttributes(code, inObject, hasAttributes || !!firstChild, hasSpread, firstAttribute || firstChild, '{}', attributesEnd);
|
|
15508
15437
|
if (keyAttribute) {
|
|
15509
15438
|
const { value } = keyAttribute;
|
|
15510
15439
|
// This will appear to the left of the moved code...
|
|
15511
|
-
code.appendLeft(
|
|
15440
|
+
code.appendLeft(attributesEnd, ', ');
|
|
15512
15441
|
if (value) {
|
|
15513
|
-
code.move(value.start, value.end,
|
|
15442
|
+
code.move(value.start, value.end, attributesEnd);
|
|
15514
15443
|
}
|
|
15515
15444
|
else {
|
|
15516
|
-
code.appendLeft(
|
|
15445
|
+
code.appendLeft(attributesEnd, 'true');
|
|
15517
15446
|
}
|
|
15518
15447
|
}
|
|
15519
15448
|
if (selfClosing) {
|
|
@@ -15563,9 +15492,7 @@ class JSXElement extends JSXElementBase {
|
|
|
15563
15492
|
hasSpread = true;
|
|
15564
15493
|
}
|
|
15565
15494
|
previousEnd = attribute.end;
|
|
15566
|
-
|
|
15567
|
-
firstAttribute = attribute;
|
|
15568
|
-
}
|
|
15495
|
+
firstAttribute ??= attribute;
|
|
15569
15496
|
}
|
|
15570
15497
|
code.remove(attributes.at(-1)?.end || previousEnd, openingEnd);
|
|
15571
15498
|
return { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd };
|
|
@@ -16126,7 +16053,7 @@ ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
|
16126
16053
|
|
|
16127
16054
|
class PanicError extends NodeBase {
|
|
16128
16055
|
initialise() {
|
|
16129
|
-
const id = this.scope.context.module
|
|
16056
|
+
const { id } = this.scope.context.module;
|
|
16130
16057
|
// This simulates the current nested error structure. We could also just
|
|
16131
16058
|
// replace it with a flat error.
|
|
16132
16059
|
const parseError = parseAst_js.getRollupError(parseAst_js.logParseError(this.message));
|
|
@@ -16138,7 +16065,7 @@ class PanicError extends NodeBase {
|
|
|
16138
16065
|
class ParseError extends NodeBase {
|
|
16139
16066
|
initialise() {
|
|
16140
16067
|
const pos = this.start;
|
|
16141
|
-
const id = this.scope.context.module
|
|
16068
|
+
const { id } = this.scope.context.module;
|
|
16142
16069
|
// This simulates the current nested error structure. We could also just
|
|
16143
16070
|
// replace it with a flat error.
|
|
16144
16071
|
const parseError = parseAst_js.getRollupError(parseAst_js.logParseError(this.message, pos));
|
|
@@ -16597,9 +16524,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
16597
16524
|
set hasCheckedForWarnings(value) {
|
|
16598
16525
|
this.flags = setFlag(this.flags, 134217728 /* Flag.checkedForWarnings */, value);
|
|
16599
16526
|
}
|
|
16600
|
-
bind() {
|
|
16601
|
-
super.bind();
|
|
16602
|
-
}
|
|
16603
16527
|
hasEffects(context) {
|
|
16604
16528
|
if (!this.deoptimized)
|
|
16605
16529
|
this.applyDeoptimizations();
|
|
@@ -16719,12 +16643,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
16719
16643
|
}
|
|
16720
16644
|
|
|
16721
16645
|
class ModuleScope extends ChildScope {
|
|
16722
|
-
constructor(parent, context) {
|
|
16646
|
+
constructor(parent, context, importDescriptions) {
|
|
16723
16647
|
super(parent, context);
|
|
16648
|
+
this.importDescriptions = importDescriptions;
|
|
16724
16649
|
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
16725
16650
|
}
|
|
16726
16651
|
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
16727
|
-
if (this.
|
|
16652
|
+
if (this.importDescriptions.has(identifier.name)) {
|
|
16728
16653
|
context.error(parseAst_js.logRedeclarationError(identifier.name), identifier.start);
|
|
16729
16654
|
}
|
|
16730
16655
|
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
@@ -17036,6 +16961,10 @@ class UpdateExpression extends NodeBase {
|
|
|
17036
16961
|
}
|
|
17037
16962
|
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
17038
16963
|
|
|
16964
|
+
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
16965
|
+
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
16966
|
+
}
|
|
16967
|
+
|
|
17039
16968
|
class VariableDeclaration extends NodeBase {
|
|
17040
16969
|
deoptimizePath() {
|
|
17041
16970
|
for (const declarator of this.declarations) {
|
|
@@ -17221,6 +17150,92 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
17221
17150
|
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
17222
17151
|
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
17223
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
|
+
|
|
17224
17239
|
class WhileStatement extends NodeBase {
|
|
17225
17240
|
hasEffects(context) {
|
|
17226
17241
|
if (this.test.hasEffects(context))
|
|
@@ -18501,27 +18516,26 @@ class Module {
|
|
|
18501
18516
|
this.needsExportShim = false;
|
|
18502
18517
|
this.sideEffectDependenciesByVariable = new Map();
|
|
18503
18518
|
this.sourcesWithAttributes = new Map();
|
|
18504
|
-
this.allExportNames = null;
|
|
18505
18519
|
this.allExportsIncluded = false;
|
|
18506
18520
|
this.ast = null;
|
|
18507
18521
|
this.exportAllModules = [];
|
|
18508
18522
|
this.exportAllSources = new Set();
|
|
18523
|
+
this.exportDescriptions = new Map();
|
|
18524
|
+
this.exportedVariablesByName = null;
|
|
18509
18525
|
this.exportNamesByVariable = null;
|
|
18510
18526
|
this.exportShimVariable = new ExportShimVariable(this);
|
|
18511
|
-
this.exports = new Map();
|
|
18512
18527
|
this.namespaceReexportsByName = new Map();
|
|
18513
18528
|
this.reexportDescriptions = new Map();
|
|
18514
18529
|
this.relevantDependencies = null;
|
|
18515
18530
|
this.syntheticExports = new Map();
|
|
18516
18531
|
this.syntheticNamespace = null;
|
|
18517
18532
|
this.transformDependencies = [];
|
|
18518
|
-
this.transitiveReexports = null;
|
|
18519
18533
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
18520
18534
|
this.context = options.moduleContext(id);
|
|
18521
18535
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
18522
18536
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
18523
18537
|
const module = this;
|
|
18524
|
-
const { dynamicImports, dynamicImporters, exportAllSources,
|
|
18538
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAttributes } = this;
|
|
18525
18539
|
this.info = {
|
|
18526
18540
|
ast: null,
|
|
18527
18541
|
attributes,
|
|
@@ -18540,7 +18554,7 @@ class Module {
|
|
|
18540
18554
|
return dynamicImporters.sort();
|
|
18541
18555
|
},
|
|
18542
18556
|
get exportedBindings() {
|
|
18543
|
-
const exportBindings = { '.': [...
|
|
18557
|
+
const exportBindings = { '.': [...exportDescriptions.keys()] };
|
|
18544
18558
|
for (const [name, { source }] of reexportDescriptions) {
|
|
18545
18559
|
(exportBindings[source] ??= []).push(name);
|
|
18546
18560
|
}
|
|
@@ -18551,7 +18565,7 @@ class Module {
|
|
|
18551
18565
|
},
|
|
18552
18566
|
get exports() {
|
|
18553
18567
|
return [
|
|
18554
|
-
...
|
|
18568
|
+
...exportDescriptions.keys(),
|
|
18555
18569
|
...reexportDescriptions.keys(),
|
|
18556
18570
|
...[...exportAllSources].map(() => '*')
|
|
18557
18571
|
];
|
|
@@ -18561,7 +18575,7 @@ class Module {
|
|
|
18561
18575
|
if (!module.ast) {
|
|
18562
18576
|
return null;
|
|
18563
18577
|
}
|
|
18564
|
-
return module.
|
|
18578
|
+
return module.exportDescriptions.has('default') || reexportDescriptions.has('default');
|
|
18565
18579
|
},
|
|
18566
18580
|
id,
|
|
18567
18581
|
get implicitlyLoadedAfterOneOf() {
|
|
@@ -18634,28 +18648,6 @@ class Module {
|
|
|
18634
18648
|
}
|
|
18635
18649
|
return size;
|
|
18636
18650
|
}
|
|
18637
|
-
getAllExportNames() {
|
|
18638
|
-
if (this.allExportNames) {
|
|
18639
|
-
return this.allExportNames;
|
|
18640
|
-
}
|
|
18641
|
-
this.allExportNames = new Set([...this.exports.keys(), ...this.reexportDescriptions.keys()]);
|
|
18642
|
-
for (const module of this.exportAllModules) {
|
|
18643
|
-
if (module instanceof ExternalModule) {
|
|
18644
|
-
this.allExportNames.add(`*${module.id}`);
|
|
18645
|
-
continue;
|
|
18646
|
-
}
|
|
18647
|
-
for (const name of module.getAllExportNames()) {
|
|
18648
|
-
if (name !== 'default')
|
|
18649
|
-
this.allExportNames.add(name);
|
|
18650
|
-
}
|
|
18651
|
-
}
|
|
18652
|
-
// We do not count the synthetic namespace as a regular export to hide it
|
|
18653
|
-
// from entry signatures and namespace objects
|
|
18654
|
-
if (typeof this.info.syntheticNamedExports === 'string') {
|
|
18655
|
-
this.allExportNames.delete(this.info.syntheticNamedExports);
|
|
18656
|
-
}
|
|
18657
|
-
return this.allExportNames;
|
|
18658
|
-
}
|
|
18659
18651
|
getDependenciesToBeIncluded() {
|
|
18660
18652
|
if (this.relevantDependencies)
|
|
18661
18653
|
return this.relevantDependencies;
|
|
@@ -18667,10 +18659,9 @@ class Module {
|
|
|
18667
18659
|
this.includedDynamicImporters.length > 0 ||
|
|
18668
18660
|
this.namespace.included ||
|
|
18669
18661
|
this.implicitlyLoadedAfter.size > 0) {
|
|
18670
|
-
for (const
|
|
18671
|
-
|
|
18672
|
-
|
|
18673
|
-
dependencyVariables.add(exportedVariable);
|
|
18662
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
18663
|
+
if (variable.included) {
|
|
18664
|
+
dependencyVariables.add(variable);
|
|
18674
18665
|
}
|
|
18675
18666
|
}
|
|
18676
18667
|
}
|
|
@@ -18702,18 +18693,56 @@ class Module {
|
|
|
18702
18693
|
}
|
|
18703
18694
|
return this.relevantDependencies;
|
|
18704
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
|
+
}
|
|
18705
18738
|
getExportNamesByVariable() {
|
|
18706
18739
|
if (this.exportNamesByVariable) {
|
|
18707
18740
|
return this.exportNamesByVariable;
|
|
18708
18741
|
}
|
|
18709
18742
|
const exportNamesByVariable = new Map();
|
|
18710
|
-
for (const exportName of this.
|
|
18711
|
-
|
|
18712
|
-
if (
|
|
18713
|
-
tracedVariable = tracedVariable.getOriginalVariable();
|
|
18714
|
-
}
|
|
18715
|
-
if (!tracedVariable ||
|
|
18716
|
-
!(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)) {
|
|
18717
18746
|
continue;
|
|
18718
18747
|
}
|
|
18719
18748
|
const existingExportNames = exportNamesByVariable.get(tracedVariable);
|
|
@@ -18726,36 +18755,14 @@ class Module {
|
|
|
18726
18755
|
}
|
|
18727
18756
|
return (this.exportNamesByVariable = exportNamesByVariable);
|
|
18728
18757
|
}
|
|
18729
|
-
getExports() {
|
|
18730
|
-
return [...this.exports.keys()];
|
|
18731
|
-
}
|
|
18732
|
-
getReexports() {
|
|
18733
|
-
if (this.transitiveReexports) {
|
|
18734
|
-
return this.transitiveReexports;
|
|
18735
|
-
}
|
|
18736
|
-
// to avoid infinite recursion when using circular `export * from X`
|
|
18737
|
-
this.transitiveReexports = [];
|
|
18738
|
-
const reexports = new Set(this.reexportDescriptions.keys());
|
|
18739
|
-
for (const module of this.exportAllModules) {
|
|
18740
|
-
if (module instanceof ExternalModule) {
|
|
18741
|
-
reexports.add(`*${module.id}`);
|
|
18742
|
-
}
|
|
18743
|
-
else {
|
|
18744
|
-
for (const name of [...module.getReexports(), ...module.getExports()]) {
|
|
18745
|
-
if (name !== 'default')
|
|
18746
|
-
reexports.add(name);
|
|
18747
|
-
}
|
|
18748
|
-
}
|
|
18749
|
-
}
|
|
18750
|
-
return (this.transitiveReexports = [...reexports]);
|
|
18751
|
-
}
|
|
18752
18758
|
getRenderedExports() {
|
|
18753
18759
|
// only direct exports are counted here, not reexports at all
|
|
18754
18760
|
const renderedExports = [];
|
|
18755
18761
|
const removedExports = [];
|
|
18756
|
-
for (const exportName of this.
|
|
18757
|
-
|
|
18758
|
-
|
|
18762
|
+
for (const exportName of this.exportDescriptions.keys()) {
|
|
18763
|
+
(this.getExportedVariablesByName().get(exportName)?.included
|
|
18764
|
+
? renderedExports
|
|
18765
|
+
: removedExports).push(exportName);
|
|
18759
18766
|
}
|
|
18760
18767
|
return { removedExports, renderedExports };
|
|
18761
18768
|
}
|
|
@@ -18798,7 +18805,7 @@ class Module {
|
|
|
18798
18805
|
}
|
|
18799
18806
|
return [variable];
|
|
18800
18807
|
}
|
|
18801
|
-
const exportDeclaration = this.
|
|
18808
|
+
const exportDeclaration = this.exportDescriptions.get(name);
|
|
18802
18809
|
if (exportDeclaration) {
|
|
18803
18810
|
if (exportDeclaration === MISSING_EXPORT_SHIM_DESCRIPTION) {
|
|
18804
18811
|
return [this.exportShimVariable];
|
|
@@ -18849,63 +18856,29 @@ class Module {
|
|
|
18849
18856
|
if (this.ast.shouldBeIncluded(context))
|
|
18850
18857
|
this.ast.include(context, false);
|
|
18851
18858
|
}
|
|
18852
|
-
includeAllExports(
|
|
18853
|
-
if (includeNamespaceMembers) {
|
|
18854
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
18855
|
-
}
|
|
18859
|
+
includeAllExports() {
|
|
18856
18860
|
if (this.allExportsIncluded)
|
|
18857
18861
|
return;
|
|
18858
18862
|
this.allExportsIncluded = true;
|
|
18859
|
-
|
|
18860
|
-
markModuleAndImpureDependenciesAsExecuted(this);
|
|
18861
|
-
this.graph.needsTreeshakingPass = true;
|
|
18862
|
-
}
|
|
18863
|
+
this.includeModuleInExecution();
|
|
18863
18864
|
const inclusionContext = createInclusionContext();
|
|
18864
|
-
for (const
|
|
18865
|
-
|
|
18866
|
-
|
|
18867
|
-
|
|
18868
|
-
|
|
18869
|
-
}
|
|
18870
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18871
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18872
|
-
}
|
|
18873
|
-
}
|
|
18874
|
-
for (const name of this.getReexports()) {
|
|
18875
|
-
const [variable] = this.getVariableForExportName(name);
|
|
18876
|
-
if (variable) {
|
|
18877
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18878
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18879
|
-
if (variable instanceof ExternalVariable) {
|
|
18880
|
-
variable.module.reexported = true;
|
|
18881
|
-
}
|
|
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;
|
|
18882
18870
|
}
|
|
18883
18871
|
}
|
|
18884
18872
|
}
|
|
18885
18873
|
includeAllInBundle() {
|
|
18886
18874
|
this.ast.include(createInclusionContext(), true);
|
|
18887
|
-
this.includeAllExports(
|
|
18875
|
+
this.includeAllExports();
|
|
18888
18876
|
}
|
|
18889
|
-
|
|
18877
|
+
includeModuleInExecution() {
|
|
18890
18878
|
if (!this.isExecuted) {
|
|
18891
18879
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
18892
18880
|
this.graph.needsTreeshakingPass = true;
|
|
18893
18881
|
}
|
|
18894
|
-
let includeNamespaceMembers = false;
|
|
18895
|
-
const inclusionContext = createInclusionContext();
|
|
18896
|
-
for (const name of names) {
|
|
18897
|
-
const variable = this.getVariableForExportName(name)[0];
|
|
18898
|
-
if (variable) {
|
|
18899
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18900
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18901
|
-
}
|
|
18902
|
-
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
18903
|
-
includeNamespaceMembers = true;
|
|
18904
|
-
}
|
|
18905
|
-
}
|
|
18906
|
-
if (includeNamespaceMembers) {
|
|
18907
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
18908
|
-
}
|
|
18909
18882
|
}
|
|
18910
18883
|
isIncluded() {
|
|
18911
18884
|
// Modules where this.ast is missing have been loaded via this.load and are
|
|
@@ -18984,14 +18957,11 @@ class Module {
|
|
|
18984
18957
|
deoptimizationTracker: this.graph.deoptimizationTracker,
|
|
18985
18958
|
error: this.error.bind(this),
|
|
18986
18959
|
fileName, // Needed for warnings
|
|
18987
|
-
getExports: this.getExports.bind(this),
|
|
18988
18960
|
getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this),
|
|
18989
18961
|
getModuleExecIndex: () => this.execIndex,
|
|
18990
18962
|
getModuleName: this.basename.bind(this),
|
|
18991
18963
|
getNodeConstructor: (name) => nodeConstructors[name] || nodeConstructors.UnknownNode,
|
|
18992
|
-
getReexports: this.getReexports.bind(this),
|
|
18993
18964
|
importDescriptions: this.importDescriptions,
|
|
18994
|
-
includeAllExports: () => this.includeAllExports(true),
|
|
18995
18965
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
18996
18966
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
18997
18967
|
log: this.log.bind(this),
|
|
@@ -19006,7 +18976,7 @@ class Module {
|
|
|
19006
18976
|
traceVariable: this.traceVariable.bind(this),
|
|
19007
18977
|
usesTopLevelAwait: false
|
|
19008
18978
|
};
|
|
19009
|
-
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
18979
|
+
this.scope = new ModuleScope(this.graph.scope, this.astContext, this.importDescriptions);
|
|
19010
18980
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
19011
18981
|
const programParent = { context: this.astContext, type: 'Module' };
|
|
19012
18982
|
if (ast) {
|
|
@@ -19107,10 +19077,10 @@ class Module {
|
|
|
19107
19077
|
typeof argument.value === 'string') {
|
|
19108
19078
|
argument = argument.value;
|
|
19109
19079
|
}
|
|
19110
|
-
this.dynamicImports.push({ argument, id: null, node
|
|
19080
|
+
this.dynamicImports.push({ argument, id: null, node });
|
|
19111
19081
|
}
|
|
19112
19082
|
assertUniqueExportName(name, nodeStart) {
|
|
19113
|
-
if (this.
|
|
19083
|
+
if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
|
|
19114
19084
|
this.error(parseAst_js.logDuplicateExportError(name), nodeStart);
|
|
19115
19085
|
}
|
|
19116
19086
|
}
|
|
@@ -19118,7 +19088,7 @@ class Module {
|
|
|
19118
19088
|
if (node instanceof ExportDefaultDeclaration) {
|
|
19119
19089
|
// export default foo;
|
|
19120
19090
|
this.assertUniqueExportName('default', node.start);
|
|
19121
|
-
this.
|
|
19091
|
+
this.exportDescriptions.set('default', {
|
|
19122
19092
|
identifier: node.variable.getAssignedVariableName(),
|
|
19123
19093
|
localName: 'default'
|
|
19124
19094
|
});
|
|
@@ -19165,7 +19135,7 @@ class Module {
|
|
|
19165
19135
|
for (const declarator of declaration.declarations) {
|
|
19166
19136
|
for (const localName of extractAssignedNames(declarator.id)) {
|
|
19167
19137
|
this.assertUniqueExportName(localName, declarator.id.start);
|
|
19168
|
-
this.
|
|
19138
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
19169
19139
|
}
|
|
19170
19140
|
}
|
|
19171
19141
|
}
|
|
@@ -19173,7 +19143,7 @@ class Module {
|
|
|
19173
19143
|
// export function foo () {}
|
|
19174
19144
|
const localName = declaration.id.name;
|
|
19175
19145
|
this.assertUniqueExportName(localName, declaration.id.start);
|
|
19176
|
-
this.
|
|
19146
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
19177
19147
|
}
|
|
19178
19148
|
}
|
|
19179
19149
|
else {
|
|
@@ -19183,7 +19153,7 @@ class Module {
|
|
|
19183
19153
|
const localName = local.name;
|
|
19184
19154
|
const exportedName = exported instanceof Identifier ? exported.name : exported.value;
|
|
19185
19155
|
this.assertUniqueExportName(exportedName, exported.start);
|
|
19186
|
-
this.
|
|
19156
|
+
this.exportDescriptions.set(exportedName, { identifier: null, localName });
|
|
19187
19157
|
}
|
|
19188
19158
|
}
|
|
19189
19159
|
}
|
|
@@ -19357,7 +19327,7 @@ class Module {
|
|
|
19357
19327
|
return [...syntheticNamespaces, ...externalNamespaces];
|
|
19358
19328
|
}
|
|
19359
19329
|
includeDynamicImport(node) {
|
|
19360
|
-
const resolution =
|
|
19330
|
+
const { resolution } = node;
|
|
19361
19331
|
if (resolution instanceof Module) {
|
|
19362
19332
|
if (!resolution.includedDynamicImporters.includes(this)) {
|
|
19363
19333
|
resolution.includedDynamicImporters.push(this);
|
|
@@ -19367,15 +19337,6 @@ class Module {
|
|
|
19367
19337
|
resolution.includedTopLevelAwaitingDynamicImporters.add(this);
|
|
19368
19338
|
}
|
|
19369
19339
|
}
|
|
19370
|
-
const importedNames = this.options.treeshake
|
|
19371
|
-
? node.getDeterministicImportedNames()
|
|
19372
|
-
: undefined;
|
|
19373
|
-
if (importedNames) {
|
|
19374
|
-
resolution.includeExportsByNames(importedNames);
|
|
19375
|
-
}
|
|
19376
|
-
else {
|
|
19377
|
-
resolution.includeAllExports(true);
|
|
19378
|
-
}
|
|
19379
19340
|
}
|
|
19380
19341
|
}
|
|
19381
19342
|
includeVariable(variable, path, context) {
|
|
@@ -19385,21 +19346,17 @@ class Module {
|
|
|
19385
19346
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
19386
19347
|
getAndExtendSideEffectModules(variable, this);
|
|
19387
19348
|
}
|
|
19349
|
+
return;
|
|
19388
19350
|
}
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19393
|
-
|
|
19394
|
-
|
|
19395
|
-
|
|
19396
|
-
|
|
19397
|
-
|
|
19398
|
-
if (!module.isExecuted) {
|
|
19399
|
-
markModuleAndImpureDependenciesAsExecuted(module);
|
|
19400
|
-
}
|
|
19401
|
-
}
|
|
19402
|
-
}
|
|
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();
|
|
19403
19360
|
}
|
|
19404
19361
|
}
|
|
19405
19362
|
}
|
|
@@ -19412,7 +19369,7 @@ class Module {
|
|
|
19412
19369
|
}
|
|
19413
19370
|
shimMissingExport(name) {
|
|
19414
19371
|
this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logShimmedExport(this.id, name));
|
|
19415
|
-
this.
|
|
19372
|
+
this.exportDescriptions.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
|
|
19416
19373
|
}
|
|
19417
19374
|
tryParse() {
|
|
19418
19375
|
try {
|
|
@@ -19442,6 +19399,7 @@ function setAlternativeExporterIfCyclic(variable, importer, reexporter) {
|
|
|
19442
19399
|
}
|
|
19443
19400
|
const copyNameToModulesMap = (searchedNamesAndModules) => searchedNamesAndModules &&
|
|
19444
19401
|
new Map(Array.from(searchedNamesAndModules, ([name, modules]) => [name, new Set(modules)]));
|
|
19402
|
+
const sortExportedVariables = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
19445
19403
|
|
|
19446
19404
|
const concatSeparator = (out, next) => (next ? `${out}\n${next}` : out);
|
|
19447
19405
|
const concatDblSeparator = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
@@ -19824,6 +19782,8 @@ class Chunk {
|
|
|
19824
19782
|
includedNamespaces.add(module);
|
|
19825
19783
|
this.exports.add(module.namespace);
|
|
19826
19784
|
}
|
|
19785
|
+
// This only needs to run once
|
|
19786
|
+
break;
|
|
19827
19787
|
}
|
|
19828
19788
|
}
|
|
19829
19789
|
if (module.implicitlyLoadedAfter.size > 0) {
|
|
@@ -20461,10 +20421,11 @@ class Chunk {
|
|
|
20461
20421
|
}
|
|
20462
20422
|
const includedDynamicImports = [];
|
|
20463
20423
|
for (const module of this.orderedModules) {
|
|
20464
|
-
for (const { node
|
|
20424
|
+
for (const { node } of module.dynamicImports) {
|
|
20465
20425
|
if (!node.included) {
|
|
20466
20426
|
continue;
|
|
20467
20427
|
}
|
|
20428
|
+
const { resolution } = node;
|
|
20468
20429
|
includedDynamicImports.push(resolution instanceof Module
|
|
20469
20430
|
? {
|
|
20470
20431
|
chunk: this.chunkByModule.get(resolution),
|
|
@@ -20722,13 +20683,13 @@ class Chunk {
|
|
|
20722
20683
|
node.setInternalResolution(resolution.namespace);
|
|
20723
20684
|
}
|
|
20724
20685
|
else {
|
|
20725
|
-
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);
|
|
20726
20687
|
}
|
|
20727
20688
|
}
|
|
20728
20689
|
else {
|
|
20729
20690
|
const { node, resolution } = resolvedDynamicImport;
|
|
20730
20691
|
const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
|
|
20731
|
-
node.setExternalResolution('external',
|
|
20692
|
+
node.setExternalResolution('external', outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
|
|
20732
20693
|
}
|
|
20733
20694
|
}
|
|
20734
20695
|
}
|
|
@@ -20781,8 +20742,7 @@ class Chunk {
|
|
|
20781
20742
|
// when we are not preserving modules, we need to make all namespace variables available for
|
|
20782
20743
|
// rendering the namespace object
|
|
20783
20744
|
if (!this.outputOptions.preserveModules && this.includedNamespaces.has(module)) {
|
|
20784
|
-
const
|
|
20785
|
-
for (const variable of Object.values(memberVariables)) {
|
|
20745
|
+
for (const variable of module.getExportedVariablesByName().values()) {
|
|
20786
20746
|
if (variable.included) {
|
|
20787
20747
|
moduleImports.add(variable);
|
|
20788
20748
|
}
|
|
@@ -20813,8 +20773,8 @@ class Chunk {
|
|
|
20813
20773
|
module.includedDynamicImporters.some(importer => this.chunkByModule.get(importer) !== this)) {
|
|
20814
20774
|
this.ensureReexportsAreAvailableForModule(module);
|
|
20815
20775
|
}
|
|
20816
|
-
for (const { node, resolution } of module.dynamicImports) {
|
|
20817
|
-
if (
|
|
20776
|
+
for (const { node: { included, resolution } } of module.dynamicImports) {
|
|
20777
|
+
if (included &&
|
|
20818
20778
|
resolution instanceof Module &&
|
|
20819
20779
|
this.chunkByModule.get(resolution) === this &&
|
|
20820
20780
|
!this.includedNamespaces.has(resolution)) {
|
|
@@ -21045,7 +21005,7 @@ function analyzeModuleGraph(entries) {
|
|
|
21045
21005
|
staticDependencies.add(dependency);
|
|
21046
21006
|
}
|
|
21047
21007
|
}
|
|
21048
|
-
for (const { resolution } of module.dynamicImports) {
|
|
21008
|
+
for (const { node: { resolution } } of module.dynamicImports) {
|
|
21049
21009
|
if (resolution instanceof Module &&
|
|
21050
21010
|
resolution.includedDynamicImporters.length > 0 &&
|
|
21051
21011
|
!allEntriesSet.has(resolution)) {
|
|
@@ -21586,9 +21546,9 @@ function analyseModuleExecution(entryModules) {
|
|
|
21586
21546
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
21587
21547
|
dynamicImports.add(dependency);
|
|
21588
21548
|
}
|
|
21589
|
-
for (const { resolution,
|
|
21549
|
+
for (const { node: { resolution, scope } } of module.dynamicImports) {
|
|
21590
21550
|
if (resolution instanceof Module) {
|
|
21591
|
-
if (
|
|
21551
|
+
if (scope.context.usesTopLevelAwait) {
|
|
21592
21552
|
handleSyncLoadedModule(resolution, module);
|
|
21593
21553
|
}
|
|
21594
21554
|
else {
|
|
@@ -22740,14 +22700,14 @@ class ModuleLoader {
|
|
|
22740
22700
|
return loadNewModulesPromise;
|
|
22741
22701
|
}
|
|
22742
22702
|
async fetchDynamicDependencies(module, resolveDynamicImportPromises) {
|
|
22743
|
-
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]) => {
|
|
22744
22704
|
if (resolvedId === null)
|
|
22745
22705
|
return null;
|
|
22746
22706
|
if (typeof resolvedId === 'string') {
|
|
22747
|
-
|
|
22707
|
+
node.resolution = resolvedId;
|
|
22748
22708
|
return null;
|
|
22749
22709
|
}
|
|
22750
|
-
return (
|
|
22710
|
+
return (node.resolution = await this.fetchResolvedDependency(parseAst_js.relativeId(resolvedId.id), module.id, resolvedId));
|
|
22751
22711
|
})));
|
|
22752
22712
|
for (const dependency of dependencies) {
|
|
22753
22713
|
if (dependency) {
|
|
@@ -23129,7 +23089,7 @@ class Graph {
|
|
|
23129
23089
|
timeEnd('generate module graph', 2);
|
|
23130
23090
|
timeStart('sort and bind modules', 2);
|
|
23131
23091
|
this.phase = BuildPhase.ANALYSE;
|
|
23132
|
-
this.
|
|
23092
|
+
this.sortAndBindModules();
|
|
23133
23093
|
timeEnd('sort and bind modules', 2);
|
|
23134
23094
|
timeStart('mark included statements', 2);
|
|
23135
23095
|
this.includeStatements();
|
|
@@ -23202,7 +23162,7 @@ class Graph {
|
|
|
23202
23162
|
// the TDZ detection logic
|
|
23203
23163
|
for (const module of entryModules) {
|
|
23204
23164
|
if (module.preserveSignature !== false) {
|
|
23205
|
-
module.includeAllExports(
|
|
23165
|
+
module.includeAllExports();
|
|
23206
23166
|
this.needsTreeshakingPass = true;
|
|
23207
23167
|
}
|
|
23208
23168
|
}
|
|
@@ -23224,7 +23184,7 @@ class Graph {
|
|
|
23224
23184
|
}
|
|
23225
23185
|
}
|
|
23226
23186
|
}
|
|
23227
|
-
|
|
23187
|
+
sortAndBindModules() {
|
|
23228
23188
|
const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
|
|
23229
23189
|
for (const cyclePath of cyclePaths) {
|
|
23230
23190
|
this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logCircularDependency(cyclePath));
|