rollup 4.64.0 → 4.64.6

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.
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.64.0
4
- Fri, 02 Oct 2026 15:38:16 GMT - commit 77773bf8ee9130c4edbde14c017855c41e500692
3
+ Rollup.js v4.64.6
4
+ Tue, 13 Oct 2026 09:01:30 GMT - commit 3ba51901a0f41d8e6d4152c407cba036fb599feb
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, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$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, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, 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, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, 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';
10
+ import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, FunctionExpression as FunctionExpression$1, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$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, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, 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, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, 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, join } 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.64.0";
30
+ var version = "4.64.6";
31
31
  const pkg = {
32
32
  version: version};
33
33
 
@@ -1248,7 +1248,7 @@ var MagicString = class MagicString {
1248
1248
  while (chunk !== last) {
1249
1249
  if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
1250
1250
  chunk = chunk.next;
1251
- chunk.edit("", false);
1251
+ chunk.edit("", false, !overwrite);
1252
1252
  }
1253
1253
  first.edit(content, storeName, !overwrite);
1254
1254
  } else {
@@ -1602,8 +1602,8 @@ var MagicString = class MagicString {
1602
1602
  if (this._hasRemovedContent(match.index, match.index + match[0].length)) return false;
1603
1603
  const replacement = getReplacement(match, this.original);
1604
1604
  if (replacement === match[0]) return true;
1605
- if (match[0].length === 0) this.appendRight(match.index, replacement);
1606
- else this.overwrite(match.index, match.index + match[0].length, replacement);
1605
+ if (match[0].length === 0) this.appendRight(match.index - this.offset, replacement);
1606
+ else this.overwrite(match.index - this.offset, match.index + match[0].length - this.offset, replacement);
1607
1607
  return true;
1608
1608
  };
1609
1609
  if (searchValue.global) {
@@ -1630,8 +1630,8 @@ var MagicString = class MagicString {
1630
1630
  if (typeof replacement === "function") replacement = replacement(string, index, original);
1631
1631
  else replacement = expandReplacement(replacement, string, index, original, [], void 0);
1632
1632
  if (string !== replacement) {
1633
- if (string.length === 0) this.appendRight(index, replacement);
1634
- else this.overwrite(index, index + string.length, replacement);
1633
+ if (string.length === 0) this.appendRight(index - this.offset, replacement);
1634
+ else this.overwrite(index - this.offset, index + string.length - this.offset, replacement);
1635
1635
  }
1636
1636
  break;
1637
1637
  }
@@ -1652,7 +1652,7 @@ var MagicString = class MagicString {
1652
1652
  for (let index = 0; index <= original.length; index += 1) {
1653
1653
  if (this._hasRemovedContent(index, index)) continue;
1654
1654
  const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
1655
- if (_replacement !== "") this.appendRight(index, _replacement);
1655
+ if (_replacement !== "") this.appendRight(index - this.offset, _replacement);
1656
1656
  }
1657
1657
  return this;
1658
1658
  }
@@ -1660,7 +1660,7 @@ var MagicString = class MagicString {
1660
1660
  if (this._hasRemovedContent(index, index + stringLength)) continue;
1661
1661
  const previous = original.slice(index, index + stringLength);
1662
1662
  const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
1663
- if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1663
+ if (previous !== _replacement) this.overwrite(index - this.offset, index + stringLength - this.offset, _replacement);
1664
1664
  }
1665
1665
  return this;
1666
1666
  }
@@ -2437,7 +2437,6 @@ function createInclusionContext() {
2437
2437
  hasBreak: false,
2438
2438
  hasContinue: false,
2439
2439
  includedCallArguments: new Set(),
2440
- includedCallArgumentsOfPossibleValues: null,
2441
2440
  includedLabels: new Set()
2442
2441
  };
2443
2442
  }
@@ -2586,6 +2585,9 @@ class Variable extends ExpressionEntity {
2586
2585
  markReassigned() {
2587
2586
  this.isReassigned = true;
2588
2587
  }
2588
+ markTargetOfAssignment() {
2589
+ this.isTargetOfAssignment = true;
2590
+ }
2589
2591
  constructor(name) {
2590
2592
  super();
2591
2593
  this.name = name;
@@ -2598,6 +2600,9 @@ class Variable extends ExpressionEntity {
2598
2600
  this.renderBaseName = null;
2599
2601
  this.renderName = null;
2600
2602
  this.isReassigned = false;
2603
+ // Unlike isReassigned, set eagerly during binding for every assignment,
2604
+ // including ones that are never included
2605
+ this.isTargetOfAssignment = false;
2601
2606
  this.onlyFunctionCallUsed = true;
2602
2607
  }
2603
2608
  /**
@@ -5325,10 +5330,9 @@ class LocalVariable extends Variable {
5325
5330
  this.kind = kind;
5326
5331
  this.calledFromTryStatement = false;
5327
5332
  this.additionalInitializers = null;
5328
- // A possibly incomplete list of values assigned to this variable after its
5329
- // declaration; as it is incomplete, it must never be used for value queries
5330
- // but only to forward call arguments to possible values
5331
- this.reassignedValues = null;
5333
+ // A possibly incomplete list of functions assigned to this variable; only used
5334
+ // to retain call arguments of assigned try-catch helpers, never for value queries
5335
+ this.assignedFunctions = null;
5332
5336
  this.includedPathTracker = new IncludedFullPathTracker();
5333
5337
  this.expressionsToBeDeoptimized = [];
5334
5338
  this.declarations = declarator ? [declarator] : [];
@@ -5454,16 +5458,12 @@ class LocalVariable extends Variable {
5454
5458
  }
5455
5459
  includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
5456
5460
  if (this.isReassigned) {
5457
- // Even when the value is unknown, it may be one of the assigned values;
5458
- // forwarding to all of them retains the arguments of try-catch helpers
5461
+ // The value may still be one of the assigned functions, whose try-catch
5462
+ // helpers need their call arguments retained
5459
5463
  includeInteraction(interaction, context);
5460
- // Each possible value is visited at most once per path and call
5461
- // per traversal so that dense assignment graphs do not repeat work
5462
- // for every simple path
5463
- const previousTracker = context.includedCallArgumentsOfPossibleValues;
5464
- context.includedCallArgumentsOfPossibleValues ??= new DiscriminatedPathTracker();
5465
- this.includeCallArgumentsOfPossibleValues(path, interaction, context, context.includedCallArgumentsOfPossibleValues);
5466
- context.includedCallArgumentsOfPossibleValues = previousTracker;
5464
+ if (path.length === 0) {
5465
+ this.includeCallArgumentsOfAssignedTryCatchHelpers(interaction, context);
5466
+ }
5467
5467
  return;
5468
5468
  }
5469
5469
  if (context.includedCallArguments.has(this.init) ||
@@ -5475,25 +5475,25 @@ class LocalVariable extends Variable {
5475
5475
  this.init.includeCallArgumentsWhenCalledAtPath([...this.initPath, ...path], interaction, context);
5476
5476
  context.includedCallArguments.delete(this.init);
5477
5477
  }
5478
- includeCallArgumentsOfPossibleValues(path, interaction, context, tracker) {
5479
- if (this.reassignedValues === null || path.length + this.initPath.length > MAX_PATH_DEPTH) {
5480
- return;
5478
+ includeCallArgumentsOfAssignedTryCatchHelpers(interaction, context) {
5479
+ if (this.initPath.length === 0) {
5480
+ this.includeCallArgumentsOfTryCatchHelper(this.init, interaction, context);
5481
5481
  }
5482
- this.includeCallArgumentsOfPossibleValue(this.init, [...this.initPath, ...path], interaction, context, tracker);
5483
- for (const entity of this.reassignedValues) {
5484
- this.includeCallArgumentsOfPossibleValue(entity, path, interaction, context, tracker);
5482
+ for (const assignedFunction of this.assignedFunctions ?? EMPTY_ARRAY) {
5483
+ this.includeCallArgumentsOfTryCatchHelper(assignedFunction, interaction, context);
5485
5484
  }
5486
5485
  }
5487
- includeCallArgumentsOfPossibleValue(entity, path, interaction, context, tracker) {
5488
- if (entity === UNKNOWN_EXPRESSION ||
5489
- entity === UNDEFINED_EXPRESSION ||
5490
- tracker.trackEntityAtPathAndGetIfTracked(path, interaction, entity)) {
5491
- return;
5486
+ includeCallArgumentsOfTryCatchHelper(value, interaction, context) {
5487
+ if (isArrowFunctionExpressionNode(value) || isFunctionExpressionNode(value)) {
5488
+ if (value.scope.hasParameterCalledFromTryStatement()) {
5489
+ value.scope.includeCallArguments(interaction, context);
5490
+ }
5492
5491
  }
5493
- entity.includeCallArgumentsWhenCalledAtPath(path, interaction, context);
5494
5492
  }
5495
5493
  addReassignedValue(value) {
5496
- (this.reassignedValues ??= []).push(value);
5494
+ if (isArrowFunctionExpressionNode(value) || isFunctionExpressionNode(value)) {
5495
+ (this.assignedFunctions ??= []).push(value);
5496
+ }
5497
5497
  }
5498
5498
  markCalledFromTryStatement() {
5499
5499
  this.calledFromTryStatement = true;
@@ -5727,6 +5727,9 @@ class Identifier extends IdentifierBase {
5727
5727
  this.variable = this.scope.findVariable(this.name);
5728
5728
  this.variable.addReference(this);
5729
5729
  this.isVariableReference = true;
5730
+ if (this.assignmentInteraction) {
5731
+ this.variable.markTargetOfAssignment();
5732
+ }
5730
5733
  }
5731
5734
  }
5732
5735
  declare(kind, destructuredInitPath, init) {
@@ -6061,6 +6064,47 @@ class MethodDefinition extends MethodBase {
6061
6064
  }
6062
6065
  }
6063
6066
 
6067
+ class PropertyDefinition extends NodeBase {
6068
+ get computed() {
6069
+ return isFlagSet(this.flags, 1024 /* Flag.computed */);
6070
+ }
6071
+ set computed(value) {
6072
+ this.flags = setFlag(this.flags, 1024 /* Flag.computed */, value);
6073
+ }
6074
+ deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
6075
+ this.value?.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
6076
+ }
6077
+ deoptimizePath(path) {
6078
+ this.value?.deoptimizePath(path);
6079
+ }
6080
+ getLiteralValueAtPath(path, recursionTracker, origin) {
6081
+ return this.value
6082
+ ? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
6083
+ : UnknownValue;
6084
+ }
6085
+ getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
6086
+ return this.value
6087
+ ? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
6088
+ : UNKNOWN_RETURN_EXPRESSION;
6089
+ }
6090
+ hasEffects(context) {
6091
+ return (this.key.hasEffects(context) ||
6092
+ (this.static && !!this.value?.hasEffects(context)) ||
6093
+ checkEffectForNodes(this.decorators, context));
6094
+ }
6095
+ hasEffectsOnInteractionAtPath(path, interaction, context) {
6096
+ return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
6097
+ }
6098
+ includeNode(context) {
6099
+ this.included = true;
6100
+ this.value?.includePath(UNKNOWN_PATH, context);
6101
+ for (const decorator of this.decorators) {
6102
+ decorator.includePath(UNKNOWN_PATH, context);
6103
+ }
6104
+ }
6105
+ }
6106
+ PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
6107
+
6064
6108
  class BlockScope extends ChildScope {
6065
6109
  constructor(parent) {
6066
6110
  super(parent, parent.context);
@@ -6126,6 +6170,7 @@ function isStaticBlock(statement) {
6126
6170
  class ClassNode extends NodeBase {
6127
6171
  constructor() {
6128
6172
  super(...arguments);
6173
+ this.instanceFieldValues = null;
6129
6174
  this.objectEntity = null;
6130
6175
  }
6131
6176
  createScope(parentScope) {
@@ -6159,7 +6204,7 @@ class ClassNode extends NodeBase {
6159
6204
  (this.classConstructor === null
6160
6205
  ? this.superClass?.hasEffectsOnInteractionAtPath(path, interaction, context)
6161
6206
  : this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
6162
- false
6207
+ this.hasEffectsOnInstanceFieldInitialization(context)
6163
6208
  : this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
6164
6209
  }
6165
6210
  include(context, includeChildrenRecursively) {
@@ -6177,6 +6222,10 @@ class ClassNode extends NodeBase {
6177
6222
  initialise() {
6178
6223
  super.initialise();
6179
6224
  this.id?.declare('class', EMPTY_PATH, this);
6225
+ this.instanceEntity = new ObjectEntity(new Map(), new ObjectMember(this, ['prototype']));
6226
+ // This makes sure that all deoptimizations of "this" are applied to the
6227
+ // instance entity, even if the class is only instantiated by unknown code.
6228
+ this.body.scope.instanceThisVariable.addArgumentForDeoptimization(this.instanceEntity);
6180
6229
  for (const method of this.body.body) {
6181
6230
  if (method instanceof MethodDefinition && method.kind === 'constructor') {
6182
6231
  this.classConstructor = method;
@@ -6197,6 +6246,36 @@ class ClassNode extends NodeBase {
6197
6246
  }
6198
6247
  this.scope.context.requestTreeshakingPass();
6199
6248
  }
6249
+ hasEffectsOnInstanceFieldInitialization(context) {
6250
+ const fieldValues = this.getInstanceFieldValues();
6251
+ if (fieldValues.length === 0)
6252
+ return false;
6253
+ const { replacedVariableInits } = context;
6254
+ const thisVariable = this.body.scope.instanceThisVariable;
6255
+ const thisInit = replacedVariableInits.get(thisVariable);
6256
+ replacedVariableInits.set(thisVariable, this.instanceEntity);
6257
+ const hasEffects = fieldValues.some(value => value.hasEffects(context));
6258
+ if (thisInit) {
6259
+ replacedVariableInits.set(thisVariable, thisInit);
6260
+ }
6261
+ else {
6262
+ replacedVariableInits.delete(thisVariable);
6263
+ }
6264
+ return hasEffects;
6265
+ }
6266
+ getInstanceFieldValues() {
6267
+ if (this.instanceFieldValues === null) {
6268
+ this.instanceFieldValues = [];
6269
+ for (const definition of this.body.body) {
6270
+ if (definition instanceof PropertyDefinition &&
6271
+ !definition.static &&
6272
+ definition.value !== null) {
6273
+ this.instanceFieldValues.push(definition.value);
6274
+ }
6275
+ }
6276
+ }
6277
+ return this.instanceFieldValues;
6278
+ }
6200
6279
  getObjectEntity() {
6201
6280
  if (this.objectEntity !== null) {
6202
6281
  return this.objectEntity;
@@ -6523,6 +6602,31 @@ class ThisVariable extends ParameterVariable {
6523
6602
  }
6524
6603
  }
6525
6604
 
6605
+ /**
6606
+ * Represents the return value of a function where all return statements return
6607
+ * the same variable that is the target of an assignment. As the assigned value
6608
+ * may replace the declaration initializer before the function returns, value
6609
+ * queries resolve to unknown, and call arguments are deoptimized directly
6610
+ * instead of being forwarded to the initializer alone.
6611
+ */
6612
+ class ReturnedIdentifier extends ExpressionEntity {
6613
+ constructor(returnedIdentifier) {
6614
+ super();
6615
+ this.returnedIdentifier = returnedIdentifier;
6616
+ }
6617
+ deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
6618
+ // The initializer may never be the value that is returned
6619
+ deoptimizeInteraction(interaction);
6620
+ this.returnedIdentifier.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
6621
+ }
6622
+ deoptimizePath(path) {
6623
+ this.returnedIdentifier.deoptimizePath(path);
6624
+ }
6625
+ includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
6626
+ this.returnedIdentifier.includeCallArgumentsWhenCalledAtPath(path, interaction, context);
6627
+ }
6628
+ }
6629
+
6526
6630
  class CatchBodyScope extends ChildScope {
6527
6631
  constructor(parent) {
6528
6632
  super(parent, parent.context);
@@ -6631,6 +6735,9 @@ class ParameterScope extends ChildScope {
6631
6735
  }
6632
6736
  this.hasRest = hasRest;
6633
6737
  }
6738
+ hasParameterCalledFromTryStatement() {
6739
+ return this.parameters.some(parameterVariables => parameterVariables.some(variable => variable.calledFromTryStatement));
6740
+ }
6634
6741
  includeCallArguments({ args }, context) {
6635
6742
  let calledFromTryStatement = false;
6636
6743
  let argumentIncluded = false;
@@ -6754,21 +6861,21 @@ class ReturnValueScope extends ParameterScope {
6754
6861
  addArgumentToBeDeoptimized(_argument) { }
6755
6862
  updateReturnExpression() {
6756
6863
  const { returnExpressions } = this;
6757
- if (returnExpressions.length === 1) {
6758
- this.returnExpression = returnExpressions[0];
6864
+ const [firstExpression] = returnExpressions;
6865
+ // A single return, or the same variable returned on all paths, can be
6866
+ // resolved to that variable
6867
+ if (firstExpression && this.returnExpressionsResolveToSameVariable(firstExpression)) {
6868
+ this.returnExpression = firstExpression.variable.isTargetOfAssignment
6869
+ ? new ReturnedIdentifier(firstExpression)
6870
+ : firstExpression;
6871
+ }
6872
+ else if (returnExpressions.length === 1) {
6873
+ this.returnExpression = firstExpression;
6759
6874
  }
6760
6875
  else {
6761
- // Returning the same variable on all paths is equivalent to a single
6762
- // return, so the return expression can be resolved to that variable
6763
- const [firstExpression] = returnExpressions;
6764
- if (firstExpression && this.returnExpressionsResolveToSameVariable(firstExpression)) {
6765
- this.returnExpression = firstExpression;
6766
- }
6767
- else {
6768
- this.returnExpression = UNKNOWN_EXPRESSION;
6769
- for (const expression of returnExpressions) {
6770
- expression.deoptimizePath(UNKNOWN_PATH);
6771
- }
6876
+ this.returnExpression = UNKNOWN_EXPRESSION;
6877
+ for (const expression of returnExpressions) {
6878
+ expression.deoptimizePath(UNKNOWN_PATH);
6772
6879
  }
6773
6880
  }
6774
6881
  }
@@ -6949,6 +7056,9 @@ class RestElement extends NodeBase {
6949
7056
  markDeclarationReached() {
6950
7057
  this.argument.markDeclarationReached();
6951
7058
  }
7059
+ setAssignedValue(value) {
7060
+ this.argument.setAssignedValue(value);
7061
+ }
6952
7062
  applyDeoptimizations() {
6953
7063
  this.deoptimized = true;
6954
7064
  if (this.declarationInit !== null) {
@@ -12228,6 +12338,14 @@ class ArrayPattern extends NodeBase {
12228
12338
  }
12229
12339
  }
12230
12340
  }
12341
+ setAssignedValue(value) {
12342
+ super.setAssignedValue(value);
12343
+ // Destructuring assigns each target only some subpath of the assigned
12344
+ // value, which is not tracked
12345
+ for (const element of this.elements) {
12346
+ element?.setAssignedValue(UNKNOWN_EXPRESSION);
12347
+ }
12348
+ }
12231
12349
  markDeclarationReached() {
12232
12350
  for (const element of this.elements) {
12233
12351
  element?.markDeclarationReached();
@@ -12398,6 +12516,14 @@ class ObjectPattern extends NodeBase {
12398
12516
  }
12399
12517
  }
12400
12518
  }
12519
+ setAssignedValue(value) {
12520
+ super.setAssignedValue(value);
12521
+ // Destructuring assigns each target only some subpath of the assigned
12522
+ // value, which is not tracked
12523
+ for (const property of this.properties) {
12524
+ property.setAssignedValue(UNKNOWN_EXPRESSION);
12525
+ }
12526
+ }
12401
12527
  }
12402
12528
  ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
12403
12529
  ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
@@ -12562,6 +12688,9 @@ class AssignmentPattern extends NodeBase {
12562
12688
  this.left.render(code, options, { isShorthandProperty });
12563
12689
  this.right.render(code, options);
12564
12690
  }
12691
+ setAssignedValue(value) {
12692
+ this.left.setAssignedValue(value);
12693
+ }
12565
12694
  applyDeoptimizations() {
12566
12695
  this.deoptimized = true;
12567
12696
  this.left.deoptimizePath(EMPTY_PATH);
@@ -12570,6 +12699,17 @@ class AssignmentPattern extends NodeBase {
12570
12699
  }
12571
12700
  }
12572
12701
 
12702
+ function markTopLevelAwait(node) {
12703
+ if (node.scope.context.usesTopLevelAwait)
12704
+ return;
12705
+ let parent = node.parent;
12706
+ do {
12707
+ if (parent instanceof FunctionBase)
12708
+ return;
12709
+ } while ((parent = parent.parent));
12710
+ node.scope.context.usesTopLevelAwait = true;
12711
+ }
12712
+
12573
12713
  class AwaitExpression extends NodeBase {
12574
12714
  deoptimizePath(path) {
12575
12715
  this.argument.deoptimizePath(path);
@@ -12581,12 +12721,7 @@ class AwaitExpression extends NodeBase {
12581
12721
  }
12582
12722
  initialise() {
12583
12723
  super.initialise();
12584
- let parent = this.parent;
12585
- do {
12586
- if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
12587
- return;
12588
- } while ((parent = parent.parent));
12589
- this.scope.context.usesTopLevelAwait = true;
12724
+ markTopLevelAwait(this);
12590
12725
  }
12591
12726
  include(context, includeChildrenRecursively) {
12592
12727
  if (!this.included)
@@ -13077,7 +13212,8 @@ class ClassBodyScope extends ChildScope {
13077
13212
  super(parent, context);
13078
13213
  this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, EMPTY_PATH, context, 'other')));
13079
13214
  this.instanceScope = new ChildScope(this, context);
13080
- this.instanceScope.variables.set('this', new ThisVariable(context));
13215
+ this.instanceThisVariable = new ThisVariable(context);
13216
+ this.instanceScope.variables.set('this', this.instanceThisVariable);
13081
13217
  }
13082
13218
  findLexicalBoundary() {
13083
13219
  return this;
@@ -13577,6 +13713,8 @@ class ForOfStatement extends NodeBase {
13577
13713
  }
13578
13714
  initialise() {
13579
13715
  super.initialise();
13716
+ if (this.await)
13717
+ markTopLevelAwait(this);
13580
13718
  this.left.setAssignedValue(UNKNOWN_EXPRESSION);
13581
13719
  }
13582
13720
  render(code, options) {
@@ -15361,6 +15499,9 @@ class Property extends MethodBase {
15361
15499
  }
15362
15500
  this.value.render(code, options, { isShorthandProperty: this.shorthand });
15363
15501
  }
15502
+ setAssignedValue(value) {
15503
+ this.value.setAssignedValue(value);
15504
+ }
15364
15505
  getPathInProperty(destructuredInitPath) {
15365
15506
  return destructuredInitPath.at(-1) === UnknownKey
15366
15507
  ? destructuredInitPath
@@ -15376,47 +15517,6 @@ class Property extends MethodBase {
15376
15517
  Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
15377
15518
  Property.prototype.applyDeoptimizations = doNotDeoptimize;
15378
15519
 
15379
- class PropertyDefinition extends NodeBase {
15380
- get computed() {
15381
- return isFlagSet(this.flags, 1024 /* Flag.computed */);
15382
- }
15383
- set computed(value) {
15384
- this.flags = setFlag(this.flags, 1024 /* Flag.computed */, value);
15385
- }
15386
- deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
15387
- this.value?.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
15388
- }
15389
- deoptimizePath(path) {
15390
- this.value?.deoptimizePath(path);
15391
- }
15392
- getLiteralValueAtPath(path, recursionTracker, origin) {
15393
- return this.value
15394
- ? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
15395
- : UnknownValue;
15396
- }
15397
- getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
15398
- return this.value
15399
- ? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
15400
- : UNKNOWN_RETURN_EXPRESSION;
15401
- }
15402
- hasEffects(context) {
15403
- return (this.key.hasEffects(context) ||
15404
- (this.static && !!this.value?.hasEffects(context)) ||
15405
- checkEffectForNodes(this.decorators, context));
15406
- }
15407
- hasEffectsOnInteractionAtPath(path, interaction, context) {
15408
- return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
15409
- }
15410
- includeNode(context) {
15411
- this.included = true;
15412
- this.value?.includePath(UNKNOWN_PATH, context);
15413
- for (const decorator of this.decorators) {
15414
- decorator.includePath(UNKNOWN_PATH, context);
15415
- }
15416
- }
15417
- }
15418
- PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
15419
-
15420
15520
  class ReturnStatement extends NodeBase {
15421
15521
  hasEffects(context) {
15422
15522
  if (!context.ignore.returnYield || this.argument?.hasEffects(context))
@@ -16144,6 +16244,8 @@ class VariableDeclaration extends NodeBase {
16144
16244
  }
16145
16245
  initialise() {
16146
16246
  super.initialise();
16247
+ if (this.kind === 'await using')
16248
+ markTopLevelAwait(this);
16147
16249
  for (const declarator of this.declarations) {
16148
16250
  declarator.declareDeclarator(this.kind);
16149
16251
  }
@@ -18037,6 +18139,9 @@ class Module {
18037
18139
  hasEffects() {
18038
18140
  return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
18039
18141
  }
18142
+ hasTopLevelAwait() {
18143
+ return this.astContext.usesTopLevelAwait;
18144
+ }
18040
18145
  include() {
18041
18146
  const context = createInclusionContext();
18042
18147
  if (this.ast.shouldBeIncluded(context))
@@ -19421,6 +19526,7 @@ class Chunk {
19421
19526
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
19422
19527
  const renderedDependencies = [...this.getRenderedDependencies().values()];
19423
19528
  const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
19529
+ const renderedExportNames = format === 'es' && new Set(renderedExports.map(({ exported }) => exported));
19424
19530
  let hasExports = renderedExports.length > 0;
19425
19531
  let hasDefaultExport = false;
19426
19532
  for (const renderedDependency of renderedDependencies) {
@@ -19430,8 +19536,8 @@ class Chunk {
19430
19536
  if (!hasDefaultExport && reexports.some(reexport => reexport.reexported === 'default')) {
19431
19537
  hasDefaultExport = true;
19432
19538
  }
19433
- if (format === 'es') {
19434
- renderedDependency.reexports = reexports.filter(({ reexported }) => !renderedExports.find(({ exported }) => exported === reexported));
19539
+ if (renderedExportNames) {
19540
+ renderedDependency.reexports = reexports.filter(({ reexported }) => !renderedExportNames.has(reexported));
19435
19541
  }
19436
19542
  }
19437
19543
  }
@@ -20302,7 +20408,8 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log
20302
20408
  // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
20303
20409
  // If we no longer want this, we should make a copy here.
20304
20410
  const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, entriesAndManualChunksCount);
20305
- const awaitedAlreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, entriesAndManualChunksCount);
20411
+ // Warning: This will consume dynamicallyDependentEntriesByAwaitedDynamicEntry.
20412
+ const awaitedAlreadyLoadedAtomsByEntry = getAwaitedAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, entriesAndManualChunksCount);
20306
20413
  // This mutates the dependentEntries in chunkAtoms
20307
20414
  removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry);
20308
20415
  const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
@@ -20365,13 +20472,16 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
20365
20472
  for (const currentEntryModules of allEntriesAndManualChunks) {
20366
20473
  const dynamicImportsForCurrentEntry = new Set();
20367
20474
  const awaitedDynamicImportsForCurrentEntry = new Set();
20475
+ const dynamicEntriesForCurrentEntry = new Set();
20368
20476
  dynamicImportModulesByEntry[entryOrManualChunkIndex] = dynamicImportsForCurrentEntry;
20369
20477
  awaitedDynamicImportModulesByEntry[entryOrManualChunkIndex] =
20370
20478
  awaitedDynamicImportsForCurrentEntry;
20371
20479
  const staticDependencies = new Set(currentEntryModules);
20480
+ let hasTopLevelAwait = false;
20372
20481
  // If we have a very large manual chunk, tracking if it is already added to the dependencies will improve performance
20373
20482
  const addedManualChunks = new Set();
20374
20483
  for (const module of staticDependencies) {
20484
+ hasTopLevelAwait ||= module.hasTopLevelAwait();
20375
20485
  getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryOrManualChunkIndex);
20376
20486
  const manualChunkMembers = manualChunkModulesByModule.get(module);
20377
20487
  if (manualChunkMembers && !addedManualChunks.has(manualChunkMembers)) {
@@ -20388,17 +20498,13 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
20388
20498
  for (const { node: { resolution } } of module.dynamicImports) {
20389
20499
  if (resolution instanceof Module &&
20390
20500
  resolution.includedDynamicImporters.length > 0 &&
20391
- !allEntriesSet.has(resolution)) {
20392
- dynamicEntryModules.add(resolution);
20393
- allEntriesSet.add(resolution);
20394
- allEntriesAndManualChunks.push([resolution]);
20395
- dynamicImportsForCurrentEntry.add(resolution);
20396
- for (const includedTopLevelAwaitingDynamicImporter of resolution.includedTopLevelAwaitingDynamicImporters) {
20397
- if (staticDependencies.has(includedTopLevelAwaitingDynamicImporter)) {
20398
- awaitedDynamicEntryModules.add(resolution);
20399
- awaitedDynamicImportsForCurrentEntry.add(resolution);
20400
- break;
20401
- }
20501
+ (dynamicEntryModules.has(resolution) || !allEntriesSet.has(resolution))) {
20502
+ dynamicEntriesForCurrentEntry.add(resolution);
20503
+ if (!allEntriesSet.has(resolution)) {
20504
+ dynamicEntryModules.add(resolution);
20505
+ allEntriesSet.add(resolution);
20506
+ allEntriesAndManualChunks.push([resolution]);
20507
+ dynamicImportsForCurrentEntry.add(resolution);
20402
20508
  }
20403
20509
  }
20404
20510
  }
@@ -20410,13 +20516,20 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
20410
20516
  }
20411
20517
  }
20412
20518
  }
20519
+ // A dynamic import can be awaited indirectly through a static dependency.
20520
+ if (hasTopLevelAwait) {
20521
+ for (const dynamicEntry of dynamicEntriesForCurrentEntry) {
20522
+ awaitedDynamicEntryModules.add(dynamicEntry);
20523
+ awaitedDynamicImportsForCurrentEntry.add(dynamicEntry);
20524
+ }
20525
+ }
20413
20526
  entryOrManualChunkIndex++;
20414
20527
  }
20415
20528
  const { awaitedDynamicEntries, awaitedDynamicImportsByEntry, dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntriesAndManualChunks, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry);
20416
20529
  return {
20417
20530
  awaitedDynamicImportsByEntry,
20418
20531
  dependentEntriesByModule,
20419
- dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntriesAndManualChunks, dynamicEntry => dynamicEntry.includedTopLevelAwaitingDynamicImporters),
20532
+ dynamicallyDependentEntriesByAwaitedDynamicEntry: addAwaitingEntries(getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntriesAndManualChunks, dynamicEntry => dynamicEntry.includedTopLevelAwaitingDynamicImporters), awaitedDynamicImportsByEntry),
20420
20533
  dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntriesAndManualChunks, dynamicEntry => dynamicEntry.includedDynamicImporters),
20421
20534
  dynamicImportsByEntry,
20422
20535
  entriesAndManualChunksCount: allEntriesAndManualChunks.length
@@ -20458,6 +20571,18 @@ function getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModul
20458
20571
  }
20459
20572
  return dynamicImportsByEntry;
20460
20573
  }
20574
+ // A dynamic entry can be awaited by an entry even if the importing module does
20575
+ // not have a top-level await itself, e.g. if the import is inside a function
20576
+ // that is awaited in the entry. In that case, the entry is still evaluating
20577
+ // when the dynamic entry is executed, so we add all awaiting entries here.
20578
+ function addAwaitingEntries(dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry) {
20579
+ for (const [entryIndex, awaitedDynamicImports] of awaitedDynamicImportsByEntry.entries()) {
20580
+ for (const dynamicEntryIndex of awaitedDynamicImports) {
20581
+ getOrCreate(dynamicallyDependentEntriesByAwaitedDynamicEntry, dynamicEntryIndex, (getNewSet)).add(entryIndex);
20582
+ }
20583
+ }
20584
+ return dynamicallyDependentEntriesByAwaitedDynamicEntry;
20585
+ }
20461
20586
  function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntriesAndManualChunks, getDynamicImporters) {
20462
20587
  const dynamicallyDependentEntriesByDynamicEntry = new Map();
20463
20588
  for (const dynamicEntryIndex of dynamicEntries) {
@@ -20552,6 +20677,34 @@ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyD
20552
20677
  }
20553
20678
  return alreadyLoadedAtomsByEntry;
20554
20679
  }
20680
+ // Warning: This will consume dynamicallyDependentEntriesByAwaitedDynamicEntry.
20681
+ function getAwaitedAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, allEntriesCount) {
20682
+ // Unlike already loaded atoms, this is a union and not an intersection: If
20683
+ // any importer that is still evaluating while it awaits a dynamic entry has
20684
+ // loaded an atom, merging that atom into the chunk of this importer would
20685
+ // create a cycle. Entries that are not awaited have no such atoms.
20686
+ const awaitedAlreadyLoadedAtomsByEntry = new Array(allEntriesCount).fill(0n);
20687
+ for (const [dynamicEntryIndex, dynamicallyDependentEntries] of dynamicallyDependentEntriesByAwaitedDynamicEntry) {
20688
+ // We delete here so that they can be added again if necessary to be handled
20689
+ // again by the loop
20690
+ dynamicallyDependentEntriesByAwaitedDynamicEntry.delete(dynamicEntryIndex);
20691
+ const knownLoadedAtoms = awaitedAlreadyLoadedAtomsByEntry[dynamicEntryIndex];
20692
+ let updatedLoadedAtoms = knownLoadedAtoms;
20693
+ for (const entryIndex of dynamicallyDependentEntries) {
20694
+ updatedLoadedAtoms |=
20695
+ staticDependencyAtomsByEntry[entryIndex] | awaitedAlreadyLoadedAtomsByEntry[entryIndex];
20696
+ }
20697
+ // If the knownLoadedAtoms changed, all awaited dynamic imports of this
20698
+ // entry need to be updated again
20699
+ if (updatedLoadedAtoms !== knownLoadedAtoms) {
20700
+ awaitedAlreadyLoadedAtomsByEntry[dynamicEntryIndex] = updatedLoadedAtoms;
20701
+ for (const dynamicImport of awaitedDynamicImportsByEntry[dynamicEntryIndex]) {
20702
+ getOrCreate(dynamicallyDependentEntriesByAwaitedDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
20703
+ }
20704
+ }
20705
+ }
20706
+ return awaitedAlreadyLoadedAtomsByEntry;
20707
+ }
20555
20708
  /**
20556
20709
  * This removes all unnecessary dynamic entries from the dependentEntries in its
20557
20710
  * first argument if a chunk is already loaded without that entry.
@@ -24355,17 +24508,17 @@ async function rollupInternal(rawInputOptions, registerWatchHooks) {
24355
24508
  ...error_,
24356
24509
  message: `There was an error during the build:\n ${error_.message}\nAdditionally, handling the error in the 'buildEnd' hook caused the following error:\n ${buildEndError.message}`
24357
24510
  });
24358
- await graph.pluginDriver.hookParallel('closeBundle', [compoundError]);
24511
+ await graph.pluginDriver.hookParallel('closeBundle', [compoundError]).catch(() => { });
24359
24512
  throw compoundError;
24360
24513
  }
24361
- await graph.pluginDriver.hookParallel('closeBundle', [error_]);
24514
+ await graph.pluginDriver.hookParallel('closeBundle', [error_]).catch(() => { });
24362
24515
  throw error_;
24363
24516
  }
24364
24517
  try {
24365
24518
  await graph.pluginDriver.hookParallel('buildEnd', []);
24366
24519
  }
24367
24520
  catch (buildEndError) {
24368
- await graph.pluginDriver.hookParallel('closeBundle', [buildEndError]);
24521
+ await graph.pluginDriver.hookParallel('closeBundle', [buildEndError]).catch(() => { });
24369
24522
  throw buildEndError;
24370
24523
  }
24371
24524
  });