@rollup/wasm-node 4.55.3 → 4.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +381 -424
- package/dist/es/shared/parseAst.js +3 -4
- package/dist/es/shared/watch.js +3 -3
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +3 -3
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -4
- package/dist/shared/rollup.js +380 -423
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +3 -3
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
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
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY,
|
|
10
|
+
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, Identifier as Identifier$1, FunctionExpression as FunctionExpression$1, ArrowFunctionExpression as ArrowFunctionExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, logMissingExport, normalize, getImportPath, logMissingNodeBuiltins, logReservedNamespace, error, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, RestElement as RestElement$1, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logMissingEntryExport, logSyntheticNamedExportsNeedNamespaceExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logInvalidFormatForTopLevelAwait, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logCircularChunk, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, warnDeprecation, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
|
|
12
12
|
import { posix, isAbsolute, resolve, win32 } from 'path';
|
|
13
13
|
import { parseAsync, xxhashBase16, xxhashBase64Url, xxhashBase36 } from '../../native.js';
|
|
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.
|
|
30
|
+
var version = "4.56.0";
|
|
31
31
|
|
|
32
32
|
// src/vlq.ts
|
|
33
33
|
var comma = ",".charCodeAt(0);
|
|
@@ -3027,15 +3027,15 @@ function isCallExpressionNode(node) {
|
|
|
3027
3027
|
function isMemberExpressionNode(node) {
|
|
3028
3028
|
return node instanceof NodeBase && node.type === MemberExpression$1;
|
|
3029
3029
|
}
|
|
3030
|
-
function isImportExpressionNode(node) {
|
|
3031
|
-
return node instanceof NodeBase && node.type === ImportExpression$1;
|
|
3032
|
-
}
|
|
3033
3030
|
function isAwaitExpressionNode(node) {
|
|
3034
3031
|
return node instanceof NodeBase && node.type === AwaitExpression$1;
|
|
3035
3032
|
}
|
|
3036
3033
|
function isIdentifierNode(node) {
|
|
3037
3034
|
return node instanceof NodeBase && node.type === Identifier$1;
|
|
3038
3035
|
}
|
|
3036
|
+
function isExpressionStatementNode(node) {
|
|
3037
|
+
return node instanceof NodeBase && node.type === ExpressionStatement$1;
|
|
3038
|
+
}
|
|
3039
3039
|
|
|
3040
3040
|
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
3041
3041
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
@@ -5193,21 +5193,6 @@ class LocalVariable extends Variable {
|
|
|
5193
5193
|
break;
|
|
5194
5194
|
node = node.parent;
|
|
5195
5195
|
}
|
|
5196
|
-
/**
|
|
5197
|
-
* import('foo').then(m => {
|
|
5198
|
-
* console.log(m.foo)
|
|
5199
|
-
* })
|
|
5200
|
-
*/
|
|
5201
|
-
if (this.kind === 'parameter' &&
|
|
5202
|
-
(isArrowFunctionExpressionNode(declaration.parent) ||
|
|
5203
|
-
isFunctionExpressionNode(declaration.parent)) &&
|
|
5204
|
-
isCallExpressionNode(declaration.parent.parent) &&
|
|
5205
|
-
isMemberExpressionNode(declaration.parent.parent.callee) &&
|
|
5206
|
-
isIdentifierNode(declaration.parent.parent.callee.property) &&
|
|
5207
|
-
declaration.parent.parent.callee.property.name === 'then' &&
|
|
5208
|
-
isImportExpressionNode(declaration.parent.parent.callee.object)) {
|
|
5209
|
-
declaration.parent.parent.callee.object.includePath(path, context);
|
|
5210
|
-
}
|
|
5211
5196
|
}
|
|
5212
5197
|
// We need to make sure we include the correct path of the init
|
|
5213
5198
|
if (path.length > 0) {
|
|
@@ -7367,6 +7352,7 @@ function getStringFromPath(path) {
|
|
|
7367
7352
|
class MemberExpression extends NodeBase {
|
|
7368
7353
|
constructor() {
|
|
7369
7354
|
super(...arguments);
|
|
7355
|
+
this.promiseHandler = null;
|
|
7370
7356
|
this.variable = null;
|
|
7371
7357
|
this.expressionsToBeDeoptimized = [];
|
|
7372
7358
|
}
|
|
@@ -7422,7 +7408,10 @@ class MemberExpression extends NodeBase {
|
|
|
7422
7408
|
}
|
|
7423
7409
|
}
|
|
7424
7410
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7425
|
-
if (this.
|
|
7411
|
+
if (this.promiseHandler) {
|
|
7412
|
+
this.promiseHandler.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
7413
|
+
}
|
|
7414
|
+
else if (this.variable) {
|
|
7426
7415
|
this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
7427
7416
|
}
|
|
7428
7417
|
else if (!this.isUndefined) {
|
|
@@ -7612,25 +7601,14 @@ class MemberExpression extends NodeBase {
|
|
|
7612
7601
|
this.property.include(context, includeChildrenRecursively);
|
|
7613
7602
|
}
|
|
7614
7603
|
includeCallArguments(interaction, context) {
|
|
7615
|
-
if (this.
|
|
7604
|
+
if (this.promiseHandler) {
|
|
7605
|
+
this.promiseHandler.includeCallArguments(interaction, context);
|
|
7606
|
+
}
|
|
7607
|
+
else if (this.variable) {
|
|
7616
7608
|
this.variable.includeCallArguments(interaction, context);
|
|
7617
7609
|
}
|
|
7618
7610
|
else {
|
|
7619
|
-
|
|
7620
|
-
/**
|
|
7621
|
-
* const c = await import('foo')
|
|
7622
|
-
* c.foo();
|
|
7623
|
-
*/
|
|
7624
|
-
(this.object.variable &&
|
|
7625
|
-
!this.object.variable.isReassigned &&
|
|
7626
|
-
this.object.variable instanceof LocalVariable &&
|
|
7627
|
-
isAwaitExpressionNode(this.object.variable.init) &&
|
|
7628
|
-
isImportExpressionNode(this.object.variable.init.argument))) {
|
|
7629
|
-
includeInteractionWithoutThis(interaction, context);
|
|
7630
|
-
}
|
|
7631
|
-
else {
|
|
7632
|
-
includeInteraction(interaction, context);
|
|
7633
|
-
}
|
|
7611
|
+
includeInteraction(interaction, context);
|
|
7634
7612
|
}
|
|
7635
7613
|
}
|
|
7636
7614
|
includeDestructuredIfNecessary() {
|
|
@@ -7678,7 +7656,7 @@ class MemberExpression extends NodeBase {
|
|
|
7678
7656
|
// Namespaces are not bound and should not be deoptimized
|
|
7679
7657
|
this.bound &&
|
|
7680
7658
|
propertyReadSideEffects &&
|
|
7681
|
-
!(this.variable || this.isUndefined)) {
|
|
7659
|
+
!(this.variable || this.isUndefined || this.promiseHandler)) {
|
|
7682
7660
|
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [this.propertyKey], SHARED_RECURSION_TRACKER);
|
|
7683
7661
|
this.scope.context.requestTreeshakingPass();
|
|
7684
7662
|
}
|
|
@@ -7986,8 +7964,9 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
7986
7964
|
class NamespaceVariable extends Variable {
|
|
7987
7965
|
constructor(context) {
|
|
7988
7966
|
super(context.getModuleName());
|
|
7989
|
-
this.
|
|
7967
|
+
this.areAllMembersDeoptimized = false;
|
|
7990
7968
|
this.mergedNamespaces = [];
|
|
7969
|
+
this.nonExplicitNamespacesIncluded = false;
|
|
7991
7970
|
this.referencedEarly = false;
|
|
7992
7971
|
this.references = [];
|
|
7993
7972
|
this.context = context;
|
|
@@ -8001,7 +7980,10 @@ class NamespaceVariable extends Variable {
|
|
|
8001
7980
|
if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) {
|
|
8002
7981
|
const key = path[0];
|
|
8003
7982
|
if (typeof key === 'string') {
|
|
8004
|
-
this.
|
|
7983
|
+
this.module
|
|
7984
|
+
.getExportedVariablesByName()
|
|
7985
|
+
.get(key)
|
|
7986
|
+
?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
|
|
8005
7987
|
}
|
|
8006
7988
|
else {
|
|
8007
7989
|
deoptimizeInteraction(interaction);
|
|
@@ -8012,7 +7994,13 @@ class NamespaceVariable extends Variable {
|
|
|
8012
7994
|
if (path.length > 1) {
|
|
8013
7995
|
const key = path[0];
|
|
8014
7996
|
if (typeof key === 'string') {
|
|
8015
|
-
this.
|
|
7997
|
+
this.module.getExportedVariablesByName().get(key)?.deoptimizePath(path.slice(1));
|
|
7998
|
+
}
|
|
7999
|
+
else if (!this.areAllMembersDeoptimized) {
|
|
8000
|
+
this.areAllMembersDeoptimized = true;
|
|
8001
|
+
for (const variable of this.module.getExportedVariablesByName().values()) {
|
|
8002
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
8003
|
+
}
|
|
8016
8004
|
}
|
|
8017
8005
|
}
|
|
8018
8006
|
}
|
|
@@ -8022,22 +8010,6 @@ class NamespaceVariable extends Variable {
|
|
|
8022
8010
|
}
|
|
8023
8011
|
return UnknownValue;
|
|
8024
8012
|
}
|
|
8025
|
-
getMemberVariables() {
|
|
8026
|
-
if (this.memberVariables) {
|
|
8027
|
-
return this.memberVariables;
|
|
8028
|
-
}
|
|
8029
|
-
const memberVariables = Object.create(null);
|
|
8030
|
-
const sortedExports = [...this.context.getExports(), ...this.context.getReexports()].sort();
|
|
8031
|
-
for (const name of sortedExports) {
|
|
8032
|
-
if (name[0] !== '*' && name !== this.module.info.syntheticNamedExports) {
|
|
8033
|
-
const [exportedVariable] = this.context.traceExport(name);
|
|
8034
|
-
if (exportedVariable) {
|
|
8035
|
-
memberVariables[name] = exportedVariable;
|
|
8036
|
-
}
|
|
8037
|
-
}
|
|
8038
|
-
}
|
|
8039
|
-
return (this.memberVariables = memberVariables);
|
|
8040
|
-
}
|
|
8041
8013
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8042
8014
|
const { type } = interaction;
|
|
8043
8015
|
if (path.length === 0) {
|
|
@@ -8051,13 +8023,31 @@ class NamespaceVariable extends Variable {
|
|
|
8051
8023
|
if (typeof key !== 'string') {
|
|
8052
8024
|
return true;
|
|
8053
8025
|
}
|
|
8054
|
-
const memberVariable = this.
|
|
8026
|
+
const memberVariable = this.module.getExportedVariablesByName().get(key);
|
|
8055
8027
|
return (!memberVariable ||
|
|
8056
8028
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
8057
8029
|
}
|
|
8058
8030
|
includePath(path, context) {
|
|
8059
8031
|
super.includePath(path, context);
|
|
8060
|
-
this.context
|
|
8032
|
+
this.includeMemberPath(path, context);
|
|
8033
|
+
}
|
|
8034
|
+
includeMemberPath(path, context) {
|
|
8035
|
+
if (path.length > 0) {
|
|
8036
|
+
const [name, ...remainingPath] = path;
|
|
8037
|
+
if (typeof name === 'string') {
|
|
8038
|
+
const variable = this.module.getExportedVariablesByName().get(name);
|
|
8039
|
+
if (variable) {
|
|
8040
|
+
this.context.includeVariableInModule(variable, remainingPath, context);
|
|
8041
|
+
}
|
|
8042
|
+
else {
|
|
8043
|
+
this.includeNonExplicitNamespaces();
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
8046
|
+
else if (name) {
|
|
8047
|
+
this.module.includeAllExports();
|
|
8048
|
+
this.includeNonExplicitNamespaces();
|
|
8049
|
+
}
|
|
8050
|
+
}
|
|
8061
8051
|
}
|
|
8062
8052
|
prepare(accessedGlobalsByScope) {
|
|
8063
8053
|
if (this.mergedNamespaces.length > 0) {
|
|
@@ -8066,9 +8056,9 @@ class NamespaceVariable extends Variable {
|
|
|
8066
8056
|
}
|
|
8067
8057
|
renderBlock(options) {
|
|
8068
8058
|
const { exportNamesByVariable, format, freeze, indent: t, symbols, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
|
|
8069
|
-
const memberVariables = this.
|
|
8070
|
-
const members =
|
|
8071
|
-
.filter(([
|
|
8059
|
+
const memberVariables = this.module.getExportedVariablesByName();
|
|
8060
|
+
const members = [...memberVariables.entries()]
|
|
8061
|
+
.filter(([name, variable]) => !name.startsWith('*') && variable.included)
|
|
8072
8062
|
.map(([name, variable]) => {
|
|
8073
8063
|
if (this.referencedEarly || variable.isReassigned || variable === this) {
|
|
8074
8064
|
return [
|
|
@@ -8114,8 +8104,22 @@ class NamespaceVariable extends Variable {
|
|
|
8114
8104
|
}
|
|
8115
8105
|
}
|
|
8116
8106
|
}
|
|
8107
|
+
includeNonExplicitNamespaces() {
|
|
8108
|
+
if (!this.nonExplicitNamespacesIncluded) {
|
|
8109
|
+
this.nonExplicitNamespacesIncluded = true;
|
|
8110
|
+
this.setMergedNamespaces(this.module.includeAndGetAdditionalMergedNamespaces());
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8117
8113
|
}
|
|
8118
8114
|
NamespaceVariable.prototype.isNamespace = true;
|
|
8115
|
+
// This is a proxy that does not include the namespace object when a path is included
|
|
8116
|
+
const getDynamicNamespaceVariable = (namespace) => Object.create(namespace, {
|
|
8117
|
+
includePath: {
|
|
8118
|
+
value(path, context) {
|
|
8119
|
+
namespace.includeMemberPath(path, context);
|
|
8120
|
+
}
|
|
8121
|
+
}
|
|
8122
|
+
});
|
|
8119
8123
|
|
|
8120
8124
|
class SyntheticNamedExportVariable extends Variable {
|
|
8121
8125
|
constructor(context, name, syntheticNamespace) {
|
|
@@ -8151,7 +8155,7 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
8151
8155
|
}
|
|
8152
8156
|
includePath(path, context) {
|
|
8153
8157
|
super.includePath(path, context);
|
|
8154
|
-
this.context.includeVariableInModule(this.syntheticNamespace, path, context);
|
|
8158
|
+
this.context.includeVariableInModule(this.syntheticNamespace, [this.name, ...path], context);
|
|
8155
8159
|
}
|
|
8156
8160
|
setRenderNames(baseName, name) {
|
|
8157
8161
|
super.setRenderNames(baseName, name);
|
|
@@ -11832,6 +11836,9 @@ class AssignmentPattern extends NodeBase {
|
|
|
11832
11836
|
}
|
|
11833
11837
|
|
|
11834
11838
|
class AwaitExpression extends NodeBase {
|
|
11839
|
+
deoptimizePath(path) {
|
|
11840
|
+
this.argument.deoptimizePath(path);
|
|
11841
|
+
}
|
|
11835
11842
|
hasEffects() {
|
|
11836
11843
|
if (!this.deoptimized)
|
|
11837
11844
|
this.applyDeoptimizations();
|
|
@@ -12234,11 +12241,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
12234
12241
|
this.callee.includeCallArguments(this.interaction, context);
|
|
12235
12242
|
}
|
|
12236
12243
|
}
|
|
12237
|
-
includeNode(
|
|
12244
|
+
includeNode(_context) {
|
|
12238
12245
|
this.included = true;
|
|
12239
12246
|
if (!this.deoptimized)
|
|
12240
12247
|
this.applyDeoptimizations();
|
|
12241
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
12242
12248
|
}
|
|
12243
12249
|
initialise() {
|
|
12244
12250
|
super.initialise();
|
|
@@ -13096,95 +13102,41 @@ class ImportDefaultSpecifier extends NodeBase {
|
|
|
13096
13102
|
ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13097
13103
|
ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13098
13104
|
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
this.isAsyncUsingDeclaration = kind === 'await using';
|
|
13107
|
-
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
13108
|
-
}
|
|
13109
|
-
deoptimizePath(path) {
|
|
13110
|
-
this.id.deoptimizePath(path);
|
|
13111
|
-
}
|
|
13112
|
-
hasEffects(context) {
|
|
13113
|
-
const initEffect = this.init?.hasEffects(context);
|
|
13114
|
-
this.id.markDeclarationReached();
|
|
13115
|
-
return (initEffect ||
|
|
13116
|
-
this.isUsingDeclaration ||
|
|
13117
|
-
this.isAsyncUsingDeclaration ||
|
|
13118
|
-
this.id.hasEffects(context) ||
|
|
13119
|
-
(this.scope.context.options.treeshake
|
|
13120
|
-
.propertyReadSideEffects &&
|
|
13121
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
13105
|
+
class ObjectPromiseHandler {
|
|
13106
|
+
constructor(resolvedVariable) {
|
|
13107
|
+
this.interaction = {
|
|
13108
|
+
args: [null, resolvedVariable],
|
|
13109
|
+
type: INTERACTION_CALLED,
|
|
13110
|
+
withNew: false
|
|
13111
|
+
};
|
|
13122
13112
|
}
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
if (
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
id.include(context, includeChildrenRecursively);
|
|
13131
|
-
}
|
|
13132
|
-
else {
|
|
13133
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
13113
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13114
|
+
deoptimizeInteraction(interaction);
|
|
13115
|
+
if (interaction.type === INTERACTION_CALLED &&
|
|
13116
|
+
path.length === 0 &&
|
|
13117
|
+
(isFunctionExpressionNode(interaction.args[1]) ||
|
|
13118
|
+
isArrowFunctionExpressionNode(interaction.args[1]))) {
|
|
13119
|
+
interaction.args[1].deoptimizeArgumentsOnInteractionAtPath(this.interaction, [], recursionTracker);
|
|
13134
13120
|
}
|
|
13135
13121
|
}
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
if (renderId) {
|
|
13144
|
-
id.render(code, options);
|
|
13145
|
-
}
|
|
13146
|
-
else {
|
|
13147
|
-
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
13148
|
-
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
13149
|
-
}
|
|
13150
|
-
if (init) {
|
|
13151
|
-
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
13152
|
-
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
13153
|
-
if (renderedVariable !== id.name) {
|
|
13154
|
-
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
13155
|
-
}
|
|
13156
|
-
}
|
|
13157
|
-
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
|
|
13158
|
-
}
|
|
13159
|
-
else if (id instanceof Identifier &&
|
|
13160
|
-
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
13161
|
-
code.appendLeft(end, `${_}=${_}void 0`);
|
|
13122
|
+
includeCallArguments(interaction, context) {
|
|
13123
|
+
// This includes the function call itself
|
|
13124
|
+
includeInteractionWithoutThis(interaction, context);
|
|
13125
|
+
if (interaction.type === INTERACTION_CALLED &&
|
|
13126
|
+
(isFunctionExpressionNode(interaction.args[1]) ||
|
|
13127
|
+
isArrowFunctionExpressionNode(interaction.args[1]))) {
|
|
13128
|
+
interaction.args[1].includeCallArguments(this.interaction, context);
|
|
13162
13129
|
}
|
|
13163
13130
|
}
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
else if (this.isAsyncUsingDeclaration) {
|
|
13172
|
-
init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context);
|
|
13173
|
-
}
|
|
13174
|
-
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
13175
|
-
const { name, variable } = id;
|
|
13176
|
-
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
13177
|
-
if (accessedVariable !== variable) {
|
|
13178
|
-
accessedVariable.forbidName(name);
|
|
13179
|
-
}
|
|
13180
|
-
}
|
|
13181
|
-
}
|
|
13182
|
-
}
|
|
13131
|
+
}
|
|
13132
|
+
class EmptyPromiseHandler {
|
|
13133
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction) {
|
|
13134
|
+
deoptimizeInteraction(interaction);
|
|
13135
|
+
}
|
|
13136
|
+
includeCallArguments(interaction, context) {
|
|
13137
|
+
includeInteractionWithoutThis(interaction, context);
|
|
13183
13138
|
}
|
|
13184
13139
|
}
|
|
13185
|
-
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13186
|
-
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
13187
|
-
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
13188
13140
|
|
|
13189
13141
|
function getChunkInfoWithPath(chunk) {
|
|
13190
13142
|
return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() };
|
|
@@ -13193,12 +13145,11 @@ class ImportExpression extends NodeBase {
|
|
|
13193
13145
|
constructor() {
|
|
13194
13146
|
super(...arguments);
|
|
13195
13147
|
this.inlineNamespace = null;
|
|
13196
|
-
this.
|
|
13197
|
-
this.accessedPropKey = new Set();
|
|
13148
|
+
this.resolution = null;
|
|
13198
13149
|
this.attributes = null;
|
|
13199
13150
|
this.mechanism = null;
|
|
13200
13151
|
this.namespaceExportName = undefined;
|
|
13201
|
-
this.
|
|
13152
|
+
this.localResolution = null;
|
|
13202
13153
|
this.resolutionString = null;
|
|
13203
13154
|
}
|
|
13204
13155
|
get shouldIncludeDynamicAttributes() {
|
|
@@ -13208,84 +13159,65 @@ class ImportExpression extends NodeBase {
|
|
|
13208
13159
|
this.flags = setFlag(this.flags, 268435456 /* Flag.shouldIncludeDynamicAttributes */, value);
|
|
13209
13160
|
}
|
|
13210
13161
|
bind() {
|
|
13211
|
-
this
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
*
|
|
13217
|
-
* 1. `const { foo } = await import('bar')`.
|
|
13218
|
-
* 2. `(await import('bar')).foo`
|
|
13219
|
-
* 3. `import('bar').then(({ foo }) => {})`
|
|
13220
|
-
*
|
|
13221
|
-
* Returns empty array if it's side-effect only import.
|
|
13222
|
-
* Returns undefined if it's not fully deterministic.
|
|
13223
|
-
*/
|
|
13224
|
-
getDeterministicImportedNames() {
|
|
13225
|
-
const parent1 = this.parent;
|
|
13226
|
-
// Side-effect only: import('bar')
|
|
13227
|
-
if (parent1 instanceof ExpressionStatement) {
|
|
13228
|
-
return EMPTY_ARRAY;
|
|
13229
|
-
}
|
|
13230
|
-
if (parent1 instanceof AwaitExpression) {
|
|
13231
|
-
const parent2 = parent1.parent;
|
|
13232
|
-
// Side effect only: await import('bar')
|
|
13233
|
-
if (parent2 instanceof ExpressionStatement) {
|
|
13234
|
-
return EMPTY_ARRAY;
|
|
13235
|
-
}
|
|
13236
|
-
// Case 1: const { foo } / module = await import('bar')
|
|
13237
|
-
if (parent2 instanceof VariableDeclarator) {
|
|
13238
|
-
const declaration = parent2.id;
|
|
13239
|
-
if (declaration instanceof Identifier) {
|
|
13240
|
-
return this.hasUnknownAccessedKey ? undefined : [...this.accessedPropKey];
|
|
13241
|
-
}
|
|
13242
|
-
if (declaration instanceof ObjectPattern) {
|
|
13243
|
-
return getDeterministicObjectDestructure(declaration);
|
|
13244
|
-
}
|
|
13245
|
-
}
|
|
13246
|
-
// Case 2: (await import('bar')).foo
|
|
13247
|
-
if (parent2 instanceof MemberExpression) {
|
|
13248
|
-
const id = parent2.property;
|
|
13249
|
-
if (!parent2.computed && id instanceof Identifier) {
|
|
13250
|
-
return [id.name];
|
|
13251
|
-
}
|
|
13252
|
-
}
|
|
13162
|
+
const { options, parent, resolution, source } = this;
|
|
13163
|
+
source.bind();
|
|
13164
|
+
options?.bind();
|
|
13165
|
+
// Check if we resolved to a Module without using instanceof
|
|
13166
|
+
if (typeof resolution !== 'object' || !resolution || !('namespace' in resolution)) {
|
|
13253
13167
|
return;
|
|
13254
13168
|
}
|
|
13255
|
-
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
}
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
thenCallback instanceof FunctionExpression)) {
|
|
13277
|
-
return;
|
|
13169
|
+
// In these cases, we can track exactly what is included or deoptimized:
|
|
13170
|
+
// * import('foo'); // as statement
|
|
13171
|
+
// * await import('foo') // use as awaited expression in any way
|
|
13172
|
+
// * import('foo').then(n => {...}) // only if .then is called directly on the import()
|
|
13173
|
+
if (isExpressionStatementNode(parent) || isAwaitExpressionNode(parent)) {
|
|
13174
|
+
this.localResolution = { resolution, tracked: true };
|
|
13175
|
+
return;
|
|
13176
|
+
}
|
|
13177
|
+
if (!isMemberExpressionNode(parent)) {
|
|
13178
|
+
this.localResolution = { resolution, tracked: false };
|
|
13179
|
+
return;
|
|
13180
|
+
}
|
|
13181
|
+
let currentParent = parent;
|
|
13182
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13183
|
+
let callExpression = this;
|
|
13184
|
+
while (true) {
|
|
13185
|
+
if (currentParent.computed ||
|
|
13186
|
+
currentParent.object !== callExpression ||
|
|
13187
|
+
!isIdentifierNode(currentParent.property) ||
|
|
13188
|
+
!isCallExpressionNode(currentParent.parent)) {
|
|
13189
|
+
break;
|
|
13278
13190
|
}
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13191
|
+
const propertyName = currentParent.property.name;
|
|
13192
|
+
callExpression = currentParent.parent;
|
|
13193
|
+
if (propertyName === 'then') {
|
|
13194
|
+
const firstArgument = callExpression.arguments[0];
|
|
13195
|
+
if (firstArgument === undefined ||
|
|
13196
|
+
isFunctionExpressionNode(firstArgument) ||
|
|
13197
|
+
isArrowFunctionExpressionNode(firstArgument)) {
|
|
13198
|
+
currentParent.promiseHandler = new ObjectPromiseHandler(getDynamicNamespaceVariable(resolution.namespace));
|
|
13199
|
+
this.localResolution = { resolution, tracked: true };
|
|
13200
|
+
return;
|
|
13201
|
+
}
|
|
13282
13202
|
}
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13203
|
+
else if (propertyName === 'catch' || propertyName === 'finally') {
|
|
13204
|
+
if (isMemberExpressionNode(callExpression.parent)) {
|
|
13205
|
+
currentParent.promiseHandler = new EmptyPromiseHandler();
|
|
13206
|
+
currentParent = callExpression.parent;
|
|
13207
|
+
continue;
|
|
13208
|
+
}
|
|
13209
|
+
if (isExpressionStatementNode(callExpression.parent)) {
|
|
13210
|
+
currentParent.promiseHandler = new EmptyPromiseHandler();
|
|
13211
|
+
this.localResolution = { resolution, tracked: true };
|
|
13212
|
+
return;
|
|
13213
|
+
}
|
|
13286
13214
|
}
|
|
13287
|
-
|
|
13215
|
+
break;
|
|
13288
13216
|
}
|
|
13217
|
+
this.localResolution = { resolution, tracked: false };
|
|
13218
|
+
}
|
|
13219
|
+
deoptimizePath(path) {
|
|
13220
|
+
this.localResolution?.resolution?.namespace.deoptimizePath(path);
|
|
13289
13221
|
}
|
|
13290
13222
|
hasEffects() {
|
|
13291
13223
|
return true;
|
|
@@ -13294,30 +13226,31 @@ class ImportExpression extends NodeBase {
|
|
|
13294
13226
|
if (!this.included)
|
|
13295
13227
|
this.includeNode(context);
|
|
13296
13228
|
this.source.include(context, includeChildrenRecursively);
|
|
13297
|
-
if (this.shouldIncludeDynamicAttributes)
|
|
13229
|
+
if (this.shouldIncludeDynamicAttributes) {
|
|
13298
13230
|
this.options?.include(context, includeChildrenRecursively);
|
|
13231
|
+
}
|
|
13299
13232
|
}
|
|
13300
13233
|
includeNode(context) {
|
|
13301
13234
|
this.included = true;
|
|
13302
|
-
|
|
13235
|
+
const { localResolution, scope, shouldIncludeDynamicAttributes } = this;
|
|
13236
|
+
if (shouldIncludeDynamicAttributes) {
|
|
13303
13237
|
this.options?.includePath(UNKNOWN_PATH, context);
|
|
13304
|
-
|
|
13305
|
-
|
|
13238
|
+
}
|
|
13239
|
+
scope.context.includeDynamicImport(this);
|
|
13240
|
+
scope.addAccessedDynamicImport(this);
|
|
13241
|
+
if (localResolution) {
|
|
13242
|
+
if (localResolution.tracked) {
|
|
13243
|
+
localResolution.resolution.includeModuleInExecution();
|
|
13244
|
+
}
|
|
13245
|
+
else {
|
|
13246
|
+
localResolution.resolution.includeAllExports();
|
|
13247
|
+
}
|
|
13248
|
+
}
|
|
13306
13249
|
}
|
|
13307
13250
|
includePath(path, context) {
|
|
13308
13251
|
if (!this.included)
|
|
13309
13252
|
this.includeNode(context);
|
|
13310
|
-
|
|
13311
|
-
if (this.hasUnknownAccessedKey)
|
|
13312
|
-
return;
|
|
13313
|
-
if (path[0] === UnknownKey) {
|
|
13314
|
-
this.hasUnknownAccessedKey = true;
|
|
13315
|
-
}
|
|
13316
|
-
else if (typeof path[0] === 'string') {
|
|
13317
|
-
this.accessedPropKey.add(path[0]);
|
|
13318
|
-
}
|
|
13319
|
-
// Update included paths
|
|
13320
|
-
this.scope.context.includeDynamicImport(this);
|
|
13253
|
+
this.localResolution?.resolution?.namespace.includeMemberPath(path, context);
|
|
13321
13254
|
}
|
|
13322
13255
|
initialise() {
|
|
13323
13256
|
super.initialise();
|
|
@@ -13367,16 +13300,15 @@ class ImportExpression extends NodeBase {
|
|
|
13367
13300
|
}
|
|
13368
13301
|
}
|
|
13369
13302
|
}
|
|
13370
|
-
setExternalResolution(exportMode,
|
|
13303
|
+
setExternalResolution(exportMode, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes, ownChunk, targetChunk) {
|
|
13371
13304
|
const { format } = options;
|
|
13372
13305
|
this.inlineNamespace = null;
|
|
13373
|
-
this.resolution = resolution;
|
|
13374
13306
|
this.resolutionString = resolutionString;
|
|
13375
13307
|
this.namespaceExportName = namespaceExportName;
|
|
13376
13308
|
this.attributes = attributes;
|
|
13377
13309
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
13378
13310
|
let helper;
|
|
13379
|
-
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(
|
|
13311
|
+
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(exportMode, options, snippets, pluginDriver, ownChunk, targetChunk));
|
|
13380
13312
|
if (helper) {
|
|
13381
13313
|
accessedGlobals.push(helper);
|
|
13382
13314
|
}
|
|
@@ -13387,11 +13319,12 @@ class ImportExpression extends NodeBase {
|
|
|
13387
13319
|
setInternalResolution(inlineNamespace) {
|
|
13388
13320
|
this.inlineNamespace = inlineNamespace;
|
|
13389
13321
|
}
|
|
13390
|
-
getDynamicImportMechanismAndHelper(
|
|
13322
|
+
getDynamicImportMechanismAndHelper(exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver, ownChunk, targetChunk) {
|
|
13323
|
+
const { resolution, scope } = this;
|
|
13391
13324
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
13392
13325
|
{
|
|
13393
13326
|
chunk: getChunkInfoWithPath(ownChunk),
|
|
13394
|
-
customResolution: typeof
|
|
13327
|
+
customResolution: typeof resolution === 'string' ? resolution : null,
|
|
13395
13328
|
format,
|
|
13396
13329
|
getTargetChunkImports() {
|
|
13397
13330
|
if (targetChunk === null)
|
|
@@ -13418,15 +13351,15 @@ class ImportExpression extends NodeBase {
|
|
|
13418
13351
|
}
|
|
13419
13352
|
return chunkInfos;
|
|
13420
13353
|
},
|
|
13421
|
-
moduleId:
|
|
13354
|
+
moduleId: scope.context.module.id,
|
|
13422
13355
|
targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null,
|
|
13423
|
-
targetModuleId:
|
|
13356
|
+
targetModuleId: resolution && typeof resolution !== 'string' ? resolution.id : null
|
|
13424
13357
|
}
|
|
13425
13358
|
]);
|
|
13426
13359
|
if (mechanism) {
|
|
13427
13360
|
return { helper: null, mechanism };
|
|
13428
13361
|
}
|
|
13429
|
-
const hasDynamicTarget = !
|
|
13362
|
+
const hasDynamicTarget = !resolution || typeof resolution === 'string';
|
|
13430
13363
|
switch (format) {
|
|
13431
13364
|
case 'cjs': {
|
|
13432
13365
|
if (dynamicImportInCjs &&
|
|
@@ -13516,15 +13449,6 @@ const accessedImportGlobals = {
|
|
|
13516
13449
|
cjs: ['require'],
|
|
13517
13450
|
system: ['module']
|
|
13518
13451
|
};
|
|
13519
|
-
function getDeterministicObjectDestructure(objectPattern) {
|
|
13520
|
-
const variables = [];
|
|
13521
|
-
for (const property of objectPattern.properties) {
|
|
13522
|
-
if (property.type === 'RestElement' || property.computed || property.key.type !== 'Identifier')
|
|
13523
|
-
return;
|
|
13524
|
-
variables.push(property.key.name);
|
|
13525
|
-
}
|
|
13526
|
-
return variables;
|
|
13527
|
-
}
|
|
13528
13452
|
|
|
13529
13453
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
13530
13454
|
}
|
|
@@ -14519,7 +14443,7 @@ ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
|
14519
14443
|
|
|
14520
14444
|
class PanicError extends NodeBase {
|
|
14521
14445
|
initialise() {
|
|
14522
|
-
const id = this.scope.context.module
|
|
14446
|
+
const { id } = this.scope.context.module;
|
|
14523
14447
|
// This simulates the current nested error structure. We could also just
|
|
14524
14448
|
// replace it with a flat error.
|
|
14525
14449
|
const parseError = getRollupError(logParseError(this.message));
|
|
@@ -14531,7 +14455,7 @@ class PanicError extends NodeBase {
|
|
|
14531
14455
|
class ParseError extends NodeBase {
|
|
14532
14456
|
initialise() {
|
|
14533
14457
|
const pos = this.start;
|
|
14534
|
-
const id = this.scope.context.module
|
|
14458
|
+
const { id } = this.scope.context.module;
|
|
14535
14459
|
// This simulates the current nested error structure. We could also just
|
|
14536
14460
|
// replace it with a flat error.
|
|
14537
14461
|
const parseError = getRollupError(logParseError(this.message, pos));
|
|
@@ -14990,9 +14914,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14990
14914
|
set hasCheckedForWarnings(value) {
|
|
14991
14915
|
this.flags = setFlag(this.flags, 134217728 /* Flag.checkedForWarnings */, value);
|
|
14992
14916
|
}
|
|
14993
|
-
bind() {
|
|
14994
|
-
super.bind();
|
|
14995
|
-
}
|
|
14996
14917
|
hasEffects(context) {
|
|
14997
14918
|
if (!this.deoptimized)
|
|
14998
14919
|
this.applyDeoptimizations();
|
|
@@ -15112,12 +15033,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
15112
15033
|
}
|
|
15113
15034
|
|
|
15114
15035
|
class ModuleScope extends ChildScope {
|
|
15115
|
-
constructor(parent, context) {
|
|
15036
|
+
constructor(parent, context, importDescriptions) {
|
|
15116
15037
|
super(parent, context);
|
|
15038
|
+
this.importDescriptions = importDescriptions;
|
|
15117
15039
|
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
15118
15040
|
}
|
|
15119
15041
|
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
15120
|
-
if (this.
|
|
15042
|
+
if (this.importDescriptions.has(identifier.name)) {
|
|
15121
15043
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
15122
15044
|
}
|
|
15123
15045
|
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
@@ -15429,6 +15351,10 @@ class UpdateExpression extends NodeBase {
|
|
|
15429
15351
|
}
|
|
15430
15352
|
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
15431
15353
|
|
|
15354
|
+
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
15355
|
+
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
15356
|
+
}
|
|
15357
|
+
|
|
15432
15358
|
class VariableDeclaration extends NodeBase {
|
|
15433
15359
|
deoptimizePath() {
|
|
15434
15360
|
for (const declarator of this.declarations) {
|
|
@@ -15614,6 +15540,92 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
15614
15540
|
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15615
15541
|
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15616
15542
|
|
|
15543
|
+
class VariableDeclarator extends NodeBase {
|
|
15544
|
+
declareDeclarator(kind) {
|
|
15545
|
+
this.isUsingDeclaration = kind === 'using';
|
|
15546
|
+
this.isAsyncUsingDeclaration = kind === 'await using';
|
|
15547
|
+
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
15548
|
+
}
|
|
15549
|
+
deoptimizePath(path) {
|
|
15550
|
+
this.id.deoptimizePath(path);
|
|
15551
|
+
}
|
|
15552
|
+
hasEffects(context) {
|
|
15553
|
+
const initEffect = this.init?.hasEffects(context);
|
|
15554
|
+
this.id.markDeclarationReached();
|
|
15555
|
+
return (initEffect ||
|
|
15556
|
+
this.isUsingDeclaration ||
|
|
15557
|
+
this.isAsyncUsingDeclaration ||
|
|
15558
|
+
this.id.hasEffects(context) ||
|
|
15559
|
+
(this.scope.context.options.treeshake
|
|
15560
|
+
.propertyReadSideEffects &&
|
|
15561
|
+
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
15562
|
+
}
|
|
15563
|
+
include(context, includeChildrenRecursively) {
|
|
15564
|
+
const { id, init } = this;
|
|
15565
|
+
if (!this.included)
|
|
15566
|
+
this.includeNode(context);
|
|
15567
|
+
init?.include(context, includeChildrenRecursively);
|
|
15568
|
+
id.markDeclarationReached();
|
|
15569
|
+
if (includeChildrenRecursively) {
|
|
15570
|
+
id.include(context, includeChildrenRecursively);
|
|
15571
|
+
}
|
|
15572
|
+
else {
|
|
15573
|
+
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
15574
|
+
}
|
|
15575
|
+
}
|
|
15576
|
+
removeAnnotations(code) {
|
|
15577
|
+
this.init?.removeAnnotations(code);
|
|
15578
|
+
}
|
|
15579
|
+
render(code, options) {
|
|
15580
|
+
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
15581
|
+
const { end, id, init, start } = this;
|
|
15582
|
+
const renderId = id.included || this.isUsingDeclaration || this.isAsyncUsingDeclaration;
|
|
15583
|
+
if (renderId) {
|
|
15584
|
+
id.render(code, options);
|
|
15585
|
+
}
|
|
15586
|
+
else {
|
|
15587
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
15588
|
+
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
15589
|
+
}
|
|
15590
|
+
if (init) {
|
|
15591
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
15592
|
+
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
15593
|
+
if (renderedVariable !== id.name) {
|
|
15594
|
+
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
15595
|
+
}
|
|
15596
|
+
}
|
|
15597
|
+
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
|
|
15598
|
+
}
|
|
15599
|
+
else if (id instanceof Identifier &&
|
|
15600
|
+
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
15601
|
+
code.appendLeft(end, `${_}=${_}void 0`);
|
|
15602
|
+
}
|
|
15603
|
+
}
|
|
15604
|
+
includeNode(context) {
|
|
15605
|
+
this.included = true;
|
|
15606
|
+
const { id, init } = this;
|
|
15607
|
+
if (init) {
|
|
15608
|
+
if (this.isUsingDeclaration) {
|
|
15609
|
+
init.includePath(SYMBOL_DISPOSE_PATH, context);
|
|
15610
|
+
}
|
|
15611
|
+
else if (this.isAsyncUsingDeclaration) {
|
|
15612
|
+
init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context);
|
|
15613
|
+
}
|
|
15614
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
15615
|
+
const { name, variable } = id;
|
|
15616
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
15617
|
+
if (accessedVariable !== variable) {
|
|
15618
|
+
accessedVariable.forbidName(name);
|
|
15619
|
+
}
|
|
15620
|
+
}
|
|
15621
|
+
}
|
|
15622
|
+
}
|
|
15623
|
+
}
|
|
15624
|
+
}
|
|
15625
|
+
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15626
|
+
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
15627
|
+
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
15628
|
+
|
|
15617
15629
|
class WhileStatement extends NodeBase {
|
|
15618
15630
|
hasEffects(context) {
|
|
15619
15631
|
if (this.test.hasEffects(context))
|
|
@@ -16901,27 +16913,26 @@ class Module {
|
|
|
16901
16913
|
this.needsExportShim = false;
|
|
16902
16914
|
this.sideEffectDependenciesByVariable = new Map();
|
|
16903
16915
|
this.sourcesWithAttributes = new Map();
|
|
16904
|
-
this.allExportNames = null;
|
|
16905
16916
|
this.allExportsIncluded = false;
|
|
16906
16917
|
this.ast = null;
|
|
16907
16918
|
this.exportAllModules = [];
|
|
16908
16919
|
this.exportAllSources = new Set();
|
|
16920
|
+
this.exportDescriptions = new Map();
|
|
16921
|
+
this.exportedVariablesByName = null;
|
|
16909
16922
|
this.exportNamesByVariable = null;
|
|
16910
16923
|
this.exportShimVariable = new ExportShimVariable(this);
|
|
16911
|
-
this.exports = new Map();
|
|
16912
16924
|
this.namespaceReexportsByName = new Map();
|
|
16913
16925
|
this.reexportDescriptions = new Map();
|
|
16914
16926
|
this.relevantDependencies = null;
|
|
16915
16927
|
this.syntheticExports = new Map();
|
|
16916
16928
|
this.syntheticNamespace = null;
|
|
16917
16929
|
this.transformDependencies = [];
|
|
16918
|
-
this.transitiveReexports = null;
|
|
16919
16930
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
16920
16931
|
this.context = options.moduleContext(id);
|
|
16921
16932
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
16922
16933
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
16923
16934
|
const module = this;
|
|
16924
|
-
const { dynamicImports, dynamicImporters, exportAllSources,
|
|
16935
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAttributes } = this;
|
|
16925
16936
|
this.info = {
|
|
16926
16937
|
ast: null,
|
|
16927
16938
|
attributes,
|
|
@@ -16940,7 +16951,7 @@ class Module {
|
|
|
16940
16951
|
return dynamicImporters.sort();
|
|
16941
16952
|
},
|
|
16942
16953
|
get exportedBindings() {
|
|
16943
|
-
const exportBindings = { '.': [...
|
|
16954
|
+
const exportBindings = { '.': [...exportDescriptions.keys()] };
|
|
16944
16955
|
for (const [name, { source }] of reexportDescriptions) {
|
|
16945
16956
|
(exportBindings[source] ??= []).push(name);
|
|
16946
16957
|
}
|
|
@@ -16951,7 +16962,7 @@ class Module {
|
|
|
16951
16962
|
},
|
|
16952
16963
|
get exports() {
|
|
16953
16964
|
return [
|
|
16954
|
-
...
|
|
16965
|
+
...exportDescriptions.keys(),
|
|
16955
16966
|
...reexportDescriptions.keys(),
|
|
16956
16967
|
...[...exportAllSources].map(() => '*')
|
|
16957
16968
|
];
|
|
@@ -16961,7 +16972,7 @@ class Module {
|
|
|
16961
16972
|
if (!module.ast) {
|
|
16962
16973
|
return null;
|
|
16963
16974
|
}
|
|
16964
|
-
return module.
|
|
16975
|
+
return module.exportDescriptions.has('default') || reexportDescriptions.has('default');
|
|
16965
16976
|
},
|
|
16966
16977
|
id,
|
|
16967
16978
|
get implicitlyLoadedAfterOneOf() {
|
|
@@ -17034,28 +17045,6 @@ class Module {
|
|
|
17034
17045
|
}
|
|
17035
17046
|
return size;
|
|
17036
17047
|
}
|
|
17037
|
-
getAllExportNames() {
|
|
17038
|
-
if (this.allExportNames) {
|
|
17039
|
-
return this.allExportNames;
|
|
17040
|
-
}
|
|
17041
|
-
this.allExportNames = new Set([...this.exports.keys(), ...this.reexportDescriptions.keys()]);
|
|
17042
|
-
for (const module of this.exportAllModules) {
|
|
17043
|
-
if (module instanceof ExternalModule) {
|
|
17044
|
-
this.allExportNames.add(`*${module.id}`);
|
|
17045
|
-
continue;
|
|
17046
|
-
}
|
|
17047
|
-
for (const name of module.getAllExportNames()) {
|
|
17048
|
-
if (name !== 'default')
|
|
17049
|
-
this.allExportNames.add(name);
|
|
17050
|
-
}
|
|
17051
|
-
}
|
|
17052
|
-
// We do not count the synthetic namespace as a regular export to hide it
|
|
17053
|
-
// from entry signatures and namespace objects
|
|
17054
|
-
if (typeof this.info.syntheticNamedExports === 'string') {
|
|
17055
|
-
this.allExportNames.delete(this.info.syntheticNamedExports);
|
|
17056
|
-
}
|
|
17057
|
-
return this.allExportNames;
|
|
17058
|
-
}
|
|
17059
17048
|
getDependenciesToBeIncluded() {
|
|
17060
17049
|
if (this.relevantDependencies)
|
|
17061
17050
|
return this.relevantDependencies;
|
|
@@ -17067,10 +17056,9 @@ class Module {
|
|
|
17067
17056
|
this.includedDynamicImporters.length > 0 ||
|
|
17068
17057
|
this.namespace.included ||
|
|
17069
17058
|
this.implicitlyLoadedAfter.size > 0) {
|
|
17070
|
-
for (const
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
dependencyVariables.add(exportedVariable);
|
|
17059
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
17060
|
+
if (variable.included) {
|
|
17061
|
+
dependencyVariables.add(variable);
|
|
17074
17062
|
}
|
|
17075
17063
|
}
|
|
17076
17064
|
}
|
|
@@ -17102,18 +17090,56 @@ class Module {
|
|
|
17102
17090
|
}
|
|
17103
17091
|
return this.relevantDependencies;
|
|
17104
17092
|
}
|
|
17093
|
+
getExportedVariablesByName() {
|
|
17094
|
+
if (this.exportedVariablesByName) {
|
|
17095
|
+
return this.exportedVariablesByName;
|
|
17096
|
+
}
|
|
17097
|
+
const exportedVariablesByName = (this.exportedVariablesByName = new Map());
|
|
17098
|
+
for (const name of this.exportDescriptions.keys()) {
|
|
17099
|
+
// We do not count the synthetic namespace as a regular export to hide it
|
|
17100
|
+
// from entry signatures and namespace objects
|
|
17101
|
+
if (name !== this.info.syntheticNamedExports) {
|
|
17102
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
17103
|
+
if (exportedVariable) {
|
|
17104
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
17105
|
+
}
|
|
17106
|
+
else {
|
|
17107
|
+
return error(logMissingEntryExport(name, this.id));
|
|
17108
|
+
}
|
|
17109
|
+
}
|
|
17110
|
+
}
|
|
17111
|
+
for (const name of this.reexportDescriptions.keys()) {
|
|
17112
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
17113
|
+
if (exportedVariable) {
|
|
17114
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
17115
|
+
}
|
|
17116
|
+
}
|
|
17117
|
+
for (const module of this.exportAllModules) {
|
|
17118
|
+
if (module instanceof ExternalModule) {
|
|
17119
|
+
exportedVariablesByName.set(`*${module.id}`, module.getVariableForExportName('*', {
|
|
17120
|
+
importChain: [this.id]
|
|
17121
|
+
})[0]);
|
|
17122
|
+
continue;
|
|
17123
|
+
}
|
|
17124
|
+
for (const name of module.getExportedVariablesByName().keys()) {
|
|
17125
|
+
if (name !== 'default' && !exportedVariablesByName.has(name)) {
|
|
17126
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
17127
|
+
if (exportedVariable) {
|
|
17128
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
17129
|
+
}
|
|
17130
|
+
}
|
|
17131
|
+
}
|
|
17132
|
+
}
|
|
17133
|
+
return (this.exportedVariablesByName = new Map([...exportedVariablesByName].sort(sortExportedVariables)));
|
|
17134
|
+
}
|
|
17105
17135
|
getExportNamesByVariable() {
|
|
17106
17136
|
if (this.exportNamesByVariable) {
|
|
17107
17137
|
return this.exportNamesByVariable;
|
|
17108
17138
|
}
|
|
17109
17139
|
const exportNamesByVariable = new Map();
|
|
17110
|
-
for (const exportName of this.
|
|
17111
|
-
|
|
17112
|
-
if (
|
|
17113
|
-
tracedVariable = tracedVariable.getOriginalVariable();
|
|
17114
|
-
}
|
|
17115
|
-
if (!tracedVariable ||
|
|
17116
|
-
!(tracedVariable.included || tracedVariable instanceof ExternalVariable)) {
|
|
17140
|
+
for (const [exportName, variable] of this.getExportedVariablesByName().entries()) {
|
|
17141
|
+
const tracedVariable = variable instanceof ExportDefaultVariable ? variable.getOriginalVariable() : variable;
|
|
17142
|
+
if (!variable || !(variable.included || variable instanceof ExternalVariable)) {
|
|
17117
17143
|
continue;
|
|
17118
17144
|
}
|
|
17119
17145
|
const existingExportNames = exportNamesByVariable.get(tracedVariable);
|
|
@@ -17126,36 +17152,14 @@ class Module {
|
|
|
17126
17152
|
}
|
|
17127
17153
|
return (this.exportNamesByVariable = exportNamesByVariable);
|
|
17128
17154
|
}
|
|
17129
|
-
getExports() {
|
|
17130
|
-
return [...this.exports.keys()];
|
|
17131
|
-
}
|
|
17132
|
-
getReexports() {
|
|
17133
|
-
if (this.transitiveReexports) {
|
|
17134
|
-
return this.transitiveReexports;
|
|
17135
|
-
}
|
|
17136
|
-
// to avoid infinite recursion when using circular `export * from X`
|
|
17137
|
-
this.transitiveReexports = [];
|
|
17138
|
-
const reexports = new Set(this.reexportDescriptions.keys());
|
|
17139
|
-
for (const module of this.exportAllModules) {
|
|
17140
|
-
if (module instanceof ExternalModule) {
|
|
17141
|
-
reexports.add(`*${module.id}`);
|
|
17142
|
-
}
|
|
17143
|
-
else {
|
|
17144
|
-
for (const name of [...module.getReexports(), ...module.getExports()]) {
|
|
17145
|
-
if (name !== 'default')
|
|
17146
|
-
reexports.add(name);
|
|
17147
|
-
}
|
|
17148
|
-
}
|
|
17149
|
-
}
|
|
17150
|
-
return (this.transitiveReexports = [...reexports]);
|
|
17151
|
-
}
|
|
17152
17155
|
getRenderedExports() {
|
|
17153
17156
|
// only direct exports are counted here, not reexports at all
|
|
17154
17157
|
const renderedExports = [];
|
|
17155
17158
|
const removedExports = [];
|
|
17156
|
-
for (const exportName of this.
|
|
17157
|
-
|
|
17158
|
-
|
|
17159
|
+
for (const exportName of this.exportDescriptions.keys()) {
|
|
17160
|
+
(this.getExportedVariablesByName().get(exportName)?.included
|
|
17161
|
+
? renderedExports
|
|
17162
|
+
: removedExports).push(exportName);
|
|
17159
17163
|
}
|
|
17160
17164
|
return { removedExports, renderedExports };
|
|
17161
17165
|
}
|
|
@@ -17198,7 +17202,7 @@ class Module {
|
|
|
17198
17202
|
}
|
|
17199
17203
|
return [variable];
|
|
17200
17204
|
}
|
|
17201
|
-
const exportDeclaration = this.
|
|
17205
|
+
const exportDeclaration = this.exportDescriptions.get(name);
|
|
17202
17206
|
if (exportDeclaration) {
|
|
17203
17207
|
if (exportDeclaration === MISSING_EXPORT_SHIM_DESCRIPTION) {
|
|
17204
17208
|
return [this.exportShimVariable];
|
|
@@ -17249,63 +17253,29 @@ class Module {
|
|
|
17249
17253
|
if (this.ast.shouldBeIncluded(context))
|
|
17250
17254
|
this.ast.include(context, false);
|
|
17251
17255
|
}
|
|
17252
|
-
includeAllExports(
|
|
17253
|
-
if (includeNamespaceMembers) {
|
|
17254
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
17255
|
-
}
|
|
17256
|
+
includeAllExports() {
|
|
17256
17257
|
if (this.allExportsIncluded)
|
|
17257
17258
|
return;
|
|
17258
17259
|
this.allExportsIncluded = true;
|
|
17259
|
-
|
|
17260
|
-
markModuleAndImpureDependenciesAsExecuted(this);
|
|
17261
|
-
this.graph.needsTreeshakingPass = true;
|
|
17262
|
-
}
|
|
17260
|
+
this.includeModuleInExecution();
|
|
17263
17261
|
const inclusionContext = createInclusionContext();
|
|
17264
|
-
for (const
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
}
|
|
17270
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
17271
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17272
|
-
}
|
|
17273
|
-
}
|
|
17274
|
-
for (const name of this.getReexports()) {
|
|
17275
|
-
const [variable] = this.getVariableForExportName(name);
|
|
17276
|
-
if (variable) {
|
|
17277
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17278
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
17279
|
-
if (variable instanceof ExternalVariable) {
|
|
17280
|
-
variable.module.reexported = true;
|
|
17281
|
-
}
|
|
17262
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
17263
|
+
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
17264
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17265
|
+
if (variable instanceof ExternalVariable) {
|
|
17266
|
+
variable.module.reexported = true;
|
|
17282
17267
|
}
|
|
17283
17268
|
}
|
|
17284
17269
|
}
|
|
17285
17270
|
includeAllInBundle() {
|
|
17286
17271
|
this.ast.include(createInclusionContext(), true);
|
|
17287
|
-
this.includeAllExports(
|
|
17272
|
+
this.includeAllExports();
|
|
17288
17273
|
}
|
|
17289
|
-
|
|
17274
|
+
includeModuleInExecution() {
|
|
17290
17275
|
if (!this.isExecuted) {
|
|
17291
17276
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
17292
17277
|
this.graph.needsTreeshakingPass = true;
|
|
17293
17278
|
}
|
|
17294
|
-
let includeNamespaceMembers = false;
|
|
17295
|
-
const inclusionContext = createInclusionContext();
|
|
17296
|
-
for (const name of names) {
|
|
17297
|
-
const variable = this.getVariableForExportName(name)[0];
|
|
17298
|
-
if (variable) {
|
|
17299
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17300
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
17301
|
-
}
|
|
17302
|
-
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
17303
|
-
includeNamespaceMembers = true;
|
|
17304
|
-
}
|
|
17305
|
-
}
|
|
17306
|
-
if (includeNamespaceMembers) {
|
|
17307
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
17308
|
-
}
|
|
17309
17279
|
}
|
|
17310
17280
|
isIncluded() {
|
|
17311
17281
|
// Modules where this.ast is missing have been loaded via this.load and are
|
|
@@ -17384,14 +17354,11 @@ class Module {
|
|
|
17384
17354
|
deoptimizationTracker: this.graph.deoptimizationTracker,
|
|
17385
17355
|
error: this.error.bind(this),
|
|
17386
17356
|
fileName, // Needed for warnings
|
|
17387
|
-
getExports: this.getExports.bind(this),
|
|
17388
17357
|
getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this),
|
|
17389
17358
|
getModuleExecIndex: () => this.execIndex,
|
|
17390
17359
|
getModuleName: this.basename.bind(this),
|
|
17391
17360
|
getNodeConstructor: (name) => nodeConstructors[name] || nodeConstructors.UnknownNode,
|
|
17392
|
-
getReexports: this.getReexports.bind(this),
|
|
17393
17361
|
importDescriptions: this.importDescriptions,
|
|
17394
|
-
includeAllExports: () => this.includeAllExports(true),
|
|
17395
17362
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
17396
17363
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
17397
17364
|
log: this.log.bind(this),
|
|
@@ -17406,7 +17373,7 @@ class Module {
|
|
|
17406
17373
|
traceVariable: this.traceVariable.bind(this),
|
|
17407
17374
|
usesTopLevelAwait: false
|
|
17408
17375
|
};
|
|
17409
|
-
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
17376
|
+
this.scope = new ModuleScope(this.graph.scope, this.astContext, this.importDescriptions);
|
|
17410
17377
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
17411
17378
|
const programParent = { context: this.astContext, type: 'Module' };
|
|
17412
17379
|
if (ast) {
|
|
@@ -17507,10 +17474,10 @@ class Module {
|
|
|
17507
17474
|
typeof argument.value === 'string') {
|
|
17508
17475
|
argument = argument.value;
|
|
17509
17476
|
}
|
|
17510
|
-
this.dynamicImports.push({ argument, id: null, node
|
|
17477
|
+
this.dynamicImports.push({ argument, id: null, node });
|
|
17511
17478
|
}
|
|
17512
17479
|
assertUniqueExportName(name, nodeStart) {
|
|
17513
|
-
if (this.
|
|
17480
|
+
if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
|
|
17514
17481
|
this.error(logDuplicateExportError(name), nodeStart);
|
|
17515
17482
|
}
|
|
17516
17483
|
}
|
|
@@ -17518,7 +17485,7 @@ class Module {
|
|
|
17518
17485
|
if (node instanceof ExportDefaultDeclaration) {
|
|
17519
17486
|
// export default foo;
|
|
17520
17487
|
this.assertUniqueExportName('default', node.start);
|
|
17521
|
-
this.
|
|
17488
|
+
this.exportDescriptions.set('default', {
|
|
17522
17489
|
identifier: node.variable.getAssignedVariableName(),
|
|
17523
17490
|
localName: 'default'
|
|
17524
17491
|
});
|
|
@@ -17565,7 +17532,7 @@ class Module {
|
|
|
17565
17532
|
for (const declarator of declaration.declarations) {
|
|
17566
17533
|
for (const localName of extractAssignedNames(declarator.id)) {
|
|
17567
17534
|
this.assertUniqueExportName(localName, declarator.id.start);
|
|
17568
|
-
this.
|
|
17535
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
17569
17536
|
}
|
|
17570
17537
|
}
|
|
17571
17538
|
}
|
|
@@ -17573,7 +17540,7 @@ class Module {
|
|
|
17573
17540
|
// export function foo () {}
|
|
17574
17541
|
const localName = declaration.id.name;
|
|
17575
17542
|
this.assertUniqueExportName(localName, declaration.id.start);
|
|
17576
|
-
this.
|
|
17543
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
17577
17544
|
}
|
|
17578
17545
|
}
|
|
17579
17546
|
else {
|
|
@@ -17583,7 +17550,7 @@ class Module {
|
|
|
17583
17550
|
const localName = local.name;
|
|
17584
17551
|
const exportedName = exported instanceof Identifier ? exported.name : exported.value;
|
|
17585
17552
|
this.assertUniqueExportName(exportedName, exported.start);
|
|
17586
|
-
this.
|
|
17553
|
+
this.exportDescriptions.set(exportedName, { identifier: null, localName });
|
|
17587
17554
|
}
|
|
17588
17555
|
}
|
|
17589
17556
|
}
|
|
@@ -17757,7 +17724,7 @@ class Module {
|
|
|
17757
17724
|
return [...syntheticNamespaces, ...externalNamespaces];
|
|
17758
17725
|
}
|
|
17759
17726
|
includeDynamicImport(node) {
|
|
17760
|
-
const resolution =
|
|
17727
|
+
const { resolution } = node;
|
|
17761
17728
|
if (resolution instanceof Module) {
|
|
17762
17729
|
if (!resolution.includedDynamicImporters.includes(this)) {
|
|
17763
17730
|
resolution.includedDynamicImporters.push(this);
|
|
@@ -17767,15 +17734,6 @@ class Module {
|
|
|
17767
17734
|
resolution.includedTopLevelAwaitingDynamicImporters.add(this);
|
|
17768
17735
|
}
|
|
17769
17736
|
}
|
|
17770
|
-
const importedNames = this.options.treeshake
|
|
17771
|
-
? node.getDeterministicImportedNames()
|
|
17772
|
-
: undefined;
|
|
17773
|
-
if (importedNames) {
|
|
17774
|
-
resolution.includeExportsByNames(importedNames);
|
|
17775
|
-
}
|
|
17776
|
-
else {
|
|
17777
|
-
resolution.includeAllExports(true);
|
|
17778
|
-
}
|
|
17779
17737
|
}
|
|
17780
17738
|
}
|
|
17781
17739
|
includeVariable(variable, path, context) {
|
|
@@ -17785,21 +17743,17 @@ class Module {
|
|
|
17785
17743
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
17786
17744
|
getAndExtendSideEffectModules(variable, this);
|
|
17787
17745
|
}
|
|
17746
|
+
return;
|
|
17788
17747
|
}
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
if (!module.isExecuted) {
|
|
17799
|
-
markModuleAndImpureDependenciesAsExecuted(module);
|
|
17800
|
-
}
|
|
17801
|
-
}
|
|
17802
|
-
}
|
|
17748
|
+
this.graph.needsTreeshakingPass = true;
|
|
17749
|
+
if (!(variableModule instanceof Module)) {
|
|
17750
|
+
return;
|
|
17751
|
+
}
|
|
17752
|
+
variableModule.includeModuleInExecution();
|
|
17753
|
+
if (variableModule !== this) {
|
|
17754
|
+
const sideEffectModules = getAndExtendSideEffectModules(variable, this);
|
|
17755
|
+
for (const module of sideEffectModules) {
|
|
17756
|
+
module.includeModuleInExecution();
|
|
17803
17757
|
}
|
|
17804
17758
|
}
|
|
17805
17759
|
}
|
|
@@ -17812,7 +17766,7 @@ class Module {
|
|
|
17812
17766
|
}
|
|
17813
17767
|
shimMissingExport(name) {
|
|
17814
17768
|
this.options.onLog(LOGLEVEL_WARN, logShimmedExport(this.id, name));
|
|
17815
|
-
this.
|
|
17769
|
+
this.exportDescriptions.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
|
|
17816
17770
|
}
|
|
17817
17771
|
tryParse() {
|
|
17818
17772
|
try {
|
|
@@ -17842,6 +17796,7 @@ function setAlternativeExporterIfCyclic(variable, importer, reexporter) {
|
|
|
17842
17796
|
}
|
|
17843
17797
|
const copyNameToModulesMap = (searchedNamesAndModules) => searchedNamesAndModules &&
|
|
17844
17798
|
new Map(Array.from(searchedNamesAndModules, ([name, modules]) => [name, new Set(modules)]));
|
|
17799
|
+
const sortExportedVariables = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
17845
17800
|
|
|
17846
17801
|
const concatSeparator = (out, next) => (next ? `${out}\n${next}` : out);
|
|
17847
17802
|
const concatDblSeparator = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
@@ -18333,6 +18288,8 @@ class Chunk {
|
|
|
18333
18288
|
includedNamespaces.add(module);
|
|
18334
18289
|
this.exports.add(module.namespace);
|
|
18335
18290
|
}
|
|
18291
|
+
// This only needs to run once
|
|
18292
|
+
break;
|
|
18336
18293
|
}
|
|
18337
18294
|
}
|
|
18338
18295
|
if (module.implicitlyLoadedAfter.size > 0) {
|
|
@@ -18970,10 +18927,11 @@ class Chunk {
|
|
|
18970
18927
|
}
|
|
18971
18928
|
const includedDynamicImports = [];
|
|
18972
18929
|
for (const module of this.orderedModules) {
|
|
18973
|
-
for (const { node
|
|
18930
|
+
for (const { node } of module.dynamicImports) {
|
|
18974
18931
|
if (!node.included) {
|
|
18975
18932
|
continue;
|
|
18976
18933
|
}
|
|
18934
|
+
const { resolution } = node;
|
|
18977
18935
|
includedDynamicImports.push(resolution instanceof Module
|
|
18978
18936
|
? {
|
|
18979
18937
|
chunk: this.chunkByModule.get(resolution),
|
|
@@ -19231,13 +19189,13 @@ class Chunk {
|
|
|
19231
19189
|
node.setInternalResolution(resolution.namespace);
|
|
19232
19190
|
}
|
|
19233
19191
|
else {
|
|
19234
|
-
node.setExternalResolution((facadeChunk || chunk).exportMode,
|
|
19192
|
+
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);
|
|
19235
19193
|
}
|
|
19236
19194
|
}
|
|
19237
19195
|
else {
|
|
19238
19196
|
const { node, resolution } = resolvedDynamicImport;
|
|
19239
19197
|
const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
|
|
19240
|
-
node.setExternalResolution('external',
|
|
19198
|
+
node.setExternalResolution('external', outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
|
|
19241
19199
|
}
|
|
19242
19200
|
}
|
|
19243
19201
|
}
|
|
@@ -19290,8 +19248,7 @@ class Chunk {
|
|
|
19290
19248
|
// when we are not preserving modules, we need to make all namespace variables available for
|
|
19291
19249
|
// rendering the namespace object
|
|
19292
19250
|
if (!this.outputOptions.preserveModules && this.includedNamespaces.has(module)) {
|
|
19293
|
-
const
|
|
19294
|
-
for (const variable of Object.values(memberVariables)) {
|
|
19251
|
+
for (const variable of module.getExportedVariablesByName().values()) {
|
|
19295
19252
|
if (variable.included) {
|
|
19296
19253
|
moduleImports.add(variable);
|
|
19297
19254
|
}
|
|
@@ -19322,8 +19279,8 @@ class Chunk {
|
|
|
19322
19279
|
module.includedDynamicImporters.some(importer => this.chunkByModule.get(importer) !== this)) {
|
|
19323
19280
|
this.ensureReexportsAreAvailableForModule(module);
|
|
19324
19281
|
}
|
|
19325
|
-
for (const { node, resolution } of module.dynamicImports) {
|
|
19326
|
-
if (
|
|
19282
|
+
for (const { node: { included, resolution } } of module.dynamicImports) {
|
|
19283
|
+
if (included &&
|
|
19327
19284
|
resolution instanceof Module &&
|
|
19328
19285
|
this.chunkByModule.get(resolution) === this &&
|
|
19329
19286
|
!this.includedNamespaces.has(resolution)) {
|
|
@@ -19554,7 +19511,7 @@ function analyzeModuleGraph(entries) {
|
|
|
19554
19511
|
staticDependencies.add(dependency);
|
|
19555
19512
|
}
|
|
19556
19513
|
}
|
|
19557
|
-
for (const { resolution } of module.dynamicImports) {
|
|
19514
|
+
for (const { node: { resolution } } of module.dynamicImports) {
|
|
19558
19515
|
if (resolution instanceof Module &&
|
|
19559
19516
|
resolution.includedDynamicImporters.length > 0 &&
|
|
19560
19517
|
!allEntriesSet.has(resolution)) {
|
|
@@ -20095,9 +20052,9 @@ function analyseModuleExecution(entryModules) {
|
|
|
20095
20052
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
20096
20053
|
dynamicImports.add(dependency);
|
|
20097
20054
|
}
|
|
20098
|
-
for (const { resolution,
|
|
20055
|
+
for (const { node: { resolution, scope } } of module.dynamicImports) {
|
|
20099
20056
|
if (resolution instanceof Module) {
|
|
20100
|
-
if (
|
|
20057
|
+
if (scope.context.usesTopLevelAwait) {
|
|
20101
20058
|
handleSyncLoadedModule(resolution, module);
|
|
20102
20059
|
}
|
|
20103
20060
|
else {
|
|
@@ -21514,14 +21471,14 @@ class ModuleLoader {
|
|
|
21514
21471
|
return loadNewModulesPromise;
|
|
21515
21472
|
}
|
|
21516
21473
|
async fetchDynamicDependencies(module, resolveDynamicImportPromises) {
|
|
21517
|
-
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([
|
|
21474
|
+
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([{ node }, resolvedId]) => {
|
|
21518
21475
|
if (resolvedId === null)
|
|
21519
21476
|
return null;
|
|
21520
21477
|
if (typeof resolvedId === 'string') {
|
|
21521
|
-
|
|
21478
|
+
node.resolution = resolvedId;
|
|
21522
21479
|
return null;
|
|
21523
21480
|
}
|
|
21524
|
-
return (
|
|
21481
|
+
return (node.resolution = await this.fetchResolvedDependency(relativeId(resolvedId.id), module.id, resolvedId));
|
|
21525
21482
|
})));
|
|
21526
21483
|
for (const dependency of dependencies) {
|
|
21527
21484
|
if (dependency) {
|
|
@@ -22760,7 +22717,7 @@ class Graph {
|
|
|
22760
22717
|
timeEnd('generate module graph', 2);
|
|
22761
22718
|
timeStart('sort and bind modules', 2);
|
|
22762
22719
|
this.phase = BuildPhase.ANALYSE;
|
|
22763
|
-
this.
|
|
22720
|
+
this.sortAndBindModules();
|
|
22764
22721
|
timeEnd('sort and bind modules', 2);
|
|
22765
22722
|
timeStart('mark included statements', 2);
|
|
22766
22723
|
this.includeStatements();
|
|
@@ -22833,7 +22790,7 @@ class Graph {
|
|
|
22833
22790
|
// the TDZ detection logic
|
|
22834
22791
|
for (const module of entryModules) {
|
|
22835
22792
|
if (module.preserveSignature !== false) {
|
|
22836
|
-
module.includeAllExports(
|
|
22793
|
+
module.includeAllExports();
|
|
22837
22794
|
this.needsTreeshakingPass = true;
|
|
22838
22795
|
}
|
|
22839
22796
|
}
|
|
@@ -22855,7 +22812,7 @@ class Graph {
|
|
|
22855
22812
|
}
|
|
22856
22813
|
}
|
|
22857
22814
|
}
|
|
22858
|
-
|
|
22815
|
+
sortAndBindModules() {
|
|
22859
22816
|
const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
|
|
22860
22817
|
for (const cyclePath of cyclePaths) {
|
|
22861
22818
|
this.options.onLog(LOGLEVEL_WARN, logCircularDependency(cyclePath));
|