@rollup/wasm-node 4.65.0 → 4.66.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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/parseAst.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.d.ts CHANGED
@@ -69,8 +69,8 @@ export interface ExistingDecodedSourceMap {
69
69
  readonly mappings: SourceMapSegment[][];
70
70
  names: string[];
71
71
  sourceRoot?: string | undefined;
72
- sources: string[];
73
- sourcesContent?: string[] | undefined;
72
+ sources: (string | null)[];
73
+ sourcesContent?: (string | null)[] | undefined;
74
74
  version: number;
75
75
  x_google_ignoreList?: number[] | undefined;
76
76
  }
@@ -80,8 +80,8 @@ export interface ExistingRawSourceMap {
80
80
  mappings: string;
81
81
  names: string[];
82
82
  sourceRoot?: string | undefined;
83
- sources: string[];
84
- sourcesContent?: string[] | undefined;
83
+ sources: (string | null)[];
84
+ sourcesContent?: (string | null)[] | undefined;
85
85
  version: number;
86
86
  x_google_ignoreList?: number[] | undefined;
87
87
  }
@@ -105,7 +105,17 @@ export interface SourceMap {
105
105
  toUrl(): string;
106
106
  }
107
107
 
108
- export type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
108
+ export type SourceMapInput =
109
+ ExistingRawSourceMap | IndexSourceMap | string | null | { mappings: '' };
110
+
111
+ export interface IndexSourceMap {
112
+ file?: string | undefined;
113
+ sections: {
114
+ map: ExistingRawSourceMap | IndexSourceMap;
115
+ offset: { column: number; line: number };
116
+ }[];
117
+ version: number;
118
+ }
109
119
 
110
120
  interface ModuleOptions {
111
121
  attributes: Record<string, string>;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -322,6 +322,15 @@ function getRollupError(base) {
322
322
  });
323
323
  return errorInstance;
324
324
  }
325
+ function logErrorInHook(originalError, hookError, hookName) {
326
+ augmentLogMessage(originalError);
327
+ augmentLogMessage(hookError);
328
+ const phase = hookName === 'buildEnd' ? 'the build' : 'rendering';
329
+ return {
330
+ ...originalError,
331
+ message: `There was an error during ${phase}:\n ${originalError.message}\nAdditionally, handling the error in the '${hookName}' hook caused the following error:\n ${hookError.message}`
332
+ };
333
+ }
325
334
  function augmentCodeLocation(properties, pos, source, id) {
326
335
  if (typeof pos === 'object') {
327
336
  const { line, column } = pos;
@@ -2304,6 +2313,7 @@ exports.logDuplicateImportOptions = logDuplicateImportOptions;
2304
2313
  exports.logDuplicatePluginName = logDuplicatePluginName;
2305
2314
  exports.logEmptyChunk = logEmptyChunk;
2306
2315
  exports.logEntryCannotBeExternal = logEntryCannotBeExternal;
2316
+ exports.logErrorInHook = logErrorInHook;
2307
2317
  exports.logEval = logEval;
2308
2318
  exports.logExternalModulesCannotBeIncludedInManualChunks = logExternalModulesCannotBeIncludedInManualChunks;
2309
2319
  exports.logExternalModulesCannotBeTransformedToModules = logExternalModulesCannotBeTransformedToModules;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.65.0
4
- Thu, 22 Oct 2026 08:51:29 GMT - commit 9aac09a39dc1fa297a7b06f1ad6907f7bd41b310
3
+ Rollup.js v4.66.0
4
+ Wed, 28 Oct 2026 13:27:47 GMT - commit 4de8104f55fe5c0df06aab54c1f9f2967dbe66ac
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
42
42
 
43
43
  const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
44
44
 
45
- var version = "4.65.0";
45
+ var version = "4.66.0";
46
46
  const package_ = {
47
47
  version: version};
48
48
 
@@ -6388,8 +6388,8 @@ const UnknownNonAccessorKey = Symbol('Unknown Non-Accessor Key');
6388
6388
  const UnknownInteger = Symbol('Unknown Integer');
6389
6389
  const UnknownWellKnown = Symbol('Unknown Well-Known');
6390
6390
  const SymbolToStringTag = Symbol('Symbol.toStringTag');
6391
- const SymbolDispose = Symbol('Symbol.asyncDispose');
6392
- const SymbolAsyncDispose = Symbol('Symbol.dispose');
6391
+ const SymbolDispose = Symbol('Symbol.dispose');
6392
+ const SymbolAsyncDispose = Symbol('Symbol.asyncDispose');
6393
6393
  const SymbolHasInstance = Symbol('Symbol.hasInstance');
6394
6394
  const WELL_KNOWN_SYMBOLS_LIST = [
6395
6395
  SymbolToStringTag,
@@ -6496,6 +6496,25 @@ class IncludedFullPathTracker {
6496
6496
  }
6497
6497
  return included;
6498
6498
  }
6499
+ includeAllPaths(entity, context, basePath) {
6500
+ if (this.includedPaths) {
6501
+ includeAllSubPaths(entity, context, basePath, this.includedPaths);
6502
+ }
6503
+ }
6504
+ }
6505
+ function includeAllSubPaths(entity, context, path, includedPaths) {
6506
+ if (includedPaths[UnknownKey]) {
6507
+ entity.includePath([...path, UnknownKey], context);
6508
+ return;
6509
+ }
6510
+ const keys = Reflect.ownKeys(includedPaths);
6511
+ if (keys.length === 0) {
6512
+ entity.includePath(path, context);
6513
+ return;
6514
+ }
6515
+ for (const key of keys) {
6516
+ includeAllSubPaths(entity, context, [...path, key], includedPaths[key]);
6517
+ }
6499
6518
  }
6500
6519
  const UNKNOWN_INCLUDED_TOP_LEVEL_PATH = Object.freeze({
6501
6520
  [UnknownKey]: true
@@ -6539,13 +6558,15 @@ class IncludedTopLevelPathTracker {
6539
6558
  entity.includePath([...basePath, UnknownKey], context);
6540
6559
  }
6541
6560
  else {
6542
- const inclusionEntries = Object.entries(includedPaths);
6543
- if (inclusionEntries.length === 0) {
6561
+ const keys = Reflect.ownKeys(includedPaths);
6562
+ if (keys.length === 0) {
6544
6563
  entity.includePath(basePath, context);
6545
6564
  }
6546
6565
  else {
6547
- for (const [key, value] of inclusionEntries) {
6548
- entity.includePath(value === UnknownKey ? [...basePath, key, UnknownKey] : [...basePath, key], context);
6566
+ for (const key of keys) {
6567
+ entity.includePath(includedPaths[key] === UnknownKey
6568
+ ? [...basePath, key, UnknownKey]
6569
+ : [...basePath, key], context);
6549
6570
  }
6550
6571
  }
6551
6572
  }
@@ -6659,6 +6680,9 @@ class ExpressionEntity {
6659
6680
  deoptimizeInteraction(interaction);
6660
6681
  }
6661
6682
  deoptimizePath(_path) { }
6683
+ getKnownFunctionAtPath(_path, _recursionTracker, _origin) {
6684
+ return null;
6685
+ }
6662
6686
  /**
6663
6687
  * If possible it returns a stringifyable literal value for this node that
6664
6688
  * can be used for inlining or comparing values. Otherwise, it should return
@@ -7912,6 +7936,17 @@ class ObjectEntity extends ExpressionEntity {
7912
7936
  }
7913
7937
  this.prototypeExpression?.deoptimizePath(path.length === 1 ? [path[0], UnknownKey] : path);
7914
7938
  }
7939
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
7940
+ const key = path[0];
7941
+ // Setters can shadow data properties or inherited methods without appearing in the getter map.
7942
+ if (!isConcreteKey(key) || this.settersByKey.has(key) || this.unmatchableSetters.length > 0) {
7943
+ return null;
7944
+ }
7945
+ const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
7946
+ return expressionAtPath
7947
+ ? expressionAtPath.getKnownFunctionAtPath(path.slice(1), recursionTracker, origin)
7948
+ : this.prototypeExpression?.getKnownFunctionAtPath(path, recursionTracker, origin) || null;
7949
+ }
7915
7950
  getLiteralValueAtPath(path, recursionTracker, origin) {
7916
7951
  if (path.length === 0) {
7917
7952
  // This should actually be "UnknownTruthyValue". However, this currently
@@ -8168,22 +8203,25 @@ class ObjectEntity extends ExpressionEntity {
8168
8203
  }
8169
8204
  }
8170
8205
 
8171
- const isInteger = (property) => typeof property === 'string' && /^\d+$/.test(property);
8206
+ const isKnownToBeMissing = (property) => property === SymbolDispose ||
8207
+ property === SymbolAsyncDispose ||
8208
+ (typeof property === 'string' && /^\d+$/.test(property));
8172
8209
  // This makes sure unknown properties are not handled as "undefined" but as
8173
8210
  // "unknown" but without access side effects. An exception is done for numeric
8174
8211
  // properties as we do not expect new builtin properties to be numbers, this
8175
- // will improve tree-shaking for out-of-bounds array properties
8212
+ // will improve tree-shaking for out-of-bounds array properties. Disposal
8213
+ // methods are also known to be missing so that "await using" can rely on the
8214
+ // fallback to Symbol.dispose for plain objects.
8176
8215
  const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression extends ExpressionEntity {
8177
8216
  deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
8178
- if (interaction.type === INTERACTION_CALLED && path.length === 1 && !isInteger(path[0])) {
8217
+ if (interaction.type === INTERACTION_CALLED &&
8218
+ path.length === 1 &&
8219
+ !isKnownToBeMissing(path[0])) {
8179
8220
  deoptimizeInteraction(interaction);
8180
8221
  }
8181
8222
  }
8182
8223
  getLiteralValueAtPath(path) {
8183
- // We ignore number properties as we do not expect new properties to be
8184
- // numbers and also want to keep handling out-of-bound array elements as
8185
- // "undefined"
8186
- return path.length === 1 && isInteger(path[0]) ? undefined : UnknownValue;
8224
+ return path.length === 1 && isKnownToBeMissing(path[0]) ? undefined : UnknownValue;
8187
8225
  }
8188
8226
  hasEffectsOnInteractionAtPath(path, { type }) {
8189
8227
  return path.length > 1 || type === INTERACTION_CALLED;
@@ -8197,6 +8235,9 @@ const OBJECT_PROTOTYPE = new ObjectEntity(new Map([
8197
8235
  ['toString', METHOD_RETURNS_STRING],
8198
8236
  ['valueOf', METHOD_RETURNS_UNKNOWN]
8199
8237
  ]), OBJECT_PROTOTYPE_FALLBACK, true);
8238
+ // Generator prototypes inherit disposal methods from the iterator prototypes
8239
+ const GENERATOR_PROTOTYPE = new ObjectEntity([{ key: SymbolDispose, kind: 'init', property: UNKNOWN_EXPRESSION }], OBJECT_PROTOTYPE, true);
8240
+ const ASYNC_GENERATOR_PROTOTYPE = new ObjectEntity([{ key: SymbolAsyncDispose, kind: 'init', property: UNKNOWN_EXPRESSION }], OBJECT_PROTOTYPE, true);
8200
8241
 
8201
8242
  const NEW_ARRAY_PROPERTIES = [
8202
8243
  { key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION },
@@ -8341,7 +8382,8 @@ const ARRAY_PROTOTYPE = new ObjectEntity(new Map([
8341
8382
 
8342
8383
  class SpreadElement extends NodeBase {
8343
8384
  deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
8344
- if (path.length > 0) {
8385
+ // Spread values are copied as data properties, so only calling them can still reach the argument
8386
+ if (path.length > 0 || interaction.type === INTERACTION_CALLED) {
8345
8387
  this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
8346
8388
  }
8347
8389
  }
@@ -9561,6 +9603,15 @@ class LocalVariable extends Variable {
9561
9603
  this.init.deoptimizePath(limitConcatenatedPathDepth(this.initPath, path));
9562
9604
  }
9563
9605
  }
9606
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
9607
+ if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) {
9608
+ return null;
9609
+ }
9610
+ return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
9611
+ this.expressionsToBeDeoptimized.push(origin);
9612
+ return this.init.getKnownFunctionAtPath([...this.initPath, ...path], recursionTracker, origin);
9613
+ }, null);
9614
+ }
9564
9615
  getLiteralValueAtPath(path, recursionTracker, origin) {
9565
9616
  if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) {
9566
9617
  return UnknownValue;
@@ -9720,6 +9771,9 @@ class IdentifierBase extends NodeBase {
9720
9771
  // Identifier as property that might be deoptimized by default
9721
9772
  this.variable?.deoptimizePath(path);
9722
9773
  }
9774
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
9775
+ return this.getVariableRespectingTDZ().getKnownFunctionAtPath(path, recursionTracker, origin);
9776
+ }
9723
9777
  getLiteralValueAtPath(path, recursionTracker, origin) {
9724
9778
  return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
9725
9779
  }
@@ -10187,6 +10241,11 @@ class MethodBase extends NodeBase {
10187
10241
  deoptimizePath(path) {
10188
10242
  this.getAccessedValue()[0].deoptimizePath(path);
10189
10243
  }
10244
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
10245
+ return this.kind === 'get' || this.kind === 'set'
10246
+ ? null
10247
+ : this.value.getKnownFunctionAtPath(path, recursionTracker, origin);
10248
+ }
10190
10249
  getLiteralValueAtPath(path, recursionTracker, origin) {
10191
10250
  return this.getAccessedValue()[0].getLiteralValueAtPath(path, recursionTracker, origin);
10192
10251
  }
@@ -10768,6 +10827,8 @@ class ParameterVariable extends LocalVariable {
10768
10827
  class ThisVariable extends ParameterVariable {
10769
10828
  constructor(context) {
10770
10829
  super('this', null, EMPTY_PATH, context);
10830
+ // Unlike parameters, track nested paths so receivers only keep what is accessed via "this"
10831
+ this.includedPathTracker = new IncludedFullPathTracker();
10771
10832
  }
10772
10833
  hasEffectsOnInteractionAtPath(path, interaction, context) {
10773
10834
  return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
@@ -11072,8 +11133,11 @@ class FunctionScope extends ReturnValueScope {
11072
11133
  }
11073
11134
  includeCallArguments(interaction, context) {
11074
11135
  super.includeCallArguments(interaction, context);
11136
+ const { args } = interaction;
11137
+ if (args[0]) {
11138
+ this.thisVariable.includeArgumentPaths(args[0], context);
11139
+ }
11075
11140
  if (this.argumentsVariable.included) {
11076
- const { args } = interaction;
11077
11141
  for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) {
11078
11142
  const argument = args[argumentIndex];
11079
11143
  if (argument) {
@@ -11290,6 +11354,11 @@ class FunctionBase extends NodeBase {
11290
11354
  this.scope.deoptimizeAllParameters();
11291
11355
  }
11292
11356
  }
11357
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
11358
+ return path.length === 0
11359
+ ? this
11360
+ : this.getObjectEntity().getKnownFunctionAtPath(path, recursionTracker, origin);
11361
+ }
11293
11362
  getLiteralValueAtPath(path, recursionTracker, origin) {
11294
11363
  return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
11295
11364
  }
@@ -11297,7 +11366,7 @@ class FunctionBase extends NodeBase {
11297
11366
  if (path.length > 0) {
11298
11367
  return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
11299
11368
  }
11300
- if (this.async) {
11369
+ if (this.async || this.generator) {
11301
11370
  if (!this.deoptimizedReturn) {
11302
11371
  this.deoptimizedReturn = true;
11303
11372
  this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
@@ -11493,10 +11562,15 @@ class FunctionNode extends FunctionBase {
11493
11562
  {
11494
11563
  key: 'prototype',
11495
11564
  kind: 'init',
11496
- property: new ObjectEntity([], OBJECT_PROTOTYPE)
11565
+ property: new ObjectEntity([], this.getPrototypeOfPrototype())
11497
11566
  }
11498
11567
  ], OBJECT_PROTOTYPE));
11499
11568
  }
11569
+ getPrototypeOfPrototype() {
11570
+ if (!this.generator)
11571
+ return OBJECT_PROTOTYPE;
11572
+ return this.async ? ASYNC_GENERATOR_PROTOTYPE : GENERATOR_PROTOTYPE;
11573
+ }
11500
11574
  }
11501
11575
 
11502
11576
  class FunctionDeclaration extends FunctionNode {
@@ -12060,6 +12134,20 @@ class MemberExpression extends NodeBase {
12060
12134
  ]);
12061
12135
  }
12062
12136
  }
12137
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
12138
+ if (this.variable) {
12139
+ return this.variable.getKnownFunctionAtPath(path, recursionTracker, origin);
12140
+ }
12141
+ if (this.isUndefined)
12142
+ return null;
12143
+ const propertyKey = this.getDynamicPropertyKey();
12144
+ if (propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
12145
+ if (propertyKey !== this.propertyKey)
12146
+ this.expressionsToBeDeoptimized.push(origin);
12147
+ return this.object.getKnownFunctionAtPath([propertyKey, ...path], recursionTracker, origin);
12148
+ }
12149
+ return null;
12150
+ }
12063
12151
  getLiteralValueAtPath(path, recursionTracker, origin) {
12064
12152
  if (this.variable) {
12065
12153
  return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
@@ -16874,6 +16962,9 @@ class ObjectExpression extends NodeBase {
16874
16962
  deoptimizePath(path) {
16875
16963
  this.getObjectEntity().deoptimizePath(path);
16876
16964
  }
16965
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
16966
+ return this.getObjectEntity().getKnownFunctionAtPath(path, recursionTracker, origin);
16967
+ }
16877
16968
  getLiteralValueAtPath(path, recursionTracker, origin) {
16878
16969
  return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
16879
16970
  }
@@ -18042,6 +18133,14 @@ class VariableDeclarator extends NodeBase {
18042
18133
  deoptimizePath(path) {
18043
18134
  this.id.deoptimizePath(path);
18044
18135
  }
18136
+ deoptimizeCache() {
18137
+ if (!this.hasDeoptimizedDisposal && this.init) {
18138
+ this.hasDeoptimizedDisposal = true;
18139
+ this.init.deoptimizePath(UNKNOWN_PATH);
18140
+ this.init.includePath(UNKNOWN_PATH, createInclusionContext());
18141
+ this.scope.context.requestTreeshakingPass();
18142
+ }
18143
+ }
18045
18144
  hasEffects(context) {
18046
18145
  const initEffect = this.init?.hasEffects(context);
18047
18146
  this.id.markDeclarationReached();
@@ -18057,6 +18156,11 @@ class VariableDeclarator extends NodeBase {
18057
18156
  const { id, init } = this;
18058
18157
  if (!this.included)
18059
18158
  this.includeNode(context);
18159
+ const { disposalCall, disposalFunction } = this;
18160
+ // Before including init so that newly included receiver paths are included in this pass
18161
+ if (disposalFunction && disposalCall) {
18162
+ disposalFunction.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, disposalCall, context);
18163
+ }
18060
18164
  init?.include(context, includeChildrenRecursively);
18061
18165
  id.markDeclarationReached();
18062
18166
  if (includeChildrenRecursively) {
@@ -18098,11 +18202,16 @@ class VariableDeclarator extends NodeBase {
18098
18202
  this.included = true;
18099
18203
  const { id, init } = this;
18100
18204
  if (init) {
18101
- if (this.isUsingDeclaration) {
18102
- init.includePath(SYMBOL_DISPOSE_PATH, context);
18103
- }
18104
- else if (this.isAsyncUsingDeclaration) {
18105
- init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context);
18205
+ if (this.isUsingDeclaration || this.isAsyncUsingDeclaration) {
18206
+ const disposalInteractions = {
18207
+ access: { args: [init], type: INTERACTION_ACCESSED },
18208
+ call: { args: [init], type: INTERACTION_CALLED, withNew: false }
18209
+ };
18210
+ if (this.isUsingDeclaration ||
18211
+ !this.includeDisposalMethodAndCheckIfKnownFunction(init, SYMBOL_ASYNC_DISPOSE_PATH, disposalInteractions, context)) {
18212
+ this.includeDisposalMethodAndCheckIfKnownFunction(init, SYMBOL_DISPOSE_PATH, disposalInteractions, context);
18213
+ }
18214
+ this.scope.context.requestTreeshakingPass();
18106
18215
  }
18107
18216
  if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
18108
18217
  const { name, variable } = id;
@@ -18114,6 +18223,23 @@ class VariableDeclarator extends NodeBase {
18114
18223
  }
18115
18224
  }
18116
18225
  }
18226
+ includeDisposalMethodAndCheckIfKnownFunction(init, path, { access, call }, context) {
18227
+ init.deoptimizeArgumentsOnInteractionAtPath(access, path, SHARED_RECURSION_TRACKER);
18228
+ const disposalFunction = init.getKnownFunctionAtPath(path, SHARED_RECURSION_TRACKER, this);
18229
+ init.includePath(path, context);
18230
+ if (!disposalFunction) {
18231
+ const disposalValue = init.getLiteralValueAtPath(path, SHARED_RECURSION_TRACKER, this);
18232
+ if (disposalValue !== null && disposalValue !== undefined) {
18233
+ init.deoptimizeArgumentsOnInteractionAtPath(call, path, SHARED_RECURSION_TRACKER);
18234
+ init.includeCallArgumentsWhenCalledAtPath(path, call, context);
18235
+ }
18236
+ return false;
18237
+ }
18238
+ this.disposalFunction = disposalFunction;
18239
+ this.disposalCall = call;
18240
+ disposalFunction.deoptimizeArgumentsOnInteractionAtPath(call, EMPTY_PATH, SHARED_RECURSION_TRACKER);
18241
+ return true;
18242
+ }
18117
18243
  }
18118
18244
  VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
18119
18245
  const SYMBOL_DISPOSE_PATH = [SymbolDispose];
@@ -19091,6 +19217,9 @@ function decodedSourcemap(map) {
19091
19217
  if (typeof map === 'string') {
19092
19218
  map = JSON.parse(map);
19093
19219
  }
19220
+ if ('sections' in map) {
19221
+ map = flattenIndexSourceMap(map);
19222
+ }
19094
19223
  if (!map.mappings) {
19095
19224
  return {
19096
19225
  mappings: [],
@@ -19126,6 +19255,74 @@ function decodedSourcemap(map) {
19126
19255
  sourceMapCache.set(decodedMap, cache);
19127
19256
  return decodedMap;
19128
19257
  }
19258
+ function flattenIndexSourceMap({ file, sections }) {
19259
+ const mappings = [];
19260
+ const names = [];
19261
+ const sources = [];
19262
+ const sourcesContent = [];
19263
+ // As when collapsing sourcemaps, sources with the same name are shared unless their contents differ
19264
+ const sourceIndicesByName = new Map();
19265
+ for (const { map, offset } of sections) {
19266
+ const section = decodedSourcemap(map);
19267
+ const { sourceRoot } = section;
19268
+ const sourcePrefix = sourceRoot
19269
+ ? sourceRoot.endsWith('/')
19270
+ ? sourceRoot
19271
+ : `${sourceRoot}/`
19272
+ : '';
19273
+ const sourceIndices = section.sources.map((source, index) => {
19274
+ const name = source == null || parseAst_js.isAbsolute(source) ? source : sourcePrefix + source;
19275
+ const content = section.sourcesContent?.[index] ?? null;
19276
+ let indices = sourceIndicesByName.get(name);
19277
+ if (!indices) {
19278
+ sourceIndicesByName.set(name, (indices = []));
19279
+ }
19280
+ let sourceIndex = indices.find(candidate => content == null ||
19281
+ sourcesContent[candidate] == null ||
19282
+ sourcesContent[candidate] === content);
19283
+ if (sourceIndex === undefined) {
19284
+ sourceIndex = sources.push(name) - 1;
19285
+ sourcesContent.push(content);
19286
+ indices.push(sourceIndex);
19287
+ }
19288
+ else {
19289
+ sourcesContent[sourceIndex] ??= content;
19290
+ }
19291
+ return sourceIndex;
19292
+ });
19293
+ const namesOffset = names.length;
19294
+ for (const name of section.names ?? []) {
19295
+ names.push(name);
19296
+ }
19297
+ for (const [lineIndex, line] of section.mappings.entries()) {
19298
+ const generatedLine = offset.line + lineIndex;
19299
+ while (mappings.length <= generatedLine) {
19300
+ mappings.push([]);
19301
+ }
19302
+ // Only the first line of a section starts at the column offset
19303
+ const columnOffset = lineIndex === 0 ? offset.column : 0;
19304
+ for (const segment of line) {
19305
+ const flatSegment = segment.slice();
19306
+ flatSegment[0] += columnOffset;
19307
+ if (flatSegment.length !== 1) {
19308
+ flatSegment[1] = sourceIndices[flatSegment[1]];
19309
+ if (flatSegment.length === 5) {
19310
+ flatSegment[4] += namesOffset;
19311
+ }
19312
+ }
19313
+ mappings[generatedLine].push(flatSegment);
19314
+ }
19315
+ }
19316
+ }
19317
+ return {
19318
+ file,
19319
+ mappings,
19320
+ names,
19321
+ sources,
19322
+ sourcesContent,
19323
+ version: 3
19324
+ };
19325
+ }
19129
19326
 
19130
19327
  function getId(m) {
19131
19328
  return m.id;
@@ -22867,7 +23064,10 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
22867
23064
  const sourcesContent = originalSourcemap.sourcesContent || [];
22868
23065
  const directory = path.dirname(id) || '.';
22869
23066
  const sourceRoot = originalSourcemap.sourceRoot || '.';
22870
- const baseSources = sources.map((source, index) => new Source(path.resolve(directory, sourceRoot, source), sourcesContent[index]));
23067
+ // A source whose name is not known is null, and mappings to it are treated as unmapped
23068
+ const baseSources = sources.map((source, index) => source == null
23069
+ ? null
23070
+ : new Source(path.resolve(directory, sourceRoot, source), sourcesContent[index]));
22871
23071
  source = new Link(originalSourcemap, baseSources);
22872
23072
  }
22873
23073
  else {
@@ -22900,13 +23100,17 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
22900
23100
  });
22901
23101
  }
22902
23102
  function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log) {
22903
- if (sourcemapChain.length === 0) {
23103
+ if (sourcemapChain.length === 0 &&
23104
+ (!originalSourcemap || hasOnlyNamedSources(originalSourcemap))) {
22904
23105
  return originalSourcemap;
22905
23106
  }
22906
23107
  const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(log));
22907
23108
  const map = source.traceMappings();
22908
23109
  return decodedSourcemap({ version: 3, ...map });
22909
23110
  }
23111
+ function hasOnlyNamedSources(map) {
23112
+ return map.sources.every(source => source != null);
23113
+ }
22910
23114
 
22911
23115
  // this looks ridiculous, but it prevents sourcemap tooling from mistaking
22912
23116
  // this for an actual sourceMappingURL
@@ -23216,7 +23420,12 @@ class Bundle {
23216
23420
  await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onLog);
23217
23421
  }
23218
23422
  catch (error_) {
23219
- await this.pluginDriver.hookParallel('renderError', [error_]);
23423
+ try {
23424
+ await this.pluginDriver.hookParallel('renderError', [error_]);
23425
+ }
23426
+ catch (hookError) {
23427
+ parseAst_js.error(parseAst_js.logErrorInHook(error_, hookError, 'renderError'));
23428
+ }
23220
23429
  throw error_;
23221
23430
  }
23222
23431
  removeUnreferencedAssets(outputBundle);
@@ -24932,11 +25141,7 @@ async function rollupInternal(rawInputOptions, registerWatchHooks) {
24932
25141
  await graph.pluginDriver.hookParallel('buildEnd', [error_]);
24933
25142
  }
24934
25143
  catch (buildEndError) {
24935
- // Create a compound error object to include both errors, based on the original error
24936
- const compoundError = parseAst_js.getRollupError({
24937
- ...error_,
24938
- 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}`
24939
- });
25144
+ const compoundError = parseAst_js.getRollupError(parseAst_js.logErrorInHook(error_, buildEndError, 'buildEnd'));
24940
25145
  await graph.pluginDriver.hookParallel('closeBundle', [compoundError]).catch(() => { });
24941
25146
  throw compoundError;
24942
25147
  }