@rollup/wasm-node 4.55.3 → 4.57.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 +511 -536
- package/dist/es/shared/parseAst.js +5 -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.d.ts +40 -5
- 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 +6 -4
- package/dist/shared/rollup.js +427 -452
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +3 -3
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +12 -12
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.57.0
|
|
4
|
+
Tue, 27 Jan 2026 07:16:05 GMT - commit 743d0546f59799a8f7e4e2f4e1ad167f7dae333d
|
|
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.57.0";
|
|
46
46
|
|
|
47
47
|
function ensureArray$1(items) {
|
|
48
48
|
if (Array.isArray(items)) {
|
|
@@ -926,9 +926,9 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
926
926
|
watchMode: graph.watchMode
|
|
927
927
|
},
|
|
928
928
|
parse: parseAst_js.parseAst,
|
|
929
|
-
resolve(source, importer, { attributes, custom, isEntry, skipSelf } = parseAst_js.BLANK) {
|
|
929
|
+
resolve(source, importer, { attributes, custom, isEntry, skipSelf, importerAttributes } = parseAst_js.BLANK) {
|
|
930
930
|
skipSelf ??= true;
|
|
931
|
-
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, attributes || parseAst_js.EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
|
|
931
|
+
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, attributes || parseAst_js.EMPTY_OBJECT, importerAttributes, skipSelf ? [{ importer, plugin, source }] : null);
|
|
932
932
|
},
|
|
933
933
|
setAssetSource: fileEmitter.setAssetSource,
|
|
934
934
|
warn: getLogHandler(parseAst_js.LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel)
|
|
@@ -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
|
}
|
|
@@ -11580,7 +11558,7 @@ class MetaProperty extends NodeBase {
|
|
|
11580
11558
|
render(code, renderOptions) {
|
|
11581
11559
|
const { format, pluginDriver, snippets } = renderOptions;
|
|
11582
11560
|
const { scope: { context: { module } }, meta: { name }, metaProperty, parent, preliminaryChunkId, referenceId, start, end } = this;
|
|
11583
|
-
const { id: moduleId } = module;
|
|
11561
|
+
const { id: moduleId, info: { attributes } } = module;
|
|
11584
11562
|
if (name !== IMPORT)
|
|
11585
11563
|
return;
|
|
11586
11564
|
const chunkId = preliminaryChunkId;
|
|
@@ -11589,14 +11567,14 @@ class MetaProperty extends NodeBase {
|
|
|
11589
11567
|
const relativePath = parseAst_js.normalize(path.relative(path.dirname(chunkId), fileName));
|
|
11590
11568
|
const isUrlObject = !!metaProperty?.startsWith(FILE_OBJ_PREFIX);
|
|
11591
11569
|
const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
|
|
11592
|
-
{ chunkId, fileName, format, moduleId, referenceId, relativePath }
|
|
11570
|
+
{ attributes, chunkId, fileName, format, moduleId, referenceId, relativePath }
|
|
11593
11571
|
]) || relativeUrlMechanisms[format](relativePath, isUrlObject);
|
|
11594
11572
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
11595
11573
|
return;
|
|
11596
11574
|
}
|
|
11597
11575
|
let replacement = pluginDriver.hookFirstSync('resolveImportMeta', [
|
|
11598
11576
|
metaProperty,
|
|
11599
|
-
{ chunkId, format, moduleId }
|
|
11577
|
+
{ attributes, chunkId, format, moduleId }
|
|
11600
11578
|
]);
|
|
11601
11579
|
if (!replacement) {
|
|
11602
11580
|
replacement = importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets });
|
|
@@ -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,16 @@ 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
|
-
|
|
14966
|
+
targetModuleAttributes: resolution && typeof resolution !== 'string' ? resolution.info.attributes : {},
|
|
14967
|
+
targetModuleId: resolution && typeof resolution !== 'string' ? resolution.id : null
|
|
15034
14968
|
}
|
|
15035
14969
|
]);
|
|
15036
14970
|
if (mechanism) {
|
|
15037
14971
|
return { helper: null, mechanism };
|
|
15038
14972
|
}
|
|
15039
|
-
const hasDynamicTarget = !
|
|
14973
|
+
const hasDynamicTarget = !resolution || typeof resolution === 'string';
|
|
15040
14974
|
switch (format) {
|
|
15041
14975
|
case 'cjs': {
|
|
15042
14976
|
if (dynamicImportInCjs &&
|
|
@@ -15126,15 +15060,6 @@ const accessedImportGlobals = {
|
|
|
15126
15060
|
cjs: ['require'],
|
|
15127
15061
|
system: ['module']
|
|
15128
15062
|
};
|
|
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
15063
|
|
|
15139
15064
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
15140
15065
|
}
|
|
@@ -16129,7 +16054,7 @@ ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
|
16129
16054
|
|
|
16130
16055
|
class PanicError extends NodeBase {
|
|
16131
16056
|
initialise() {
|
|
16132
|
-
const id = this.scope.context.module
|
|
16057
|
+
const { id } = this.scope.context.module;
|
|
16133
16058
|
// This simulates the current nested error structure. We could also just
|
|
16134
16059
|
// replace it with a flat error.
|
|
16135
16060
|
const parseError = parseAst_js.getRollupError(parseAst_js.logParseError(this.message));
|
|
@@ -16141,7 +16066,7 @@ class PanicError extends NodeBase {
|
|
|
16141
16066
|
class ParseError extends NodeBase {
|
|
16142
16067
|
initialise() {
|
|
16143
16068
|
const pos = this.start;
|
|
16144
|
-
const id = this.scope.context.module
|
|
16069
|
+
const { id } = this.scope.context.module;
|
|
16145
16070
|
// This simulates the current nested error structure. We could also just
|
|
16146
16071
|
// replace it with a flat error.
|
|
16147
16072
|
const parseError = parseAst_js.getRollupError(parseAst_js.logParseError(this.message, pos));
|
|
@@ -16600,9 +16525,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
16600
16525
|
set hasCheckedForWarnings(value) {
|
|
16601
16526
|
this.flags = setFlag(this.flags, 134217728 /* Flag.checkedForWarnings */, value);
|
|
16602
16527
|
}
|
|
16603
|
-
bind() {
|
|
16604
|
-
super.bind();
|
|
16605
|
-
}
|
|
16606
16528
|
hasEffects(context) {
|
|
16607
16529
|
if (!this.deoptimized)
|
|
16608
16530
|
this.applyDeoptimizations();
|
|
@@ -16722,12 +16644,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
16722
16644
|
}
|
|
16723
16645
|
|
|
16724
16646
|
class ModuleScope extends ChildScope {
|
|
16725
|
-
constructor(parent, context) {
|
|
16647
|
+
constructor(parent, context, importDescriptions) {
|
|
16726
16648
|
super(parent, context);
|
|
16649
|
+
this.importDescriptions = importDescriptions;
|
|
16727
16650
|
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
16728
16651
|
}
|
|
16729
16652
|
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
16730
|
-
if (this.
|
|
16653
|
+
if (this.importDescriptions.has(identifier.name)) {
|
|
16731
16654
|
context.error(parseAst_js.logRedeclarationError(identifier.name), identifier.start);
|
|
16732
16655
|
}
|
|
16733
16656
|
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
@@ -17039,6 +16962,10 @@ class UpdateExpression extends NodeBase {
|
|
|
17039
16962
|
}
|
|
17040
16963
|
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
17041
16964
|
|
|
16965
|
+
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
16966
|
+
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
16967
|
+
}
|
|
16968
|
+
|
|
17042
16969
|
class VariableDeclaration extends NodeBase {
|
|
17043
16970
|
deoptimizePath() {
|
|
17044
16971
|
for (const declarator of this.declarations) {
|
|
@@ -17224,6 +17151,92 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
17224
17151
|
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
17225
17152
|
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
17226
17153
|
|
|
17154
|
+
class VariableDeclarator extends NodeBase {
|
|
17155
|
+
declareDeclarator(kind) {
|
|
17156
|
+
this.isUsingDeclaration = kind === 'using';
|
|
17157
|
+
this.isAsyncUsingDeclaration = kind === 'await using';
|
|
17158
|
+
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
17159
|
+
}
|
|
17160
|
+
deoptimizePath(path) {
|
|
17161
|
+
this.id.deoptimizePath(path);
|
|
17162
|
+
}
|
|
17163
|
+
hasEffects(context) {
|
|
17164
|
+
const initEffect = this.init?.hasEffects(context);
|
|
17165
|
+
this.id.markDeclarationReached();
|
|
17166
|
+
return (initEffect ||
|
|
17167
|
+
this.isUsingDeclaration ||
|
|
17168
|
+
this.isAsyncUsingDeclaration ||
|
|
17169
|
+
this.id.hasEffects(context) ||
|
|
17170
|
+
(this.scope.context.options.treeshake
|
|
17171
|
+
.propertyReadSideEffects &&
|
|
17172
|
+
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
17173
|
+
}
|
|
17174
|
+
include(context, includeChildrenRecursively) {
|
|
17175
|
+
const { id, init } = this;
|
|
17176
|
+
if (!this.included)
|
|
17177
|
+
this.includeNode(context);
|
|
17178
|
+
init?.include(context, includeChildrenRecursively);
|
|
17179
|
+
id.markDeclarationReached();
|
|
17180
|
+
if (includeChildrenRecursively) {
|
|
17181
|
+
id.include(context, includeChildrenRecursively);
|
|
17182
|
+
}
|
|
17183
|
+
else {
|
|
17184
|
+
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
17185
|
+
}
|
|
17186
|
+
}
|
|
17187
|
+
removeAnnotations(code) {
|
|
17188
|
+
this.init?.removeAnnotations(code);
|
|
17189
|
+
}
|
|
17190
|
+
render(code, options) {
|
|
17191
|
+
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
17192
|
+
const { end, id, init, start } = this;
|
|
17193
|
+
const renderId = id.included || this.isUsingDeclaration || this.isAsyncUsingDeclaration;
|
|
17194
|
+
if (renderId) {
|
|
17195
|
+
id.render(code, options);
|
|
17196
|
+
}
|
|
17197
|
+
else {
|
|
17198
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
17199
|
+
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
17200
|
+
}
|
|
17201
|
+
if (init) {
|
|
17202
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
17203
|
+
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
17204
|
+
if (renderedVariable !== id.name) {
|
|
17205
|
+
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
17206
|
+
}
|
|
17207
|
+
}
|
|
17208
|
+
init.render(code, options, renderId ? parseAst_js.BLANK : { renderedSurroundingElement: parseAst_js.ExpressionStatement });
|
|
17209
|
+
}
|
|
17210
|
+
else if (id instanceof Identifier &&
|
|
17211
|
+
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
17212
|
+
code.appendLeft(end, `${_}=${_}void 0`);
|
|
17213
|
+
}
|
|
17214
|
+
}
|
|
17215
|
+
includeNode(context) {
|
|
17216
|
+
this.included = true;
|
|
17217
|
+
const { id, init } = this;
|
|
17218
|
+
if (init) {
|
|
17219
|
+
if (this.isUsingDeclaration) {
|
|
17220
|
+
init.includePath(SYMBOL_DISPOSE_PATH, context);
|
|
17221
|
+
}
|
|
17222
|
+
else if (this.isAsyncUsingDeclaration) {
|
|
17223
|
+
init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context);
|
|
17224
|
+
}
|
|
17225
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
17226
|
+
const { name, variable } = id;
|
|
17227
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
17228
|
+
if (accessedVariable !== variable) {
|
|
17229
|
+
accessedVariable.forbidName(name);
|
|
17230
|
+
}
|
|
17231
|
+
}
|
|
17232
|
+
}
|
|
17233
|
+
}
|
|
17234
|
+
}
|
|
17235
|
+
}
|
|
17236
|
+
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
17237
|
+
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
17238
|
+
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
17239
|
+
|
|
17227
17240
|
class WhileStatement extends NodeBase {
|
|
17228
17241
|
hasEffects(context) {
|
|
17229
17242
|
if (this.test.hasEffects(context))
|
|
@@ -18504,27 +18517,26 @@ class Module {
|
|
|
18504
18517
|
this.needsExportShim = false;
|
|
18505
18518
|
this.sideEffectDependenciesByVariable = new Map();
|
|
18506
18519
|
this.sourcesWithAttributes = new Map();
|
|
18507
|
-
this.allExportNames = null;
|
|
18508
18520
|
this.allExportsIncluded = false;
|
|
18509
18521
|
this.ast = null;
|
|
18510
18522
|
this.exportAllModules = [];
|
|
18511
18523
|
this.exportAllSources = new Set();
|
|
18524
|
+
this.exportDescriptions = new Map();
|
|
18525
|
+
this.exportedVariablesByName = null;
|
|
18512
18526
|
this.exportNamesByVariable = null;
|
|
18513
18527
|
this.exportShimVariable = new ExportShimVariable(this);
|
|
18514
|
-
this.exports = new Map();
|
|
18515
18528
|
this.namespaceReexportsByName = new Map();
|
|
18516
18529
|
this.reexportDescriptions = new Map();
|
|
18517
18530
|
this.relevantDependencies = null;
|
|
18518
18531
|
this.syntheticExports = new Map();
|
|
18519
18532
|
this.syntheticNamespace = null;
|
|
18520
18533
|
this.transformDependencies = [];
|
|
18521
|
-
this.transitiveReexports = null;
|
|
18522
18534
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
18523
18535
|
this.context = options.moduleContext(id);
|
|
18524
18536
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
18525
18537
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
18526
18538
|
const module = this;
|
|
18527
|
-
const { dynamicImports, dynamicImporters, exportAllSources,
|
|
18539
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAttributes } = this;
|
|
18528
18540
|
this.info = {
|
|
18529
18541
|
ast: null,
|
|
18530
18542
|
attributes,
|
|
@@ -18543,7 +18555,7 @@ class Module {
|
|
|
18543
18555
|
return dynamicImporters.sort();
|
|
18544
18556
|
},
|
|
18545
18557
|
get exportedBindings() {
|
|
18546
|
-
const exportBindings = { '.': [...
|
|
18558
|
+
const exportBindings = { '.': [...exportDescriptions.keys()] };
|
|
18547
18559
|
for (const [name, { source }] of reexportDescriptions) {
|
|
18548
18560
|
(exportBindings[source] ??= []).push(name);
|
|
18549
18561
|
}
|
|
@@ -18554,7 +18566,7 @@ class Module {
|
|
|
18554
18566
|
},
|
|
18555
18567
|
get exports() {
|
|
18556
18568
|
return [
|
|
18557
|
-
...
|
|
18569
|
+
...exportDescriptions.keys(),
|
|
18558
18570
|
...reexportDescriptions.keys(),
|
|
18559
18571
|
...[...exportAllSources].map(() => '*')
|
|
18560
18572
|
];
|
|
@@ -18564,7 +18576,7 @@ class Module {
|
|
|
18564
18576
|
if (!module.ast) {
|
|
18565
18577
|
return null;
|
|
18566
18578
|
}
|
|
18567
|
-
return module.
|
|
18579
|
+
return module.exportDescriptions.has('default') || reexportDescriptions.has('default');
|
|
18568
18580
|
},
|
|
18569
18581
|
id,
|
|
18570
18582
|
get implicitlyLoadedAfterOneOf() {
|
|
@@ -18637,28 +18649,6 @@ class Module {
|
|
|
18637
18649
|
}
|
|
18638
18650
|
return size;
|
|
18639
18651
|
}
|
|
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
18652
|
getDependenciesToBeIncluded() {
|
|
18663
18653
|
if (this.relevantDependencies)
|
|
18664
18654
|
return this.relevantDependencies;
|
|
@@ -18670,10 +18660,9 @@ class Module {
|
|
|
18670
18660
|
this.includedDynamicImporters.length > 0 ||
|
|
18671
18661
|
this.namespace.included ||
|
|
18672
18662
|
this.implicitlyLoadedAfter.size > 0) {
|
|
18673
|
-
for (const
|
|
18674
|
-
|
|
18675
|
-
|
|
18676
|
-
dependencyVariables.add(exportedVariable);
|
|
18663
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
18664
|
+
if (variable.included) {
|
|
18665
|
+
dependencyVariables.add(variable);
|
|
18677
18666
|
}
|
|
18678
18667
|
}
|
|
18679
18668
|
}
|
|
@@ -18705,18 +18694,56 @@ class Module {
|
|
|
18705
18694
|
}
|
|
18706
18695
|
return this.relevantDependencies;
|
|
18707
18696
|
}
|
|
18697
|
+
getExportedVariablesByName() {
|
|
18698
|
+
if (this.exportedVariablesByName) {
|
|
18699
|
+
return this.exportedVariablesByName;
|
|
18700
|
+
}
|
|
18701
|
+
const exportedVariablesByName = (this.exportedVariablesByName = new Map());
|
|
18702
|
+
for (const name of this.exportDescriptions.keys()) {
|
|
18703
|
+
// We do not count the synthetic namespace as a regular export to hide it
|
|
18704
|
+
// from entry signatures and namespace objects
|
|
18705
|
+
if (name !== this.info.syntheticNamedExports) {
|
|
18706
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
18707
|
+
if (exportedVariable) {
|
|
18708
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
18709
|
+
}
|
|
18710
|
+
else {
|
|
18711
|
+
return parseAst_js.error(parseAst_js.logMissingEntryExport(name, this.id));
|
|
18712
|
+
}
|
|
18713
|
+
}
|
|
18714
|
+
}
|
|
18715
|
+
for (const name of this.reexportDescriptions.keys()) {
|
|
18716
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
18717
|
+
if (exportedVariable) {
|
|
18718
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
18719
|
+
}
|
|
18720
|
+
}
|
|
18721
|
+
for (const module of this.exportAllModules) {
|
|
18722
|
+
if (module instanceof ExternalModule) {
|
|
18723
|
+
exportedVariablesByName.set(`*${module.id}`, module.getVariableForExportName('*', {
|
|
18724
|
+
importChain: [this.id]
|
|
18725
|
+
})[0]);
|
|
18726
|
+
continue;
|
|
18727
|
+
}
|
|
18728
|
+
for (const name of module.getExportedVariablesByName().keys()) {
|
|
18729
|
+
if (name !== 'default' && !exportedVariablesByName.has(name)) {
|
|
18730
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
18731
|
+
if (exportedVariable) {
|
|
18732
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
18733
|
+
}
|
|
18734
|
+
}
|
|
18735
|
+
}
|
|
18736
|
+
}
|
|
18737
|
+
return (this.exportedVariablesByName = new Map([...exportedVariablesByName].sort(sortExportedVariables)));
|
|
18738
|
+
}
|
|
18708
18739
|
getExportNamesByVariable() {
|
|
18709
18740
|
if (this.exportNamesByVariable) {
|
|
18710
18741
|
return this.exportNamesByVariable;
|
|
18711
18742
|
}
|
|
18712
18743
|
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)) {
|
|
18744
|
+
for (const [exportName, variable] of this.getExportedVariablesByName().entries()) {
|
|
18745
|
+
const tracedVariable = variable instanceof ExportDefaultVariable ? variable.getOriginalVariable() : variable;
|
|
18746
|
+
if (!variable || !(variable.included || variable instanceof ExternalVariable)) {
|
|
18720
18747
|
continue;
|
|
18721
18748
|
}
|
|
18722
18749
|
const existingExportNames = exportNamesByVariable.get(tracedVariable);
|
|
@@ -18729,36 +18756,14 @@ class Module {
|
|
|
18729
18756
|
}
|
|
18730
18757
|
return (this.exportNamesByVariable = exportNamesByVariable);
|
|
18731
18758
|
}
|
|
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
18759
|
getRenderedExports() {
|
|
18756
18760
|
// only direct exports are counted here, not reexports at all
|
|
18757
18761
|
const renderedExports = [];
|
|
18758
18762
|
const removedExports = [];
|
|
18759
|
-
for (const exportName of this.
|
|
18760
|
-
|
|
18761
|
-
|
|
18763
|
+
for (const exportName of this.exportDescriptions.keys()) {
|
|
18764
|
+
(this.getExportedVariablesByName().get(exportName)?.included
|
|
18765
|
+
? renderedExports
|
|
18766
|
+
: removedExports).push(exportName);
|
|
18762
18767
|
}
|
|
18763
18768
|
return { removedExports, renderedExports };
|
|
18764
18769
|
}
|
|
@@ -18801,7 +18806,7 @@ class Module {
|
|
|
18801
18806
|
}
|
|
18802
18807
|
return [variable];
|
|
18803
18808
|
}
|
|
18804
|
-
const exportDeclaration = this.
|
|
18809
|
+
const exportDeclaration = this.exportDescriptions.get(name);
|
|
18805
18810
|
if (exportDeclaration) {
|
|
18806
18811
|
if (exportDeclaration === MISSING_EXPORT_SHIM_DESCRIPTION) {
|
|
18807
18812
|
return [this.exportShimVariable];
|
|
@@ -18852,63 +18857,29 @@ class Module {
|
|
|
18852
18857
|
if (this.ast.shouldBeIncluded(context))
|
|
18853
18858
|
this.ast.include(context, false);
|
|
18854
18859
|
}
|
|
18855
|
-
includeAllExports(
|
|
18856
|
-
if (includeNamespaceMembers) {
|
|
18857
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
18858
|
-
}
|
|
18860
|
+
includeAllExports() {
|
|
18859
18861
|
if (this.allExportsIncluded)
|
|
18860
18862
|
return;
|
|
18861
18863
|
this.allExportsIncluded = true;
|
|
18862
|
-
|
|
18863
|
-
markModuleAndImpureDependenciesAsExecuted(this);
|
|
18864
|
-
this.graph.needsTreeshakingPass = true;
|
|
18865
|
-
}
|
|
18864
|
+
this.includeModuleInExecution();
|
|
18866
18865
|
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
|
-
}
|
|
18866
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
18867
|
+
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18868
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18869
|
+
if (variable instanceof ExternalVariable) {
|
|
18870
|
+
variable.module.reexported = true;
|
|
18885
18871
|
}
|
|
18886
18872
|
}
|
|
18887
18873
|
}
|
|
18888
18874
|
includeAllInBundle() {
|
|
18889
18875
|
this.ast.include(createInclusionContext(), true);
|
|
18890
|
-
this.includeAllExports(
|
|
18876
|
+
this.includeAllExports();
|
|
18891
18877
|
}
|
|
18892
|
-
|
|
18878
|
+
includeModuleInExecution() {
|
|
18893
18879
|
if (!this.isExecuted) {
|
|
18894
18880
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
18895
18881
|
this.graph.needsTreeshakingPass = true;
|
|
18896
18882
|
}
|
|
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
18883
|
}
|
|
18913
18884
|
isIncluded() {
|
|
18914
18885
|
// Modules where this.ast is missing have been loaded via this.load and are
|
|
@@ -18987,14 +18958,11 @@ class Module {
|
|
|
18987
18958
|
deoptimizationTracker: this.graph.deoptimizationTracker,
|
|
18988
18959
|
error: this.error.bind(this),
|
|
18989
18960
|
fileName, // Needed for warnings
|
|
18990
|
-
getExports: this.getExports.bind(this),
|
|
18991
18961
|
getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this),
|
|
18992
18962
|
getModuleExecIndex: () => this.execIndex,
|
|
18993
18963
|
getModuleName: this.basename.bind(this),
|
|
18994
18964
|
getNodeConstructor: (name) => nodeConstructors[name] || nodeConstructors.UnknownNode,
|
|
18995
|
-
getReexports: this.getReexports.bind(this),
|
|
18996
18965
|
importDescriptions: this.importDescriptions,
|
|
18997
|
-
includeAllExports: () => this.includeAllExports(true),
|
|
18998
18966
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
18999
18967
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
19000
18968
|
log: this.log.bind(this),
|
|
@@ -19009,7 +18977,7 @@ class Module {
|
|
|
19009
18977
|
traceVariable: this.traceVariable.bind(this),
|
|
19010
18978
|
usesTopLevelAwait: false
|
|
19011
18979
|
};
|
|
19012
|
-
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
18980
|
+
this.scope = new ModuleScope(this.graph.scope, this.astContext, this.importDescriptions);
|
|
19013
18981
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
19014
18982
|
const programParent = { context: this.astContext, type: 'Module' };
|
|
19015
18983
|
if (ast) {
|
|
@@ -19110,10 +19078,10 @@ class Module {
|
|
|
19110
19078
|
typeof argument.value === 'string') {
|
|
19111
19079
|
argument = argument.value;
|
|
19112
19080
|
}
|
|
19113
|
-
this.dynamicImports.push({ argument, id: null, node
|
|
19081
|
+
this.dynamicImports.push({ argument, id: null, node });
|
|
19114
19082
|
}
|
|
19115
19083
|
assertUniqueExportName(name, nodeStart) {
|
|
19116
|
-
if (this.
|
|
19084
|
+
if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
|
|
19117
19085
|
this.error(parseAst_js.logDuplicateExportError(name), nodeStart);
|
|
19118
19086
|
}
|
|
19119
19087
|
}
|
|
@@ -19121,7 +19089,7 @@ class Module {
|
|
|
19121
19089
|
if (node instanceof ExportDefaultDeclaration) {
|
|
19122
19090
|
// export default foo;
|
|
19123
19091
|
this.assertUniqueExportName('default', node.start);
|
|
19124
|
-
this.
|
|
19092
|
+
this.exportDescriptions.set('default', {
|
|
19125
19093
|
identifier: node.variable.getAssignedVariableName(),
|
|
19126
19094
|
localName: 'default'
|
|
19127
19095
|
});
|
|
@@ -19168,7 +19136,7 @@ class Module {
|
|
|
19168
19136
|
for (const declarator of declaration.declarations) {
|
|
19169
19137
|
for (const localName of extractAssignedNames(declarator.id)) {
|
|
19170
19138
|
this.assertUniqueExportName(localName, declarator.id.start);
|
|
19171
|
-
this.
|
|
19139
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
19172
19140
|
}
|
|
19173
19141
|
}
|
|
19174
19142
|
}
|
|
@@ -19176,7 +19144,7 @@ class Module {
|
|
|
19176
19144
|
// export function foo () {}
|
|
19177
19145
|
const localName = declaration.id.name;
|
|
19178
19146
|
this.assertUniqueExportName(localName, declaration.id.start);
|
|
19179
|
-
this.
|
|
19147
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
19180
19148
|
}
|
|
19181
19149
|
}
|
|
19182
19150
|
else {
|
|
@@ -19186,7 +19154,7 @@ class Module {
|
|
|
19186
19154
|
const localName = local.name;
|
|
19187
19155
|
const exportedName = exported instanceof Identifier ? exported.name : exported.value;
|
|
19188
19156
|
this.assertUniqueExportName(exportedName, exported.start);
|
|
19189
|
-
this.
|
|
19157
|
+
this.exportDescriptions.set(exportedName, { identifier: null, localName });
|
|
19190
19158
|
}
|
|
19191
19159
|
}
|
|
19192
19160
|
}
|
|
@@ -19360,7 +19328,7 @@ class Module {
|
|
|
19360
19328
|
return [...syntheticNamespaces, ...externalNamespaces];
|
|
19361
19329
|
}
|
|
19362
19330
|
includeDynamicImport(node) {
|
|
19363
|
-
const resolution =
|
|
19331
|
+
const { resolution } = node;
|
|
19364
19332
|
if (resolution instanceof Module) {
|
|
19365
19333
|
if (!resolution.includedDynamicImporters.includes(this)) {
|
|
19366
19334
|
resolution.includedDynamicImporters.push(this);
|
|
@@ -19370,15 +19338,6 @@ class Module {
|
|
|
19370
19338
|
resolution.includedTopLevelAwaitingDynamicImporters.add(this);
|
|
19371
19339
|
}
|
|
19372
19340
|
}
|
|
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
19341
|
}
|
|
19383
19342
|
}
|
|
19384
19343
|
includeVariable(variable, path, context) {
|
|
@@ -19388,21 +19347,17 @@ class Module {
|
|
|
19388
19347
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
19389
19348
|
getAndExtendSideEffectModules(variable, this);
|
|
19390
19349
|
}
|
|
19350
|
+
return;
|
|
19391
19351
|
}
|
|
19392
|
-
|
|
19393
|
-
|
|
19394
|
-
|
|
19395
|
-
|
|
19396
|
-
|
|
19397
|
-
|
|
19398
|
-
|
|
19399
|
-
|
|
19400
|
-
|
|
19401
|
-
if (!module.isExecuted) {
|
|
19402
|
-
markModuleAndImpureDependenciesAsExecuted(module);
|
|
19403
|
-
}
|
|
19404
|
-
}
|
|
19405
|
-
}
|
|
19352
|
+
this.graph.needsTreeshakingPass = true;
|
|
19353
|
+
if (!(variableModule instanceof Module)) {
|
|
19354
|
+
return;
|
|
19355
|
+
}
|
|
19356
|
+
variableModule.includeModuleInExecution();
|
|
19357
|
+
if (variableModule !== this) {
|
|
19358
|
+
const sideEffectModules = getAndExtendSideEffectModules(variable, this);
|
|
19359
|
+
for (const module of sideEffectModules) {
|
|
19360
|
+
module.includeModuleInExecution();
|
|
19406
19361
|
}
|
|
19407
19362
|
}
|
|
19408
19363
|
}
|
|
@@ -19415,7 +19370,7 @@ class Module {
|
|
|
19415
19370
|
}
|
|
19416
19371
|
shimMissingExport(name) {
|
|
19417
19372
|
this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logShimmedExport(this.id, name));
|
|
19418
|
-
this.
|
|
19373
|
+
this.exportDescriptions.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
|
|
19419
19374
|
}
|
|
19420
19375
|
tryParse() {
|
|
19421
19376
|
try {
|
|
@@ -19445,6 +19400,7 @@ function setAlternativeExporterIfCyclic(variable, importer, reexporter) {
|
|
|
19445
19400
|
}
|
|
19446
19401
|
const copyNameToModulesMap = (searchedNamesAndModules) => searchedNamesAndModules &&
|
|
19447
19402
|
new Map(Array.from(searchedNamesAndModules, ([name, modules]) => [name, new Set(modules)]));
|
|
19403
|
+
const sortExportedVariables = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
19448
19404
|
|
|
19449
19405
|
const concatSeparator = (out, next) => (next ? `${out}\n${next}` : out);
|
|
19450
19406
|
const concatDblSeparator = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
@@ -19827,6 +19783,8 @@ class Chunk {
|
|
|
19827
19783
|
includedNamespaces.add(module);
|
|
19828
19784
|
this.exports.add(module.namespace);
|
|
19829
19785
|
}
|
|
19786
|
+
// This only needs to run once
|
|
19787
|
+
break;
|
|
19830
19788
|
}
|
|
19831
19789
|
}
|
|
19832
19790
|
if (module.implicitlyLoadedAfter.size > 0) {
|
|
@@ -20464,10 +20422,11 @@ class Chunk {
|
|
|
20464
20422
|
}
|
|
20465
20423
|
const includedDynamicImports = [];
|
|
20466
20424
|
for (const module of this.orderedModules) {
|
|
20467
|
-
for (const { node
|
|
20425
|
+
for (const { node } of module.dynamicImports) {
|
|
20468
20426
|
if (!node.included) {
|
|
20469
20427
|
continue;
|
|
20470
20428
|
}
|
|
20429
|
+
const { resolution } = node;
|
|
20471
20430
|
includedDynamicImports.push(resolution instanceof Module
|
|
20472
20431
|
? {
|
|
20473
20432
|
chunk: this.chunkByModule.get(resolution),
|
|
@@ -20725,13 +20684,13 @@ class Chunk {
|
|
|
20725
20684
|
node.setInternalResolution(resolution.namespace);
|
|
20726
20685
|
}
|
|
20727
20686
|
else {
|
|
20728
|
-
node.setExternalResolution((facadeChunk || chunk).exportMode,
|
|
20687
|
+
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
20688
|
}
|
|
20730
20689
|
}
|
|
20731
20690
|
else {
|
|
20732
20691
|
const { node, resolution } = resolvedDynamicImport;
|
|
20733
20692
|
const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
|
|
20734
|
-
node.setExternalResolution('external',
|
|
20693
|
+
node.setExternalResolution('external', outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
|
|
20735
20694
|
}
|
|
20736
20695
|
}
|
|
20737
20696
|
}
|
|
@@ -20784,8 +20743,7 @@ class Chunk {
|
|
|
20784
20743
|
// when we are not preserving modules, we need to make all namespace variables available for
|
|
20785
20744
|
// rendering the namespace object
|
|
20786
20745
|
if (!this.outputOptions.preserveModules && this.includedNamespaces.has(module)) {
|
|
20787
|
-
const
|
|
20788
|
-
for (const variable of Object.values(memberVariables)) {
|
|
20746
|
+
for (const variable of module.getExportedVariablesByName().values()) {
|
|
20789
20747
|
if (variable.included) {
|
|
20790
20748
|
moduleImports.add(variable);
|
|
20791
20749
|
}
|
|
@@ -20816,8 +20774,8 @@ class Chunk {
|
|
|
20816
20774
|
module.includedDynamicImporters.some(importer => this.chunkByModule.get(importer) !== this)) {
|
|
20817
20775
|
this.ensureReexportsAreAvailableForModule(module);
|
|
20818
20776
|
}
|
|
20819
|
-
for (const { node, resolution } of module.dynamicImports) {
|
|
20820
|
-
if (
|
|
20777
|
+
for (const { node: { included, resolution } } of module.dynamicImports) {
|
|
20778
|
+
if (included &&
|
|
20821
20779
|
resolution instanceof Module &&
|
|
20822
20780
|
this.chunkByModule.get(resolution) === this &&
|
|
20823
20781
|
!this.includedNamespaces.has(resolution)) {
|
|
@@ -21048,7 +21006,7 @@ function analyzeModuleGraph(entries) {
|
|
|
21048
21006
|
staticDependencies.add(dependency);
|
|
21049
21007
|
}
|
|
21050
21008
|
}
|
|
21051
|
-
for (const { resolution } of module.dynamicImports) {
|
|
21009
|
+
for (const { node: { resolution } } of module.dynamicImports) {
|
|
21052
21010
|
if (resolution instanceof Module &&
|
|
21053
21011
|
resolution.includedDynamicImporters.length > 0 &&
|
|
21054
21012
|
!allEntriesSet.has(resolution)) {
|
|
@@ -21589,9 +21547,9 @@ function analyseModuleExecution(entryModules) {
|
|
|
21589
21547
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
21590
21548
|
dynamicImports.add(dependency);
|
|
21591
21549
|
}
|
|
21592
|
-
for (const { resolution,
|
|
21550
|
+
for (const { node: { resolution, scope } } of module.dynamicImports) {
|
|
21593
21551
|
if (resolution instanceof Module) {
|
|
21594
|
-
if (
|
|
21552
|
+
if (scope.context.usesTopLevelAwait) {
|
|
21595
21553
|
handleSyncLoadedModule(resolution, module);
|
|
21596
21554
|
}
|
|
21597
21555
|
else {
|
|
@@ -22367,7 +22325,7 @@ class GlobalScope extends Scope {
|
|
|
22367
22325
|
}
|
|
22368
22326
|
}
|
|
22369
22327
|
|
|
22370
|
-
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes) {
|
|
22328
|
+
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, importerAttributes) {
|
|
22371
22329
|
let skipped = null;
|
|
22372
22330
|
let replaceContext = null;
|
|
22373
22331
|
if (skip) {
|
|
@@ -22379,7 +22337,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
22379
22337
|
}
|
|
22380
22338
|
replaceContext = (pluginContext, plugin) => ({
|
|
22381
22339
|
...pluginContext,
|
|
22382
|
-
resolve: (source, importer, { attributes, custom, isEntry, skipSelf } = parseAst_js.BLANK) => {
|
|
22340
|
+
resolve: (source, importer, { attributes, custom, isEntry, skipSelf, importerAttributes } = parseAst_js.BLANK) => {
|
|
22383
22341
|
skipSelf ??= true;
|
|
22384
22342
|
if (skipSelf &&
|
|
22385
22343
|
skip.findIndex(skippedCall => {
|
|
@@ -22391,15 +22349,15 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
22391
22349
|
// Thus returning Promise.resolve(null) in purpose of fallback to default behavior of `resolveId` plugin hook.
|
|
22392
22350
|
return Promise.resolve(null);
|
|
22393
22351
|
}
|
|
22394
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, attributes || parseAst_js.EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
22352
|
+
return moduleLoaderResolveId(source, importer, custom, isEntry, attributes || parseAst_js.EMPTY_OBJECT, importerAttributes, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
22395
22353
|
}
|
|
22396
22354
|
});
|
|
22397
22355
|
}
|
|
22398
|
-
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { attributes, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
22356
|
+
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { attributes, custom: customOptions, importerAttributes, isEntry }], replaceContext, skipped);
|
|
22399
22357
|
}
|
|
22400
22358
|
|
|
22401
|
-
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, fs) {
|
|
22402
|
-
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes);
|
|
22359
|
+
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, importerAttributes, fs) {
|
|
22360
|
+
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, importerAttributes);
|
|
22403
22361
|
if (pluginResult != null) {
|
|
22404
22362
|
const [resolveIdResult, plugin] = pluginResult;
|
|
22405
22363
|
if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) {
|
|
@@ -22456,7 +22414,7 @@ function stripBom(content) {
|
|
|
22456
22414
|
return content;
|
|
22457
22415
|
}
|
|
22458
22416
|
|
|
22459
|
-
async function transform(source, module, pluginDriver,
|
|
22417
|
+
async function transform(source, module, pluginDriver, options) {
|
|
22460
22418
|
const id = module.id;
|
|
22461
22419
|
const sourcemapChain = [];
|
|
22462
22420
|
let originalSourcemap = source.map === null ? null : decodedSourcemap(source.map);
|
|
@@ -22478,10 +22436,13 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
22478
22436
|
module.updateOptions(result);
|
|
22479
22437
|
if (result.code == null) {
|
|
22480
22438
|
if (result.map || result.ast) {
|
|
22481
|
-
|
|
22439
|
+
options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logNoTransformMapOrAstWithoutCode(plugin.name));
|
|
22482
22440
|
}
|
|
22483
22441
|
return previousCode;
|
|
22484
22442
|
}
|
|
22443
|
+
if (result.attributes) {
|
|
22444
|
+
parseAst_js.warnDeprecation('Returning attributes from the "transform" hook is forbidden.', parseAst_js.URL_TRANSFORM, false, options);
|
|
22445
|
+
}
|
|
22485
22446
|
({ code, map, ast } = result);
|
|
22486
22447
|
}
|
|
22487
22448
|
else {
|
|
@@ -22508,7 +22469,13 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
22508
22469
|
};
|
|
22509
22470
|
let code;
|
|
22510
22471
|
try {
|
|
22511
|
-
code = await pluginDriver.hookReduceArg0('transform', [
|
|
22472
|
+
code = await pluginDriver.hookReduceArg0('transform', [
|
|
22473
|
+
currentSource,
|
|
22474
|
+
id,
|
|
22475
|
+
{
|
|
22476
|
+
attributes: module.info.attributes
|
|
22477
|
+
}
|
|
22478
|
+
], transformReducer, (pluginContext, plugin) => {
|
|
22512
22479
|
pluginName = plugin.name;
|
|
22513
22480
|
return {
|
|
22514
22481
|
...pluginContext,
|
|
@@ -22534,7 +22501,7 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
22534
22501
|
return pluginContext.error(error_);
|
|
22535
22502
|
},
|
|
22536
22503
|
getCombinedSourcemap() {
|
|
22537
|
-
const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
|
|
22504
|
+
const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, options.onLog);
|
|
22538
22505
|
if (!combinedMap) {
|
|
22539
22506
|
const magicString = new MagicString(originalCode);
|
|
22540
22507
|
return magicString.generateMap({ hires: true, includeContent: true, source: id });
|
|
@@ -22589,15 +22556,15 @@ class ModuleLoader {
|
|
|
22589
22556
|
this.modulesWithLoadedDependencies = new Set();
|
|
22590
22557
|
this.nextChunkNamePriority = 0;
|
|
22591
22558
|
this.nextEntryModuleIndex = 0;
|
|
22592
|
-
this.resolveId = async (source, importer, customOptions, isEntry, attributes, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
22559
|
+
this.resolveId = async (source, importer, customOptions, isEntry, attributes, importerAttributes, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
22593
22560
|
? false
|
|
22594
|
-
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer, attributes, this.options.fs), importer, source), attributes);
|
|
22561
|
+
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer, attributes, importerAttributes, this.options.fs), importer, source), attributes);
|
|
22595
22562
|
this.hasModuleSideEffects = options.treeshake
|
|
22596
22563
|
? options.treeshake.moduleSideEffects
|
|
22597
22564
|
: () => true;
|
|
22598
22565
|
}
|
|
22599
22566
|
async addAdditionalModules(unresolvedModules, isAddForManualChunks) {
|
|
22600
|
-
const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null, isAddForManualChunks))));
|
|
22567
|
+
const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null, isAddForManualChunks, undefined))));
|
|
22601
22568
|
await this.awaitLoadModulesPromise();
|
|
22602
22569
|
return result;
|
|
22603
22570
|
}
|
|
@@ -22606,7 +22573,7 @@ class ModuleLoader {
|
|
|
22606
22573
|
this.nextEntryModuleIndex += unresolvedEntryModules.length;
|
|
22607
22574
|
const firstChunkNamePriority = this.nextChunkNamePriority;
|
|
22608
22575
|
this.nextChunkNamePriority += unresolvedEntryModules.length;
|
|
22609
|
-
const newEntryModules = await this.extendLoadModulesPromise(Promise.all(unresolvedEntryModules.map(({ id, importer }) => this.loadEntryModule(id, true, importer, null))).then(entryModules => {
|
|
22576
|
+
const newEntryModules = await this.extendLoadModulesPromise(Promise.all(unresolvedEntryModules.map(({ id, importer }) => this.loadEntryModule(id, true, importer, null, undefined, undefined))).then(entryModules => {
|
|
22610
22577
|
for (const [index, entryModule] of entryModules.entries()) {
|
|
22611
22578
|
entryModule.isUserDefinedEntryPoint =
|
|
22612
22579
|
entryModule.isUserDefinedEntryPoint || isUserDefined;
|
|
@@ -22653,10 +22620,10 @@ class ModuleLoader {
|
|
|
22653
22620
|
}
|
|
22654
22621
|
addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
|
|
22655
22622
|
const chunkNamePriority = this.nextChunkNamePriority++;
|
|
22656
|
-
return this.extendLoadModulesPromise(this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null).then(async (entryModule) => {
|
|
22623
|
+
return this.extendLoadModulesPromise(this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null, undefined, undefined).then(async (entryModule) => {
|
|
22657
22624
|
addChunkNamesToModule(entryModule, unresolvedModule, false, chunkNamePriority);
|
|
22658
22625
|
if (!entryModule.info.isEntry) {
|
|
22659
|
-
const implicitlyLoadedAfterModules = await Promise.all(implicitlyLoadedAfter.map(id => this.loadEntryModule(id, false, unresolvedModule.importer, entryModule.id)));
|
|
22626
|
+
const implicitlyLoadedAfterModules = await Promise.all(implicitlyLoadedAfter.map(id => this.loadEntryModule(id, false, unresolvedModule.importer, entryModule.id, undefined, undefined)));
|
|
22660
22627
|
// We need to check again if this is still an entry module as these
|
|
22661
22628
|
// changes need to be performed atomically to avoid race conditions
|
|
22662
22629
|
// if the same module is re-emitted as an entry module.
|
|
@@ -22678,9 +22645,16 @@ class ModuleLoader {
|
|
|
22678
22645
|
let source;
|
|
22679
22646
|
try {
|
|
22680
22647
|
source = await this.graph.fileOperationQueue.run(async () => {
|
|
22681
|
-
const content = await this.pluginDriver.hookFirst('load', [
|
|
22682
|
-
|
|
22648
|
+
const content = await this.pluginDriver.hookFirst('load', [
|
|
22649
|
+
id,
|
|
22650
|
+
{ attributes: module.info.attributes }
|
|
22651
|
+
]);
|
|
22652
|
+
if (content !== null) {
|
|
22653
|
+
if (typeof content === 'object' && content.attributes) {
|
|
22654
|
+
parseAst_js.warnDeprecation('Returning attributes from the "load" hook is forbidden.', parseAst_js.URL_LOAD, false, this.options);
|
|
22655
|
+
}
|
|
22683
22656
|
return content;
|
|
22657
|
+
}
|
|
22684
22658
|
this.graph.watchFiles[id] = true;
|
|
22685
22659
|
return (await this.options.fs.readFile(id, { encoding: 'utf8' }));
|
|
22686
22660
|
});
|
|
@@ -22706,6 +22680,7 @@ class ModuleLoader {
|
|
|
22706
22680
|
!(await this.pluginDriver.hookFirst('shouldTransformCachedModule', [
|
|
22707
22681
|
{
|
|
22708
22682
|
ast: cachedModule.ast,
|
|
22683
|
+
attributes: cachedModule.attributes,
|
|
22709
22684
|
code: cachedModule.code,
|
|
22710
22685
|
id: cachedModule.id,
|
|
22711
22686
|
meta: cachedModule.meta,
|
|
@@ -22722,7 +22697,7 @@ class ModuleLoader {
|
|
|
22722
22697
|
}
|
|
22723
22698
|
else {
|
|
22724
22699
|
module.updateOptions(sourceDescription);
|
|
22725
|
-
await module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options
|
|
22700
|
+
await module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options));
|
|
22726
22701
|
}
|
|
22727
22702
|
}
|
|
22728
22703
|
async awaitLoadModulesPromise() {
|
|
@@ -22743,14 +22718,14 @@ class ModuleLoader {
|
|
|
22743
22718
|
return loadNewModulesPromise;
|
|
22744
22719
|
}
|
|
22745
22720
|
async fetchDynamicDependencies(module, resolveDynamicImportPromises) {
|
|
22746
|
-
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([
|
|
22721
|
+
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([{ node }, resolvedId]) => {
|
|
22747
22722
|
if (resolvedId === null)
|
|
22748
22723
|
return null;
|
|
22749
22724
|
if (typeof resolvedId === 'string') {
|
|
22750
|
-
|
|
22725
|
+
node.resolution = resolvedId;
|
|
22751
22726
|
return null;
|
|
22752
22727
|
}
|
|
22753
|
-
return (
|
|
22728
|
+
return (node.resolution = await this.fetchResolvedDependency(parseAst_js.relativeId(resolvedId.id), module.id, resolvedId));
|
|
22754
22729
|
})));
|
|
22755
22730
|
for (const dependency of dependencies) {
|
|
22756
22731
|
if (dependency) {
|
|
@@ -22895,7 +22870,7 @@ class ModuleLoader {
|
|
|
22895
22870
|
source,
|
|
22896
22871
|
(module.resolvedIds[source] =
|
|
22897
22872
|
module.resolvedIds[source] ||
|
|
22898
|
-
this.handleInvalidResolvedId(await this.resolveId(source, module.id, parseAst_js.EMPTY_OBJECT, false, attributes), source, module.id, attributes))
|
|
22873
|
+
this.handleInvalidResolvedId(await this.resolveId(source, module.id, parseAst_js.EMPTY_OBJECT, false, attributes, module.info.attributes), source, module.id, attributes))
|
|
22899
22874
|
]);
|
|
22900
22875
|
}
|
|
22901
22876
|
getResolvedIdWithDefaults(resolvedId, attributes) {
|
|
@@ -22953,8 +22928,8 @@ class ModuleLoader {
|
|
|
22953
22928
|
}
|
|
22954
22929
|
return resolvedId;
|
|
22955
22930
|
}
|
|
22956
|
-
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore, isLoadForManualChunks = false) {
|
|
22957
|
-
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, parseAst_js.EMPTY_OBJECT, true, parseAst_js.EMPTY_OBJECT, this.options.fs);
|
|
22931
|
+
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore, isLoadForManualChunks = false, importerAttributes) {
|
|
22932
|
+
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, parseAst_js.EMPTY_OBJECT, true, parseAst_js.EMPTY_OBJECT, importerAttributes, this.options.fs);
|
|
22958
22933
|
if (resolveIdResult == null) {
|
|
22959
22934
|
return parseAst_js.error(implicitlyLoadedBefore === null
|
|
22960
22935
|
? parseAst_js.logUnresolvedEntry(unresolvedId)
|
|
@@ -22976,7 +22951,7 @@ class ModuleLoader {
|
|
|
22976
22951
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
22977
22952
|
specifier,
|
|
22978
22953
|
importer,
|
|
22979
|
-
{ attributes }
|
|
22954
|
+
{ attributes, importerAttributes: module.info.attributes }
|
|
22980
22955
|
]);
|
|
22981
22956
|
if (typeof specifier !== 'string') {
|
|
22982
22957
|
if (typeof resolution === 'string') {
|
|
@@ -22995,7 +22970,7 @@ class ModuleLoader {
|
|
|
22995
22970
|
}
|
|
22996
22971
|
return existingResolution;
|
|
22997
22972
|
}
|
|
22998
|
-
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, parseAst_js.EMPTY_OBJECT, false, attributes), specifier, module.id, attributes));
|
|
22973
|
+
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, parseAst_js.EMPTY_OBJECT, false, attributes, module.info.attributes), specifier, module.id, attributes));
|
|
22999
22974
|
}
|
|
23000
22975
|
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), attributes), specifier, importer, attributes);
|
|
23001
22976
|
}
|
|
@@ -23132,7 +23107,7 @@ class Graph {
|
|
|
23132
23107
|
timeEnd('generate module graph', 2);
|
|
23133
23108
|
timeStart('sort and bind modules', 2);
|
|
23134
23109
|
this.phase = BuildPhase.ANALYSE;
|
|
23135
|
-
this.
|
|
23110
|
+
this.sortAndBindModules();
|
|
23136
23111
|
timeEnd('sort and bind modules', 2);
|
|
23137
23112
|
timeStart('mark included statements', 2);
|
|
23138
23113
|
this.includeStatements();
|
|
@@ -23205,7 +23180,7 @@ class Graph {
|
|
|
23205
23180
|
// the TDZ detection logic
|
|
23206
23181
|
for (const module of entryModules) {
|
|
23207
23182
|
if (module.preserveSignature !== false) {
|
|
23208
|
-
module.includeAllExports(
|
|
23183
|
+
module.includeAllExports();
|
|
23209
23184
|
this.needsTreeshakingPass = true;
|
|
23210
23185
|
}
|
|
23211
23186
|
}
|
|
@@ -23227,7 +23202,7 @@ class Graph {
|
|
|
23227
23202
|
}
|
|
23228
23203
|
}
|
|
23229
23204
|
}
|
|
23230
|
-
|
|
23205
|
+
sortAndBindModules() {
|
|
23231
23206
|
const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
|
|
23232
23207
|
for (const cyclePath of cyclePaths) {
|
|
23233
23208
|
this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logCircularDependency(cyclePath));
|