@rollup/wasm-node 4.62.4 → 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.
- package/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +303 -174
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +6 -54
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +6 -54
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +302 -173
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm.js +4 -4
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +21 -21
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
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,
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 (
|
|
902
|
-
if (
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
985
|
-
if (start > end) throw new
|
|
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
|
|
1009
|
-
if (start > end) throw new
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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) =>
|
|
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) =>
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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
|
|
6167
|
-
this.
|
|
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
|
|
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
|
-
|
|
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() {
|
|
@@ -6691,6 +6904,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6691
6904
|
render(code, options, nodeRenderOptions) {
|
|
6692
6905
|
const { start, end } = nodeRenderOptions;
|
|
6693
6906
|
const declarationStart = getDeclarationStart(code.original, this.start);
|
|
6907
|
+
let needsTrailingSemicolon = false;
|
|
6694
6908
|
if (this.declaration instanceof FunctionDeclaration) {
|
|
6695
6909
|
this.renderNamedDeclaration(code, declarationStart, this.declaration.id === null
|
|
6696
6910
|
? getFunctionIdInsertPosition(code.original, declarationStart)
|
|
@@ -6707,7 +6921,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6707
6921
|
return;
|
|
6708
6922
|
}
|
|
6709
6923
|
else if (this.variable.included) {
|
|
6710
|
-
this.renderVariableDeclaration(code, declarationStart, options);
|
|
6924
|
+
needsTrailingSemicolon = this.renderVariableDeclaration(code, declarationStart, options);
|
|
6711
6925
|
}
|
|
6712
6926
|
else {
|
|
6713
6927
|
code.remove(this.start, declarationStart);
|
|
@@ -6720,6 +6934,12 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6720
6934
|
return;
|
|
6721
6935
|
}
|
|
6722
6936
|
this.declaration.render(code, options);
|
|
6937
|
+
if (needsTrailingSemicolon) {
|
|
6938
|
+
// This needs to happen after the declaration was rendered as rendering can
|
|
6939
|
+
// replace the entire declaration, which would drop anything appended to the
|
|
6940
|
+
// left of its end.
|
|
6941
|
+
code.appendLeft(this.end, ';');
|
|
6942
|
+
}
|
|
6723
6943
|
}
|
|
6724
6944
|
renderNamedDeclaration(code, declarationStart, idInsertPosition, options) {
|
|
6725
6945
|
const { exportNamesByVariable, format, snippets: { getPropertyAccess } } = options;
|
|
@@ -6735,19 +6955,18 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6735
6955
|
code.appendLeft(this.end, ` ${getSystemExportStatement([this.variable], options)};`);
|
|
6736
6956
|
}
|
|
6737
6957
|
}
|
|
6958
|
+
// Returns whether a semicolon still needs to be appended after the declaration
|
|
6959
|
+
// was rendered.
|
|
6738
6960
|
renderVariableDeclaration(code, declarationStart, { format, exportNamesByVariable, snippets: { cnst, getPropertyAccess } }) {
|
|
6739
6961
|
const hasTrailingSemicolon = code.original.charCodeAt(this.end - 1) === 59; /*";"*/
|
|
6740
6962
|
const systemExportNames = format === 'system' && exportNamesByVariable.get(this.variable);
|
|
6741
6963
|
if (systemExportNames) {
|
|
6742
6964
|
code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(systemExportNames[0])}, `);
|
|
6743
6965
|
code.appendRight(hasTrailingSemicolon ? this.end - 1 : this.end, ')' + (hasTrailingSemicolon ? '' : ';'));
|
|
6966
|
+
return false;
|
|
6744
6967
|
}
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
if (!hasTrailingSemicolon) {
|
|
6748
|
-
code.appendLeft(this.end, ';');
|
|
6749
|
-
}
|
|
6750
|
-
}
|
|
6968
|
+
code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = `);
|
|
6969
|
+
return !hasTrailingSemicolon;
|
|
6751
6970
|
}
|
|
6752
6971
|
}
|
|
6753
6972
|
ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
@@ -7305,7 +7524,7 @@ class MemberExpression extends NodeBase {
|
|
|
7305
7524
|
if (!this.included)
|
|
7306
7525
|
this.includeNode(context);
|
|
7307
7526
|
if (this.variable) {
|
|
7308
|
-
this.variable
|
|
7527
|
+
this.variable.includePath(path, context);
|
|
7309
7528
|
}
|
|
7310
7529
|
else if (!this.isUndefined) {
|
|
7311
7530
|
this.object.includePath([
|
|
@@ -10132,33 +10351,9 @@ function requireParse () {
|
|
|
10132
10351
|
};
|
|
10133
10352
|
|
|
10134
10353
|
const extglobClose = token => {
|
|
10135
|
-
|
|
10354
|
+
input.slice(token.startIndex, state.index + 1);
|
|
10136
10355
|
const body = input.slice(token.startIndex + 2, state.index);
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
10140
|
-
const safeOutput = analysis.safeOutput
|
|
10141
|
-
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
10142
|
-
: undefined;
|
|
10143
|
-
const open = tokens[token.tokensIndex];
|
|
10144
|
-
|
|
10145
|
-
open.type = 'text';
|
|
10146
|
-
open.value = literal;
|
|
10147
|
-
open.output = safeOutput || utils.escapeRegex(literal);
|
|
10148
|
-
|
|
10149
|
-
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
10150
|
-
tokens[i].value = '';
|
|
10151
|
-
tokens[i].output = '';
|
|
10152
|
-
delete tokens[i].suffix;
|
|
10153
|
-
}
|
|
10154
|
-
|
|
10155
|
-
state.output = token.output + open.output;
|
|
10156
|
-
state.backtrack = true;
|
|
10157
|
-
|
|
10158
|
-
push({ type: 'paren', extglob: true, value, output: '' });
|
|
10159
|
-
decrement('parens');
|
|
10160
|
-
return;
|
|
10161
|
-
}
|
|
10356
|
+
analyzeRepeatedExtglob(body, opts);
|
|
10162
10357
|
|
|
10163
10358
|
let output = token.close + (opts.capture ? ')' : '');
|
|
10164
10359
|
let rest;
|
|
@@ -12035,11 +12230,10 @@ const binaryOperators = {
|
|
|
12035
12230
|
// in: () => UnknownValue,
|
|
12036
12231
|
// instanceof: () => UnknownValue,
|
|
12037
12232
|
};
|
|
12038
|
-
const UNASSIGNED$1 = Symbol('Unassigned');
|
|
12039
12233
|
class BinaryExpression extends NodeBase {
|
|
12040
12234
|
constructor() {
|
|
12041
12235
|
super(...arguments);
|
|
12042
|
-
this.renderedLiteralValue = UNASSIGNED
|
|
12236
|
+
this.renderedLiteralValue = UNASSIGNED;
|
|
12043
12237
|
}
|
|
12044
12238
|
deoptimizeCache() {
|
|
12045
12239
|
this.renderedLiteralValue = UnknownValue;
|
|
@@ -12072,7 +12266,7 @@ class BinaryExpression extends NodeBase {
|
|
|
12072
12266
|
if (this.operator !== 'in' || !(this.right.variable instanceof NamespaceVariable)) {
|
|
12073
12267
|
return UnknownValue;
|
|
12074
12268
|
}
|
|
12075
|
-
if (this.renderedLiteralValue !== UNASSIGNED
|
|
12269
|
+
if (this.renderedLiteralValue !== UNASSIGNED)
|
|
12076
12270
|
return this.renderedLiteralValue;
|
|
12077
12271
|
return (this.renderedLiteralValue = getRenderedLiteralValue(this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
12078
12272
|
}
|
|
@@ -12207,10 +12401,10 @@ class CallExpressionBase extends NodeBase {
|
|
|
12207
12401
|
}
|
|
12208
12402
|
deoptimizeCache() {
|
|
12209
12403
|
if (this.returnExpression?.[0] !== UNKNOWN_EXPRESSION) {
|
|
12210
|
-
this.returnExpression =
|
|
12404
|
+
this.returnExpression = null;
|
|
12211
12405
|
const { deoptimizableDependentExpressions, expressionsToBeDeoptimized } = this;
|
|
12212
|
-
this.expressionsToBeDeoptimized =
|
|
12213
|
-
this.deoptimizableDependentExpressions =
|
|
12406
|
+
this.expressionsToBeDeoptimized = new Set();
|
|
12407
|
+
this.deoptimizableDependentExpressions = [];
|
|
12214
12408
|
for (const expression of deoptimizableDependentExpressions) {
|
|
12215
12409
|
expression.deoptimizeCache();
|
|
12216
12410
|
}
|
|
@@ -12236,7 +12430,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
12236
12430
|
}
|
|
12237
12431
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
12238
12432
|
this.deoptimizableDependentExpressions.push(origin);
|
|
12239
|
-
return returnExpression.getLiteralValueAtPath(path, recursionTracker,
|
|
12433
|
+
return returnExpression.getLiteralValueAtPath(path, recursionTracker, this);
|
|
12240
12434
|
}, UnknownValue);
|
|
12241
12435
|
}
|
|
12242
12436
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -12348,11 +12542,6 @@ class CallExpression extends CallExpressionBase {
|
|
|
12348
12542
|
this.callee.includeCallArguments(this.interaction, context);
|
|
12349
12543
|
}
|
|
12350
12544
|
}
|
|
12351
|
-
includeNode(_context) {
|
|
12352
|
-
this.included = true;
|
|
12353
|
-
if (!this.deoptimized)
|
|
12354
|
-
this.applyDeoptimizations();
|
|
12355
|
-
}
|
|
12356
12545
|
initialise() {
|
|
12357
12546
|
super.initialise();
|
|
12358
12547
|
if (this.annotations &&
|
|
@@ -12384,12 +12573,13 @@ class CallExpression extends CallExpressionBase {
|
|
|
12384
12573
|
}
|
|
12385
12574
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
12386
12575
|
if (this.returnExpression === null) {
|
|
12387
|
-
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
12388
|
-
|
|
12576
|
+
this.returnExpression = UNKNOWN_RETURN_EXPRESSION; // In case of recursion
|
|
12577
|
+
this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this);
|
|
12389
12578
|
}
|
|
12390
12579
|
return this.returnExpression;
|
|
12391
12580
|
}
|
|
12392
12581
|
}
|
|
12582
|
+
CallExpression.prototype.includeNode = onlyIncludeSelf;
|
|
12393
12583
|
|
|
12394
12584
|
class CatchClause extends NodeBase {
|
|
12395
12585
|
createScope(parentScope) {
|
|
@@ -12489,31 +12679,6 @@ function tryCastLiteralValueToBoolean(literalValue) {
|
|
|
12489
12679
|
return !!literalValue;
|
|
12490
12680
|
}
|
|
12491
12681
|
|
|
12492
|
-
class MultiExpression extends ExpressionEntity {
|
|
12493
|
-
constructor(expressions) {
|
|
12494
|
-
super();
|
|
12495
|
-
this.expressions = expressions;
|
|
12496
|
-
}
|
|
12497
|
-
deoptimizePath(path) {
|
|
12498
|
-
for (const expression of this.expressions) {
|
|
12499
|
-
expression.deoptimizePath(path);
|
|
12500
|
-
}
|
|
12501
|
-
}
|
|
12502
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
12503
|
-
return [
|
|
12504
|
-
new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0])),
|
|
12505
|
-
false
|
|
12506
|
-
];
|
|
12507
|
-
}
|
|
12508
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
12509
|
-
for (const expression of this.expressions) {
|
|
12510
|
-
if (expression.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
12511
|
-
return true;
|
|
12512
|
-
}
|
|
12513
|
-
return false;
|
|
12514
|
-
}
|
|
12515
|
-
}
|
|
12516
|
-
|
|
12517
12682
|
class ConditionalExpression extends NodeBase {
|
|
12518
12683
|
constructor() {
|
|
12519
12684
|
super(...arguments);
|
|
@@ -13017,14 +13182,13 @@ class TrackingScope extends BlockScope {
|
|
|
13017
13182
|
}
|
|
13018
13183
|
}
|
|
13019
13184
|
|
|
13020
|
-
const unset = Symbol('unset');
|
|
13021
13185
|
class IfStatement extends NodeBase {
|
|
13022
13186
|
constructor() {
|
|
13023
13187
|
super(...arguments);
|
|
13024
|
-
this.testValue =
|
|
13188
|
+
this.testValue = UNASSIGNED;
|
|
13025
13189
|
}
|
|
13026
13190
|
deoptimizeCache() {
|
|
13027
|
-
this.testValue =
|
|
13191
|
+
this.testValue = UNASSIGNED;
|
|
13028
13192
|
}
|
|
13029
13193
|
hasEffects(context) {
|
|
13030
13194
|
if (this.test.hasEffects(context)) {
|
|
@@ -13113,8 +13277,8 @@ class IfStatement extends NodeBase {
|
|
|
13113
13277
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
13114
13278
|
}
|
|
13115
13279
|
getTestValue() {
|
|
13116
|
-
if (this.testValue ===
|
|
13117
|
-
|
|
13280
|
+
if (this.testValue === UNASSIGNED) {
|
|
13281
|
+
this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
13118
13282
|
}
|
|
13119
13283
|
return this.testValue;
|
|
13120
13284
|
}
|
|
@@ -14768,38 +14932,6 @@ class PropertyDefinition extends NodeBase {
|
|
|
14768
14932
|
}
|
|
14769
14933
|
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14770
14934
|
|
|
14771
|
-
class ReturnStatement extends NodeBase {
|
|
14772
|
-
hasEffects(context) {
|
|
14773
|
-
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
14774
|
-
return true;
|
|
14775
|
-
context.brokenFlow = true;
|
|
14776
|
-
return false;
|
|
14777
|
-
}
|
|
14778
|
-
include(context, includeChildrenRecursively) {
|
|
14779
|
-
if (!this.included)
|
|
14780
|
-
this.includeNode(context);
|
|
14781
|
-
this.argument?.include(context, includeChildrenRecursively);
|
|
14782
|
-
context.brokenFlow = true;
|
|
14783
|
-
}
|
|
14784
|
-
includeNode(context) {
|
|
14785
|
-
this.included = true;
|
|
14786
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
14787
|
-
}
|
|
14788
|
-
initialise() {
|
|
14789
|
-
super.initialise();
|
|
14790
|
-
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
14791
|
-
}
|
|
14792
|
-
render(code, options) {
|
|
14793
|
-
if (this.argument) {
|
|
14794
|
-
this.argument.render(code, options, { preventASI: true });
|
|
14795
|
-
if (this.argument.start === this.start + 6 /* 'return'.length */) {
|
|
14796
|
-
code.prependLeft(this.start + 6, ' ');
|
|
14797
|
-
}
|
|
14798
|
-
}
|
|
14799
|
-
}
|
|
14800
|
-
}
|
|
14801
|
-
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14802
|
-
|
|
14803
14935
|
class SequenceExpression extends NodeBase {
|
|
14804
14936
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
14805
14937
|
this.expressions[this.expressions.length - 1].deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -15323,7 +15455,6 @@ const unaryOperators = {
|
|
|
15323
15455
|
void: () => undefined,
|
|
15324
15456
|
'~': value => ~value
|
|
15325
15457
|
};
|
|
15326
|
-
const UNASSIGNED = Symbol('Unassigned');
|
|
15327
15458
|
class UnaryExpression extends NodeBase {
|
|
15328
15459
|
constructor() {
|
|
15329
15460
|
super(...arguments);
|
|
@@ -19293,7 +19424,6 @@ class Chunk {
|
|
|
19293
19424
|
const usedModules = [];
|
|
19294
19425
|
let hoistedSource = '';
|
|
19295
19426
|
const accessedGlobals = new Set();
|
|
19296
|
-
const renderedModuleSources = new Map();
|
|
19297
19427
|
const renderOptions = {
|
|
19298
19428
|
accessedDocumentCurrentScript: false,
|
|
19299
19429
|
exportNamesByVariable,
|
|
@@ -19323,7 +19453,6 @@ class Chunk {
|
|
|
19323
19453
|
if (renderedLength) {
|
|
19324
19454
|
if (compact && source.lastLine().includes('//'))
|
|
19325
19455
|
source.append('\n');
|
|
19326
|
-
renderedModuleSources.set(module, source);
|
|
19327
19456
|
magicString.addSource(source);
|
|
19328
19457
|
usedModules.push(module);
|
|
19329
19458
|
}
|