rollup 4.63.0 → 4.63.2
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 +21 -12
- package/dist/es/getLogFilter.js +3 -3
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +247 -299
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +54 -6
- package/dist/getLogFilter.js +3 -3
- 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 +54 -6
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +246 -298
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +49 -49
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.63.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.63.2
|
|
4
|
+
Sat, 12 Sep 2026 06:36:48 GMT - commit 43ed4ec364940fbce7054d8da1f92c695d1e6808
|
|
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,
|
|
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';
|
|
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.63.
|
|
30
|
+
var version = "4.63.2";
|
|
31
31
|
const pkg = {
|
|
32
32
|
version: version};
|
|
33
33
|
|
|
@@ -42,7 +42,7 @@ for (let i = 0; i < chars$1.length; i++) {
|
|
|
42
42
|
intToChar[i] = c;
|
|
43
43
|
charToInt[c] = i;
|
|
44
44
|
}
|
|
45
|
-
function decodeInteger(reader
|
|
45
|
+
function decodeInteger(reader) {
|
|
46
46
|
let value = 0;
|
|
47
47
|
let shift = 0;
|
|
48
48
|
let integer = 0;
|
|
@@ -52,23 +52,21 @@ function decodeInteger(reader, relative) {
|
|
|
52
52
|
value |= (integer & 31) << shift;
|
|
53
53
|
shift += 5;
|
|
54
54
|
} while (integer & 32);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
return relative + value;
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
function decodeSign(num) {
|
|
58
|
+
return num & 1 ? -2147483648 | -(num >>> 1) : num >>> 1;
|
|
61
59
|
}
|
|
62
|
-
function encodeInteger(builder, num
|
|
63
|
-
let delta = num - relative;
|
|
64
|
-
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
60
|
+
function encodeInteger(builder, num) {
|
|
65
61
|
do {
|
|
66
|
-
let clamped =
|
|
67
|
-
|
|
68
|
-
if (
|
|
62
|
+
let clamped = num & 31;
|
|
63
|
+
num >>>= 5;
|
|
64
|
+
if (num > 0) clamped |= 32;
|
|
69
65
|
builder.write(intToChar[clamped]);
|
|
70
|
-
} while (
|
|
71
|
-
|
|
66
|
+
} while (num > 0);
|
|
67
|
+
}
|
|
68
|
+
function encodeSign(num) {
|
|
69
|
+
return num < 0 ? -num << 1 | 1 : num << 1;
|
|
72
70
|
}
|
|
73
71
|
function hasMoreVlq(reader, max) {
|
|
74
72
|
if (reader.pos >= max) return false;
|
|
@@ -146,15 +144,15 @@ function decode(mappings) {
|
|
|
146
144
|
genColumn = 0;
|
|
147
145
|
while (reader.pos < semi) {
|
|
148
146
|
let seg;
|
|
149
|
-
genColumn
|
|
147
|
+
genColumn += decodeSign(decodeInteger(reader));
|
|
150
148
|
if (genColumn < lastCol) sorted = false;
|
|
151
149
|
lastCol = genColumn;
|
|
152
150
|
if (hasMoreVlq(reader, semi)) {
|
|
153
|
-
sourcesIndex
|
|
154
|
-
sourceLine
|
|
155
|
-
sourceColumn
|
|
151
|
+
sourcesIndex += decodeSign(decodeInteger(reader));
|
|
152
|
+
sourceLine += decodeSign(decodeInteger(reader));
|
|
153
|
+
sourceColumn += decodeSign(decodeInteger(reader));
|
|
156
154
|
if (hasMoreVlq(reader, semi)) {
|
|
157
|
-
namesIndex
|
|
155
|
+
namesIndex += decodeSign(decodeInteger(reader));
|
|
158
156
|
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
159
157
|
} else {
|
|
160
158
|
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
@@ -191,13 +189,18 @@ function encode(decoded) {
|
|
|
191
189
|
for (let j = 0; j < line.length; j++) {
|
|
192
190
|
const segment = line[j];
|
|
193
191
|
if (j > 0) writer.write(comma);
|
|
194
|
-
|
|
192
|
+
encodeInteger(writer, encodeSign(segment[0] - genColumn));
|
|
193
|
+
genColumn = segment[0];
|
|
195
194
|
if (segment.length === 1) continue;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
encodeInteger(writer, encodeSign(segment[1] - sourcesIndex));
|
|
196
|
+
encodeInteger(writer, encodeSign(segment[2] - sourceLine));
|
|
197
|
+
encodeInteger(writer, encodeSign(segment[3] - sourceColumn));
|
|
198
|
+
sourcesIndex = segment[1];
|
|
199
|
+
sourceLine = segment[2];
|
|
200
|
+
sourceColumn = segment[3];
|
|
199
201
|
if (segment.length === 4) continue;
|
|
200
|
-
|
|
202
|
+
encodeInteger(writer, encodeSign(segment[4] - namesIndex));
|
|
203
|
+
namesIndex = segment[4];
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
return writer.flush();
|
|
@@ -922,8 +925,8 @@ var MagicString = class MagicString {
|
|
|
922
925
|
end = end + this.offset;
|
|
923
926
|
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
924
927
|
if (this.original.length !== 0) {
|
|
925
|
-
|
|
926
|
-
|
|
928
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
929
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
927
930
|
}
|
|
928
931
|
if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
|
|
929
932
|
if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
|
|
@@ -1006,8 +1009,8 @@ var MagicString = class MagicString {
|
|
|
1006
1009
|
start = start + this.offset;
|
|
1007
1010
|
end = end + this.offset;
|
|
1008
1011
|
if (this.original.length !== 0) {
|
|
1009
|
-
|
|
1010
|
-
|
|
1012
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
1013
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
1011
1014
|
}
|
|
1012
1015
|
if (start === end) return this;
|
|
1013
1016
|
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
@@ -1030,8 +1033,8 @@ var MagicString = class MagicString {
|
|
|
1030
1033
|
start = start + this.offset;
|
|
1031
1034
|
end = end + this.offset;
|
|
1032
1035
|
if (this.original.length !== 0) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1036
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
1037
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
1035
1038
|
}
|
|
1036
1039
|
if (start === end) return this;
|
|
1037
1040
|
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
@@ -1092,8 +1095,8 @@ var MagicString = class MagicString {
|
|
|
1092
1095
|
start = start + this.offset;
|
|
1093
1096
|
end = end + this.offset;
|
|
1094
1097
|
if (this.original.length !== 0) {
|
|
1095
|
-
|
|
1096
|
-
|
|
1098
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
1099
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
1097
1100
|
}
|
|
1098
1101
|
let result = "";
|
|
1099
1102
|
let chunk = this.firstChunk;
|
|
@@ -1279,27 +1282,19 @@ var MagicString = class MagicString {
|
|
|
1279
1282
|
});
|
|
1280
1283
|
else return replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
1281
1284
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
const replacement = getReplacement(match, this.original);
|
|
1294
|
-
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
else {
|
|
1285
|
+
const replaceMatch = (match) => {
|
|
1286
|
+
if (match.index == null) return;
|
|
1287
|
+
const replacement = getReplacement(match, this.original);
|
|
1288
|
+
if (replacement === match[0]) return;
|
|
1289
|
+
if (match[0].length === 0) this.appendRight(match.index, replacement);
|
|
1290
|
+
else this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1291
|
+
};
|
|
1292
|
+
if (searchValue.global) {
|
|
1293
|
+
searchValue.lastIndex = 0;
|
|
1294
|
+
for (const match of this.original.matchAll(searchValue)) replaceMatch(match);
|
|
1295
|
+
} else {
|
|
1298
1296
|
const match = this.original.match(searchValue);
|
|
1299
|
-
if (match
|
|
1300
|
-
const replacement = getReplacement(match, this.original);
|
|
1301
|
-
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1302
|
-
}
|
|
1297
|
+
if (match) replaceMatch(match);
|
|
1303
1298
|
}
|
|
1304
1299
|
return this;
|
|
1305
1300
|
}
|
|
@@ -1309,7 +1304,8 @@ var MagicString = class MagicString {
|
|
|
1309
1304
|
const index = original.indexOf(string);
|
|
1310
1305
|
if (index !== -1) {
|
|
1311
1306
|
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
1312
|
-
if (string !== replacement)
|
|
1307
|
+
if (string !== replacement) if (string.length === 0) this.appendRight(index, replacement);
|
|
1308
|
+
else this.overwrite(index, index + string.length, replacement);
|
|
1313
1309
|
}
|
|
1314
1310
|
return this;
|
|
1315
1311
|
}
|
|
@@ -1324,6 +1320,13 @@ var MagicString = class MagicString {
|
|
|
1324
1320
|
_replaceAllString(string, replacement) {
|
|
1325
1321
|
const { original } = this;
|
|
1326
1322
|
const stringLength = string.length;
|
|
1323
|
+
if (stringLength === 0) {
|
|
1324
|
+
for (let index = 0; index <= original.length; index += 1) {
|
|
1325
|
+
const _replacement = typeof replacement === "function" ? replacement("", index, original) : replacement;
|
|
1326
|
+
if (_replacement !== "") this.appendRight(index, _replacement);
|
|
1327
|
+
}
|
|
1328
|
+
return this;
|
|
1329
|
+
}
|
|
1327
1330
|
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
1328
1331
|
const previous = original.slice(index, index + stringLength);
|
|
1329
1332
|
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : replacement;
|
|
@@ -1468,7 +1471,7 @@ var Bundle$1 = class Bundle {
|
|
|
1468
1471
|
indentStringCounts[indentStr] += 1;
|
|
1469
1472
|
});
|
|
1470
1473
|
return Object.keys(indentStringCounts).sort((a, b) => {
|
|
1471
|
-
return indentStringCounts[
|
|
1474
|
+
return indentStringCounts[b] - indentStringCounts[a];
|
|
1472
1475
|
})[0] || " ";
|
|
1473
1476
|
}
|
|
1474
1477
|
indent(indentStr) {
|
|
@@ -1523,27 +1526,27 @@ var Bundle$1 = class Bundle {
|
|
|
1523
1526
|
trimStart(charType) {
|
|
1524
1527
|
const rx = new RegExp(`^${charType || "\\s"}+`);
|
|
1525
1528
|
this.intro = this.intro.replace(rx, "");
|
|
1526
|
-
if (!this.intro) {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
source
|
|
1531
|
-
|
|
1532
|
-
|
|
1529
|
+
if (!this.intro) for (let i = 0; i < this.sources.length; i += 1) {
|
|
1530
|
+
const source = this.sources[i];
|
|
1531
|
+
if (i > 0) {
|
|
1532
|
+
source.separator = (source.separator !== void 0 ? source.separator : this.separator).replace(rx, "");
|
|
1533
|
+
if (source.separator) break;
|
|
1534
|
+
}
|
|
1535
|
+
if (source.content.trimStartAborted(charType)) break;
|
|
1533
1536
|
}
|
|
1534
1537
|
return this;
|
|
1535
1538
|
}
|
|
1536
1539
|
trimEnd(charType) {
|
|
1537
1540
|
const rx = new RegExp(`${charType || "\\s"}+$`);
|
|
1538
|
-
let
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
break;
|
|
1541
|
+
for (let i = this.sources.length - 1; i >= 0; i -= 1) {
|
|
1542
|
+
const source = this.sources[i];
|
|
1543
|
+
if (source.content.trimEndAborted(charType)) return this;
|
|
1544
|
+
if (i > 0) {
|
|
1545
|
+
source.separator = (source.separator !== void 0 ? source.separator : this.separator).replace(rx, "");
|
|
1546
|
+
if (source.separator) return this;
|
|
1545
1547
|
}
|
|
1546
|
-
}
|
|
1548
|
+
}
|
|
1549
|
+
this.intro = this.intro.replace(rx, "");
|
|
1547
1550
|
return this;
|
|
1548
1551
|
}
|
|
1549
1552
|
};
|
|
@@ -2073,17 +2076,8 @@ class ExpressionEntity {
|
|
|
2073
2076
|
return true;
|
|
2074
2077
|
}
|
|
2075
2078
|
}
|
|
2076
|
-
class
|
|
2077
|
-
|
|
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);
|
|
2079
|
+
const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
|
|
2080
|
+
})();
|
|
2087
2081
|
const UNKNOWN_RETURN_EXPRESSION = [
|
|
2088
2082
|
UNKNOWN_EXPRESSION,
|
|
2089
2083
|
false
|
|
@@ -2815,7 +2809,11 @@ function isExpressionStatementNode(node) {
|
|
|
2815
2809
|
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
2816
2810
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2817
2811
|
}
|
|
2818
|
-
const UNDEFINED_EXPRESSION = new
|
|
2812
|
+
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2813
|
+
getLiteralValueAtPath(path) {
|
|
2814
|
+
return path.length > 0 ? UnknownValue : undefined;
|
|
2815
|
+
}
|
|
2816
|
+
})();
|
|
2819
2817
|
const returnsUnknown = {
|
|
2820
2818
|
value: {
|
|
2821
2819
|
hasEffectsWhenCalled: null,
|
|
@@ -2996,7 +2994,7 @@ function getLiteralMembersForValue(value) {
|
|
|
2996
2994
|
return literalStringMembers;
|
|
2997
2995
|
}
|
|
2998
2996
|
}
|
|
2999
|
-
return
|
|
2997
|
+
return Object.create(null);
|
|
3000
2998
|
}
|
|
3001
2999
|
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
3002
3000
|
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
@@ -3296,8 +3294,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3296
3294
|
// causes an issue with TypeScript enums in files with moduleSideEffects:
|
|
3297
3295
|
// false because we cannot properly track whether a "var" has been
|
|
3298
3296
|
// 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
|
|
3301
3297
|
// return UnknownTruthyValue;
|
|
3302
3298
|
return UnknownValue;
|
|
3303
3299
|
}
|
|
@@ -6010,156 +6006,6 @@ class ThisVariable extends ParameterVariable {
|
|
|
6010
6006
|
}
|
|
6011
6007
|
}
|
|
6012
6008
|
|
|
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
|
-
|
|
6163
6009
|
class CatchBodyScope extends ChildScope {
|
|
6164
6010
|
constructor(parent) {
|
|
6165
6011
|
super(parent, parent.context);
|
|
@@ -6369,12 +6215,8 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6369
6215
|
}
|
|
6370
6216
|
}
|
|
6371
6217
|
getReturnExpression() {
|
|
6372
|
-
if (
|
|
6373
|
-
this.
|
|
6374
|
-
this.returnExpressions.length === 1
|
|
6375
|
-
? this.returnExpressions[0]
|
|
6376
|
-
: new MultiExpression(this.returnExpressions);
|
|
6377
|
-
}
|
|
6218
|
+
if (this.returnExpression === null)
|
|
6219
|
+
this.updateReturnExpression();
|
|
6378
6220
|
return this.returnExpression;
|
|
6379
6221
|
}
|
|
6380
6222
|
deoptimizeAllParameters() {
|
|
@@ -6393,6 +6235,17 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6393
6235
|
}
|
|
6394
6236
|
}
|
|
6395
6237
|
addArgumentToBeDeoptimized(_argument) { }
|
|
6238
|
+
updateReturnExpression() {
|
|
6239
|
+
if (this.returnExpressions.length === 1) {
|
|
6240
|
+
this.returnExpression = this.returnExpressions[0];
|
|
6241
|
+
}
|
|
6242
|
+
else {
|
|
6243
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
6244
|
+
for (const expression of this.returnExpressions) {
|
|
6245
|
+
expression.deoptimizePath(UNKNOWN_PATH);
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
6248
|
+
}
|
|
6396
6249
|
}
|
|
6397
6250
|
|
|
6398
6251
|
class FunctionScope extends ReturnValueScope {
|
|
@@ -6454,10 +6307,6 @@ ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
|
6454
6307
|
ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6455
6308
|
|
|
6456
6309
|
class BlockStatement extends NodeBase {
|
|
6457
|
-
constructor() {
|
|
6458
|
-
super(...arguments);
|
|
6459
|
-
this.virtualReturnStatement = null;
|
|
6460
|
-
}
|
|
6461
6310
|
get deoptimizeBody() {
|
|
6462
6311
|
return isFlagSet(this.flags, 32768 /* Flag.deoptimizeBody */);
|
|
6463
6312
|
}
|
|
@@ -6473,13 +6322,7 @@ class BlockStatement extends NodeBase {
|
|
|
6473
6322
|
addImplicitReturnExpressionToScope() {
|
|
6474
6323
|
const lastStatement = this.body[this.body.length - 1];
|
|
6475
6324
|
if (!lastStatement || lastStatement.type !== ReturnStatement$1) {
|
|
6476
|
-
|
|
6477
|
-
virtualReturnStatement.type = ReturnStatement$1;
|
|
6478
|
-
virtualReturnStatement.argument = null;
|
|
6479
|
-
virtualReturnStatement.initialise();
|
|
6480
|
-
if (this.deoptimizeBody)
|
|
6481
|
-
virtualReturnStatement.includeNode(createInclusionContext());
|
|
6482
|
-
this.virtualReturnStatement = virtualReturnStatement;
|
|
6325
|
+
this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
|
|
6483
6326
|
}
|
|
6484
6327
|
}
|
|
6485
6328
|
createScope(parentScope) {
|
|
@@ -6490,15 +6333,13 @@ class BlockStatement extends NodeBase {
|
|
|
6490
6333
|
hasEffects(context) {
|
|
6491
6334
|
if (this.deoptimizeBody)
|
|
6492
6335
|
return true;
|
|
6493
|
-
let hasEffect = false;
|
|
6494
6336
|
for (const node of this.body) {
|
|
6495
|
-
if (context.brokenFlow
|
|
6337
|
+
if (context.brokenFlow)
|
|
6496
6338
|
break;
|
|
6339
|
+
if (node.hasEffects(context))
|
|
6340
|
+
return true;
|
|
6497
6341
|
}
|
|
6498
|
-
|
|
6499
|
-
hasEffect ||= !!this.virtualReturnStatement?.hasEffects(context);
|
|
6500
|
-
}
|
|
6501
|
-
return hasEffect;
|
|
6342
|
+
return false;
|
|
6502
6343
|
}
|
|
6503
6344
|
include(context, includeChildrenRecursively) {
|
|
6504
6345
|
if (!(this.deoptimizeBody && this.directlyIncluded)) {
|
|
@@ -6510,8 +6351,6 @@ class BlockStatement extends NodeBase {
|
|
|
6510
6351
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
6511
6352
|
node.include(context, includeChildrenRecursively);
|
|
6512
6353
|
}
|
|
6513
|
-
if (includeChildrenRecursively || !context.brokenFlow)
|
|
6514
|
-
this.virtualReturnStatement?.include(context, includeChildrenRecursively);
|
|
6515
6354
|
}
|
|
6516
6355
|
}
|
|
6517
6356
|
initialise() {
|
|
@@ -7524,7 +7363,7 @@ class MemberExpression extends NodeBase {
|
|
|
7524
7363
|
if (!this.included)
|
|
7525
7364
|
this.includeNode(context);
|
|
7526
7365
|
if (this.variable) {
|
|
7527
|
-
this.variable
|
|
7366
|
+
this.variable?.includePath(path, context);
|
|
7528
7367
|
}
|
|
7529
7368
|
else if (!this.isUndefined) {
|
|
7530
7369
|
this.object.includePath([
|
|
@@ -9472,7 +9311,7 @@ function requireScan () {
|
|
|
9472
9311
|
const opts = options || {};
|
|
9473
9312
|
|
|
9474
9313
|
const length = input.length - 1;
|
|
9475
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
9314
|
+
const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
|
|
9476
9315
|
const slashes = [];
|
|
9477
9316
|
const tokens = [];
|
|
9478
9317
|
const parts = [];
|
|
@@ -9606,15 +9445,21 @@ function requireScan () {
|
|
|
9606
9445
|
}
|
|
9607
9446
|
|
|
9608
9447
|
if (scanToEnd === true) {
|
|
9448
|
+
let parens = 0;
|
|
9449
|
+
|
|
9609
9450
|
while (eos() !== true && (code = advance())) {
|
|
9610
9451
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
9611
9452
|
backslashes = token.backslashes = true;
|
|
9612
|
-
|
|
9453
|
+
advance();
|
|
9613
9454
|
continue;
|
|
9614
9455
|
}
|
|
9615
9456
|
|
|
9616
|
-
if (code ===
|
|
9617
|
-
|
|
9457
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
9458
|
+
parens++;
|
|
9459
|
+
continue;
|
|
9460
|
+
}
|
|
9461
|
+
|
|
9462
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
9618
9463
|
finished = true;
|
|
9619
9464
|
break;
|
|
9620
9465
|
}
|
|
@@ -9679,14 +9524,21 @@ function requireScan () {
|
|
|
9679
9524
|
isGlob = token.isGlob = true;
|
|
9680
9525
|
|
|
9681
9526
|
if (scanToEnd === true) {
|
|
9527
|
+
let parens = 1;
|
|
9528
|
+
|
|
9682
9529
|
while (eos() !== true && (code = advance())) {
|
|
9683
|
-
if (code ===
|
|
9530
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
9684
9531
|
backslashes = token.backslashes = true;
|
|
9685
|
-
|
|
9532
|
+
advance();
|
|
9686
9533
|
continue;
|
|
9687
9534
|
}
|
|
9688
9535
|
|
|
9689
|
-
if (code ===
|
|
9536
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
9537
|
+
parens++;
|
|
9538
|
+
continue;
|
|
9539
|
+
}
|
|
9540
|
+
|
|
9541
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
9690
9542
|
finished = true;
|
|
9691
9543
|
break;
|
|
9692
9544
|
}
|
|
@@ -9773,7 +9625,7 @@ function requireScan () {
|
|
|
9773
9625
|
let prevIndex;
|
|
9774
9626
|
|
|
9775
9627
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
9776
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
9628
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
9777
9629
|
const i = slashes[idx];
|
|
9778
9630
|
const value = input.slice(n, i);
|
|
9779
9631
|
if (opts.tokens) {
|
|
@@ -9786,21 +9638,20 @@ function requireScan () {
|
|
|
9786
9638
|
depth(tokens[idx]);
|
|
9787
9639
|
state.maxDepth += tokens[idx].depth;
|
|
9788
9640
|
}
|
|
9789
|
-
if (
|
|
9641
|
+
if (i >= start) {
|
|
9790
9642
|
parts.push(value);
|
|
9643
|
+
prevIndex = i;
|
|
9791
9644
|
}
|
|
9792
|
-
prevIndex = i;
|
|
9793
9645
|
}
|
|
9794
9646
|
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9647
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
9648
|
+
const value = input.slice(n);
|
|
9649
|
+
parts.push(value);
|
|
9798
9650
|
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
}
|
|
9651
|
+
if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
|
|
9652
|
+
tokens[tokens.length - 1].value = value;
|
|
9653
|
+
depth(tokens[tokens.length - 1]);
|
|
9654
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
9804
9655
|
}
|
|
9805
9656
|
|
|
9806
9657
|
state.slashes = slashes;
|
|
@@ -10351,9 +10202,33 @@ function requireParse () {
|
|
|
10351
10202
|
};
|
|
10352
10203
|
|
|
10353
10204
|
const extglobClose = token => {
|
|
10354
|
-
input.slice(token.startIndex, state.index + 1);
|
|
10205
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
10355
10206
|
const body = input.slice(token.startIndex + 2, state.index);
|
|
10356
|
-
analyzeRepeatedExtglob(body, opts);
|
|
10207
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
10208
|
+
|
|
10209
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
10210
|
+
const safeOutput = analysis.safeOutput
|
|
10211
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
10212
|
+
: undefined;
|
|
10213
|
+
const open = tokens[token.tokensIndex];
|
|
10214
|
+
|
|
10215
|
+
open.type = 'text';
|
|
10216
|
+
open.value = literal;
|
|
10217
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
10218
|
+
|
|
10219
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
10220
|
+
tokens[i].value = '';
|
|
10221
|
+
tokens[i].output = '';
|
|
10222
|
+
delete tokens[i].suffix;
|
|
10223
|
+
}
|
|
10224
|
+
|
|
10225
|
+
state.output = token.output + open.output;
|
|
10226
|
+
state.backtrack = true;
|
|
10227
|
+
|
|
10228
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
10229
|
+
decrement('parens');
|
|
10230
|
+
return;
|
|
10231
|
+
}
|
|
10357
10232
|
|
|
10358
10233
|
let output = token.close + (opts.capture ? ')' : '');
|
|
10359
10234
|
let rest;
|
|
@@ -10965,6 +10840,15 @@ function requireParse () {
|
|
|
10965
10840
|
consume('/**', 3);
|
|
10966
10841
|
}
|
|
10967
10842
|
|
|
10843
|
+
// A globstar followed only by balanced closing parens is at the logical end of patterns like
|
|
10844
|
+
// `test(/utils/**)` and `test?(/utils/**)`. Treat it as EOS so the trailing `/**` can match its
|
|
10845
|
+
// parent path, except in negated extglobs where that would change the exclusion semantics.
|
|
10846
|
+
const isEnd = eos() || (
|
|
10847
|
+
state.parens > 0
|
|
10848
|
+
&& rest === ')'.repeat(state.parens)
|
|
10849
|
+
&& !extglobs.some(extglob => extglob.type === 'negate')
|
|
10850
|
+
);
|
|
10851
|
+
|
|
10968
10852
|
if (prior.type === 'bos' && eos()) {
|
|
10969
10853
|
prev.type = 'globstar';
|
|
10970
10854
|
prev.value += value;
|
|
@@ -10975,7 +10859,7 @@ function requireParse () {
|
|
|
10975
10859
|
continue;
|
|
10976
10860
|
}
|
|
10977
10861
|
|
|
10978
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar &&
|
|
10862
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && isEnd) {
|
|
10979
10863
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
10980
10864
|
prior.output = `(?:${prior.output}`;
|
|
10981
10865
|
|
|
@@ -12230,10 +12114,11 @@ const binaryOperators = {
|
|
|
12230
12114
|
// in: () => UnknownValue,
|
|
12231
12115
|
// instanceof: () => UnknownValue,
|
|
12232
12116
|
};
|
|
12117
|
+
const UNASSIGNED$1 = Symbol('Unassigned');
|
|
12233
12118
|
class BinaryExpression extends NodeBase {
|
|
12234
12119
|
constructor() {
|
|
12235
12120
|
super(...arguments);
|
|
12236
|
-
this.renderedLiteralValue = UNASSIGNED;
|
|
12121
|
+
this.renderedLiteralValue = UNASSIGNED$1;
|
|
12237
12122
|
}
|
|
12238
12123
|
deoptimizeCache() {
|
|
12239
12124
|
this.renderedLiteralValue = UnknownValue;
|
|
@@ -12266,7 +12151,7 @@ class BinaryExpression extends NodeBase {
|
|
|
12266
12151
|
if (this.operator !== 'in' || !(this.right.variable instanceof NamespaceVariable)) {
|
|
12267
12152
|
return UnknownValue;
|
|
12268
12153
|
}
|
|
12269
|
-
if (this.renderedLiteralValue !== UNASSIGNED)
|
|
12154
|
+
if (this.renderedLiteralValue !== UNASSIGNED$1)
|
|
12270
12155
|
return this.renderedLiteralValue;
|
|
12271
12156
|
return (this.renderedLiteralValue = getRenderedLiteralValue(this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
12272
12157
|
}
|
|
@@ -12401,10 +12286,10 @@ class CallExpressionBase extends NodeBase {
|
|
|
12401
12286
|
}
|
|
12402
12287
|
deoptimizeCache() {
|
|
12403
12288
|
if (this.returnExpression?.[0] !== UNKNOWN_EXPRESSION) {
|
|
12404
|
-
this.returnExpression =
|
|
12289
|
+
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
12405
12290
|
const { deoptimizableDependentExpressions, expressionsToBeDeoptimized } = this;
|
|
12406
|
-
this.expressionsToBeDeoptimized =
|
|
12407
|
-
this.deoptimizableDependentExpressions =
|
|
12291
|
+
this.expressionsToBeDeoptimized = EMPTY_SET;
|
|
12292
|
+
this.deoptimizableDependentExpressions = EMPTY_ARRAY;
|
|
12408
12293
|
for (const expression of deoptimizableDependentExpressions) {
|
|
12409
12294
|
expression.deoptimizeCache();
|
|
12410
12295
|
}
|
|
@@ -12430,7 +12315,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
12430
12315
|
}
|
|
12431
12316
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
12432
12317
|
this.deoptimizableDependentExpressions.push(origin);
|
|
12433
|
-
return returnExpression.getLiteralValueAtPath(path, recursionTracker,
|
|
12318
|
+
return returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
12434
12319
|
}, UnknownValue);
|
|
12435
12320
|
}
|
|
12436
12321
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -12542,6 +12427,11 @@ class CallExpression extends CallExpressionBase {
|
|
|
12542
12427
|
this.callee.includeCallArguments(this.interaction, context);
|
|
12543
12428
|
}
|
|
12544
12429
|
}
|
|
12430
|
+
includeNode(_context) {
|
|
12431
|
+
this.included = true;
|
|
12432
|
+
if (!this.deoptimized)
|
|
12433
|
+
this.applyDeoptimizations();
|
|
12434
|
+
}
|
|
12545
12435
|
initialise() {
|
|
12546
12436
|
super.initialise();
|
|
12547
12437
|
if (this.annotations &&
|
|
@@ -12573,13 +12463,12 @@ class CallExpression extends CallExpressionBase {
|
|
|
12573
12463
|
}
|
|
12574
12464
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
12575
12465
|
if (this.returnExpression === null) {
|
|
12576
|
-
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
12577
|
-
this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this);
|
|
12466
|
+
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
12467
|
+
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
12578
12468
|
}
|
|
12579
12469
|
return this.returnExpression;
|
|
12580
12470
|
}
|
|
12581
12471
|
}
|
|
12582
|
-
CallExpression.prototype.includeNode = onlyIncludeSelf;
|
|
12583
12472
|
|
|
12584
12473
|
class CatchClause extends NodeBase {
|
|
12585
12474
|
createScope(parentScope) {
|
|
@@ -12679,6 +12568,31 @@ function tryCastLiteralValueToBoolean(literalValue) {
|
|
|
12679
12568
|
return !!literalValue;
|
|
12680
12569
|
}
|
|
12681
12570
|
|
|
12571
|
+
class MultiExpression extends ExpressionEntity {
|
|
12572
|
+
constructor(expressions) {
|
|
12573
|
+
super();
|
|
12574
|
+
this.expressions = expressions;
|
|
12575
|
+
}
|
|
12576
|
+
deoptimizePath(path) {
|
|
12577
|
+
for (const expression of this.expressions) {
|
|
12578
|
+
expression.deoptimizePath(path);
|
|
12579
|
+
}
|
|
12580
|
+
}
|
|
12581
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
12582
|
+
return [
|
|
12583
|
+
new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0])),
|
|
12584
|
+
false
|
|
12585
|
+
];
|
|
12586
|
+
}
|
|
12587
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
12588
|
+
for (const expression of this.expressions) {
|
|
12589
|
+
if (expression.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
12590
|
+
return true;
|
|
12591
|
+
}
|
|
12592
|
+
return false;
|
|
12593
|
+
}
|
|
12594
|
+
}
|
|
12595
|
+
|
|
12682
12596
|
class ConditionalExpression extends NodeBase {
|
|
12683
12597
|
constructor() {
|
|
12684
12598
|
super(...arguments);
|
|
@@ -13182,13 +13096,14 @@ class TrackingScope extends BlockScope {
|
|
|
13182
13096
|
}
|
|
13183
13097
|
}
|
|
13184
13098
|
|
|
13099
|
+
const unset = Symbol('unset');
|
|
13185
13100
|
class IfStatement extends NodeBase {
|
|
13186
13101
|
constructor() {
|
|
13187
13102
|
super(...arguments);
|
|
13188
|
-
this.testValue =
|
|
13103
|
+
this.testValue = unset;
|
|
13189
13104
|
}
|
|
13190
13105
|
deoptimizeCache() {
|
|
13191
|
-
this.testValue =
|
|
13106
|
+
this.testValue = UnknownValue;
|
|
13192
13107
|
}
|
|
13193
13108
|
hasEffects(context) {
|
|
13194
13109
|
if (this.test.hasEffects(context)) {
|
|
@@ -13277,8 +13192,8 @@ class IfStatement extends NodeBase {
|
|
|
13277
13192
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
13278
13193
|
}
|
|
13279
13194
|
getTestValue() {
|
|
13280
|
-
if (this.testValue ===
|
|
13281
|
-
this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
13195
|
+
if (this.testValue === unset) {
|
|
13196
|
+
return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
13282
13197
|
}
|
|
13283
13198
|
return this.testValue;
|
|
13284
13199
|
}
|
|
@@ -14932,6 +14847,38 @@ class PropertyDefinition extends NodeBase {
|
|
|
14932
14847
|
}
|
|
14933
14848
|
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14934
14849
|
|
|
14850
|
+
class ReturnStatement extends NodeBase {
|
|
14851
|
+
hasEffects(context) {
|
|
14852
|
+
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
14853
|
+
return true;
|
|
14854
|
+
context.brokenFlow = true;
|
|
14855
|
+
return false;
|
|
14856
|
+
}
|
|
14857
|
+
include(context, includeChildrenRecursively) {
|
|
14858
|
+
if (!this.included)
|
|
14859
|
+
this.includeNode(context);
|
|
14860
|
+
this.argument?.include(context, includeChildrenRecursively);
|
|
14861
|
+
context.brokenFlow = true;
|
|
14862
|
+
}
|
|
14863
|
+
includeNode(context) {
|
|
14864
|
+
this.included = true;
|
|
14865
|
+
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
14866
|
+
}
|
|
14867
|
+
initialise() {
|
|
14868
|
+
super.initialise();
|
|
14869
|
+
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
14870
|
+
}
|
|
14871
|
+
render(code, options) {
|
|
14872
|
+
if (this.argument) {
|
|
14873
|
+
this.argument.render(code, options, { preventASI: true });
|
|
14874
|
+
if (this.argument.start === this.start + 6 /* 'return'.length */) {
|
|
14875
|
+
code.prependLeft(this.start + 6, ' ');
|
|
14876
|
+
}
|
|
14877
|
+
}
|
|
14878
|
+
}
|
|
14879
|
+
}
|
|
14880
|
+
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14881
|
+
|
|
14935
14882
|
class SequenceExpression extends NodeBase {
|
|
14936
14883
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
14937
14884
|
this.expressions[this.expressions.length - 1].deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -15455,6 +15402,7 @@ const unaryOperators = {
|
|
|
15455
15402
|
void: () => undefined,
|
|
15456
15403
|
'~': value => ~value
|
|
15457
15404
|
};
|
|
15405
|
+
const UNASSIGNED = Symbol('Unassigned');
|
|
15458
15406
|
class UnaryExpression extends NodeBase {
|
|
15459
15407
|
constructor() {
|
|
15460
15408
|
super(...arguments);
|