rollup 4.62.5 → 4.63.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,13 +1,13 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.62.5
4
- Thu, 20 Aug 2026 16:59:36 GMT - commit c20402e2d4498a5861a4f49e00b2e7446c9900bb
3
+ Rollup.js v4.63.0
4
+ Tue, 25 Aug 2026 13:03:35 GMT - commit 34b8b924c815ec9413d7821f6fd54cc615584a51
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, 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, 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, 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, BLANK, Program as Program$1, logIllegalImportReassignment, 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, 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, EMPTY_SET, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_MANUALCHUNKS, 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.62.5";
30
+ var version = "4.63.0";
31
31
  const pkg = {
32
32
  version: version};
33
33
 
@@ -344,13 +344,27 @@ var Chunk$1 = class Chunk {
344
344
  }
345
345
  };
346
346
  //#endregion
347
+ //#region src/MagicStringError.ts
348
+ /**
349
+ * The single error type thrown by MagicString.
350
+ *
351
+ * Every message is prefixed with `[MagicString]` so its source is obvious at a
352
+ * glance, and is kept short and consistent in tone.
353
+ */
354
+ var MagicStringError = class extends Error {
355
+ name = "MagicStringError";
356
+ constructor(message, options) {
357
+ super(`[MagicString] ${message}`, options);
358
+ }
359
+ };
360
+ //#endregion
347
361
  //#region src/SourceMap.ts
348
362
  function getBtoa() {
349
363
  if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
350
364
  const buffer = globalThis["Buffer"];
351
365
  if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
352
366
  return () => {
353
- throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
367
+ throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
354
368
  };
355
369
  }
356
370
  const btoa = /* #__PURE__ */ getBtoa();
@@ -579,11 +593,11 @@ var MagicString = class MagicString {
579
593
  },
580
594
  byStart: {
581
595
  writable: true,
582
- value: {}
596
+ value: /* @__PURE__ */ new Map([[0, chunk]])
583
597
  },
584
598
  byEnd: {
585
599
  writable: true,
586
- value: {}
600
+ value: /* @__PURE__ */ new Map([[string.length, chunk]])
587
601
  },
588
602
  filename: {
589
603
  writable: true,
@@ -612,10 +626,12 @@ var MagicString = class MagicString {
612
626
  offset: {
613
627
  writable: true,
614
628
  value: options.offset || 0
629
+ },
630
+ hasMovedChunks: {
631
+ writable: true,
632
+ value: false
615
633
  }
616
634
  });
617
- this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
618
- this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
619
635
  }
620
636
  /**
621
637
  * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
@@ -627,7 +643,7 @@ var MagicString = class MagicString {
627
643
  * Appends the specified content to the end of the string.
628
644
  */
629
645
  append(content) {
630
- if (typeof content !== "string") throw new TypeError("outro content must be a string");
646
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
631
647
  this.outro += content;
632
648
  return this;
633
649
  }
@@ -638,7 +654,7 @@ var MagicString = class MagicString {
638
654
  */
639
655
  appendLeft(index, content) {
640
656
  index = index + this.offset;
641
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
657
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
642
658
  this._split(index);
643
659
  const chunk = this.byEnd.get(index);
644
660
  if (chunk) chunk.appendLeft(content);
@@ -652,7 +668,7 @@ var MagicString = class MagicString {
652
668
  */
653
669
  appendRight(index, content) {
654
670
  index = index + this.offset;
655
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
671
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
656
672
  this._split(index);
657
673
  const chunk = this.byStart.get(index);
658
674
  if (chunk) chunk.appendRight(content);
@@ -665,6 +681,7 @@ var MagicString = class MagicString {
665
681
  clone() {
666
682
  const cloned = new MagicString(this.original, {
667
683
  filename: this.filename,
684
+ ignoreList: this.ignoreList,
668
685
  offset: this.offset
669
686
  });
670
687
  let originalChunk = this.firstChunk;
@@ -684,8 +701,10 @@ var MagicString = class MagicString {
684
701
  cloned.lastChunk = clonedChunk;
685
702
  if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
686
703
  cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
704
+ cloned.storedNames = { ...this.storedNames };
687
705
  cloned.intro = this.intro;
688
706
  cloned.outro = this.outro;
707
+ cloned.hasMovedChunks = this.hasMovedChunks;
689
708
  return cloned;
690
709
  }
691
710
  /**
@@ -814,7 +833,7 @@ var MagicString = class MagicString {
814
833
  }
815
834
  /** @internal */
816
835
  insert() {
817
- throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
836
+ throw new MagicStringError("insert() is deprecated, use appendLeft() or prependRight()");
818
837
  }
819
838
  /** @internal */
820
839
  insertLeft(index, content) {
@@ -840,12 +859,19 @@ var MagicString = class MagicString {
840
859
  end = end + this.offset;
841
860
  index = index + this.offset;
842
861
  if (start === end) return this;
843
- if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
862
+ if (index >= start && index <= end) throw new MagicStringError("cannot move a selection inside itself");
844
863
  this._split(start);
845
864
  this._split(end);
846
865
  this._split(index);
847
866
  const first = this.byStart.get(start);
848
867
  const last = this.byEnd.get(end);
868
+ if (this.hasMovedChunks) {
869
+ let cursor = first;
870
+ while (cursor !== last) {
871
+ cursor = cursor.next;
872
+ if (!cursor || cursor.start < start || cursor.end > end) throw new MagicStringError(`cannot move ${start} to ${end} because an earlier move split that range`);
873
+ }
874
+ }
849
875
  const oldLeft = first.previous;
850
876
  const oldRight = last.next;
851
877
  const newRight = this.byStart.get(index);
@@ -864,6 +890,7 @@ var MagicString = class MagicString {
864
890
  last.next = newRight || null;
865
891
  if (!newLeft) this.firstChunk = first;
866
892
  if (!newRight) this.lastChunk = last;
893
+ this.hasMovedChunks = true;
867
894
  return this;
868
895
  }
869
896
  /**
@@ -893,13 +920,15 @@ var MagicString = class MagicString {
893
920
  update(start, end, content, options) {
894
921
  start = start + this.offset;
895
922
  end = end + this.offset;
896
- if (typeof content !== "string") throw new TypeError("replacement content must be a string");
923
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
897
924
  if (this.original.length !== 0) {
898
925
  while (start < 0) start += this.original.length;
899
926
  while (end < 0) end += this.original.length;
900
927
  }
901
- if (end > this.original.length) throw new Error("end is out of bounds");
902
- if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
928
+ if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
929
+ if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
930
+ if (start === end) throw new MagicStringError(`cannot overwrite a zero-length range at ${start}, use appendLeft() or prependRight()`);
931
+ if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
903
932
  this._split(start);
904
933
  this._split(end);
905
934
  if (options === true) {
@@ -925,7 +954,7 @@ var MagicString = class MagicString {
925
954
  if (first) {
926
955
  let chunk = first;
927
956
  while (chunk !== last) {
928
- if (chunk.next !== this.byStart.get(chunk.end)) throw new Error("Cannot overwrite across a split point");
957
+ if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
929
958
  chunk = chunk.next;
930
959
  chunk.edit("", false);
931
960
  }
@@ -941,7 +970,7 @@ var MagicString = class MagicString {
941
970
  * Prepends the string with the specified content.
942
971
  */
943
972
  prepend(content) {
944
- if (typeof content !== "string") throw new TypeError("outro content must be a string");
973
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
945
974
  this.intro = content + this.intro;
946
975
  return this;
947
976
  }
@@ -950,7 +979,7 @@ var MagicString = class MagicString {
950
979
  */
951
980
  prependLeft(index, content) {
952
981
  index = index + this.offset;
953
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
982
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
954
983
  this._split(index);
955
984
  const chunk = this.byEnd.get(index);
956
985
  if (chunk) chunk.prependLeft(content);
@@ -962,7 +991,7 @@ var MagicString = class MagicString {
962
991
  */
963
992
  prependRight(index, content) {
964
993
  index = index + this.offset;
965
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
994
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
966
995
  this._split(index);
967
996
  const chunk = this.byStart.get(index);
968
997
  if (chunk) chunk.prependRight(content);
@@ -981,8 +1010,8 @@ var MagicString = class MagicString {
981
1010
  while (end < 0) end += this.original.length;
982
1011
  }
983
1012
  if (start === end) return this;
984
- if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
985
- if (start > end) throw new Error("end must be greater than start");
1013
+ if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
1014
+ if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
986
1015
  this._split(start);
987
1016
  this._split(end);
988
1017
  let chunk = this.byStart.get(start);
@@ -1005,8 +1034,8 @@ var MagicString = class MagicString {
1005
1034
  while (end < 0) end += this.original.length;
1006
1035
  }
1007
1036
  if (start === end) return this;
1008
- if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
1009
- if (start > end) throw new Error("end must be greater than start");
1037
+ if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
1038
+ if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
1010
1039
  this._split(start);
1011
1040
  this._split(end);
1012
1041
  let chunk = this.byStart.get(start);
@@ -1072,12 +1101,12 @@ var MagicString = class MagicString {
1072
1101
  if (chunk.start < end && chunk.end >= end) return result;
1073
1102
  chunk = chunk.next;
1074
1103
  }
1075
- if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
1104
+ if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
1076
1105
  const startChunk = chunk;
1077
1106
  while (chunk) {
1078
1107
  if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
1079
1108
  const containsEnd = chunk.start < end && chunk.end >= end;
1080
- if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
1109
+ if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
1081
1110
  const sliceStart = startChunk === chunk ? start - chunk.start : 0;
1082
1111
  const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
1083
1112
  result += chunk.content.slice(sliceStart, sliceEnd);
@@ -1113,7 +1142,7 @@ var MagicString = class MagicString {
1113
1142
  _splitChunk(chunk, index) {
1114
1143
  if (chunk.edited && chunk.content.length) {
1115
1144
  const loc = getLocator(this.original)(index);
1116
- throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
1145
+ throw new MagicStringError(`cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
1117
1146
  }
1118
1147
  const newChunk = chunk.split(index);
1119
1148
  this.byEnd.set(index, chunk);
@@ -1225,7 +1254,19 @@ var MagicString = class MagicString {
1225
1254
  * Indicates if the string has been changed.
1226
1255
  */
1227
1256
  hasChanged() {
1228
- return this.original !== this.toString();
1257
+ if (this.intro || this.outro) return true;
1258
+ let outputIndex = 0;
1259
+ let chunk = this.firstChunk;
1260
+ while (chunk) {
1261
+ if (chunk.intro || chunk.outro) return true;
1262
+ if (!chunk.edited && chunk.start === outputIndex) outputIndex = chunk.end;
1263
+ else {
1264
+ if (!this.original.startsWith(chunk.content, outputIndex)) return true;
1265
+ outputIndex += chunk.content.length;
1266
+ }
1267
+ chunk = chunk.next;
1268
+ }
1269
+ return outputIndex !== this.original.length;
1229
1270
  }
1230
1271
  /** @internal */
1231
1272
  _replaceRegexp(searchValue, replacement) {
@@ -1295,7 +1336,7 @@ var MagicString = class MagicString {
1295
1336
  */
1296
1337
  replaceAll(searchValue, replacement) {
1297
1338
  if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
1298
- if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
1339
+ if (!searchValue.global) throw new MagicStringError("replaceAll() requires a global RegExp");
1299
1340
  return this._replaceRegexp(searchValue, replacement);
1300
1341
  }
1301
1342
  };
@@ -1326,7 +1367,7 @@ var Bundle$1 = class Bundle {
1326
1367
  filename: source.filename,
1327
1368
  separator: this.separator
1328
1369
  });
1329
- if (!isObject(source) || !source.content) throw new Error("bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`");
1370
+ if (!isObject(source) || !source.content) throw new MagicStringError("addSource() requires a `content` property that is a MagicString");
1330
1371
  [
1331
1372
  "filename",
1332
1373
  "ignoreList",
@@ -1344,7 +1385,7 @@ var Bundle$1 = class Bundle {
1344
1385
  });
1345
1386
  } else {
1346
1387
  const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
1347
- if (source.content.original !== uniqueSource.content) throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
1388
+ if (source.content.original !== uniqueSource.content) throw new MagicStringError(`duplicate filename "${source.filename}" with different content, use unique filenames`);
1348
1389
  }
1349
1390
  this.sources.push(source);
1350
1391
  return this;
@@ -1365,6 +1406,8 @@ var Bundle$1 = class Bundle {
1365
1406
  bundle.addSource({
1366
1407
  filename: source.filename,
1367
1408
  content: source.content.clone(),
1409
+ ignoreList: source.ignoreList,
1410
+ indentExclusionRanges: source.indentExclusionRanges,
1368
1411
  separator: source.separator
1369
1412
  });
1370
1413
  });
@@ -1381,7 +1424,7 @@ var Bundle$1 = class Bundle {
1381
1424
  const mappings = new Mappings(options.hires);
1382
1425
  if (this.intro) mappings.advance(this.intro);
1383
1426
  this.sources.forEach((source, i) => {
1384
- if (i > 0) mappings.advance(this.separator);
1427
+ if (i > 0) mappings.advance(source.separator !== void 0 ? source.separator : this.separator);
1385
1428
  const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
1386
1429
  const magicString = source.content;
1387
1430
  const locate = getLocator(magicString.original);
@@ -1459,11 +1502,17 @@ var Bundle$1 = class Bundle {
1459
1502
  }
1460
1503
  isEmpty() {
1461
1504
  if (this.intro.length && this.intro.trim()) return false;
1462
- if (this.sources.some((source) => !source.content.isEmpty())) return false;
1505
+ if (this.sources.some((source, i) => {
1506
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
1507
+ return i > 0 && separator.trim() !== "" || !source.content.isEmpty();
1508
+ })) return false;
1463
1509
  return true;
1464
1510
  }
1465
1511
  length() {
1466
- return this.sources.reduce((length, source) => length + source.content.length(), this.intro.length);
1512
+ return this.sources.reduce((length, source, i) => {
1513
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
1514
+ return length + (i > 0 ? separator.length : 0) + source.content.length();
1515
+ }, this.intro.length);
1467
1516
  }
1468
1517
  trimLines() {
1469
1518
  return this.trim("[\\r\\n]");
@@ -2024,8 +2073,17 @@ class ExpressionEntity {
2024
2073
  return true;
2025
2074
  }
2026
2075
  }
2027
- const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
2028
- })();
2076
+ class LiteralExpression extends ExpressionEntity {
2077
+ constructor(value, parent) {
2078
+ super();
2079
+ this.value = value;
2080
+ this.parent = parent;
2081
+ }
2082
+ getLiteralValueAtPath(path) {
2083
+ return path.length > 0 ? UnknownValue : this.value;
2084
+ }
2085
+ }
2086
+ const UNKNOWN_EXPRESSION = new LiteralExpression(UnknownValue);
2029
2087
  const UNKNOWN_RETURN_EXPRESSION = [
2030
2088
  UNKNOWN_EXPRESSION,
2031
2089
  false
@@ -2757,11 +2815,7 @@ function isExpressionStatementNode(node) {
2757
2815
  function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
2758
2816
  return Object.create(inheritedDescriptions, memberDescriptions);
2759
2817
  }
2760
- const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
2761
- getLiteralValueAtPath(path) {
2762
- return path.length > 0 ? UnknownValue : undefined;
2763
- }
2764
- })();
2818
+ const UNDEFINED_EXPRESSION = new LiteralExpression(undefined);
2765
2819
  const returnsUnknown = {
2766
2820
  value: {
2767
2821
  hasEffectsWhenCalled: null,
@@ -2942,7 +2996,7 @@ function getLiteralMembersForValue(value) {
2942
2996
  return literalStringMembers;
2943
2997
  }
2944
2998
  }
2945
- return Object.create(null);
2999
+ return BLANK;
2946
3000
  }
2947
3001
  function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
2948
3002
  if (typeof memberName !== 'string' || !members[memberName]) {
@@ -3242,6 +3296,8 @@ class ObjectEntity extends ExpressionEntity {
3242
3296
  // causes an issue with TypeScript enums in files with moduleSideEffects:
3243
3297
  // false because we cannot properly track whether a "var" has been
3244
3298
  // initialized. This should be reverted once we can properly track this.
3299
+ // ALSO needs to be updated once this is resolved:
3300
+ // - literals-from-return-expressions-branches/main.js
3245
3301
  // return UnknownTruthyValue;
3246
3302
  return UnknownValue;
3247
3303
  }
@@ -5954,6 +6010,156 @@ class ThisVariable extends ParameterVariable {
5954
6010
  }
5955
6011
  }
5956
6012
 
6013
+ const UNASSIGNED = Symbol('unassigned');
6014
+
6015
+ class ReturnStatement extends NodeBase {
6016
+ constructor() {
6017
+ super(...arguments);
6018
+ this.expressionsToBeDeoptimized = [];
6019
+ }
6020
+ checkReached(origin) {
6021
+ if (this.deoptimized)
6022
+ return true;
6023
+ this.expressionsToBeDeoptimized.push(origin);
6024
+ return false;
6025
+ }
6026
+ applyDeoptimizations() {
6027
+ this.deoptimized = true;
6028
+ const { expressionsToBeDeoptimized } = this;
6029
+ if (expressionsToBeDeoptimized.length) {
6030
+ this.expressionsToBeDeoptimized = EMPTY_ARRAY;
6031
+ for (const expression of expressionsToBeDeoptimized) {
6032
+ expression.deoptimizeCache();
6033
+ }
6034
+ this.scope.context.requestTreeshakingPass();
6035
+ }
6036
+ }
6037
+ hasEffects(context) {
6038
+ if (!this.deoptimized)
6039
+ this.applyDeoptimizations();
6040
+ if (!context.ignore.returnYield || this.argument?.hasEffects(context))
6041
+ return true;
6042
+ context.brokenFlow = true;
6043
+ return false;
6044
+ }
6045
+ include(context, includeChildrenRecursively) {
6046
+ if (!this.included)
6047
+ this.includeNode(context);
6048
+ this.argument?.include(context, includeChildrenRecursively);
6049
+ context.brokenFlow = true;
6050
+ }
6051
+ includeNode(context) {
6052
+ this.included = true;
6053
+ if (!this.deoptimized)
6054
+ this.applyDeoptimizations();
6055
+ this.argument?.includePath(UNKNOWN_PATH, context);
6056
+ }
6057
+ initialise() {
6058
+ super.initialise();
6059
+ this.scope.addReturnExpression(this.argument || new LiteralExpression(undefined, this));
6060
+ }
6061
+ render(code, options) {
6062
+ if (this.argument) {
6063
+ this.argument.render(code, options, { preventASI: true });
6064
+ if (this.argument.start === this.start + 6 /* 'return'.length */) {
6065
+ code.prependLeft(this.start + 6, ' ');
6066
+ }
6067
+ }
6068
+ }
6069
+ }
6070
+
6071
+ function mergeValues(a, b) {
6072
+ if (a === b)
6073
+ return a;
6074
+ if (a === UnknownTruthyValue) {
6075
+ if (b && b !== UnknownFalsyValue)
6076
+ return UnknownTruthyValue;
6077
+ return UnknownValue;
6078
+ }
6079
+ if (a === UnknownFalsyValue) {
6080
+ if (!b || b === UnknownFalsyValue)
6081
+ return UnknownFalsyValue;
6082
+ return UnknownValue;
6083
+ }
6084
+ if (a && b)
6085
+ return UnknownTruthyValue;
6086
+ if (!a && !b)
6087
+ return UnknownFalsyValue;
6088
+ return UnknownValue;
6089
+ }
6090
+ class MultiExpression extends ExpressionEntity {
6091
+ constructor(expressions) {
6092
+ super();
6093
+ this.expressions = expressions;
6094
+ this.literalValue = UNASSIGNED;
6095
+ this.dependantEntities = new Set();
6096
+ }
6097
+ deoptimizeCache() {
6098
+ if (this.literalValue !== UNASSIGNED) {
6099
+ const { dependantEntities } = this;
6100
+ this.literalValue = UNASSIGNED;
6101
+ this.dependantEntities = new Set();
6102
+ for (const entity of dependantEntities) {
6103
+ entity.deoptimizeCache();
6104
+ }
6105
+ }
6106
+ }
6107
+ deoptimizePath(path) {
6108
+ for (const expression of this.expressions) {
6109
+ expression.deoptimizePath(path);
6110
+ }
6111
+ }
6112
+ getLiteralValueAtPath(path, recursionTracker, origin) {
6113
+ if (path.length === 0) {
6114
+ if (this.literalValue === UNASSIGNED)
6115
+ this.literalValue = this.doGetLiteralValueAtPath(path, recursionTracker, this);
6116
+ this.dependantEntities.add(origin);
6117
+ return this.literalValue;
6118
+ }
6119
+ return this.doGetLiteralValueAtPath(path, recursionTracker, origin);
6120
+ }
6121
+ doGetLiteralValueAtPath(path, recursionTracker, origin) {
6122
+ let value = UnknownValue;
6123
+ for (const expression of this.expressions) {
6124
+ if (this.isTreeshaken(expression))
6125
+ continue;
6126
+ const expressionValue = expression.getLiteralValueAtPath(path, recursionTracker, origin);
6127
+ if (expressionValue === UnknownValue)
6128
+ return UnknownValue;
6129
+ if (value === UnknownValue) {
6130
+ value = expressionValue;
6131
+ continue;
6132
+ }
6133
+ value = mergeValues(value, expressionValue);
6134
+ if (value === UnknownValue)
6135
+ return UnknownValue;
6136
+ }
6137
+ return value;
6138
+ }
6139
+ getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
6140
+ const returnExpressions = this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin));
6141
+ let pure = true;
6142
+ return [
6143
+ new MultiExpression(returnExpressions.map(expression => ((pure &&= expression[1]), expression[0]))),
6144
+ pure
6145
+ ];
6146
+ }
6147
+ hasEffectsOnInteractionAtPath(path, interaction, context) {
6148
+ for (const expression of this.expressions) {
6149
+ if (!this.isTreeshaken(expression) &&
6150
+ expression.hasEffectsOnInteractionAtPath(path, interaction, context))
6151
+ return true;
6152
+ }
6153
+ return false;
6154
+ }
6155
+ isTreeshaken(expression) {
6156
+ if ('parent' in expression && expression.parent instanceof ReturnStatement) {
6157
+ return !expression.parent.checkReached(this);
6158
+ }
6159
+ return false;
6160
+ }
6161
+ }
6162
+
5957
6163
  class CatchBodyScope extends ChildScope {
5958
6164
  constructor(parent) {
5959
6165
  super(parent, parent.context);
@@ -6163,8 +6369,12 @@ class ReturnValueScope extends ParameterScope {
6163
6369
  }
6164
6370
  }
6165
6371
  getReturnExpression() {
6166
- if (this.returnExpression === null)
6167
- this.updateReturnExpression();
6372
+ if (!this.returnExpression) {
6373
+ this.returnExpression =
6374
+ this.returnExpressions.length === 1
6375
+ ? this.returnExpressions[0]
6376
+ : new MultiExpression(this.returnExpressions);
6377
+ }
6168
6378
  return this.returnExpression;
6169
6379
  }
6170
6380
  deoptimizeAllParameters() {
@@ -6183,17 +6393,6 @@ class ReturnValueScope extends ParameterScope {
6183
6393
  }
6184
6394
  }
6185
6395
  addArgumentToBeDeoptimized(_argument) { }
6186
- updateReturnExpression() {
6187
- if (this.returnExpressions.length === 1) {
6188
- this.returnExpression = this.returnExpressions[0];
6189
- }
6190
- else {
6191
- this.returnExpression = UNKNOWN_EXPRESSION;
6192
- for (const expression of this.returnExpressions) {
6193
- expression.deoptimizePath(UNKNOWN_PATH);
6194
- }
6195
- }
6196
- }
6197
6396
  }
6198
6397
 
6199
6398
  class FunctionScope extends ReturnValueScope {
@@ -6255,6 +6454,10 @@ ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
6255
6454
  ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
6256
6455
 
6257
6456
  class BlockStatement extends NodeBase {
6457
+ constructor() {
6458
+ super(...arguments);
6459
+ this.virtualReturnStatement = null;
6460
+ }
6258
6461
  get deoptimizeBody() {
6259
6462
  return isFlagSet(this.flags, 32768 /* Flag.deoptimizeBody */);
6260
6463
  }
@@ -6270,7 +6473,13 @@ class BlockStatement extends NodeBase {
6270
6473
  addImplicitReturnExpressionToScope() {
6271
6474
  const lastStatement = this.body[this.body.length - 1];
6272
6475
  if (!lastStatement || lastStatement.type !== ReturnStatement$1) {
6273
- this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
6476
+ const virtualReturnStatement = new ReturnStatement(this, this.scope);
6477
+ virtualReturnStatement.type = ReturnStatement$1;
6478
+ virtualReturnStatement.argument = null;
6479
+ virtualReturnStatement.initialise();
6480
+ if (this.deoptimizeBody)
6481
+ virtualReturnStatement.includeNode(createInclusionContext());
6482
+ this.virtualReturnStatement = virtualReturnStatement;
6274
6483
  }
6275
6484
  }
6276
6485
  createScope(parentScope) {
@@ -6281,13 +6490,15 @@ class BlockStatement extends NodeBase {
6281
6490
  hasEffects(context) {
6282
6491
  if (this.deoptimizeBody)
6283
6492
  return true;
6493
+ let hasEffect = false;
6284
6494
  for (const node of this.body) {
6285
- if (context.brokenFlow)
6495
+ if (context.brokenFlow || (hasEffect = node.hasEffects(context)))
6286
6496
  break;
6287
- if (node.hasEffects(context))
6288
- return true;
6289
6497
  }
6290
- return false;
6498
+ if (!context.brokenFlow) {
6499
+ hasEffect ||= !!this.virtualReturnStatement?.hasEffects(context);
6500
+ }
6501
+ return hasEffect;
6291
6502
  }
6292
6503
  include(context, includeChildrenRecursively) {
6293
6504
  if (!(this.deoptimizeBody && this.directlyIncluded)) {
@@ -6299,6 +6510,8 @@ class BlockStatement extends NodeBase {
6299
6510
  if (includeChildrenRecursively || node.shouldBeIncluded(context))
6300
6511
  node.include(context, includeChildrenRecursively);
6301
6512
  }
6513
+ if (includeChildrenRecursively || !context.brokenFlow)
6514
+ this.virtualReturnStatement?.include(context, includeChildrenRecursively);
6302
6515
  }
6303
6516
  }
6304
6517
  initialise() {
@@ -7311,7 +7524,7 @@ class MemberExpression extends NodeBase {
7311
7524
  if (!this.included)
7312
7525
  this.includeNode(context);
7313
7526
  if (this.variable) {
7314
- this.variable?.includePath(path, context);
7527
+ this.variable.includePath(path, context);
7315
7528
  }
7316
7529
  else if (!this.isUndefined) {
7317
7530
  this.object.includePath([
@@ -10138,33 +10351,9 @@ function requireParse () {
10138
10351
  };
10139
10352
 
10140
10353
  const extglobClose = token => {
10141
- const literal = input.slice(token.startIndex, state.index + 1);
10354
+ input.slice(token.startIndex, state.index + 1);
10142
10355
  const body = input.slice(token.startIndex + 2, state.index);
10143
- const analysis = analyzeRepeatedExtglob(body, opts);
10144
-
10145
- if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
10146
- const safeOutput = analysis.safeOutput
10147
- ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
10148
- : undefined;
10149
- const open = tokens[token.tokensIndex];
10150
-
10151
- open.type = 'text';
10152
- open.value = literal;
10153
- open.output = safeOutput || utils.escapeRegex(literal);
10154
-
10155
- for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
10156
- tokens[i].value = '';
10157
- tokens[i].output = '';
10158
- delete tokens[i].suffix;
10159
- }
10160
-
10161
- state.output = token.output + open.output;
10162
- state.backtrack = true;
10163
-
10164
- push({ type: 'paren', extglob: true, value, output: '' });
10165
- decrement('parens');
10166
- return;
10167
- }
10356
+ analyzeRepeatedExtglob(body, opts);
10168
10357
 
10169
10358
  let output = token.close + (opts.capture ? ')' : '');
10170
10359
  let rest;
@@ -12041,11 +12230,10 @@ const binaryOperators = {
12041
12230
  // in: () => UnknownValue,
12042
12231
  // instanceof: () => UnknownValue,
12043
12232
  };
12044
- const UNASSIGNED$1 = Symbol('Unassigned');
12045
12233
  class BinaryExpression extends NodeBase {
12046
12234
  constructor() {
12047
12235
  super(...arguments);
12048
- this.renderedLiteralValue = UNASSIGNED$1;
12236
+ this.renderedLiteralValue = UNASSIGNED;
12049
12237
  }
12050
12238
  deoptimizeCache() {
12051
12239
  this.renderedLiteralValue = UnknownValue;
@@ -12078,7 +12266,7 @@ class BinaryExpression extends NodeBase {
12078
12266
  if (this.operator !== 'in' || !(this.right.variable instanceof NamespaceVariable)) {
12079
12267
  return UnknownValue;
12080
12268
  }
12081
- if (this.renderedLiteralValue !== UNASSIGNED$1)
12269
+ if (this.renderedLiteralValue !== UNASSIGNED)
12082
12270
  return this.renderedLiteralValue;
12083
12271
  return (this.renderedLiteralValue = getRenderedLiteralValue(this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
12084
12272
  }
@@ -12213,10 +12401,10 @@ class CallExpressionBase extends NodeBase {
12213
12401
  }
12214
12402
  deoptimizeCache() {
12215
12403
  if (this.returnExpression?.[0] !== UNKNOWN_EXPRESSION) {
12216
- this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
12404
+ this.returnExpression = null;
12217
12405
  const { deoptimizableDependentExpressions, expressionsToBeDeoptimized } = this;
12218
- this.expressionsToBeDeoptimized = EMPTY_SET;
12219
- this.deoptimizableDependentExpressions = EMPTY_ARRAY;
12406
+ this.expressionsToBeDeoptimized = new Set();
12407
+ this.deoptimizableDependentExpressions = [];
12220
12408
  for (const expression of deoptimizableDependentExpressions) {
12221
12409
  expression.deoptimizeCache();
12222
12410
  }
@@ -12242,7 +12430,7 @@ class CallExpressionBase extends NodeBase {
12242
12430
  }
12243
12431
  return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
12244
12432
  this.deoptimizableDependentExpressions.push(origin);
12245
- return returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
12433
+ return returnExpression.getLiteralValueAtPath(path, recursionTracker, this);
12246
12434
  }, UnknownValue);
12247
12435
  }
12248
12436
  getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
@@ -12354,11 +12542,6 @@ class CallExpression extends CallExpressionBase {
12354
12542
  this.callee.includeCallArguments(this.interaction, context);
12355
12543
  }
12356
12544
  }
12357
- includeNode(_context) {
12358
- this.included = true;
12359
- if (!this.deoptimized)
12360
- this.applyDeoptimizations();
12361
- }
12362
12545
  initialise() {
12363
12546
  super.initialise();
12364
12547
  if (this.annotations &&
@@ -12390,12 +12573,13 @@ class CallExpression extends CallExpressionBase {
12390
12573
  }
12391
12574
  getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
12392
12575
  if (this.returnExpression === null) {
12393
- this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
12394
- return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
12576
+ this.returnExpression = UNKNOWN_RETURN_EXPRESSION; // In case of recursion
12577
+ this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this);
12395
12578
  }
12396
12579
  return this.returnExpression;
12397
12580
  }
12398
12581
  }
12582
+ CallExpression.prototype.includeNode = onlyIncludeSelf;
12399
12583
 
12400
12584
  class CatchClause extends NodeBase {
12401
12585
  createScope(parentScope) {
@@ -12495,31 +12679,6 @@ function tryCastLiteralValueToBoolean(literalValue) {
12495
12679
  return !!literalValue;
12496
12680
  }
12497
12681
 
12498
- class MultiExpression extends ExpressionEntity {
12499
- constructor(expressions) {
12500
- super();
12501
- this.expressions = expressions;
12502
- }
12503
- deoptimizePath(path) {
12504
- for (const expression of this.expressions) {
12505
- expression.deoptimizePath(path);
12506
- }
12507
- }
12508
- getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
12509
- return [
12510
- new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0])),
12511
- false
12512
- ];
12513
- }
12514
- hasEffectsOnInteractionAtPath(path, interaction, context) {
12515
- for (const expression of this.expressions) {
12516
- if (expression.hasEffectsOnInteractionAtPath(path, interaction, context))
12517
- return true;
12518
- }
12519
- return false;
12520
- }
12521
- }
12522
-
12523
12682
  class ConditionalExpression extends NodeBase {
12524
12683
  constructor() {
12525
12684
  super(...arguments);
@@ -13023,14 +13182,13 @@ class TrackingScope extends BlockScope {
13023
13182
  }
13024
13183
  }
13025
13184
 
13026
- const unset = Symbol('unset');
13027
13185
  class IfStatement extends NodeBase {
13028
13186
  constructor() {
13029
13187
  super(...arguments);
13030
- this.testValue = unset;
13188
+ this.testValue = UNASSIGNED;
13031
13189
  }
13032
13190
  deoptimizeCache() {
13033
- this.testValue = UnknownValue;
13191
+ this.testValue = UNASSIGNED;
13034
13192
  }
13035
13193
  hasEffects(context) {
13036
13194
  if (this.test.hasEffects(context)) {
@@ -13119,8 +13277,8 @@ class IfStatement extends NodeBase {
13119
13277
  this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
13120
13278
  }
13121
13279
  getTestValue() {
13122
- if (this.testValue === unset) {
13123
- return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
13280
+ if (this.testValue === UNASSIGNED) {
13281
+ this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
13124
13282
  }
13125
13283
  return this.testValue;
13126
13284
  }
@@ -14774,38 +14932,6 @@ class PropertyDefinition extends NodeBase {
14774
14932
  }
14775
14933
  PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
14776
14934
 
14777
- class ReturnStatement extends NodeBase {
14778
- hasEffects(context) {
14779
- if (!context.ignore.returnYield || this.argument?.hasEffects(context))
14780
- return true;
14781
- context.brokenFlow = true;
14782
- return false;
14783
- }
14784
- include(context, includeChildrenRecursively) {
14785
- if (!this.included)
14786
- this.includeNode(context);
14787
- this.argument?.include(context, includeChildrenRecursively);
14788
- context.brokenFlow = true;
14789
- }
14790
- includeNode(context) {
14791
- this.included = true;
14792
- this.argument?.includePath(UNKNOWN_PATH, context);
14793
- }
14794
- initialise() {
14795
- super.initialise();
14796
- this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
14797
- }
14798
- render(code, options) {
14799
- if (this.argument) {
14800
- this.argument.render(code, options, { preventASI: true });
14801
- if (this.argument.start === this.start + 6 /* 'return'.length */) {
14802
- code.prependLeft(this.start + 6, ' ');
14803
- }
14804
- }
14805
- }
14806
- }
14807
- ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
14808
-
14809
14935
  class SequenceExpression extends NodeBase {
14810
14936
  deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
14811
14937
  this.expressions[this.expressions.length - 1].deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
@@ -15329,7 +15455,6 @@ const unaryOperators = {
15329
15455
  void: () => undefined,
15330
15456
  '~': value => ~value
15331
15457
  };
15332
- const UNASSIGNED = Symbol('Unassigned');
15333
15458
  class UnaryExpression extends NodeBase {
15334
15459
  constructor() {
15335
15460
  super(...arguments);
@@ -19299,7 +19424,6 @@ class Chunk {
19299
19424
  const usedModules = [];
19300
19425
  let hoistedSource = '';
19301
19426
  const accessedGlobals = new Set();
19302
- const renderedModuleSources = new Map();
19303
19427
  const renderOptions = {
19304
19428
  accessedDocumentCurrentScript: false,
19305
19429
  exportNamesByVariable,
@@ -19329,7 +19453,6 @@ class Chunk {
19329
19453
  if (renderedLength) {
19330
19454
  if (compact && source.lastLine().includes('//'))
19331
19455
  source.append('\n');
19332
- renderedModuleSources.set(module, source);
19333
19456
  magicString.addSource(source);
19334
19457
  usedModules.push(module);
19335
19458
  }