@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
|
@@ -1,13 +1,13 @@
|
|
|
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
|
|
|
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, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, URL_LOAD, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, 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.57.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
|
}
|
|
@@ -7803,7 +7781,7 @@ class MetaProperty extends NodeBase {
|
|
|
7803
7781
|
render(code, renderOptions) {
|
|
7804
7782
|
const { format, pluginDriver, snippets } = renderOptions;
|
|
7805
7783
|
const { scope: { context: { module } }, meta: { name }, metaProperty, parent, preliminaryChunkId, referenceId, start, end } = this;
|
|
7806
|
-
const { id: moduleId } = module;
|
|
7784
|
+
const { id: moduleId, info: { attributes } } = module;
|
|
7807
7785
|
if (name !== IMPORT)
|
|
7808
7786
|
return;
|
|
7809
7787
|
const chunkId = preliminaryChunkId;
|
|
@@ -7812,14 +7790,14 @@ class MetaProperty extends NodeBase {
|
|
|
7812
7790
|
const relativePath = normalize(relative(dirname(chunkId), fileName));
|
|
7813
7791
|
const isUrlObject = !!metaProperty?.startsWith(FILE_OBJ_PREFIX);
|
|
7814
7792
|
const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
|
|
7815
|
-
{ chunkId, fileName, format, moduleId, referenceId, relativePath }
|
|
7793
|
+
{ attributes, chunkId, fileName, format, moduleId, referenceId, relativePath }
|
|
7816
7794
|
]) || relativeUrlMechanisms[format](relativePath, isUrlObject);
|
|
7817
7795
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
7818
7796
|
return;
|
|
7819
7797
|
}
|
|
7820
7798
|
let replacement = pluginDriver.hookFirstSync('resolveImportMeta', [
|
|
7821
7799
|
metaProperty,
|
|
7822
|
-
{ chunkId, format, moduleId }
|
|
7800
|
+
{ attributes, chunkId, format, moduleId }
|
|
7823
7801
|
]);
|
|
7824
7802
|
if (!replacement) {
|
|
7825
7803
|
replacement = importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets });
|
|
@@ -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,16 @@ 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
|
-
|
|
13356
|
+
targetModuleAttributes: resolution && typeof resolution !== 'string' ? resolution.info.attributes : {},
|
|
13357
|
+
targetModuleId: resolution && typeof resolution !== 'string' ? resolution.id : null
|
|
13424
13358
|
}
|
|
13425
13359
|
]);
|
|
13426
13360
|
if (mechanism) {
|
|
13427
13361
|
return { helper: null, mechanism };
|
|
13428
13362
|
}
|
|
13429
|
-
const hasDynamicTarget = !
|
|
13363
|
+
const hasDynamicTarget = !resolution || typeof resolution === 'string';
|
|
13430
13364
|
switch (format) {
|
|
13431
13365
|
case 'cjs': {
|
|
13432
13366
|
if (dynamicImportInCjs &&
|
|
@@ -13516,15 +13450,6 @@ const accessedImportGlobals = {
|
|
|
13516
13450
|
cjs: ['require'],
|
|
13517
13451
|
system: ['module']
|
|
13518
13452
|
};
|
|
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
13453
|
|
|
13529
13454
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
13530
13455
|
}
|
|
@@ -14519,7 +14444,7 @@ ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
|
14519
14444
|
|
|
14520
14445
|
class PanicError extends NodeBase {
|
|
14521
14446
|
initialise() {
|
|
14522
|
-
const id = this.scope.context.module
|
|
14447
|
+
const { id } = this.scope.context.module;
|
|
14523
14448
|
// This simulates the current nested error structure. We could also just
|
|
14524
14449
|
// replace it with a flat error.
|
|
14525
14450
|
const parseError = getRollupError(logParseError(this.message));
|
|
@@ -14531,7 +14456,7 @@ class PanicError extends NodeBase {
|
|
|
14531
14456
|
class ParseError extends NodeBase {
|
|
14532
14457
|
initialise() {
|
|
14533
14458
|
const pos = this.start;
|
|
14534
|
-
const id = this.scope.context.module
|
|
14459
|
+
const { id } = this.scope.context.module;
|
|
14535
14460
|
// This simulates the current nested error structure. We could also just
|
|
14536
14461
|
// replace it with a flat error.
|
|
14537
14462
|
const parseError = getRollupError(logParseError(this.message, pos));
|
|
@@ -14990,9 +14915,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14990
14915
|
set hasCheckedForWarnings(value) {
|
|
14991
14916
|
this.flags = setFlag(this.flags, 134217728 /* Flag.checkedForWarnings */, value);
|
|
14992
14917
|
}
|
|
14993
|
-
bind() {
|
|
14994
|
-
super.bind();
|
|
14995
|
-
}
|
|
14996
14918
|
hasEffects(context) {
|
|
14997
14919
|
if (!this.deoptimized)
|
|
14998
14920
|
this.applyDeoptimizations();
|
|
@@ -15112,12 +15034,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
15112
15034
|
}
|
|
15113
15035
|
|
|
15114
15036
|
class ModuleScope extends ChildScope {
|
|
15115
|
-
constructor(parent, context) {
|
|
15037
|
+
constructor(parent, context, importDescriptions) {
|
|
15116
15038
|
super(parent, context);
|
|
15039
|
+
this.importDescriptions = importDescriptions;
|
|
15117
15040
|
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
15118
15041
|
}
|
|
15119
15042
|
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
15120
|
-
if (this.
|
|
15043
|
+
if (this.importDescriptions.has(identifier.name)) {
|
|
15121
15044
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
15122
15045
|
}
|
|
15123
15046
|
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
@@ -15429,6 +15352,10 @@ class UpdateExpression extends NodeBase {
|
|
|
15429
15352
|
}
|
|
15430
15353
|
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
15431
15354
|
|
|
15355
|
+
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
15356
|
+
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
15357
|
+
}
|
|
15358
|
+
|
|
15432
15359
|
class VariableDeclaration extends NodeBase {
|
|
15433
15360
|
deoptimizePath() {
|
|
15434
15361
|
for (const declarator of this.declarations) {
|
|
@@ -15614,6 +15541,92 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
15614
15541
|
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15615
15542
|
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15616
15543
|
|
|
15544
|
+
class VariableDeclarator extends NodeBase {
|
|
15545
|
+
declareDeclarator(kind) {
|
|
15546
|
+
this.isUsingDeclaration = kind === 'using';
|
|
15547
|
+
this.isAsyncUsingDeclaration = kind === 'await using';
|
|
15548
|
+
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
15549
|
+
}
|
|
15550
|
+
deoptimizePath(path) {
|
|
15551
|
+
this.id.deoptimizePath(path);
|
|
15552
|
+
}
|
|
15553
|
+
hasEffects(context) {
|
|
15554
|
+
const initEffect = this.init?.hasEffects(context);
|
|
15555
|
+
this.id.markDeclarationReached();
|
|
15556
|
+
return (initEffect ||
|
|
15557
|
+
this.isUsingDeclaration ||
|
|
15558
|
+
this.isAsyncUsingDeclaration ||
|
|
15559
|
+
this.id.hasEffects(context) ||
|
|
15560
|
+
(this.scope.context.options.treeshake
|
|
15561
|
+
.propertyReadSideEffects &&
|
|
15562
|
+
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
15563
|
+
}
|
|
15564
|
+
include(context, includeChildrenRecursively) {
|
|
15565
|
+
const { id, init } = this;
|
|
15566
|
+
if (!this.included)
|
|
15567
|
+
this.includeNode(context);
|
|
15568
|
+
init?.include(context, includeChildrenRecursively);
|
|
15569
|
+
id.markDeclarationReached();
|
|
15570
|
+
if (includeChildrenRecursively) {
|
|
15571
|
+
id.include(context, includeChildrenRecursively);
|
|
15572
|
+
}
|
|
15573
|
+
else {
|
|
15574
|
+
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
15575
|
+
}
|
|
15576
|
+
}
|
|
15577
|
+
removeAnnotations(code) {
|
|
15578
|
+
this.init?.removeAnnotations(code);
|
|
15579
|
+
}
|
|
15580
|
+
render(code, options) {
|
|
15581
|
+
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
15582
|
+
const { end, id, init, start } = this;
|
|
15583
|
+
const renderId = id.included || this.isUsingDeclaration || this.isAsyncUsingDeclaration;
|
|
15584
|
+
if (renderId) {
|
|
15585
|
+
id.render(code, options);
|
|
15586
|
+
}
|
|
15587
|
+
else {
|
|
15588
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
15589
|
+
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
15590
|
+
}
|
|
15591
|
+
if (init) {
|
|
15592
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
15593
|
+
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
15594
|
+
if (renderedVariable !== id.name) {
|
|
15595
|
+
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
15596
|
+
}
|
|
15597
|
+
}
|
|
15598
|
+
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
|
|
15599
|
+
}
|
|
15600
|
+
else if (id instanceof Identifier &&
|
|
15601
|
+
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
15602
|
+
code.appendLeft(end, `${_}=${_}void 0`);
|
|
15603
|
+
}
|
|
15604
|
+
}
|
|
15605
|
+
includeNode(context) {
|
|
15606
|
+
this.included = true;
|
|
15607
|
+
const { id, init } = this;
|
|
15608
|
+
if (init) {
|
|
15609
|
+
if (this.isUsingDeclaration) {
|
|
15610
|
+
init.includePath(SYMBOL_DISPOSE_PATH, context);
|
|
15611
|
+
}
|
|
15612
|
+
else if (this.isAsyncUsingDeclaration) {
|
|
15613
|
+
init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context);
|
|
15614
|
+
}
|
|
15615
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
15616
|
+
const { name, variable } = id;
|
|
15617
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
15618
|
+
if (accessedVariable !== variable) {
|
|
15619
|
+
accessedVariable.forbidName(name);
|
|
15620
|
+
}
|
|
15621
|
+
}
|
|
15622
|
+
}
|
|
15623
|
+
}
|
|
15624
|
+
}
|
|
15625
|
+
}
|
|
15626
|
+
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15627
|
+
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
15628
|
+
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
15629
|
+
|
|
15617
15630
|
class WhileStatement extends NodeBase {
|
|
15618
15631
|
hasEffects(context) {
|
|
15619
15632
|
if (this.test.hasEffects(context))
|
|
@@ -16901,27 +16914,26 @@ class Module {
|
|
|
16901
16914
|
this.needsExportShim = false;
|
|
16902
16915
|
this.sideEffectDependenciesByVariable = new Map();
|
|
16903
16916
|
this.sourcesWithAttributes = new Map();
|
|
16904
|
-
this.allExportNames = null;
|
|
16905
16917
|
this.allExportsIncluded = false;
|
|
16906
16918
|
this.ast = null;
|
|
16907
16919
|
this.exportAllModules = [];
|
|
16908
16920
|
this.exportAllSources = new Set();
|
|
16921
|
+
this.exportDescriptions = new Map();
|
|
16922
|
+
this.exportedVariablesByName = null;
|
|
16909
16923
|
this.exportNamesByVariable = null;
|
|
16910
16924
|
this.exportShimVariable = new ExportShimVariable(this);
|
|
16911
|
-
this.exports = new Map();
|
|
16912
16925
|
this.namespaceReexportsByName = new Map();
|
|
16913
16926
|
this.reexportDescriptions = new Map();
|
|
16914
16927
|
this.relevantDependencies = null;
|
|
16915
16928
|
this.syntheticExports = new Map();
|
|
16916
16929
|
this.syntheticNamespace = null;
|
|
16917
16930
|
this.transformDependencies = [];
|
|
16918
|
-
this.transitiveReexports = null;
|
|
16919
16931
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
16920
16932
|
this.context = options.moduleContext(id);
|
|
16921
16933
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
16922
16934
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
16923
16935
|
const module = this;
|
|
16924
|
-
const { dynamicImports, dynamicImporters, exportAllSources,
|
|
16936
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAttributes } = this;
|
|
16925
16937
|
this.info = {
|
|
16926
16938
|
ast: null,
|
|
16927
16939
|
attributes,
|
|
@@ -16940,7 +16952,7 @@ class Module {
|
|
|
16940
16952
|
return dynamicImporters.sort();
|
|
16941
16953
|
},
|
|
16942
16954
|
get exportedBindings() {
|
|
16943
|
-
const exportBindings = { '.': [...
|
|
16955
|
+
const exportBindings = { '.': [...exportDescriptions.keys()] };
|
|
16944
16956
|
for (const [name, { source }] of reexportDescriptions) {
|
|
16945
16957
|
(exportBindings[source] ??= []).push(name);
|
|
16946
16958
|
}
|
|
@@ -16951,7 +16963,7 @@ class Module {
|
|
|
16951
16963
|
},
|
|
16952
16964
|
get exports() {
|
|
16953
16965
|
return [
|
|
16954
|
-
...
|
|
16966
|
+
...exportDescriptions.keys(),
|
|
16955
16967
|
...reexportDescriptions.keys(),
|
|
16956
16968
|
...[...exportAllSources].map(() => '*')
|
|
16957
16969
|
];
|
|
@@ -16961,7 +16973,7 @@ class Module {
|
|
|
16961
16973
|
if (!module.ast) {
|
|
16962
16974
|
return null;
|
|
16963
16975
|
}
|
|
16964
|
-
return module.
|
|
16976
|
+
return module.exportDescriptions.has('default') || reexportDescriptions.has('default');
|
|
16965
16977
|
},
|
|
16966
16978
|
id,
|
|
16967
16979
|
get implicitlyLoadedAfterOneOf() {
|
|
@@ -17034,28 +17046,6 @@ class Module {
|
|
|
17034
17046
|
}
|
|
17035
17047
|
return size;
|
|
17036
17048
|
}
|
|
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
17049
|
getDependenciesToBeIncluded() {
|
|
17060
17050
|
if (this.relevantDependencies)
|
|
17061
17051
|
return this.relevantDependencies;
|
|
@@ -17067,10 +17057,9 @@ class Module {
|
|
|
17067
17057
|
this.includedDynamicImporters.length > 0 ||
|
|
17068
17058
|
this.namespace.included ||
|
|
17069
17059
|
this.implicitlyLoadedAfter.size > 0) {
|
|
17070
|
-
for (const
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
dependencyVariables.add(exportedVariable);
|
|
17060
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
17061
|
+
if (variable.included) {
|
|
17062
|
+
dependencyVariables.add(variable);
|
|
17074
17063
|
}
|
|
17075
17064
|
}
|
|
17076
17065
|
}
|
|
@@ -17102,18 +17091,56 @@ class Module {
|
|
|
17102
17091
|
}
|
|
17103
17092
|
return this.relevantDependencies;
|
|
17104
17093
|
}
|
|
17094
|
+
getExportedVariablesByName() {
|
|
17095
|
+
if (this.exportedVariablesByName) {
|
|
17096
|
+
return this.exportedVariablesByName;
|
|
17097
|
+
}
|
|
17098
|
+
const exportedVariablesByName = (this.exportedVariablesByName = new Map());
|
|
17099
|
+
for (const name of this.exportDescriptions.keys()) {
|
|
17100
|
+
// We do not count the synthetic namespace as a regular export to hide it
|
|
17101
|
+
// from entry signatures and namespace objects
|
|
17102
|
+
if (name !== this.info.syntheticNamedExports) {
|
|
17103
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
17104
|
+
if (exportedVariable) {
|
|
17105
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
17106
|
+
}
|
|
17107
|
+
else {
|
|
17108
|
+
return error(logMissingEntryExport(name, this.id));
|
|
17109
|
+
}
|
|
17110
|
+
}
|
|
17111
|
+
}
|
|
17112
|
+
for (const name of this.reexportDescriptions.keys()) {
|
|
17113
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
17114
|
+
if (exportedVariable) {
|
|
17115
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
17116
|
+
}
|
|
17117
|
+
}
|
|
17118
|
+
for (const module of this.exportAllModules) {
|
|
17119
|
+
if (module instanceof ExternalModule) {
|
|
17120
|
+
exportedVariablesByName.set(`*${module.id}`, module.getVariableForExportName('*', {
|
|
17121
|
+
importChain: [this.id]
|
|
17122
|
+
})[0]);
|
|
17123
|
+
continue;
|
|
17124
|
+
}
|
|
17125
|
+
for (const name of module.getExportedVariablesByName().keys()) {
|
|
17126
|
+
if (name !== 'default' && !exportedVariablesByName.has(name)) {
|
|
17127
|
+
const [exportedVariable] = this.getVariableForExportName(name);
|
|
17128
|
+
if (exportedVariable) {
|
|
17129
|
+
exportedVariablesByName.set(name, exportedVariable);
|
|
17130
|
+
}
|
|
17131
|
+
}
|
|
17132
|
+
}
|
|
17133
|
+
}
|
|
17134
|
+
return (this.exportedVariablesByName = new Map([...exportedVariablesByName].sort(sortExportedVariables)));
|
|
17135
|
+
}
|
|
17105
17136
|
getExportNamesByVariable() {
|
|
17106
17137
|
if (this.exportNamesByVariable) {
|
|
17107
17138
|
return this.exportNamesByVariable;
|
|
17108
17139
|
}
|
|
17109
17140
|
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)) {
|
|
17141
|
+
for (const [exportName, variable] of this.getExportedVariablesByName().entries()) {
|
|
17142
|
+
const tracedVariable = variable instanceof ExportDefaultVariable ? variable.getOriginalVariable() : variable;
|
|
17143
|
+
if (!variable || !(variable.included || variable instanceof ExternalVariable)) {
|
|
17117
17144
|
continue;
|
|
17118
17145
|
}
|
|
17119
17146
|
const existingExportNames = exportNamesByVariable.get(tracedVariable);
|
|
@@ -17126,36 +17153,14 @@ class Module {
|
|
|
17126
17153
|
}
|
|
17127
17154
|
return (this.exportNamesByVariable = exportNamesByVariable);
|
|
17128
17155
|
}
|
|
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
17156
|
getRenderedExports() {
|
|
17153
17157
|
// only direct exports are counted here, not reexports at all
|
|
17154
17158
|
const renderedExports = [];
|
|
17155
17159
|
const removedExports = [];
|
|
17156
|
-
for (const exportName of this.
|
|
17157
|
-
|
|
17158
|
-
|
|
17160
|
+
for (const exportName of this.exportDescriptions.keys()) {
|
|
17161
|
+
(this.getExportedVariablesByName().get(exportName)?.included
|
|
17162
|
+
? renderedExports
|
|
17163
|
+
: removedExports).push(exportName);
|
|
17159
17164
|
}
|
|
17160
17165
|
return { removedExports, renderedExports };
|
|
17161
17166
|
}
|
|
@@ -17198,7 +17203,7 @@ class Module {
|
|
|
17198
17203
|
}
|
|
17199
17204
|
return [variable];
|
|
17200
17205
|
}
|
|
17201
|
-
const exportDeclaration = this.
|
|
17206
|
+
const exportDeclaration = this.exportDescriptions.get(name);
|
|
17202
17207
|
if (exportDeclaration) {
|
|
17203
17208
|
if (exportDeclaration === MISSING_EXPORT_SHIM_DESCRIPTION) {
|
|
17204
17209
|
return [this.exportShimVariable];
|
|
@@ -17249,63 +17254,29 @@ class Module {
|
|
|
17249
17254
|
if (this.ast.shouldBeIncluded(context))
|
|
17250
17255
|
this.ast.include(context, false);
|
|
17251
17256
|
}
|
|
17252
|
-
includeAllExports(
|
|
17253
|
-
if (includeNamespaceMembers) {
|
|
17254
|
-
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
17255
|
-
}
|
|
17257
|
+
includeAllExports() {
|
|
17256
17258
|
if (this.allExportsIncluded)
|
|
17257
17259
|
return;
|
|
17258
17260
|
this.allExportsIncluded = true;
|
|
17259
|
-
|
|
17260
|
-
markModuleAndImpureDependenciesAsExecuted(this);
|
|
17261
|
-
this.graph.needsTreeshakingPass = true;
|
|
17262
|
-
}
|
|
17261
|
+
this.includeModuleInExecution();
|
|
17263
17262
|
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
|
-
}
|
|
17263
|
+
for (const variable of this.getExportedVariablesByName().values()) {
|
|
17264
|
+
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
17265
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17266
|
+
if (variable instanceof ExternalVariable) {
|
|
17267
|
+
variable.module.reexported = true;
|
|
17282
17268
|
}
|
|
17283
17269
|
}
|
|
17284
17270
|
}
|
|
17285
17271
|
includeAllInBundle() {
|
|
17286
17272
|
this.ast.include(createInclusionContext(), true);
|
|
17287
|
-
this.includeAllExports(
|
|
17273
|
+
this.includeAllExports();
|
|
17288
17274
|
}
|
|
17289
|
-
|
|
17275
|
+
includeModuleInExecution() {
|
|
17290
17276
|
if (!this.isExecuted) {
|
|
17291
17277
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
17292
17278
|
this.graph.needsTreeshakingPass = true;
|
|
17293
17279
|
}
|
|
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
17280
|
}
|
|
17310
17281
|
isIncluded() {
|
|
17311
17282
|
// Modules where this.ast is missing have been loaded via this.load and are
|
|
@@ -17384,14 +17355,11 @@ class Module {
|
|
|
17384
17355
|
deoptimizationTracker: this.graph.deoptimizationTracker,
|
|
17385
17356
|
error: this.error.bind(this),
|
|
17386
17357
|
fileName, // Needed for warnings
|
|
17387
|
-
getExports: this.getExports.bind(this),
|
|
17388
17358
|
getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this),
|
|
17389
17359
|
getModuleExecIndex: () => this.execIndex,
|
|
17390
17360
|
getModuleName: this.basename.bind(this),
|
|
17391
17361
|
getNodeConstructor: (name) => nodeConstructors[name] || nodeConstructors.UnknownNode,
|
|
17392
|
-
getReexports: this.getReexports.bind(this),
|
|
17393
17362
|
importDescriptions: this.importDescriptions,
|
|
17394
|
-
includeAllExports: () => this.includeAllExports(true),
|
|
17395
17363
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
17396
17364
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
17397
17365
|
log: this.log.bind(this),
|
|
@@ -17406,7 +17374,7 @@ class Module {
|
|
|
17406
17374
|
traceVariable: this.traceVariable.bind(this),
|
|
17407
17375
|
usesTopLevelAwait: false
|
|
17408
17376
|
};
|
|
17409
|
-
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
17377
|
+
this.scope = new ModuleScope(this.graph.scope, this.astContext, this.importDescriptions);
|
|
17410
17378
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
17411
17379
|
const programParent = { context: this.astContext, type: 'Module' };
|
|
17412
17380
|
if (ast) {
|
|
@@ -17507,10 +17475,10 @@ class Module {
|
|
|
17507
17475
|
typeof argument.value === 'string') {
|
|
17508
17476
|
argument = argument.value;
|
|
17509
17477
|
}
|
|
17510
|
-
this.dynamicImports.push({ argument, id: null, node
|
|
17478
|
+
this.dynamicImports.push({ argument, id: null, node });
|
|
17511
17479
|
}
|
|
17512
17480
|
assertUniqueExportName(name, nodeStart) {
|
|
17513
|
-
if (this.
|
|
17481
|
+
if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
|
|
17514
17482
|
this.error(logDuplicateExportError(name), nodeStart);
|
|
17515
17483
|
}
|
|
17516
17484
|
}
|
|
@@ -17518,7 +17486,7 @@ class Module {
|
|
|
17518
17486
|
if (node instanceof ExportDefaultDeclaration) {
|
|
17519
17487
|
// export default foo;
|
|
17520
17488
|
this.assertUniqueExportName('default', node.start);
|
|
17521
|
-
this.
|
|
17489
|
+
this.exportDescriptions.set('default', {
|
|
17522
17490
|
identifier: node.variable.getAssignedVariableName(),
|
|
17523
17491
|
localName: 'default'
|
|
17524
17492
|
});
|
|
@@ -17565,7 +17533,7 @@ class Module {
|
|
|
17565
17533
|
for (const declarator of declaration.declarations) {
|
|
17566
17534
|
for (const localName of extractAssignedNames(declarator.id)) {
|
|
17567
17535
|
this.assertUniqueExportName(localName, declarator.id.start);
|
|
17568
|
-
this.
|
|
17536
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
17569
17537
|
}
|
|
17570
17538
|
}
|
|
17571
17539
|
}
|
|
@@ -17573,7 +17541,7 @@ class Module {
|
|
|
17573
17541
|
// export function foo () {}
|
|
17574
17542
|
const localName = declaration.id.name;
|
|
17575
17543
|
this.assertUniqueExportName(localName, declaration.id.start);
|
|
17576
|
-
this.
|
|
17544
|
+
this.exportDescriptions.set(localName, { identifier: null, localName });
|
|
17577
17545
|
}
|
|
17578
17546
|
}
|
|
17579
17547
|
else {
|
|
@@ -17583,7 +17551,7 @@ class Module {
|
|
|
17583
17551
|
const localName = local.name;
|
|
17584
17552
|
const exportedName = exported instanceof Identifier ? exported.name : exported.value;
|
|
17585
17553
|
this.assertUniqueExportName(exportedName, exported.start);
|
|
17586
|
-
this.
|
|
17554
|
+
this.exportDescriptions.set(exportedName, { identifier: null, localName });
|
|
17587
17555
|
}
|
|
17588
17556
|
}
|
|
17589
17557
|
}
|
|
@@ -17757,7 +17725,7 @@ class Module {
|
|
|
17757
17725
|
return [...syntheticNamespaces, ...externalNamespaces];
|
|
17758
17726
|
}
|
|
17759
17727
|
includeDynamicImport(node) {
|
|
17760
|
-
const resolution =
|
|
17728
|
+
const { resolution } = node;
|
|
17761
17729
|
if (resolution instanceof Module) {
|
|
17762
17730
|
if (!resolution.includedDynamicImporters.includes(this)) {
|
|
17763
17731
|
resolution.includedDynamicImporters.push(this);
|
|
@@ -17767,15 +17735,6 @@ class Module {
|
|
|
17767
17735
|
resolution.includedTopLevelAwaitingDynamicImporters.add(this);
|
|
17768
17736
|
}
|
|
17769
17737
|
}
|
|
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
17738
|
}
|
|
17780
17739
|
}
|
|
17781
17740
|
includeVariable(variable, path, context) {
|
|
@@ -17785,21 +17744,17 @@ class Module {
|
|
|
17785
17744
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
17786
17745
|
getAndExtendSideEffectModules(variable, this);
|
|
17787
17746
|
}
|
|
17747
|
+
return;
|
|
17788
17748
|
}
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
if (!module.isExecuted) {
|
|
17799
|
-
markModuleAndImpureDependenciesAsExecuted(module);
|
|
17800
|
-
}
|
|
17801
|
-
}
|
|
17802
|
-
}
|
|
17749
|
+
this.graph.needsTreeshakingPass = true;
|
|
17750
|
+
if (!(variableModule instanceof Module)) {
|
|
17751
|
+
return;
|
|
17752
|
+
}
|
|
17753
|
+
variableModule.includeModuleInExecution();
|
|
17754
|
+
if (variableModule !== this) {
|
|
17755
|
+
const sideEffectModules = getAndExtendSideEffectModules(variable, this);
|
|
17756
|
+
for (const module of sideEffectModules) {
|
|
17757
|
+
module.includeModuleInExecution();
|
|
17803
17758
|
}
|
|
17804
17759
|
}
|
|
17805
17760
|
}
|
|
@@ -17812,7 +17767,7 @@ class Module {
|
|
|
17812
17767
|
}
|
|
17813
17768
|
shimMissingExport(name) {
|
|
17814
17769
|
this.options.onLog(LOGLEVEL_WARN, logShimmedExport(this.id, name));
|
|
17815
|
-
this.
|
|
17770
|
+
this.exportDescriptions.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
|
|
17816
17771
|
}
|
|
17817
17772
|
tryParse() {
|
|
17818
17773
|
try {
|
|
@@ -17842,6 +17797,7 @@ function setAlternativeExporterIfCyclic(variable, importer, reexporter) {
|
|
|
17842
17797
|
}
|
|
17843
17798
|
const copyNameToModulesMap = (searchedNamesAndModules) => searchedNamesAndModules &&
|
|
17844
17799
|
new Map(Array.from(searchedNamesAndModules, ([name, modules]) => [name, new Set(modules)]));
|
|
17800
|
+
const sortExportedVariables = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
17845
17801
|
|
|
17846
17802
|
const concatSeparator = (out, next) => (next ? `${out}\n${next}` : out);
|
|
17847
17803
|
const concatDblSeparator = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
@@ -18333,6 +18289,8 @@ class Chunk {
|
|
|
18333
18289
|
includedNamespaces.add(module);
|
|
18334
18290
|
this.exports.add(module.namespace);
|
|
18335
18291
|
}
|
|
18292
|
+
// This only needs to run once
|
|
18293
|
+
break;
|
|
18336
18294
|
}
|
|
18337
18295
|
}
|
|
18338
18296
|
if (module.implicitlyLoadedAfter.size > 0) {
|
|
@@ -18970,10 +18928,11 @@ class Chunk {
|
|
|
18970
18928
|
}
|
|
18971
18929
|
const includedDynamicImports = [];
|
|
18972
18930
|
for (const module of this.orderedModules) {
|
|
18973
|
-
for (const { node
|
|
18931
|
+
for (const { node } of module.dynamicImports) {
|
|
18974
18932
|
if (!node.included) {
|
|
18975
18933
|
continue;
|
|
18976
18934
|
}
|
|
18935
|
+
const { resolution } = node;
|
|
18977
18936
|
includedDynamicImports.push(resolution instanceof Module
|
|
18978
18937
|
? {
|
|
18979
18938
|
chunk: this.chunkByModule.get(resolution),
|
|
@@ -19231,13 +19190,13 @@ class Chunk {
|
|
|
19231
19190
|
node.setInternalResolution(resolution.namespace);
|
|
19232
19191
|
}
|
|
19233
19192
|
else {
|
|
19234
|
-
node.setExternalResolution((facadeChunk || chunk).exportMode,
|
|
19193
|
+
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
19194
|
}
|
|
19236
19195
|
}
|
|
19237
19196
|
else {
|
|
19238
19197
|
const { node, resolution } = resolvedDynamicImport;
|
|
19239
19198
|
const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
|
|
19240
|
-
node.setExternalResolution('external',
|
|
19199
|
+
node.setExternalResolution('external', outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
|
|
19241
19200
|
}
|
|
19242
19201
|
}
|
|
19243
19202
|
}
|
|
@@ -19290,8 +19249,7 @@ class Chunk {
|
|
|
19290
19249
|
// when we are not preserving modules, we need to make all namespace variables available for
|
|
19291
19250
|
// rendering the namespace object
|
|
19292
19251
|
if (!this.outputOptions.preserveModules && this.includedNamespaces.has(module)) {
|
|
19293
|
-
const
|
|
19294
|
-
for (const variable of Object.values(memberVariables)) {
|
|
19252
|
+
for (const variable of module.getExportedVariablesByName().values()) {
|
|
19295
19253
|
if (variable.included) {
|
|
19296
19254
|
moduleImports.add(variable);
|
|
19297
19255
|
}
|
|
@@ -19322,8 +19280,8 @@ class Chunk {
|
|
|
19322
19280
|
module.includedDynamicImporters.some(importer => this.chunkByModule.get(importer) !== this)) {
|
|
19323
19281
|
this.ensureReexportsAreAvailableForModule(module);
|
|
19324
19282
|
}
|
|
19325
|
-
for (const { node, resolution } of module.dynamicImports) {
|
|
19326
|
-
if (
|
|
19283
|
+
for (const { node: { included, resolution } } of module.dynamicImports) {
|
|
19284
|
+
if (included &&
|
|
19327
19285
|
resolution instanceof Module &&
|
|
19328
19286
|
this.chunkByModule.get(resolution) === this &&
|
|
19329
19287
|
!this.includedNamespaces.has(resolution)) {
|
|
@@ -19554,7 +19512,7 @@ function analyzeModuleGraph(entries) {
|
|
|
19554
19512
|
staticDependencies.add(dependency);
|
|
19555
19513
|
}
|
|
19556
19514
|
}
|
|
19557
|
-
for (const { resolution } of module.dynamicImports) {
|
|
19515
|
+
for (const { node: { resolution } } of module.dynamicImports) {
|
|
19558
19516
|
if (resolution instanceof Module &&
|
|
19559
19517
|
resolution.includedDynamicImporters.length > 0 &&
|
|
19560
19518
|
!allEntriesSet.has(resolution)) {
|
|
@@ -20095,9 +20053,9 @@ function analyseModuleExecution(entryModules) {
|
|
|
20095
20053
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
20096
20054
|
dynamicImports.add(dependency);
|
|
20097
20055
|
}
|
|
20098
|
-
for (const { resolution,
|
|
20056
|
+
for (const { node: { resolution, scope } } of module.dynamicImports) {
|
|
20099
20057
|
if (resolution instanceof Module) {
|
|
20100
|
-
if (
|
|
20058
|
+
if (scope.context.usesTopLevelAwait) {
|
|
20101
20059
|
handleSyncLoadedModule(resolution, module);
|
|
20102
20060
|
}
|
|
20103
20061
|
else {
|
|
@@ -20893,7 +20851,7 @@ class GlobalScope extends Scope {
|
|
|
20893
20851
|
}
|
|
20894
20852
|
}
|
|
20895
20853
|
|
|
20896
|
-
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes) {
|
|
20854
|
+
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, importerAttributes) {
|
|
20897
20855
|
let skipped = null;
|
|
20898
20856
|
let replaceContext = null;
|
|
20899
20857
|
if (skip) {
|
|
@@ -20905,7 +20863,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
20905
20863
|
}
|
|
20906
20864
|
replaceContext = (pluginContext, plugin) => ({
|
|
20907
20865
|
...pluginContext,
|
|
20908
|
-
resolve: (source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) => {
|
|
20866
|
+
resolve: (source, importer, { attributes, custom, isEntry, skipSelf, importerAttributes } = BLANK) => {
|
|
20909
20867
|
skipSelf ??= true;
|
|
20910
20868
|
if (skipSelf &&
|
|
20911
20869
|
skip.findIndex(skippedCall => {
|
|
@@ -20917,15 +20875,15 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
20917
20875
|
// Thus returning Promise.resolve(null) in purpose of fallback to default behavior of `resolveId` plugin hook.
|
|
20918
20876
|
return Promise.resolve(null);
|
|
20919
20877
|
}
|
|
20920
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
20878
|
+
return moduleLoaderResolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, importerAttributes, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
20921
20879
|
}
|
|
20922
20880
|
});
|
|
20923
20881
|
}
|
|
20924
|
-
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { attributes, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
20882
|
+
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { attributes, custom: customOptions, importerAttributes, isEntry }], replaceContext, skipped);
|
|
20925
20883
|
}
|
|
20926
20884
|
|
|
20927
|
-
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, fs) {
|
|
20928
|
-
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes);
|
|
20885
|
+
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, importerAttributes, fs) {
|
|
20886
|
+
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, importerAttributes);
|
|
20929
20887
|
if (pluginResult != null) {
|
|
20930
20888
|
const [resolveIdResult, plugin] = pluginResult;
|
|
20931
20889
|
if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) {
|
|
@@ -20982,89 +20940,6 @@ function stripBom(content) {
|
|
|
20982
20940
|
return content;
|
|
20983
20941
|
}
|
|
20984
20942
|
|
|
20985
|
-
const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
|
|
20986
|
-
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = 'at output position ';
|
|
20987
|
-
|
|
20988
|
-
function createPluginCache(cache) {
|
|
20989
|
-
return {
|
|
20990
|
-
delete(id) {
|
|
20991
|
-
return delete cache[id];
|
|
20992
|
-
},
|
|
20993
|
-
get(id) {
|
|
20994
|
-
const item = cache[id];
|
|
20995
|
-
if (!item)
|
|
20996
|
-
return;
|
|
20997
|
-
item[0] = 0;
|
|
20998
|
-
return item[1];
|
|
20999
|
-
},
|
|
21000
|
-
has(id) {
|
|
21001
|
-
const item = cache[id];
|
|
21002
|
-
if (!item)
|
|
21003
|
-
return false;
|
|
21004
|
-
item[0] = 0;
|
|
21005
|
-
return true;
|
|
21006
|
-
},
|
|
21007
|
-
set(id, value) {
|
|
21008
|
-
cache[id] = [0, value];
|
|
21009
|
-
}
|
|
21010
|
-
};
|
|
21011
|
-
}
|
|
21012
|
-
function getTrackedPluginCache(pluginCache, onUse) {
|
|
21013
|
-
return {
|
|
21014
|
-
delete(id) {
|
|
21015
|
-
onUse();
|
|
21016
|
-
return pluginCache.delete(id);
|
|
21017
|
-
},
|
|
21018
|
-
get(id) {
|
|
21019
|
-
onUse();
|
|
21020
|
-
return pluginCache.get(id);
|
|
21021
|
-
},
|
|
21022
|
-
has(id) {
|
|
21023
|
-
onUse();
|
|
21024
|
-
return pluginCache.has(id);
|
|
21025
|
-
},
|
|
21026
|
-
set(id, value) {
|
|
21027
|
-
onUse();
|
|
21028
|
-
return pluginCache.set(id, value);
|
|
21029
|
-
}
|
|
21030
|
-
};
|
|
21031
|
-
}
|
|
21032
|
-
const NO_CACHE = {
|
|
21033
|
-
delete() {
|
|
21034
|
-
return false;
|
|
21035
|
-
},
|
|
21036
|
-
get() {
|
|
21037
|
-
return undefined;
|
|
21038
|
-
},
|
|
21039
|
-
has() {
|
|
21040
|
-
return false;
|
|
21041
|
-
},
|
|
21042
|
-
set() { }
|
|
21043
|
-
};
|
|
21044
|
-
function uncacheablePluginError(pluginName) {
|
|
21045
|
-
if (pluginName.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
|
|
21046
|
-
pluginName.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX)) {
|
|
21047
|
-
return error(logAnonymousPluginCache());
|
|
21048
|
-
}
|
|
21049
|
-
return error(logDuplicatePluginName(pluginName));
|
|
21050
|
-
}
|
|
21051
|
-
function getCacheForUncacheablePlugin(pluginName) {
|
|
21052
|
-
return {
|
|
21053
|
-
delete() {
|
|
21054
|
-
return uncacheablePluginError(pluginName);
|
|
21055
|
-
},
|
|
21056
|
-
get() {
|
|
21057
|
-
return uncacheablePluginError(pluginName);
|
|
21058
|
-
},
|
|
21059
|
-
has() {
|
|
21060
|
-
return uncacheablePluginError(pluginName);
|
|
21061
|
-
},
|
|
21062
|
-
set() {
|
|
21063
|
-
return uncacheablePluginError(pluginName);
|
|
21064
|
-
}
|
|
21065
|
-
};
|
|
21066
|
-
}
|
|
21067
|
-
|
|
21068
20943
|
async function asyncFlatten(array) {
|
|
21069
20944
|
do {
|
|
21070
20945
|
array = (await Promise.all(array)).flat(Infinity);
|
|
@@ -21227,7 +21102,90 @@ const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalV
|
|
|
21227
21102
|
};
|
|
21228
21103
|
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
21229
21104
|
|
|
21230
|
-
|
|
21105
|
+
const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
|
|
21106
|
+
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = 'at output position ';
|
|
21107
|
+
|
|
21108
|
+
function createPluginCache(cache) {
|
|
21109
|
+
return {
|
|
21110
|
+
delete(id) {
|
|
21111
|
+
return delete cache[id];
|
|
21112
|
+
},
|
|
21113
|
+
get(id) {
|
|
21114
|
+
const item = cache[id];
|
|
21115
|
+
if (!item)
|
|
21116
|
+
return;
|
|
21117
|
+
item[0] = 0;
|
|
21118
|
+
return item[1];
|
|
21119
|
+
},
|
|
21120
|
+
has(id) {
|
|
21121
|
+
const item = cache[id];
|
|
21122
|
+
if (!item)
|
|
21123
|
+
return false;
|
|
21124
|
+
item[0] = 0;
|
|
21125
|
+
return true;
|
|
21126
|
+
},
|
|
21127
|
+
set(id, value) {
|
|
21128
|
+
cache[id] = [0, value];
|
|
21129
|
+
}
|
|
21130
|
+
};
|
|
21131
|
+
}
|
|
21132
|
+
function getTrackedPluginCache(pluginCache, onUse) {
|
|
21133
|
+
return {
|
|
21134
|
+
delete(id) {
|
|
21135
|
+
onUse();
|
|
21136
|
+
return pluginCache.delete(id);
|
|
21137
|
+
},
|
|
21138
|
+
get(id) {
|
|
21139
|
+
onUse();
|
|
21140
|
+
return pluginCache.get(id);
|
|
21141
|
+
},
|
|
21142
|
+
has(id) {
|
|
21143
|
+
onUse();
|
|
21144
|
+
return pluginCache.has(id);
|
|
21145
|
+
},
|
|
21146
|
+
set(id, value) {
|
|
21147
|
+
onUse();
|
|
21148
|
+
return pluginCache.set(id, value);
|
|
21149
|
+
}
|
|
21150
|
+
};
|
|
21151
|
+
}
|
|
21152
|
+
const NO_CACHE = {
|
|
21153
|
+
delete() {
|
|
21154
|
+
return false;
|
|
21155
|
+
},
|
|
21156
|
+
get() {
|
|
21157
|
+
return undefined;
|
|
21158
|
+
},
|
|
21159
|
+
has() {
|
|
21160
|
+
return false;
|
|
21161
|
+
},
|
|
21162
|
+
set() { }
|
|
21163
|
+
};
|
|
21164
|
+
function uncacheablePluginError(pluginName) {
|
|
21165
|
+
if (pluginName.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
|
|
21166
|
+
pluginName.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX)) {
|
|
21167
|
+
return error(logAnonymousPluginCache());
|
|
21168
|
+
}
|
|
21169
|
+
return error(logDuplicatePluginName(pluginName));
|
|
21170
|
+
}
|
|
21171
|
+
function getCacheForUncacheablePlugin(pluginName) {
|
|
21172
|
+
return {
|
|
21173
|
+
delete() {
|
|
21174
|
+
return uncacheablePluginError(pluginName);
|
|
21175
|
+
},
|
|
21176
|
+
get() {
|
|
21177
|
+
return uncacheablePluginError(pluginName);
|
|
21178
|
+
},
|
|
21179
|
+
has() {
|
|
21180
|
+
return uncacheablePluginError(pluginName);
|
|
21181
|
+
},
|
|
21182
|
+
set() {
|
|
21183
|
+
return uncacheablePluginError(pluginName);
|
|
21184
|
+
}
|
|
21185
|
+
};
|
|
21186
|
+
}
|
|
21187
|
+
|
|
21188
|
+
async function transform(source, module, pluginDriver, options) {
|
|
21231
21189
|
const id = module.id;
|
|
21232
21190
|
const sourcemapChain = [];
|
|
21233
21191
|
let originalSourcemap = source.map === null ? null : decodedSourcemap(source.map);
|
|
@@ -21249,10 +21207,13 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
21249
21207
|
module.updateOptions(result);
|
|
21250
21208
|
if (result.code == null) {
|
|
21251
21209
|
if (result.map || result.ast) {
|
|
21252
|
-
|
|
21210
|
+
options.onLog(LOGLEVEL_WARN, logNoTransformMapOrAstWithoutCode(plugin.name));
|
|
21253
21211
|
}
|
|
21254
21212
|
return previousCode;
|
|
21255
21213
|
}
|
|
21214
|
+
if (result.attributes) {
|
|
21215
|
+
warnDeprecation('Returning attributes from the "transform" hook is forbidden.', URL_TRANSFORM, false, options);
|
|
21216
|
+
}
|
|
21256
21217
|
({ code, map, ast } = result);
|
|
21257
21218
|
}
|
|
21258
21219
|
else {
|
|
@@ -21279,7 +21240,13 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
21279
21240
|
};
|
|
21280
21241
|
let code;
|
|
21281
21242
|
try {
|
|
21282
|
-
code = await pluginDriver.hookReduceArg0('transform', [
|
|
21243
|
+
code = await pluginDriver.hookReduceArg0('transform', [
|
|
21244
|
+
currentSource,
|
|
21245
|
+
id,
|
|
21246
|
+
{
|
|
21247
|
+
attributes: module.info.attributes
|
|
21248
|
+
}
|
|
21249
|
+
], transformReducer, (pluginContext, plugin) => {
|
|
21283
21250
|
pluginName = plugin.name;
|
|
21284
21251
|
return {
|
|
21285
21252
|
...pluginContext,
|
|
@@ -21305,7 +21272,7 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
21305
21272
|
return pluginContext.error(error_);
|
|
21306
21273
|
},
|
|
21307
21274
|
getCombinedSourcemap() {
|
|
21308
|
-
const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
|
|
21275
|
+
const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, options.onLog);
|
|
21309
21276
|
if (!combinedMap) {
|
|
21310
21277
|
const magicString = new MagicString(originalCode);
|
|
21311
21278
|
return magicString.generateMap({ hires: true, includeContent: true, source: id });
|
|
@@ -21360,15 +21327,15 @@ class ModuleLoader {
|
|
|
21360
21327
|
this.modulesWithLoadedDependencies = new Set();
|
|
21361
21328
|
this.nextChunkNamePriority = 0;
|
|
21362
21329
|
this.nextEntryModuleIndex = 0;
|
|
21363
|
-
this.resolveId = async (source, importer, customOptions, isEntry, attributes, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
21330
|
+
this.resolveId = async (source, importer, customOptions, isEntry, attributes, importerAttributes, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
21364
21331
|
? false
|
|
21365
|
-
: 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);
|
|
21332
|
+
: 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);
|
|
21366
21333
|
this.hasModuleSideEffects = options.treeshake
|
|
21367
21334
|
? options.treeshake.moduleSideEffects
|
|
21368
21335
|
: () => true;
|
|
21369
21336
|
}
|
|
21370
21337
|
async addAdditionalModules(unresolvedModules, isAddForManualChunks) {
|
|
21371
|
-
const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null, isAddForManualChunks))));
|
|
21338
|
+
const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null, isAddForManualChunks, undefined))));
|
|
21372
21339
|
await this.awaitLoadModulesPromise();
|
|
21373
21340
|
return result;
|
|
21374
21341
|
}
|
|
@@ -21377,7 +21344,7 @@ class ModuleLoader {
|
|
|
21377
21344
|
this.nextEntryModuleIndex += unresolvedEntryModules.length;
|
|
21378
21345
|
const firstChunkNamePriority = this.nextChunkNamePriority;
|
|
21379
21346
|
this.nextChunkNamePriority += unresolvedEntryModules.length;
|
|
21380
|
-
const newEntryModules = await this.extendLoadModulesPromise(Promise.all(unresolvedEntryModules.map(({ id, importer }) => this.loadEntryModule(id, true, importer, null))).then(entryModules => {
|
|
21347
|
+
const newEntryModules = await this.extendLoadModulesPromise(Promise.all(unresolvedEntryModules.map(({ id, importer }) => this.loadEntryModule(id, true, importer, null, undefined, undefined))).then(entryModules => {
|
|
21381
21348
|
for (const [index, entryModule] of entryModules.entries()) {
|
|
21382
21349
|
entryModule.isUserDefinedEntryPoint =
|
|
21383
21350
|
entryModule.isUserDefinedEntryPoint || isUserDefined;
|
|
@@ -21424,10 +21391,10 @@ class ModuleLoader {
|
|
|
21424
21391
|
}
|
|
21425
21392
|
addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
|
|
21426
21393
|
const chunkNamePriority = this.nextChunkNamePriority++;
|
|
21427
|
-
return this.extendLoadModulesPromise(this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null).then(async (entryModule) => {
|
|
21394
|
+
return this.extendLoadModulesPromise(this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null, undefined, undefined).then(async (entryModule) => {
|
|
21428
21395
|
addChunkNamesToModule(entryModule, unresolvedModule, false, chunkNamePriority);
|
|
21429
21396
|
if (!entryModule.info.isEntry) {
|
|
21430
|
-
const implicitlyLoadedAfterModules = await Promise.all(implicitlyLoadedAfter.map(id => this.loadEntryModule(id, false, unresolvedModule.importer, entryModule.id)));
|
|
21397
|
+
const implicitlyLoadedAfterModules = await Promise.all(implicitlyLoadedAfter.map(id => this.loadEntryModule(id, false, unresolvedModule.importer, entryModule.id, undefined, undefined)));
|
|
21431
21398
|
// We need to check again if this is still an entry module as these
|
|
21432
21399
|
// changes need to be performed atomically to avoid race conditions
|
|
21433
21400
|
// if the same module is re-emitted as an entry module.
|
|
@@ -21449,9 +21416,16 @@ class ModuleLoader {
|
|
|
21449
21416
|
let source;
|
|
21450
21417
|
try {
|
|
21451
21418
|
source = await this.graph.fileOperationQueue.run(async () => {
|
|
21452
|
-
const content = await this.pluginDriver.hookFirst('load', [
|
|
21453
|
-
|
|
21419
|
+
const content = await this.pluginDriver.hookFirst('load', [
|
|
21420
|
+
id,
|
|
21421
|
+
{ attributes: module.info.attributes }
|
|
21422
|
+
]);
|
|
21423
|
+
if (content !== null) {
|
|
21424
|
+
if (typeof content === 'object' && content.attributes) {
|
|
21425
|
+
warnDeprecation('Returning attributes from the "load" hook is forbidden.', URL_LOAD, false, this.options);
|
|
21426
|
+
}
|
|
21454
21427
|
return content;
|
|
21428
|
+
}
|
|
21455
21429
|
this.graph.watchFiles[id] = true;
|
|
21456
21430
|
return (await this.options.fs.readFile(id, { encoding: 'utf8' }));
|
|
21457
21431
|
});
|
|
@@ -21477,6 +21451,7 @@ class ModuleLoader {
|
|
|
21477
21451
|
!(await this.pluginDriver.hookFirst('shouldTransformCachedModule', [
|
|
21478
21452
|
{
|
|
21479
21453
|
ast: cachedModule.ast,
|
|
21454
|
+
attributes: cachedModule.attributes,
|
|
21480
21455
|
code: cachedModule.code,
|
|
21481
21456
|
id: cachedModule.id,
|
|
21482
21457
|
meta: cachedModule.meta,
|
|
@@ -21493,7 +21468,7 @@ class ModuleLoader {
|
|
|
21493
21468
|
}
|
|
21494
21469
|
else {
|
|
21495
21470
|
module.updateOptions(sourceDescription);
|
|
21496
|
-
await module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options
|
|
21471
|
+
await module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options));
|
|
21497
21472
|
}
|
|
21498
21473
|
}
|
|
21499
21474
|
async awaitLoadModulesPromise() {
|
|
@@ -21514,14 +21489,14 @@ class ModuleLoader {
|
|
|
21514
21489
|
return loadNewModulesPromise;
|
|
21515
21490
|
}
|
|
21516
21491
|
async fetchDynamicDependencies(module, resolveDynamicImportPromises) {
|
|
21517
|
-
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([
|
|
21492
|
+
const dependencies = await Promise.all(resolveDynamicImportPromises.map(resolveDynamicImportPromise => resolveDynamicImportPromise.then(async ([{ node }, resolvedId]) => {
|
|
21518
21493
|
if (resolvedId === null)
|
|
21519
21494
|
return null;
|
|
21520
21495
|
if (typeof resolvedId === 'string') {
|
|
21521
|
-
|
|
21496
|
+
node.resolution = resolvedId;
|
|
21522
21497
|
return null;
|
|
21523
21498
|
}
|
|
21524
|
-
return (
|
|
21499
|
+
return (node.resolution = await this.fetchResolvedDependency(relativeId(resolvedId.id), module.id, resolvedId));
|
|
21525
21500
|
})));
|
|
21526
21501
|
for (const dependency of dependencies) {
|
|
21527
21502
|
if (dependency) {
|
|
@@ -21666,7 +21641,7 @@ class ModuleLoader {
|
|
|
21666
21641
|
source,
|
|
21667
21642
|
(module.resolvedIds[source] =
|
|
21668
21643
|
module.resolvedIds[source] ||
|
|
21669
|
-
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, attributes), source, module.id, attributes))
|
|
21644
|
+
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, attributes, module.info.attributes), source, module.id, attributes))
|
|
21670
21645
|
]);
|
|
21671
21646
|
}
|
|
21672
21647
|
getResolvedIdWithDefaults(resolvedId, attributes) {
|
|
@@ -21724,8 +21699,8 @@ class ModuleLoader {
|
|
|
21724
21699
|
}
|
|
21725
21700
|
return resolvedId;
|
|
21726
21701
|
}
|
|
21727
|
-
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore, isLoadForManualChunks = false) {
|
|
21728
|
-
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT, this.options.fs);
|
|
21702
|
+
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore, isLoadForManualChunks = false, importerAttributes) {
|
|
21703
|
+
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT, importerAttributes, this.options.fs);
|
|
21729
21704
|
if (resolveIdResult == null) {
|
|
21730
21705
|
return error(implicitlyLoadedBefore === null
|
|
21731
21706
|
? logUnresolvedEntry(unresolvedId)
|
|
@@ -21747,7 +21722,7 @@ class ModuleLoader {
|
|
|
21747
21722
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
21748
21723
|
specifier,
|
|
21749
21724
|
importer,
|
|
21750
|
-
{ attributes }
|
|
21725
|
+
{ attributes, importerAttributes: module.info.attributes }
|
|
21751
21726
|
]);
|
|
21752
21727
|
if (typeof specifier !== 'string') {
|
|
21753
21728
|
if (typeof resolution === 'string') {
|
|
@@ -21766,7 +21741,7 @@ class ModuleLoader {
|
|
|
21766
21741
|
}
|
|
21767
21742
|
return existingResolution;
|
|
21768
21743
|
}
|
|
21769
|
-
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, attributes), specifier, module.id, attributes));
|
|
21744
|
+
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, attributes, module.info.attributes), specifier, module.id, attributes));
|
|
21770
21745
|
}
|
|
21771
21746
|
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), attributes), specifier, importer, attributes);
|
|
21772
21747
|
}
|
|
@@ -22261,9 +22236,9 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22261
22236
|
watchMode: graph.watchMode
|
|
22262
22237
|
},
|
|
22263
22238
|
parse: parseAst,
|
|
22264
|
-
resolve(source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) {
|
|
22239
|
+
resolve(source, importer, { attributes, custom, isEntry, skipSelf, importerAttributes } = BLANK) {
|
|
22265
22240
|
skipSelf ??= true;
|
|
22266
|
-
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
|
|
22241
|
+
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, importerAttributes, skipSelf ? [{ importer, plugin, source }] : null);
|
|
22267
22242
|
},
|
|
22268
22243
|
setAssetSource: fileEmitter.setAssetSource,
|
|
22269
22244
|
warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel)
|
|
@@ -22760,7 +22735,7 @@ class Graph {
|
|
|
22760
22735
|
timeEnd('generate module graph', 2);
|
|
22761
22736
|
timeStart('sort and bind modules', 2);
|
|
22762
22737
|
this.phase = BuildPhase.ANALYSE;
|
|
22763
|
-
this.
|
|
22738
|
+
this.sortAndBindModules();
|
|
22764
22739
|
timeEnd('sort and bind modules', 2);
|
|
22765
22740
|
timeStart('mark included statements', 2);
|
|
22766
22741
|
this.includeStatements();
|
|
@@ -22833,7 +22808,7 @@ class Graph {
|
|
|
22833
22808
|
// the TDZ detection logic
|
|
22834
22809
|
for (const module of entryModules) {
|
|
22835
22810
|
if (module.preserveSignature !== false) {
|
|
22836
|
-
module.includeAllExports(
|
|
22811
|
+
module.includeAllExports();
|
|
22837
22812
|
this.needsTreeshakingPass = true;
|
|
22838
22813
|
}
|
|
22839
22814
|
}
|
|
@@ -22855,7 +22830,7 @@ class Graph {
|
|
|
22855
22830
|
}
|
|
22856
22831
|
}
|
|
22857
22832
|
}
|
|
22858
|
-
|
|
22833
|
+
sortAndBindModules() {
|
|
22859
22834
|
const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
|
|
22860
22835
|
for (const cyclePath of cyclePaths) {
|
|
22861
22836
|
this.options.onLog(LOGLEVEL_WARN, logCircularDependency(cyclePath));
|