@rollup/wasm-node 4.30.0-0 → 4.30.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/LICENSE.md +23 -15
- package/dist/bin/rollup +8 -9
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -3
- package/dist/es/shared/node-entry.js +802 -1569
- package/dist/es/shared/parseAst.js +3 -3
- package/dist/es/shared/watch.js +6 -7
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -3
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -3
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +6 -6
- package/dist/shared/loadConfigFile.js +4 -4
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +833 -1616
- package/dist/shared/watch-cli.js +22 -7
- package/dist/shared/watch.js +3 -4
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +12 -12
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.30.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.30.0
|
|
4
|
+
Mon, 06 Jan 2025 06:36:11 GMT - commit 958d5ebabd49297e9a4b78ad34ac0a0132305dea
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, 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, ExpressionStatement as ExpressionStatement$1, logMissingExport, normalize, getImportPath, logMissingNodeBuiltins, logReservedNamespace, error, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, ArrowFunctionExpression as ArrowFunctionExpression$1, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logParseError, logModuleParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, EMPTY_OBJECT, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logCircularReexport, logInvalidFormatForTopLevelAwait, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, 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, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, warnDeprecation, URL_GENERATEBUNDLE, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, logInvalidExportOptionValue, URL_OUTPUT_INTEROP, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
|
|
12
|
-
import { posix, isAbsolute, resolve
|
|
13
|
-
import { parseAsync,
|
|
14
|
-
import process$1, { env
|
|
12
|
+
import { posix, win32, isAbsolute, resolve } from 'path';
|
|
13
|
+
import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
|
|
14
|
+
import process$1, { env } from 'node:process';
|
|
15
15
|
import { performance } from 'node:perf_hooks';
|
|
16
16
|
import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
17
|
-
import * as tty from 'tty';
|
|
18
17
|
|
|
19
|
-
var version = "4.30.0
|
|
18
|
+
var version = "4.30.0";
|
|
20
19
|
|
|
21
20
|
const comma = ','.charCodeAt(0);
|
|
22
21
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -41,7 +40,7 @@ function decodeInteger(reader, relative) {
|
|
|
41
40
|
const shouldNegate = value & 1;
|
|
42
41
|
value >>>= 1;
|
|
43
42
|
if (shouldNegate) {
|
|
44
|
-
value = -
|
|
43
|
+
value = -2147483648 | -value;
|
|
45
44
|
}
|
|
46
45
|
return relative + value;
|
|
47
46
|
}
|
|
@@ -1965,6 +1964,71 @@ function renderSystemExportSequenceBeforeExpression(exportedVariable, expression
|
|
|
1965
1964
|
}
|
|
1966
1965
|
}
|
|
1967
1966
|
|
|
1967
|
+
/** @import { Node } from 'estree' */
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* @param {Node} node
|
|
1971
|
+
* @param {Node} parent
|
|
1972
|
+
* @returns {boolean}
|
|
1973
|
+
*/
|
|
1974
|
+
function is_reference(node, parent) {
|
|
1975
|
+
if (node.type === 'MemberExpression') {
|
|
1976
|
+
return !node.computed && is_reference(node.object, node);
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
if (node.type !== 'Identifier') return false;
|
|
1980
|
+
|
|
1981
|
+
switch (parent?.type) {
|
|
1982
|
+
// disregard `bar` in `foo.bar`
|
|
1983
|
+
case 'MemberExpression':
|
|
1984
|
+
return parent.computed || node === parent.object;
|
|
1985
|
+
|
|
1986
|
+
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
1987
|
+
case 'MethodDefinition':
|
|
1988
|
+
return parent.computed;
|
|
1989
|
+
|
|
1990
|
+
// disregard the `meta` in `import.meta`
|
|
1991
|
+
case 'MetaProperty':
|
|
1992
|
+
return parent.meta === node;
|
|
1993
|
+
|
|
1994
|
+
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
1995
|
+
case 'PropertyDefinition':
|
|
1996
|
+
return parent.computed || node === parent.value;
|
|
1997
|
+
|
|
1998
|
+
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
1999
|
+
case 'Property':
|
|
2000
|
+
return parent.computed || node === parent.value;
|
|
2001
|
+
|
|
2002
|
+
// disregard the `bar` in `export { foo as bar }` or
|
|
2003
|
+
// the foo in `import { foo as bar }`
|
|
2004
|
+
case 'ExportSpecifier':
|
|
2005
|
+
case 'ImportSpecifier':
|
|
2006
|
+
return node === parent.local;
|
|
2007
|
+
|
|
2008
|
+
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
2009
|
+
case 'LabeledStatement':
|
|
2010
|
+
case 'BreakStatement':
|
|
2011
|
+
case 'ContinueStatement':
|
|
2012
|
+
return false;
|
|
2013
|
+
|
|
2014
|
+
default:
|
|
2015
|
+
return true;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
2020
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
2021
|
+
const pureFunctions = Object.create(null);
|
|
2022
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2023
|
+
let currentFunctions = pureFunctions;
|
|
2024
|
+
for (const pathSegment of functionName.split('.')) {
|
|
2025
|
+
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2026
|
+
}
|
|
2027
|
+
currentFunctions[PureFunctionKey] = true;
|
|
2028
|
+
}
|
|
2029
|
+
return pureFunctions;
|
|
2030
|
+
};
|
|
2031
|
+
|
|
1968
2032
|
function getOrCreate(map, key, init) {
|
|
1969
2033
|
const existing = map.get(key);
|
|
1970
2034
|
if (existing !== undefined) {
|
|
@@ -1995,7 +2059,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
1995
2059
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
1996
2060
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
1997
2061
|
const EntitiesKey = Symbol('Entities');
|
|
1998
|
-
class
|
|
2062
|
+
class PathTracker {
|
|
1999
2063
|
constructor() {
|
|
2000
2064
|
this.entityPaths = Object.create(null, {
|
|
2001
2065
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -2020,14 +2084,14 @@ class EntityPathTracker {
|
|
|
2020
2084
|
getEntities(path) {
|
|
2021
2085
|
let currentPaths = this.entityPaths;
|
|
2022
2086
|
for (const pathSegment of path) {
|
|
2023
|
-
currentPaths = currentPaths[pathSegment]
|
|
2024
|
-
[
|
|
2025
|
-
|
|
2087
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2088
|
+
currentPaths[pathSegment] ||
|
|
2089
|
+
Object.create(null, { [EntitiesKey]: { value: new Set() } });
|
|
2026
2090
|
}
|
|
2027
2091
|
return currentPaths[EntitiesKey];
|
|
2028
2092
|
}
|
|
2029
2093
|
}
|
|
2030
|
-
const SHARED_RECURSION_TRACKER = new
|
|
2094
|
+
const SHARED_RECURSION_TRACKER = new PathTracker();
|
|
2031
2095
|
class DiscriminatedPathTracker {
|
|
2032
2096
|
constructor() {
|
|
2033
2097
|
this.entityPaths = Object.create(null, {
|
|
@@ -2037,9 +2101,9 @@ class DiscriminatedPathTracker {
|
|
|
2037
2101
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
2038
2102
|
let currentPaths = this.entityPaths;
|
|
2039
2103
|
for (const pathSegment of path) {
|
|
2040
|
-
currentPaths = currentPaths[pathSegment]
|
|
2041
|
-
[
|
|
2042
|
-
|
|
2104
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2105
|
+
currentPaths[pathSegment] ||
|
|
2106
|
+
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
2043
2107
|
}
|
|
2044
2108
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
2045
2109
|
if (trackedEntities.has(entity))
|
|
@@ -2048,137 +2112,6 @@ class DiscriminatedPathTracker {
|
|
|
2048
2112
|
return false;
|
|
2049
2113
|
}
|
|
2050
2114
|
}
|
|
2051
|
-
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: EMPTY_OBJECT });
|
|
2052
|
-
class IncludedPathTracker {
|
|
2053
|
-
constructor() {
|
|
2054
|
-
this.includedPaths = null;
|
|
2055
|
-
}
|
|
2056
|
-
includePathAndGetIfIncluded(path) {
|
|
2057
|
-
let included = true;
|
|
2058
|
-
let parent = this;
|
|
2059
|
-
let parentSegment = 'includedPaths';
|
|
2060
|
-
let currentPaths = (this.includedPaths ||=
|
|
2061
|
-
((included = false), Object.create(null)));
|
|
2062
|
-
for (const pathSegment of path) {
|
|
2063
|
-
// This means from here, all paths are included
|
|
2064
|
-
if (currentPaths[UnknownKey]) {
|
|
2065
|
-
return true;
|
|
2066
|
-
}
|
|
2067
|
-
// Including UnknownKey automatically includes all nested paths.
|
|
2068
|
-
// From above, we know that UnknownKey is not included yet.
|
|
2069
|
-
if (typeof pathSegment === 'symbol') {
|
|
2070
|
-
// Hopefully, this saves some memory over just setting
|
|
2071
|
-
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
2072
|
-
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
2073
|
-
return false;
|
|
2074
|
-
}
|
|
2075
|
-
parent = currentPaths;
|
|
2076
|
-
parentSegment = pathSegment;
|
|
2077
|
-
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
2078
|
-
}
|
|
2079
|
-
return included;
|
|
2080
|
-
}
|
|
2081
|
-
includeAllPaths(entity, context, basePath) {
|
|
2082
|
-
const { includedPaths } = this;
|
|
2083
|
-
if (includedPaths) {
|
|
2084
|
-
includeAllPaths(entity, context, basePath, includedPaths);
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
2089
|
-
if (currentPaths[UnknownKey]) {
|
|
2090
|
-
return entity.includePath([...basePath, UnknownKey], context);
|
|
2091
|
-
}
|
|
2092
|
-
const keys = Object.keys(currentPaths);
|
|
2093
|
-
if (keys.length === 0) {
|
|
2094
|
-
return entity.includePath(basePath, context);
|
|
2095
|
-
}
|
|
2096
|
-
for (const key of keys) {
|
|
2097
|
-
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
|
|
2101
|
-
/** @import { Node } from 'estree' */
|
|
2102
|
-
|
|
2103
|
-
/**
|
|
2104
|
-
* @param {Node} node
|
|
2105
|
-
* @param {Node} parent
|
|
2106
|
-
* @returns {boolean}
|
|
2107
|
-
*/
|
|
2108
|
-
function is_reference(node, parent) {
|
|
2109
|
-
if (node.type === 'MemberExpression') {
|
|
2110
|
-
return !node.computed && is_reference(node.object, node);
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
|
-
if (node.type !== 'Identifier') return false;
|
|
2114
|
-
|
|
2115
|
-
switch (parent?.type) {
|
|
2116
|
-
// disregard `bar` in `foo.bar`
|
|
2117
|
-
case 'MemberExpression':
|
|
2118
|
-
return parent.computed || node === parent.object;
|
|
2119
|
-
|
|
2120
|
-
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
2121
|
-
case 'MethodDefinition':
|
|
2122
|
-
return parent.computed;
|
|
2123
|
-
|
|
2124
|
-
// disregard the `meta` in `import.meta`
|
|
2125
|
-
case 'MetaProperty':
|
|
2126
|
-
return parent.meta === node;
|
|
2127
|
-
|
|
2128
|
-
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
2129
|
-
case 'PropertyDefinition':
|
|
2130
|
-
return parent.computed || node === parent.value;
|
|
2131
|
-
|
|
2132
|
-
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
2133
|
-
case 'Property':
|
|
2134
|
-
return parent.computed || node === parent.value;
|
|
2135
|
-
|
|
2136
|
-
// disregard the `bar` in `export { foo as bar }` or
|
|
2137
|
-
// the foo in `import { foo as bar }`
|
|
2138
|
-
case 'ExportSpecifier':
|
|
2139
|
-
case 'ImportSpecifier':
|
|
2140
|
-
return node === parent.local;
|
|
2141
|
-
|
|
2142
|
-
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
2143
|
-
case 'LabeledStatement':
|
|
2144
|
-
case 'BreakStatement':
|
|
2145
|
-
case 'ContinueStatement':
|
|
2146
|
-
return false;
|
|
2147
|
-
|
|
2148
|
-
default:
|
|
2149
|
-
return true;
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
|
|
2153
|
-
function createInclusionContext() {
|
|
2154
|
-
return {
|
|
2155
|
-
brokenFlow: false,
|
|
2156
|
-
hasBreak: false,
|
|
2157
|
-
hasContinue: false,
|
|
2158
|
-
includedCallArguments: new Set(),
|
|
2159
|
-
includedLabels: new Set()
|
|
2160
|
-
};
|
|
2161
|
-
}
|
|
2162
|
-
function createHasEffectsContext() {
|
|
2163
|
-
return {
|
|
2164
|
-
accessed: new EntityPathTracker(),
|
|
2165
|
-
assigned: new EntityPathTracker(),
|
|
2166
|
-
brokenFlow: false,
|
|
2167
|
-
called: new DiscriminatedPathTracker(),
|
|
2168
|
-
hasBreak: false,
|
|
2169
|
-
hasContinue: false,
|
|
2170
|
-
ignore: {
|
|
2171
|
-
breaks: false,
|
|
2172
|
-
continues: false,
|
|
2173
|
-
labels: new Set(),
|
|
2174
|
-
returnYield: false,
|
|
2175
|
-
this: false
|
|
2176
|
-
},
|
|
2177
|
-
includedLabels: new Set(),
|
|
2178
|
-
instantiated: new DiscriminatedPathTracker(),
|
|
2179
|
-
replacedVariableInits: new Map()
|
|
2180
|
-
};
|
|
2181
|
-
}
|
|
2182
2115
|
|
|
2183
2116
|
function isFlagSet(flags, flag) {
|
|
2184
2117
|
return (flags & flag) !== 0;
|
|
@@ -2218,25 +2151,12 @@ class ExpressionEntity {
|
|
|
2218
2151
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2219
2152
|
return true;
|
|
2220
2153
|
}
|
|
2221
|
-
include(
|
|
2222
|
-
if (!this.included)
|
|
2223
|
-
this.includeNode(context);
|
|
2224
|
-
}
|
|
2225
|
-
includeNode(_context) {
|
|
2154
|
+
include(_context, _includeChildrenRecursively, _options) {
|
|
2226
2155
|
this.included = true;
|
|
2227
2156
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
}
|
|
2232
|
-
/* We are both including and including an unknown path here as the former
|
|
2233
|
-
* ensures that nested nodes are included while the latter ensures that all
|
|
2234
|
-
* paths of the expression are included.
|
|
2235
|
-
* */
|
|
2236
|
-
includeCallArguments(context, interaction) {
|
|
2237
|
-
for (const argument of interaction.args) {
|
|
2238
|
-
argument?.includePath(UNKNOWN_PATH, context);
|
|
2239
|
-
argument?.include(context, false);
|
|
2157
|
+
includeCallArguments(context, parameters) {
|
|
2158
|
+
for (const argument of parameters) {
|
|
2159
|
+
argument.include(context, false);
|
|
2240
2160
|
}
|
|
2241
2161
|
}
|
|
2242
2162
|
shouldBeIncluded(_context) {
|
|
@@ -2275,19 +2195,6 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
2275
2195
|
withNew: false
|
|
2276
2196
|
};
|
|
2277
2197
|
|
|
2278
|
-
const PureFunctionKey = Symbol('PureFunction');
|
|
2279
|
-
const getPureFunctions = ({ treeshake }) => {
|
|
2280
|
-
const pureFunctions = Object.create(null);
|
|
2281
|
-
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2282
|
-
let currentFunctions = pureFunctions;
|
|
2283
|
-
for (const pathSegment of functionName.split('.')) {
|
|
2284
|
-
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2285
|
-
}
|
|
2286
|
-
currentFunctions[PureFunctionKey] = true;
|
|
2287
|
-
}
|
|
2288
|
-
return pureFunctions;
|
|
2289
|
-
};
|
|
2290
|
-
|
|
2291
2198
|
class Variable extends ExpressionEntity {
|
|
2292
2199
|
markReassigned() {
|
|
2293
2200
|
this.isReassigned = true;
|
|
@@ -2364,9 +2271,9 @@ class Variable extends ExpressionEntity {
|
|
|
2364
2271
|
* has not been included previously. Once a variable is included, it should
|
|
2365
2272
|
* take care all its declarations are included.
|
|
2366
2273
|
*/
|
|
2367
|
-
|
|
2274
|
+
include() {
|
|
2368
2275
|
this.included = true;
|
|
2369
|
-
this.renderedLikeHoisted?.
|
|
2276
|
+
this.renderedLikeHoisted?.include();
|
|
2370
2277
|
}
|
|
2371
2278
|
/**
|
|
2372
2279
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -2398,8 +2305,8 @@ class ExternalVariable extends Variable {
|
|
|
2398
2305
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2399
2306
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2400
2307
|
}
|
|
2401
|
-
|
|
2402
|
-
super.
|
|
2308
|
+
include() {
|
|
2309
|
+
super.include();
|
|
2403
2310
|
this.module.used = true;
|
|
2404
2311
|
}
|
|
2405
2312
|
}
|
|
@@ -2700,6 +2607,36 @@ const childNodeKeys = {
|
|
|
2700
2607
|
YieldExpression: ['argument']
|
|
2701
2608
|
};
|
|
2702
2609
|
|
|
2610
|
+
function createInclusionContext() {
|
|
2611
|
+
return {
|
|
2612
|
+
brokenFlow: false,
|
|
2613
|
+
hasBreak: false,
|
|
2614
|
+
hasContinue: false,
|
|
2615
|
+
includedCallArguments: new Set(),
|
|
2616
|
+
includedLabels: new Set()
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
function createHasEffectsContext() {
|
|
2620
|
+
return {
|
|
2621
|
+
accessed: new PathTracker(),
|
|
2622
|
+
assigned: new PathTracker(),
|
|
2623
|
+
brokenFlow: false,
|
|
2624
|
+
called: new DiscriminatedPathTracker(),
|
|
2625
|
+
hasBreak: false,
|
|
2626
|
+
hasContinue: false,
|
|
2627
|
+
ignore: {
|
|
2628
|
+
breaks: false,
|
|
2629
|
+
continues: false,
|
|
2630
|
+
labels: new Set(),
|
|
2631
|
+
returnYield: false,
|
|
2632
|
+
this: false
|
|
2633
|
+
},
|
|
2634
|
+
includedLabels: new Set(),
|
|
2635
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
2636
|
+
replacedVariableInits: new Map()
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2703
2640
|
const INCLUDE_PARAMETERS = 'variables';
|
|
2704
2641
|
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
2705
2642
|
class NodeBase extends ExpressionEntity {
|
|
@@ -2769,37 +2706,20 @@ class NodeBase extends ExpressionEntity {
|
|
|
2769
2706
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
2770
2707
|
}
|
|
2771
2708
|
include(context, includeChildrenRecursively, _options) {
|
|
2772
|
-
if (!this.included)
|
|
2773
|
-
this.includeNode(context);
|
|
2774
|
-
for (const key of childNodeKeys[this.type]) {
|
|
2775
|
-
const value = this[key];
|
|
2776
|
-
if (value === null)
|
|
2777
|
-
continue;
|
|
2778
|
-
if (Array.isArray(value)) {
|
|
2779
|
-
for (const child of value) {
|
|
2780
|
-
child?.include(context, includeChildrenRecursively);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
else {
|
|
2784
|
-
value.include(context, includeChildrenRecursively);
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
}
|
|
2788
|
-
includeNode(context) {
|
|
2789
|
-
this.included = true;
|
|
2790
2709
|
if (!this.deoptimized)
|
|
2791
2710
|
this.applyDeoptimizations();
|
|
2711
|
+
this.included = true;
|
|
2792
2712
|
for (const key of childNodeKeys[this.type]) {
|
|
2793
2713
|
const value = this[key];
|
|
2794
2714
|
if (value === null)
|
|
2795
2715
|
continue;
|
|
2796
2716
|
if (Array.isArray(value)) {
|
|
2797
2717
|
for (const child of value) {
|
|
2798
|
-
child?.
|
|
2718
|
+
child?.include(context, includeChildrenRecursively);
|
|
2799
2719
|
}
|
|
2800
2720
|
}
|
|
2801
2721
|
else {
|
|
2802
|
-
value.
|
|
2722
|
+
value.include(context, includeChildrenRecursively);
|
|
2803
2723
|
}
|
|
2804
2724
|
}
|
|
2805
2725
|
}
|
|
@@ -2906,17 +2826,6 @@ class NodeBase extends ExpressionEntity {
|
|
|
2906
2826
|
function createChildNodeKeysForNode(esTreeNode) {
|
|
2907
2827
|
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
2908
2828
|
}
|
|
2909
|
-
function onlyIncludeSelf() {
|
|
2910
|
-
this.included = true;
|
|
2911
|
-
if (!this.deoptimized)
|
|
2912
|
-
this.applyDeoptimizations();
|
|
2913
|
-
}
|
|
2914
|
-
function onlyIncludeSelfNoDeoptimize() {
|
|
2915
|
-
this.included = true;
|
|
2916
|
-
}
|
|
2917
|
-
function doNotDeoptimize() {
|
|
2918
|
-
this.deoptimized = true;
|
|
2919
|
-
}
|
|
2920
2829
|
|
|
2921
2830
|
function isObjectExpressionNode(node) {
|
|
2922
2831
|
return node instanceof NodeBase && node.type === ObjectExpression$1;
|
|
@@ -2929,8 +2838,8 @@ function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions =
|
|
|
2929
2838
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2930
2839
|
}
|
|
2931
2840
|
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2932
|
-
getLiteralValueAtPath(
|
|
2933
|
-
return
|
|
2841
|
+
getLiteralValueAtPath() {
|
|
2842
|
+
return undefined;
|
|
2934
2843
|
}
|
|
2935
2844
|
})();
|
|
2936
2845
|
const returnsUnknown = {
|
|
@@ -3127,6 +3036,31 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
3127
3036
|
return [members[memberName].returns, false];
|
|
3128
3037
|
}
|
|
3129
3038
|
|
|
3039
|
+
class SpreadElement extends NodeBase {
|
|
3040
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
3041
|
+
if (path.length > 0) {
|
|
3042
|
+
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
hasEffects(context) {
|
|
3046
|
+
if (!this.deoptimized)
|
|
3047
|
+
this.applyDeoptimizations();
|
|
3048
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
3049
|
+
.treeshake;
|
|
3050
|
+
return (this.argument.hasEffects(context) ||
|
|
3051
|
+
(propertyReadSideEffects &&
|
|
3052
|
+
(propertyReadSideEffects === 'always' ||
|
|
3053
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
3054
|
+
}
|
|
3055
|
+
applyDeoptimizations() {
|
|
3056
|
+
this.deoptimized = true;
|
|
3057
|
+
// Only properties of properties of the argument could become subject to reassignment
|
|
3058
|
+
// This will also reassign the return values of iterators
|
|
3059
|
+
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3060
|
+
this.scope.context.requestTreeshakingPass();
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3130
3064
|
class Method extends ExpressionEntity {
|
|
3131
3065
|
constructor(description) {
|
|
3132
3066
|
super();
|
|
@@ -3252,7 +3186,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3252
3186
|
this.unknownIntegerProps = [];
|
|
3253
3187
|
this.unmatchableGetters = [];
|
|
3254
3188
|
this.unmatchablePropertiesAndGetters = [];
|
|
3255
|
-
this.unmatchablePropertiesAndSetters = [];
|
|
3256
3189
|
this.unmatchableSetters = [];
|
|
3257
3190
|
if (Array.isArray(properties)) {
|
|
3258
3191
|
this.buildPropertyMaps(properties);
|
|
@@ -3487,38 +3420,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3487
3420
|
}
|
|
3488
3421
|
return false;
|
|
3489
3422
|
}
|
|
3490
|
-
include(context, includeChildrenRecursively) {
|
|
3491
|
-
this.included = true;
|
|
3492
|
-
for (const property of this.allProperties) {
|
|
3493
|
-
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
3494
|
-
property.include(context, includeChildrenRecursively);
|
|
3495
|
-
}
|
|
3496
|
-
}
|
|
3497
|
-
this.prototypeExpression?.include(context, includeChildrenRecursively);
|
|
3498
|
-
}
|
|
3499
|
-
includePath(path, context) {
|
|
3500
|
-
this.included = true;
|
|
3501
|
-
if (path.length === 0)
|
|
3502
|
-
return;
|
|
3503
|
-
const [key, ...subPath] = path;
|
|
3504
|
-
const [includedMembers, includedPath] = typeof key === 'string'
|
|
3505
|
-
? [
|
|
3506
|
-
[
|
|
3507
|
-
...new Set([
|
|
3508
|
-
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
3509
|
-
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
3510
|
-
])
|
|
3511
|
-
],
|
|
3512
|
-
subPath
|
|
3513
|
-
]
|
|
3514
|
-
: [this.allProperties, UNKNOWN_PATH];
|
|
3515
|
-
for (const property of includedMembers) {
|
|
3516
|
-
property.includePath(includedPath, context);
|
|
3517
|
-
}
|
|
3518
|
-
this.prototypeExpression?.includePath(path, context);
|
|
3519
|
-
}
|
|
3520
3423
|
buildPropertyMaps(properties) {
|
|
3521
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters,
|
|
3424
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3425
|
+
const unmatchablePropertiesAndSetters = [];
|
|
3522
3426
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
3523
3427
|
const { key, kind, property } = properties[index];
|
|
3524
3428
|
allProperties.push(property);
|
|
@@ -3788,37 +3692,6 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
|
|
|
3788
3692
|
values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
|
|
3789
3693
|
}, OBJECT_PROTOTYPE, true);
|
|
3790
3694
|
|
|
3791
|
-
class SpreadElement extends NodeBase {
|
|
3792
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
3793
|
-
if (path.length > 0) {
|
|
3794
|
-
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
3795
|
-
}
|
|
3796
|
-
}
|
|
3797
|
-
hasEffects(context) {
|
|
3798
|
-
if (!this.deoptimized)
|
|
3799
|
-
this.applyDeoptimizations();
|
|
3800
|
-
const { propertyReadSideEffects } = this.scope.context.options
|
|
3801
|
-
.treeshake;
|
|
3802
|
-
return (this.argument.hasEffects(context) ||
|
|
3803
|
-
(propertyReadSideEffects &&
|
|
3804
|
-
(propertyReadSideEffects === 'always' ||
|
|
3805
|
-
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
3806
|
-
}
|
|
3807
|
-
includeNode(context) {
|
|
3808
|
-
this.included = true;
|
|
3809
|
-
if (!this.deoptimized)
|
|
3810
|
-
this.applyDeoptimizations();
|
|
3811
|
-
this.argument.includePath(UNKNOWN_PATH, context);
|
|
3812
|
-
}
|
|
3813
|
-
applyDeoptimizations() {
|
|
3814
|
-
this.deoptimized = true;
|
|
3815
|
-
// Only properties of properties of the argument could become subject to reassignment
|
|
3816
|
-
// This will also reassign the return values of iterators
|
|
3817
|
-
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3818
|
-
this.scope.context.requestTreeshakingPass();
|
|
3819
|
-
}
|
|
3820
|
-
}
|
|
3821
|
-
|
|
3822
3695
|
class ArrayExpression extends NodeBase {
|
|
3823
3696
|
constructor() {
|
|
3824
3697
|
super(...arguments);
|
|
@@ -3839,16 +3712,6 @@ class ArrayExpression extends NodeBase {
|
|
|
3839
3712
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
3840
3713
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
3841
3714
|
}
|
|
3842
|
-
includeNode(context) {
|
|
3843
|
-
this.included = true;
|
|
3844
|
-
if (!this.deoptimized)
|
|
3845
|
-
this.applyDeoptimizations();
|
|
3846
|
-
for (const element of this.elements) {
|
|
3847
|
-
if (element) {
|
|
3848
|
-
element?.includePath(UNKNOWN_PATH, context);
|
|
3849
|
-
}
|
|
3850
|
-
}
|
|
3851
|
-
}
|
|
3852
3715
|
applyDeoptimizations() {
|
|
3853
3716
|
this.deoptimized = true;
|
|
3854
3717
|
let hasSpread = false;
|
|
@@ -4916,37 +4779,17 @@ class GlobalVariable extends Variable {
|
|
|
4916
4779
|
}
|
|
4917
4780
|
}
|
|
4918
4781
|
|
|
4919
|
-
// To avoid infinite recursions
|
|
4920
|
-
const MAX_PATH_DEPTH = 6;
|
|
4921
|
-
// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at
|
|
4922
|
-
// most MAX_PATH_DEPTH long. The last element is always UnknownKey
|
|
4923
|
-
const limitConcatenatedPathDepth = (path1, path2) => {
|
|
4924
|
-
const { length: length1 } = path1;
|
|
4925
|
-
const { length: length2 } = path2;
|
|
4926
|
-
return length1 === 0
|
|
4927
|
-
? path2
|
|
4928
|
-
: length2 === 0
|
|
4929
|
-
? path1
|
|
4930
|
-
: length1 + length2 > MAX_PATH_DEPTH
|
|
4931
|
-
? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey']
|
|
4932
|
-
: [...path1, ...path2];
|
|
4933
|
-
};
|
|
4934
|
-
|
|
4935
4782
|
class LocalVariable extends Variable {
|
|
4936
|
-
constructor(name, declarator, init,
|
|
4937
|
-
/** if this is non-empty, the actual init is this path of this.init */
|
|
4938
|
-
initPath, context, kind) {
|
|
4783
|
+
constructor(name, declarator, init, context, kind) {
|
|
4939
4784
|
super(name);
|
|
4940
4785
|
this.init = init;
|
|
4941
|
-
this.initPath = initPath;
|
|
4942
|
-
this.kind = kind;
|
|
4943
4786
|
this.calledFromTryStatement = false;
|
|
4944
4787
|
this.additionalInitializers = null;
|
|
4945
|
-
this.includedPathTracker = new IncludedPathTracker();
|
|
4946
4788
|
this.expressionsToBeDeoptimized = [];
|
|
4947
4789
|
this.declarations = declarator ? [declarator] : [];
|
|
4948
4790
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
4949
4791
|
this.module = context.module;
|
|
4792
|
+
this.kind = kind;
|
|
4950
4793
|
}
|
|
4951
4794
|
addDeclaration(identifier, init) {
|
|
4952
4795
|
this.declarations.push(identifier);
|
|
@@ -4957,16 +4800,15 @@ class LocalVariable extends Variable {
|
|
|
4957
4800
|
for (const initializer of this.additionalInitializers) {
|
|
4958
4801
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
4959
4802
|
}
|
|
4803
|
+
this.additionalInitializers = null;
|
|
4960
4804
|
}
|
|
4961
4805
|
}
|
|
4962
4806
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
4963
|
-
if (this.isReassigned
|
|
4807
|
+
if (this.isReassigned) {
|
|
4964
4808
|
deoptimizeInteraction(interaction);
|
|
4965
4809
|
return;
|
|
4966
4810
|
}
|
|
4967
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () =>
|
|
4968
|
-
this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], recursionTracker);
|
|
4969
|
-
}, undefined);
|
|
4811
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
4970
4812
|
}
|
|
4971
4813
|
deoptimizePath(path) {
|
|
4972
4814
|
if (this.isReassigned ||
|
|
@@ -4980,40 +4822,37 @@ class LocalVariable extends Variable {
|
|
|
4980
4822
|
for (const expression of expressionsToBeDeoptimized) {
|
|
4981
4823
|
expression.deoptimizeCache();
|
|
4982
4824
|
}
|
|
4983
|
-
this.init.deoptimizePath(
|
|
4825
|
+
this.init.deoptimizePath(UNKNOWN_PATH);
|
|
4984
4826
|
}
|
|
4985
4827
|
else {
|
|
4986
|
-
this.init.deoptimizePath(
|
|
4828
|
+
this.init.deoptimizePath(path);
|
|
4987
4829
|
}
|
|
4988
4830
|
}
|
|
4989
4831
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
4990
|
-
if (this.isReassigned
|
|
4832
|
+
if (this.isReassigned) {
|
|
4991
4833
|
return UnknownValue;
|
|
4992
4834
|
}
|
|
4993
4835
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4994
4836
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4995
|
-
return this.init.getLiteralValueAtPath(
|
|
4837
|
+
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
4996
4838
|
}, UnknownValue);
|
|
4997
4839
|
}
|
|
4998
4840
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
4999
|
-
if (this.isReassigned
|
|
4841
|
+
if (this.isReassigned) {
|
|
5000
4842
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
5001
4843
|
}
|
|
5002
4844
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
5003
4845
|
this.expressionsToBeDeoptimized.push(origin);
|
|
5004
|
-
return this.init.getReturnExpressionWhenCalledAtPath(
|
|
4846
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
5005
4847
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
5006
4848
|
}
|
|
5007
4849
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5008
|
-
if (path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5009
|
-
return true;
|
|
5010
|
-
}
|
|
5011
4850
|
switch (interaction.type) {
|
|
5012
4851
|
case INTERACTION_ACCESSED: {
|
|
5013
4852
|
if (this.isReassigned)
|
|
5014
4853
|
return true;
|
|
5015
4854
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
5016
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4855
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5017
4856
|
}
|
|
5018
4857
|
case INTERACTION_ASSIGNED: {
|
|
5019
4858
|
if (this.included)
|
|
@@ -5023,63 +4862,44 @@ class LocalVariable extends Variable {
|
|
|
5023
4862
|
if (this.isReassigned)
|
|
5024
4863
|
return true;
|
|
5025
4864
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
5026
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4865
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5027
4866
|
}
|
|
5028
4867
|
case INTERACTION_CALLED: {
|
|
5029
4868
|
if (this.isReassigned)
|
|
5030
4869
|
return true;
|
|
5031
4870
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
5032
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4871
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5033
4872
|
}
|
|
5034
4873
|
}
|
|
5035
4874
|
}
|
|
5036
|
-
|
|
5037
|
-
if (!this.
|
|
5038
|
-
|
|
5039
|
-
if (!this.included) {
|
|
5040
|
-
// This will reduce the number of tree-shaking passes by eagerly
|
|
5041
|
-
// including inits. By pushing this here instead of directly including
|
|
5042
|
-
// we avoid deep call stacks.
|
|
5043
|
-
this.module.scope.context.newlyIncludedVariableInits.add(this.init);
|
|
5044
|
-
}
|
|
5045
|
-
super.includePath(path, context);
|
|
4875
|
+
include() {
|
|
4876
|
+
if (!this.included) {
|
|
4877
|
+
super.include();
|
|
5046
4878
|
for (const declaration of this.declarations) {
|
|
5047
4879
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
5048
4880
|
if (!declaration.included)
|
|
5049
|
-
declaration.include(
|
|
4881
|
+
declaration.include(createInclusionContext(), false);
|
|
5050
4882
|
let node = declaration.parent;
|
|
5051
4883
|
while (!node.included) {
|
|
5052
4884
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
5053
4885
|
// in which case .include() might pull in more dead code
|
|
5054
|
-
node.
|
|
4886
|
+
node.included = true;
|
|
5055
4887
|
if (node.type === Program$1)
|
|
5056
4888
|
break;
|
|
5057
4889
|
node = node.parent;
|
|
5058
4890
|
}
|
|
5059
4891
|
}
|
|
5060
|
-
// We need to make sure we include the correct path of the init
|
|
5061
|
-
if (path.length > 0) {
|
|
5062
|
-
this.init.includePath(limitConcatenatedPathDepth(this.initPath, path), context);
|
|
5063
|
-
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context));
|
|
5064
|
-
}
|
|
5065
4892
|
}
|
|
5066
4893
|
}
|
|
5067
|
-
includeCallArguments(context,
|
|
5068
|
-
if (this.isReassigned ||
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
// a specific path
|
|
5072
|
-
this.initPath.length > 0) {
|
|
5073
|
-
for (const argument of interaction.args) {
|
|
5074
|
-
if (argument) {
|
|
5075
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
5076
|
-
argument.include(context, false);
|
|
5077
|
-
}
|
|
4894
|
+
includeCallArguments(context, parameters) {
|
|
4895
|
+
if (this.isReassigned || context.includedCallArguments.has(this.init)) {
|
|
4896
|
+
for (const argument of parameters) {
|
|
4897
|
+
argument.include(context, false);
|
|
5078
4898
|
}
|
|
5079
4899
|
}
|
|
5080
4900
|
else {
|
|
5081
4901
|
context.includedCallArguments.add(this.init);
|
|
5082
|
-
this.init.includeCallArguments(context,
|
|
4902
|
+
this.init.includeCallArguments(context, parameters);
|
|
5083
4903
|
context.includedCallArguments.delete(this.init);
|
|
5084
4904
|
}
|
|
5085
4905
|
}
|
|
@@ -5159,31 +4979,18 @@ class IdentifierBase extends NodeBase {
|
|
|
5159
4979
|
}
|
|
5160
4980
|
}
|
|
5161
4981
|
}
|
|
5162
|
-
include(
|
|
5163
|
-
if (!this.included)
|
|
5164
|
-
this.includeNode(context);
|
|
5165
|
-
}
|
|
5166
|
-
includeNode(context) {
|
|
5167
|
-
this.included = true;
|
|
4982
|
+
include() {
|
|
5168
4983
|
if (!this.deoptimized)
|
|
5169
4984
|
this.applyDeoptimizations();
|
|
5170
|
-
if (this.variable !== null) {
|
|
5171
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5172
|
-
}
|
|
5173
|
-
}
|
|
5174
|
-
includePath(path, context) {
|
|
5175
4985
|
if (!this.included) {
|
|
5176
4986
|
this.included = true;
|
|
5177
4987
|
if (this.variable !== null) {
|
|
5178
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
4988
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
5179
4989
|
}
|
|
5180
4990
|
}
|
|
5181
|
-
else if (path.length > 0) {
|
|
5182
|
-
this.variable?.includePath(path, context);
|
|
5183
|
-
}
|
|
5184
4991
|
}
|
|
5185
|
-
includeCallArguments(context,
|
|
5186
|
-
this.variable.includeCallArguments(context,
|
|
4992
|
+
includeCallArguments(context, parameters) {
|
|
4993
|
+
this.variable.includeCallArguments(context, parameters);
|
|
5187
4994
|
}
|
|
5188
4995
|
isPossibleTDZ() {
|
|
5189
4996
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -5266,40 +5073,11 @@ function closestParentFunctionOrProgram(node) {
|
|
|
5266
5073
|
return node;
|
|
5267
5074
|
}
|
|
5268
5075
|
|
|
5269
|
-
class ObjectMember extends ExpressionEntity {
|
|
5270
|
-
constructor(object, path) {
|
|
5271
|
-
super();
|
|
5272
|
-
this.object = object;
|
|
5273
|
-
this.path = path;
|
|
5274
|
-
}
|
|
5275
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5276
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.path, ...path], recursionTracker);
|
|
5277
|
-
}
|
|
5278
|
-
deoptimizePath(path) {
|
|
5279
|
-
this.object.deoptimizePath([...this.path, ...path]);
|
|
5280
|
-
}
|
|
5281
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5282
|
-
return this.object.getLiteralValueAtPath([...this.path, ...path], recursionTracker, origin);
|
|
5283
|
-
}
|
|
5284
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5285
|
-
return this.object.getReturnExpressionWhenCalledAtPath([...this.path, ...path], interaction, recursionTracker, origin);
|
|
5286
|
-
}
|
|
5287
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5288
|
-
return this.object.hasEffectsOnInteractionAtPath([...this.path, ...path], interaction, context);
|
|
5289
|
-
}
|
|
5290
|
-
}
|
|
5291
|
-
|
|
5292
5076
|
class Identifier extends IdentifierBase {
|
|
5293
5077
|
constructor() {
|
|
5294
5078
|
super(...arguments);
|
|
5295
5079
|
this.variable = null;
|
|
5296
5080
|
}
|
|
5297
|
-
get isDestructuringDeoptimized() {
|
|
5298
|
-
return isFlagSet(this.flags, 16777216 /* Flag.destructuringDeoptimized */);
|
|
5299
|
-
}
|
|
5300
|
-
set isDestructuringDeoptimized(value) {
|
|
5301
|
-
this.flags = setFlag(this.flags, 16777216 /* Flag.destructuringDeoptimized */, value);
|
|
5302
|
-
}
|
|
5303
5081
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
5304
5082
|
if (exportNamesByVariable.has(this.variable)) {
|
|
5305
5083
|
variables.push(this.variable);
|
|
@@ -5312,52 +5090,42 @@ class Identifier extends IdentifierBase {
|
|
|
5312
5090
|
this.isVariableReference = true;
|
|
5313
5091
|
}
|
|
5314
5092
|
}
|
|
5315
|
-
declare(kind,
|
|
5093
|
+
declare(kind, init) {
|
|
5316
5094
|
let variable;
|
|
5317
5095
|
const { treeshake } = this.scope.context.options;
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5096
|
+
switch (kind) {
|
|
5097
|
+
case 'var': {
|
|
5098
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5099
|
+
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
5100
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
5101
|
+
variable.markInitializersForDeoptimization();
|
|
5102
|
+
}
|
|
5103
|
+
break;
|
|
5326
5104
|
}
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
if ((this.included ||=
|
|
5349
|
-
destructuredInitPath.length > 0 &&
|
|
5350
|
-
!context.brokenFlow &&
|
|
5351
|
-
propertyReadSideEffects &&
|
|
5352
|
-
(propertyReadSideEffects === 'always' ||
|
|
5353
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext())))) {
|
|
5354
|
-
if (this.variable && !this.variable.included) {
|
|
5355
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5105
|
+
case 'function': {
|
|
5106
|
+
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
5107
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5108
|
+
break;
|
|
5109
|
+
}
|
|
5110
|
+
case 'let':
|
|
5111
|
+
case 'const':
|
|
5112
|
+
case 'using':
|
|
5113
|
+
case 'await using':
|
|
5114
|
+
case 'class': {
|
|
5115
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5116
|
+
break;
|
|
5117
|
+
}
|
|
5118
|
+
case 'parameter': {
|
|
5119
|
+
variable = this.scope.addParameterDeclaration(this);
|
|
5120
|
+
break;
|
|
5121
|
+
}
|
|
5122
|
+
/* istanbul ignore next */
|
|
5123
|
+
default: {
|
|
5124
|
+
/* istanbul ignore next */
|
|
5125
|
+
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
5356
5126
|
}
|
|
5357
|
-
init.includePath(destructuredInitPath, context);
|
|
5358
|
-
return true;
|
|
5359
5127
|
}
|
|
5360
|
-
return
|
|
5128
|
+
return [(this.variable = variable)];
|
|
5361
5129
|
}
|
|
5362
5130
|
markDeclarationReached() {
|
|
5363
5131
|
this.variable.initReached = true;
|
|
@@ -5423,17 +5191,18 @@ class Scope {
|
|
|
5423
5191
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
5424
5192
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
5425
5193
|
*/
|
|
5426
|
-
addDeclaration(identifier, context, init,
|
|
5194
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5427
5195
|
const name = identifier.name;
|
|
5428
5196
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5429
5197
|
if (existingVariable) {
|
|
5430
|
-
|
|
5198
|
+
const existingKind = existingVariable.kind;
|
|
5199
|
+
if (kind === 'var' && existingKind === 'var') {
|
|
5431
5200
|
existingVariable.addDeclaration(identifier, init);
|
|
5432
5201
|
return existingVariable;
|
|
5433
5202
|
}
|
|
5434
5203
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5435
5204
|
}
|
|
5436
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5205
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
5437
5206
|
this.variables.set(name, newVariable);
|
|
5438
5207
|
return newVariable;
|
|
5439
5208
|
}
|
|
@@ -5609,6 +5378,7 @@ class MethodBase extends NodeBase {
|
|
|
5609
5378
|
}
|
|
5610
5379
|
return this.getAccessedValue()[0].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5611
5380
|
}
|
|
5381
|
+
applyDeoptimizations() { }
|
|
5612
5382
|
getAccessedValue() {
|
|
5613
5383
|
if (this.accessedValue === null) {
|
|
5614
5384
|
if (this.kind === 'get') {
|
|
@@ -5622,20 +5392,19 @@ class MethodBase extends NodeBase {
|
|
|
5622
5392
|
return this.accessedValue;
|
|
5623
5393
|
}
|
|
5624
5394
|
}
|
|
5625
|
-
MethodBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5626
|
-
MethodBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5627
5395
|
|
|
5628
5396
|
class MethodDefinition extends MethodBase {
|
|
5629
5397
|
hasEffects(context) {
|
|
5630
5398
|
return super.hasEffects(context) || checkEffectForNodes(this.decorators, context);
|
|
5631
5399
|
}
|
|
5400
|
+
applyDeoptimizations() { }
|
|
5632
5401
|
}
|
|
5633
5402
|
|
|
5634
5403
|
class BlockScope extends ChildScope {
|
|
5635
5404
|
constructor(parent) {
|
|
5636
5405
|
super(parent, parent.context);
|
|
5637
5406
|
}
|
|
5638
|
-
addDeclaration(identifier, context, init,
|
|
5407
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5639
5408
|
if (kind === 'var') {
|
|
5640
5409
|
const name = identifier.name;
|
|
5641
5410
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5647,7 +5416,7 @@ class BlockScope extends ChildScope {
|
|
|
5647
5416
|
}
|
|
5648
5417
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5649
5418
|
}
|
|
5650
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init,
|
|
5419
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
5651
5420
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5652
5421
|
// We cannot call deoptimizePath here.
|
|
5653
5422
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5655,7 +5424,7 @@ class BlockScope extends ChildScope {
|
|
|
5655
5424
|
this.addHoistedVariable(name, declaredVariable);
|
|
5656
5425
|
return declaredVariable;
|
|
5657
5426
|
}
|
|
5658
|
-
return super.addDeclaration(identifier, context, init,
|
|
5427
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
5659
5428
|
}
|
|
5660
5429
|
}
|
|
5661
5430
|
|
|
@@ -5687,12 +5456,33 @@ class StaticBlock extends NodeBase {
|
|
|
5687
5456
|
}
|
|
5688
5457
|
}
|
|
5689
5458
|
}
|
|
5690
|
-
StaticBlock.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5691
|
-
StaticBlock.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5692
5459
|
function isStaticBlock(statement) {
|
|
5693
5460
|
return statement.type === StaticBlock$1;
|
|
5694
5461
|
}
|
|
5695
5462
|
|
|
5463
|
+
class ObjectMember extends ExpressionEntity {
|
|
5464
|
+
constructor(object, key) {
|
|
5465
|
+
super();
|
|
5466
|
+
this.object = object;
|
|
5467
|
+
this.key = key;
|
|
5468
|
+
}
|
|
5469
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5470
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
5471
|
+
}
|
|
5472
|
+
deoptimizePath(path) {
|
|
5473
|
+
this.object.deoptimizePath([this.key, ...path]);
|
|
5474
|
+
}
|
|
5475
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5476
|
+
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
5477
|
+
}
|
|
5478
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5479
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
5480
|
+
}
|
|
5481
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5482
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
|
|
5696
5486
|
class ClassNode extends NodeBase {
|
|
5697
5487
|
constructor() {
|
|
5698
5488
|
super(...arguments);
|
|
@@ -5733,20 +5523,21 @@ class ClassNode extends NodeBase {
|
|
|
5733
5523
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5734
5524
|
}
|
|
5735
5525
|
include(context, includeChildrenRecursively) {
|
|
5736
|
-
if (!this.
|
|
5737
|
-
this.
|
|
5526
|
+
if (!this.deoptimized)
|
|
5527
|
+
this.applyDeoptimizations();
|
|
5528
|
+
this.included = true;
|
|
5738
5529
|
this.superClass?.include(context, includeChildrenRecursively);
|
|
5739
5530
|
this.body.include(context, includeChildrenRecursively);
|
|
5740
5531
|
for (const decorator of this.decorators)
|
|
5741
5532
|
decorator.include(context, includeChildrenRecursively);
|
|
5742
5533
|
if (this.id) {
|
|
5743
5534
|
this.id.markDeclarationReached();
|
|
5744
|
-
this.id.include(
|
|
5535
|
+
this.id.include();
|
|
5745
5536
|
}
|
|
5746
5537
|
}
|
|
5747
5538
|
initialise() {
|
|
5748
5539
|
super.initialise();
|
|
5749
|
-
this.id?.declare('class',
|
|
5540
|
+
this.id?.declare('class', this);
|
|
5750
5541
|
for (const method of this.body.body) {
|
|
5751
5542
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
5752
5543
|
this.classConstructor = method;
|
|
@@ -5804,12 +5595,11 @@ class ClassNode extends NodeBase {
|
|
|
5804
5595
|
staticProperties.unshift({
|
|
5805
5596
|
key: 'prototype',
|
|
5806
5597
|
kind: 'init',
|
|
5807
|
-
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass,
|
|
5598
|
+
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass, 'prototype') : OBJECT_PROTOTYPE)
|
|
5808
5599
|
});
|
|
5809
5600
|
return (this.objectEntity = new ObjectEntity(staticProperties, this.superClass || OBJECT_PROTOTYPE));
|
|
5810
5601
|
}
|
|
5811
5602
|
}
|
|
5812
|
-
ClassNode.prototype.includeNode = onlyIncludeSelf;
|
|
5813
5603
|
|
|
5814
5604
|
class ClassDeclaration extends ClassNode {
|
|
5815
5605
|
initialise() {
|
|
@@ -5862,7 +5652,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
5862
5652
|
|
|
5863
5653
|
class ArgumentsVariable extends LocalVariable {
|
|
5864
5654
|
constructor(context) {
|
|
5865
|
-
super('arguments', null, UNKNOWN_EXPRESSION,
|
|
5655
|
+
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
5866
5656
|
this.deoptimizedArguments = [];
|
|
5867
5657
|
}
|
|
5868
5658
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -5876,8 +5666,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5876
5666
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5877
5667
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
5878
5668
|
}
|
|
5879
|
-
|
|
5880
|
-
super.
|
|
5669
|
+
include() {
|
|
5670
|
+
super.include();
|
|
5881
5671
|
for (const argument of this.deoptimizedArguments) {
|
|
5882
5672
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
5883
5673
|
}
|
|
@@ -5888,28 +5678,27 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5888
5678
|
const MAX_TRACKED_INTERACTIONS = 20;
|
|
5889
5679
|
const NO_INTERACTIONS = EMPTY_ARRAY;
|
|
5890
5680
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
5891
|
-
const EMPTY_PATH_TRACKER = new
|
|
5681
|
+
const EMPTY_PATH_TRACKER = new PathTracker();
|
|
5892
5682
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
5893
5683
|
class ParameterVariable extends LocalVariable {
|
|
5894
|
-
constructor(name, declarator,
|
|
5895
|
-
super(name, declarator, UNKNOWN_EXPRESSION,
|
|
5684
|
+
constructor(name, declarator, context) {
|
|
5685
|
+
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
5896
5686
|
this.deoptimizationInteractions = [];
|
|
5897
|
-
this.deoptimizations = new
|
|
5687
|
+
this.deoptimizations = new PathTracker();
|
|
5898
5688
|
this.deoptimizedFields = new Set();
|
|
5899
|
-
this.
|
|
5900
|
-
this.
|
|
5689
|
+
this.entitiesToBeDeoptimized = new Set();
|
|
5690
|
+
this.expressionsUseTheKnownValue = [];
|
|
5901
5691
|
this.knownValue = null;
|
|
5902
5692
|
this.knownValueLiteral = UnknownValue;
|
|
5903
5693
|
this.frozenValue = null;
|
|
5904
5694
|
}
|
|
5905
|
-
|
|
5906
|
-
this.updateKnownValue(entity);
|
|
5695
|
+
addEntityToBeDeoptimized(entity) {
|
|
5907
5696
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
5908
5697
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
5909
5698
|
// the interaction cache at this point provided we keep this optimization
|
|
5910
5699
|
// in mind when adding new interactions
|
|
5911
|
-
if (!this.
|
|
5912
|
-
this.
|
|
5700
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5701
|
+
this.entitiesToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
5913
5702
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
5914
5703
|
deoptimizeInteraction(interaction);
|
|
5915
5704
|
}
|
|
@@ -5919,34 +5708,27 @@ class ParameterVariable extends LocalVariable {
|
|
|
5919
5708
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5920
5709
|
// This means that we already deoptimized all interactions and no longer
|
|
5921
5710
|
// track them
|
|
5922
|
-
entity.deoptimizePath(
|
|
5711
|
+
entity.deoptimizePath(UNKNOWN_PATH);
|
|
5923
5712
|
}
|
|
5924
|
-
else if (!this.
|
|
5925
|
-
this.
|
|
5713
|
+
else if (!this.entitiesToBeDeoptimized.has(entity)) {
|
|
5714
|
+
this.entitiesToBeDeoptimized.add(entity);
|
|
5926
5715
|
for (const field of this.deoptimizedFields) {
|
|
5927
|
-
entity.deoptimizePath([
|
|
5716
|
+
entity.deoptimizePath([field]);
|
|
5928
5717
|
}
|
|
5929
5718
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
5930
|
-
|
|
5931
|
-
deoptimizeInteraction(interaction);
|
|
5932
|
-
continue;
|
|
5933
|
-
}
|
|
5934
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
5719
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5935
5720
|
}
|
|
5936
5721
|
}
|
|
5937
5722
|
}
|
|
5938
|
-
/** This says we should not make assumptions about the value of the parameter.
|
|
5939
|
-
* This is different from deoptimization that will also cause argument values
|
|
5940
|
-
* to be deoptimized. */
|
|
5941
5723
|
markReassigned() {
|
|
5942
5724
|
if (this.isReassigned) {
|
|
5943
5725
|
return;
|
|
5944
5726
|
}
|
|
5945
5727
|
super.markReassigned();
|
|
5946
|
-
for (const expression of this.
|
|
5728
|
+
for (const expression of this.expressionsUseTheKnownValue) {
|
|
5947
5729
|
expression.deoptimizeCache();
|
|
5948
5730
|
}
|
|
5949
|
-
this.
|
|
5731
|
+
this.expressionsUseTheKnownValue = EMPTY_ARRAY;
|
|
5950
5732
|
}
|
|
5951
5733
|
deoptimizeCache() {
|
|
5952
5734
|
this.markReassigned();
|
|
@@ -5963,7 +5745,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5963
5745
|
}
|
|
5964
5746
|
if (this.knownValue === null) {
|
|
5965
5747
|
this.knownValue = argument;
|
|
5966
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
5748
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5967
5749
|
return;
|
|
5968
5750
|
}
|
|
5969
5751
|
// the same literal or identifier, do nothing
|
|
@@ -5979,7 +5761,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5979
5761
|
return;
|
|
5980
5762
|
}
|
|
5981
5763
|
// add tracking for the new argument
|
|
5982
|
-
const newValue = argument.getLiteralValueAtPath(
|
|
5764
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5983
5765
|
if (newValue !== oldValue) {
|
|
5984
5766
|
this.markReassigned();
|
|
5985
5767
|
}
|
|
@@ -5997,31 +5779,24 @@ class ParameterVariable extends LocalVariable {
|
|
|
5997
5779
|
return this.frozenValue;
|
|
5998
5780
|
}
|
|
5999
5781
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6000
|
-
if (this.isReassigned
|
|
5782
|
+
if (this.isReassigned) {
|
|
6001
5783
|
return UnknownValue;
|
|
6002
5784
|
}
|
|
6003
5785
|
const knownValue = this.getKnownValue();
|
|
6004
|
-
this.
|
|
6005
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(
|
|
5786
|
+
this.expressionsUseTheKnownValue.push(origin);
|
|
5787
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
6006
5788
|
}
|
|
6007
5789
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6008
|
-
|
|
6009
|
-
if (this.isReassigned ||
|
|
6010
|
-
type === INTERACTION_ASSIGNED ||
|
|
6011
|
-
path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5790
|
+
if (this.isReassigned || interaction.type === INTERACTION_ASSIGNED) {
|
|
6012
5791
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6013
5792
|
}
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
? context.instantiated
|
|
6017
|
-
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
6018
|
-
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
6019
|
-
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
5793
|
+
const knownValue = this.getKnownValue();
|
|
5794
|
+
return knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6020
5795
|
}
|
|
6021
5796
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
6022
5797
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
6023
5798
|
if (path.length >= 2 ||
|
|
6024
|
-
this.
|
|
5799
|
+
this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
6025
5800
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
6026
5801
|
(path.length === 1 &&
|
|
6027
5802
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
@@ -6030,10 +5805,10 @@ class ParameterVariable extends LocalVariable {
|
|
|
6030
5805
|
return;
|
|
6031
5806
|
}
|
|
6032
5807
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
6033
|
-
for (const entity of this.
|
|
6034
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
5808
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
5809
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
6035
5810
|
}
|
|
6036
|
-
if (!this.
|
|
5811
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
6037
5812
|
this.deoptimizationInteractions.push({
|
|
6038
5813
|
interaction,
|
|
6039
5814
|
path
|
|
@@ -6054,17 +5829,17 @@ class ParameterVariable extends LocalVariable {
|
|
|
6054
5829
|
return;
|
|
6055
5830
|
}
|
|
6056
5831
|
this.deoptimizedFields.add(key);
|
|
6057
|
-
for (const entity of this.
|
|
5832
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
6058
5833
|
// We do not need a recursion tracker here as we already track whether
|
|
6059
5834
|
// this field is deoptimized
|
|
6060
|
-
entity.deoptimizePath([
|
|
5835
|
+
entity.deoptimizePath([key]);
|
|
6061
5836
|
}
|
|
6062
5837
|
if (key === UnknownKey) {
|
|
6063
5838
|
// save some memory
|
|
6064
5839
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
6065
5840
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
6066
5841
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
6067
|
-
this.
|
|
5842
|
+
this.entitiesToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
6068
5843
|
}
|
|
6069
5844
|
}
|
|
6070
5845
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -6079,14 +5854,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
6079
5854
|
}
|
|
6080
5855
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
6081
5856
|
}
|
|
6082
|
-
includeArgumentPaths(entity, context) {
|
|
6083
|
-
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
6084
|
-
}
|
|
6085
5857
|
}
|
|
6086
5858
|
|
|
6087
5859
|
class ThisVariable extends ParameterVariable {
|
|
6088
5860
|
constructor(context) {
|
|
6089
|
-
super('this', null,
|
|
5861
|
+
super('this', null, context);
|
|
6090
5862
|
}
|
|
6091
5863
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6092
5864
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -6098,7 +5870,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6098
5870
|
super(parent, parent.context);
|
|
6099
5871
|
this.parent = parent;
|
|
6100
5872
|
}
|
|
6101
|
-
addDeclaration(identifier, context, init,
|
|
5873
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6102
5874
|
if (kind === 'var') {
|
|
6103
5875
|
const name = identifier.name;
|
|
6104
5876
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -6111,7 +5883,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6111
5883
|
// the assignment actually goes to the parameter and the var is
|
|
6112
5884
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
6113
5885
|
// parameter
|
|
6114
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION,
|
|
5886
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
6115
5887
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
6116
5888
|
// names. If we ever implement a logic that splits initialization and
|
|
6117
5889
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -6130,7 +5902,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6130
5902
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
6131
5903
|
}
|
|
6132
5904
|
// We only add parameters to parameter scopes
|
|
6133
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init,
|
|
5905
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
6134
5906
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
6135
5907
|
// We cannot call deoptimizePath here.
|
|
6136
5908
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -6138,7 +5910,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6138
5910
|
this.addHoistedVariable(name, declaredVariable);
|
|
6139
5911
|
return declaredVariable;
|
|
6140
5912
|
}
|
|
6141
|
-
return super.addDeclaration(identifier, context, init,
|
|
5913
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
6142
5914
|
}
|
|
6143
5915
|
}
|
|
6144
5916
|
|
|
@@ -6148,7 +5920,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6148
5920
|
}
|
|
6149
5921
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
6150
5922
|
// be redeclared, functions and var can redeclare each other
|
|
6151
|
-
addDeclaration(identifier, context, init,
|
|
5923
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6152
5924
|
const name = identifier.name;
|
|
6153
5925
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6154
5926
|
if (existingVariable) {
|
|
@@ -6160,7 +5932,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6160
5932
|
}
|
|
6161
5933
|
context.error(logRedeclarationError(name), identifier.start);
|
|
6162
5934
|
}
|
|
6163
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5935
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
6164
5936
|
this.variables.set(name, newVariable);
|
|
6165
5937
|
return newVariable;
|
|
6166
5938
|
}
|
|
@@ -6169,21 +5941,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6169
5941
|
class ParameterScope extends ChildScope {
|
|
6170
5942
|
constructor(parent, isCatchScope) {
|
|
6171
5943
|
super(parent, parent.context);
|
|
6172
|
-
this.hasRest = false;
|
|
6173
5944
|
this.parameters = [];
|
|
5945
|
+
this.hasRest = false;
|
|
6174
5946
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
6175
5947
|
}
|
|
6176
5948
|
/**
|
|
6177
5949
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
6178
5950
|
* order, i.e. from left to right.
|
|
6179
5951
|
*/
|
|
6180
|
-
addParameterDeclaration(identifier
|
|
5952
|
+
addParameterDeclaration(identifier) {
|
|
6181
5953
|
const { name, start } = identifier;
|
|
6182
5954
|
const existingParameter = this.variables.get(name);
|
|
6183
5955
|
if (existingParameter) {
|
|
6184
5956
|
return this.context.error(logDuplicateArgumentNameError(name), start);
|
|
6185
5957
|
}
|
|
6186
|
-
const variable = new ParameterVariable(name, identifier,
|
|
5958
|
+
const variable = new ParameterVariable(name, identifier, this.context);
|
|
6187
5959
|
this.variables.set(name, variable);
|
|
6188
5960
|
// We also add it to the body scope to detect name conflicts with local
|
|
6189
5961
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -6201,56 +5973,42 @@ class ParameterScope extends ChildScope {
|
|
|
6201
5973
|
}
|
|
6202
5974
|
this.hasRest = hasRest;
|
|
6203
5975
|
}
|
|
6204
|
-
includeCallArguments(context,
|
|
5976
|
+
includeCallArguments(context, parameters) {
|
|
6205
5977
|
let calledFromTryStatement = false;
|
|
6206
5978
|
let argumentIncluded = false;
|
|
6207
5979
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
6208
|
-
const
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
if (argument instanceof SpreadElement && !argumentIncluded) {
|
|
6215
|
-
argumentIncluded = true;
|
|
6216
|
-
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
6217
|
-
}
|
|
6218
|
-
if (argumentIncluded) {
|
|
6219
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
6220
|
-
argument.include(context, false);
|
|
5980
|
+
for (const checkedArgument of parameters) {
|
|
5981
|
+
if (checkedArgument instanceof SpreadElement) {
|
|
5982
|
+
for (const argument of parameters) {
|
|
5983
|
+
argument.include(context, false);
|
|
5984
|
+
}
|
|
5985
|
+
break;
|
|
6221
5986
|
}
|
|
6222
5987
|
}
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
6227
|
-
const argument = args[index];
|
|
5988
|
+
for (let index = parameters.length - 1; index >= 0; index--) {
|
|
5989
|
+
const parameterVariables = this.parameters[index] || restParameter;
|
|
5990
|
+
const argument = parameters[index];
|
|
6228
5991
|
if (parameterVariables) {
|
|
6229
5992
|
calledFromTryStatement = false;
|
|
6230
5993
|
if (parameterVariables.length === 0) {
|
|
6231
|
-
// handle empty destructuring
|
|
5994
|
+
// handle empty destructuring
|
|
6232
5995
|
argumentIncluded = true;
|
|
6233
5996
|
}
|
|
6234
5997
|
else {
|
|
6235
5998
|
for (const variable of parameterVariables) {
|
|
6236
|
-
if (variable.calledFromTryStatement) {
|
|
6237
|
-
calledFromTryStatement = true;
|
|
6238
|
-
}
|
|
6239
5999
|
if (variable.included) {
|
|
6240
6000
|
argumentIncluded = true;
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
else {
|
|
6245
|
-
variable.includeArgumentPaths(argument, context);
|
|
6246
|
-
argument.include(context, false);
|
|
6247
|
-
}
|
|
6001
|
+
}
|
|
6002
|
+
if (variable.calledFromTryStatement) {
|
|
6003
|
+
calledFromTryStatement = true;
|
|
6248
6004
|
}
|
|
6249
6005
|
}
|
|
6250
6006
|
}
|
|
6251
6007
|
}
|
|
6252
|
-
if (!
|
|
6008
|
+
if (!argumentIncluded && argument.shouldBeIncluded(context)) {
|
|
6253
6009
|
argumentIncluded = true;
|
|
6010
|
+
}
|
|
6011
|
+
if (argumentIncluded) {
|
|
6254
6012
|
argument.include(context, calledFromTryStatement);
|
|
6255
6013
|
}
|
|
6256
6014
|
}
|
|
@@ -6266,62 +6024,11 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6266
6024
|
addReturnExpression(expression) {
|
|
6267
6025
|
this.returnExpressions.push(expression);
|
|
6268
6026
|
}
|
|
6269
|
-
deoptimizeArgumentsOnCall(interaction) {
|
|
6270
|
-
const { parameters } = this;
|
|
6271
|
-
const { args } = interaction;
|
|
6272
|
-
let position = 0;
|
|
6273
|
-
for (; position < args.length - 1; position++) {
|
|
6274
|
-
// Only the "this" argument arg[0] can be null
|
|
6275
|
-
const argument = args[position + 1];
|
|
6276
|
-
if (argument instanceof SpreadElement) {
|
|
6277
|
-
// This deoptimizes the current and remaining parameters and arguments
|
|
6278
|
-
for (; position < parameters.length; position++) {
|
|
6279
|
-
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
6280
|
-
parameters[position].forEach(variable => variable.markReassigned());
|
|
6281
|
-
}
|
|
6282
|
-
break;
|
|
6283
|
-
}
|
|
6284
|
-
if (this.hasRest && position >= parameters.length - 1) {
|
|
6285
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6286
|
-
}
|
|
6287
|
-
else {
|
|
6288
|
-
const variables = parameters[position];
|
|
6289
|
-
if (variables) {
|
|
6290
|
-
for (const variable of variables) {
|
|
6291
|
-
variable.addArgumentValue(argument);
|
|
6292
|
-
}
|
|
6293
|
-
}
|
|
6294
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
6295
|
-
}
|
|
6296
|
-
}
|
|
6297
|
-
const nonRestParameterLength = this.hasRest ? parameters.length - 1 : parameters.length;
|
|
6298
|
-
for (; position < nonRestParameterLength; position++) {
|
|
6299
|
-
for (const variable of parameters[position]) {
|
|
6300
|
-
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
6301
|
-
}
|
|
6302
|
-
}
|
|
6303
|
-
}
|
|
6304
6027
|
getReturnExpression() {
|
|
6305
6028
|
if (this.returnExpression === null)
|
|
6306
6029
|
this.updateReturnExpression();
|
|
6307
6030
|
return this.returnExpression;
|
|
6308
6031
|
}
|
|
6309
|
-
deoptimizeAllParameters() {
|
|
6310
|
-
for (const parameter of this.parameters) {
|
|
6311
|
-
for (const variable of parameter) {
|
|
6312
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
6313
|
-
variable.markReassigned();
|
|
6314
|
-
}
|
|
6315
|
-
}
|
|
6316
|
-
}
|
|
6317
|
-
reassignAllParameters() {
|
|
6318
|
-
for (const parameter of this.parameters) {
|
|
6319
|
-
for (const variable of parameter) {
|
|
6320
|
-
variable.markReassigned();
|
|
6321
|
-
}
|
|
6322
|
-
}
|
|
6323
|
-
}
|
|
6324
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
6325
6032
|
updateReturnExpression() {
|
|
6326
6033
|
if (this.returnExpressions.length === 1) {
|
|
6327
6034
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -6337,30 +6044,24 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6337
6044
|
|
|
6338
6045
|
class FunctionScope extends ReturnValueScope {
|
|
6339
6046
|
constructor(parent) {
|
|
6340
|
-
super(parent, false);
|
|
6341
6047
|
const { context } = parent;
|
|
6048
|
+
super(parent, false);
|
|
6342
6049
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
6343
6050
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
6344
6051
|
}
|
|
6345
6052
|
findLexicalBoundary() {
|
|
6346
6053
|
return this;
|
|
6347
6054
|
}
|
|
6348
|
-
includeCallArguments(context,
|
|
6349
|
-
super.includeCallArguments(context,
|
|
6055
|
+
includeCallArguments(context, parameters) {
|
|
6056
|
+
super.includeCallArguments(context, parameters);
|
|
6350
6057
|
if (this.argumentsVariable.included) {
|
|
6351
|
-
const
|
|
6352
|
-
|
|
6353
|
-
const argument = args[argumentIndex];
|
|
6354
|
-
if (argument) {
|
|
6355
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
6058
|
+
for (const argument of parameters) {
|
|
6059
|
+
if (!argument.included) {
|
|
6356
6060
|
argument.include(context, false);
|
|
6357
6061
|
}
|
|
6358
6062
|
}
|
|
6359
6063
|
}
|
|
6360
6064
|
}
|
|
6361
|
-
addArgumentToBeDeoptimized(argument) {
|
|
6362
|
-
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6363
|
-
}
|
|
6364
6065
|
}
|
|
6365
6066
|
|
|
6366
6067
|
class ExpressionStatement extends NodeBase {
|
|
@@ -6388,9 +6089,8 @@ class ExpressionStatement extends NodeBase {
|
|
|
6388
6089
|
return this.parent.type !== Program$1;
|
|
6389
6090
|
return super.shouldBeIncluded(context);
|
|
6390
6091
|
}
|
|
6092
|
+
applyDeoptimizations() { }
|
|
6391
6093
|
}
|
|
6392
|
-
ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6393
|
-
ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6394
6094
|
|
|
6395
6095
|
class BlockStatement extends NodeBase {
|
|
6396
6096
|
get deoptimizeBody() {
|
|
@@ -6455,8 +6155,6 @@ class BlockStatement extends NodeBase {
|
|
|
6455
6155
|
}
|
|
6456
6156
|
}
|
|
6457
6157
|
}
|
|
6458
|
-
BlockStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6459
|
-
BlockStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6460
6158
|
|
|
6461
6159
|
class RestElement extends NodeBase {
|
|
6462
6160
|
constructor() {
|
|
@@ -6466,12 +6164,9 @@ class RestElement extends NodeBase {
|
|
|
6466
6164
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6467
6165
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6468
6166
|
}
|
|
6469
|
-
declare(kind,
|
|
6167
|
+
declare(kind, init) {
|
|
6470
6168
|
this.declarationInit = init;
|
|
6471
|
-
return this.argument.declare(kind,
|
|
6472
|
-
}
|
|
6473
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
6474
|
-
this.argument.deoptimizeAssignment(getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6169
|
+
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
6475
6170
|
}
|
|
6476
6171
|
deoptimizePath(path) {
|
|
6477
6172
|
if (path.length === 0) {
|
|
@@ -6482,20 +6177,6 @@ class RestElement extends NodeBase {
|
|
|
6482
6177
|
return (path.length > 0 ||
|
|
6483
6178
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
6484
6179
|
}
|
|
6485
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
6486
|
-
return this.argument.hasEffectsWhenDestructuring(context, getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6487
|
-
}
|
|
6488
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
6489
|
-
return (this.included =
|
|
6490
|
-
this.argument.includeDestructuredIfNecessary(context, getIncludedPatternPath$1(destructuredInitPath), init) || this.included);
|
|
6491
|
-
}
|
|
6492
|
-
include(context, includeChildrenRecursively) {
|
|
6493
|
-
if (!this.included)
|
|
6494
|
-
this.includeNode(context);
|
|
6495
|
-
// This should just include the identifier, its properties should be
|
|
6496
|
-
// included where the variable is used.
|
|
6497
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
6498
|
-
}
|
|
6499
6180
|
markDeclarationReached() {
|
|
6500
6181
|
this.argument.markDeclarationReached();
|
|
6501
6182
|
}
|
|
@@ -6507,16 +6188,12 @@ class RestElement extends NodeBase {
|
|
|
6507
6188
|
}
|
|
6508
6189
|
}
|
|
6509
6190
|
}
|
|
6510
|
-
RestElement.prototype.includeNode = onlyIncludeSelf;
|
|
6511
|
-
const getIncludedPatternPath$1 = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
6512
|
-
? destructuredInitPath
|
|
6513
|
-
: [...destructuredInitPath, UnknownKey];
|
|
6514
6191
|
|
|
6515
6192
|
class FunctionBase extends NodeBase {
|
|
6516
6193
|
constructor() {
|
|
6517
6194
|
super(...arguments);
|
|
6195
|
+
this.objectEntity = null;
|
|
6518
6196
|
this.parameterVariableValuesDeoptimized = false;
|
|
6519
|
-
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
6520
6197
|
}
|
|
6521
6198
|
get async() {
|
|
6522
6199
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -6536,9 +6213,53 @@ class FunctionBase extends NodeBase {
|
|
|
6536
6213
|
set generator(value) {
|
|
6537
6214
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
6538
6215
|
}
|
|
6216
|
+
updateParameterVariableValues(_arguments) {
|
|
6217
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
6218
|
+
const parameter = this.params[position];
|
|
6219
|
+
if (!(parameter instanceof Identifier)) {
|
|
6220
|
+
continue;
|
|
6221
|
+
}
|
|
6222
|
+
const parameterVariable = parameter.variable;
|
|
6223
|
+
const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
6224
|
+
parameterVariable.updateKnownValue(argument);
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
deoptimizeParameterVariableValues() {
|
|
6228
|
+
for (const parameter of this.params) {
|
|
6229
|
+
if (parameter instanceof Identifier) {
|
|
6230
|
+
const parameterVariable = parameter.variable;
|
|
6231
|
+
parameterVariable.markReassigned();
|
|
6232
|
+
}
|
|
6233
|
+
}
|
|
6234
|
+
}
|
|
6539
6235
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6540
|
-
if (interaction.type === INTERACTION_CALLED
|
|
6541
|
-
this.scope
|
|
6236
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
6237
|
+
const { parameters } = this.scope;
|
|
6238
|
+
const { args } = interaction;
|
|
6239
|
+
let hasRest = false;
|
|
6240
|
+
for (let position = 0; position < args.length - 1; position++) {
|
|
6241
|
+
const parameter = this.params[position];
|
|
6242
|
+
// Only the "this" argument arg[0] can be null
|
|
6243
|
+
const argument = args[position + 1];
|
|
6244
|
+
if (argument instanceof SpreadElement) {
|
|
6245
|
+
this.deoptimizeParameterVariableValues();
|
|
6246
|
+
}
|
|
6247
|
+
if (hasRest || parameter instanceof RestElement) {
|
|
6248
|
+
hasRest = true;
|
|
6249
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6250
|
+
}
|
|
6251
|
+
else if (parameter instanceof Identifier) {
|
|
6252
|
+
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
6253
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6254
|
+
}
|
|
6255
|
+
else if (parameter) {
|
|
6256
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6257
|
+
}
|
|
6258
|
+
else {
|
|
6259
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
this.updateParameterVariableValues(args);
|
|
6542
6263
|
}
|
|
6543
6264
|
else {
|
|
6544
6265
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -6550,7 +6271,12 @@ class FunctionBase extends NodeBase {
|
|
|
6550
6271
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
6551
6272
|
// which means the return expression and parameters need to be reassigned
|
|
6552
6273
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
6553
|
-
this.scope.
|
|
6274
|
+
for (const parameterList of this.scope.parameters) {
|
|
6275
|
+
for (const parameter of parameterList) {
|
|
6276
|
+
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
6277
|
+
parameter.markReassigned();
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6554
6280
|
}
|
|
6555
6281
|
}
|
|
6556
6282
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6588,13 +6314,8 @@ class FunctionBase extends NodeBase {
|
|
|
6588
6314
|
return true;
|
|
6589
6315
|
}
|
|
6590
6316
|
}
|
|
6591
|
-
const
|
|
6592
|
-
.
|
|
6593
|
-
for (let index = 0; index < this.params.length; index++) {
|
|
6594
|
-
const parameter = this.params[index];
|
|
6595
|
-
if (parameter.hasEffects(context) ||
|
|
6596
|
-
(propertyReadSideEffects &&
|
|
6597
|
-
parameter.hasEffectsWhenDestructuring(context, EMPTY_PATH, interaction.args[index + 1] || UNDEFINED_EXPRESSION)))
|
|
6317
|
+
for (const parameter of this.params) {
|
|
6318
|
+
if (parameter.hasEffects(context))
|
|
6598
6319
|
return true;
|
|
6599
6320
|
}
|
|
6600
6321
|
return false;
|
|
@@ -6613,17 +6334,21 @@ class FunctionBase extends NodeBase {
|
|
|
6613
6334
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
6614
6335
|
}
|
|
6615
6336
|
include(context, includeChildrenRecursively) {
|
|
6616
|
-
if (!this.
|
|
6617
|
-
this.includeNode(context);
|
|
6618
|
-
if (!(this.parameterVariableValuesDeoptimized || this.onlyFunctionCallUsed())) {
|
|
6337
|
+
if (!this.parameterVariableValuesDeoptimized && !this.onlyFunctionCallUsed()) {
|
|
6619
6338
|
this.parameterVariableValuesDeoptimized = true;
|
|
6620
|
-
this.
|
|
6339
|
+
this.deoptimizeParameterVariableValues();
|
|
6621
6340
|
}
|
|
6341
|
+
if (!this.deoptimized)
|
|
6342
|
+
this.applyDeoptimizations();
|
|
6343
|
+
this.included = true;
|
|
6622
6344
|
const { brokenFlow } = context;
|
|
6623
6345
|
context.brokenFlow = false;
|
|
6624
6346
|
this.body.include(context, includeChildrenRecursively);
|
|
6625
6347
|
context.brokenFlow = brokenFlow;
|
|
6626
6348
|
}
|
|
6349
|
+
includeCallArguments(context, parameters) {
|
|
6350
|
+
this.scope.includeCallArguments(context, parameters);
|
|
6351
|
+
}
|
|
6627
6352
|
initialise() {
|
|
6628
6353
|
super.initialise();
|
|
6629
6354
|
if (this.body instanceof BlockStatement) {
|
|
@@ -6645,14 +6370,14 @@ class FunctionBase extends NodeBase {
|
|
|
6645
6370
|
// so that the scope already knows all parameters and can detect conflicts
|
|
6646
6371
|
// when parsing the body.
|
|
6647
6372
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
6648
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
6373
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
6649
6374
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
6650
6375
|
return super.parseNode(esTreeNode);
|
|
6651
6376
|
}
|
|
6377
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
6378
|
+
applyDeoptimizations() { }
|
|
6652
6379
|
}
|
|
6653
6380
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
6654
|
-
FunctionBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6655
|
-
FunctionBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6656
6381
|
|
|
6657
6382
|
class FunctionNode extends FunctionBase {
|
|
6658
6383
|
constructor() {
|
|
@@ -6664,16 +6389,18 @@ class FunctionNode extends FunctionBase {
|
|
|
6664
6389
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
6665
6390
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
6666
6391
|
// constructed entity.
|
|
6667
|
-
this.scope.thisVariable.
|
|
6392
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
|
|
6668
6393
|
}
|
|
6669
6394
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6670
6395
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6671
6396
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
6672
6397
|
// args[0] is the "this" argument
|
|
6673
|
-
this.scope.thisVariable.
|
|
6398
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.args[0]);
|
|
6674
6399
|
}
|
|
6675
6400
|
}
|
|
6676
6401
|
hasEffects(context) {
|
|
6402
|
+
if (!this.deoptimized)
|
|
6403
|
+
this.applyDeoptimizations();
|
|
6677
6404
|
if (this.annotationNoSideEffects) {
|
|
6678
6405
|
return false;
|
|
6679
6406
|
}
|
|
@@ -6711,7 +6438,7 @@ class FunctionNode extends FunctionBase {
|
|
|
6711
6438
|
}
|
|
6712
6439
|
include(context, includeChildrenRecursively) {
|
|
6713
6440
|
super.include(context, includeChildrenRecursively);
|
|
6714
|
-
this.id?.include(
|
|
6441
|
+
this.id?.include();
|
|
6715
6442
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
6716
6443
|
for (const parameter of this.params) {
|
|
6717
6444
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
@@ -6719,18 +6446,12 @@ class FunctionNode extends FunctionBase {
|
|
|
6719
6446
|
}
|
|
6720
6447
|
}
|
|
6721
6448
|
}
|
|
6722
|
-
includeNode(context) {
|
|
6723
|
-
this.included = true;
|
|
6724
|
-
const hasArguments = this.scope.argumentsVariable.included;
|
|
6725
|
-
for (const parameter of this.params) {
|
|
6726
|
-
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
6727
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
6728
|
-
}
|
|
6729
|
-
}
|
|
6730
|
-
}
|
|
6731
6449
|
initialise() {
|
|
6732
6450
|
super.initialise();
|
|
6733
|
-
this.id?.declare('function',
|
|
6451
|
+
this.id?.declare('function', this);
|
|
6452
|
+
}
|
|
6453
|
+
addArgumentToBeDeoptimized(argument) {
|
|
6454
|
+
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6734
6455
|
}
|
|
6735
6456
|
getObjectEntity() {
|
|
6736
6457
|
if (this.objectEntity !== null) {
|
|
@@ -6780,16 +6501,11 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
6780
6501
|
}
|
|
6781
6502
|
class ExportDefaultDeclaration extends NodeBase {
|
|
6782
6503
|
include(context, includeChildrenRecursively) {
|
|
6783
|
-
|
|
6784
|
-
this.declaration.include(context, includeChildrenRecursively);
|
|
6504
|
+
super.include(context, includeChildrenRecursively);
|
|
6785
6505
|
if (includeChildrenRecursively) {
|
|
6786
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
6506
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
6787
6507
|
}
|
|
6788
6508
|
}
|
|
6789
|
-
includePath(path, context) {
|
|
6790
|
-
this.included = true;
|
|
6791
|
-
this.declaration.includePath(path, context);
|
|
6792
|
-
}
|
|
6793
6509
|
initialise() {
|
|
6794
6510
|
super.initialise();
|
|
6795
6511
|
const declaration = this.declaration;
|
|
@@ -6834,6 +6550,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6834
6550
|
}
|
|
6835
6551
|
this.declaration.render(code, options);
|
|
6836
6552
|
}
|
|
6553
|
+
applyDeoptimizations() { }
|
|
6837
6554
|
renderNamedDeclaration(code, declarationStart, idInsertPosition, options) {
|
|
6838
6555
|
const { exportNamesByVariable, format, snippets: { getPropertyAccess } } = options;
|
|
6839
6556
|
const name = this.variable.getName(getPropertyAccess);
|
|
@@ -6864,8 +6581,6 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6864
6581
|
}
|
|
6865
6582
|
}
|
|
6866
6583
|
ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
6867
|
-
ExportDefaultDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6868
|
-
ExportDefaultDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6869
6584
|
|
|
6870
6585
|
const needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/;
|
|
6871
6586
|
const quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g;
|
|
@@ -7135,7 +6850,6 @@ class Literal extends NodeBase {
|
|
|
7135
6850
|
}
|
|
7136
6851
|
}
|
|
7137
6852
|
}
|
|
7138
|
-
Literal.prototype.includeNode = onlyIncludeSelf;
|
|
7139
6853
|
|
|
7140
6854
|
function getChainElementLiteralValueAtPath(element, object, path, recursionTracker, origin) {
|
|
7141
6855
|
if ('getLiteralValueAtPathAsChainElement' in object) {
|
|
@@ -7151,6 +6865,8 @@ function getChainElementLiteralValueAtPath(element, object, path, recursionTrack
|
|
|
7151
6865
|
return element.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7152
6866
|
}
|
|
7153
6867
|
|
|
6868
|
+
// To avoid infinite recursions
|
|
6869
|
+
const MAX_PATH_DEPTH = 7;
|
|
7154
6870
|
function getResolvablePropertyKey(memberExpression) {
|
|
7155
6871
|
return memberExpression.computed
|
|
7156
6872
|
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
@@ -7249,27 +6965,18 @@ class MemberExpression extends NodeBase {
|
|
|
7249
6965
|
}
|
|
7250
6966
|
else if (!this.isUndefined) {
|
|
7251
6967
|
if (path.length < MAX_PATH_DEPTH) {
|
|
7252
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
6968
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
7253
6969
|
}
|
|
7254
6970
|
else {
|
|
7255
6971
|
deoptimizeInteraction(interaction);
|
|
7256
6972
|
}
|
|
7257
6973
|
}
|
|
7258
6974
|
}
|
|
7259
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
7260
|
-
this.deoptimizePath(EMPTY_PATH);
|
|
7261
|
-
init.deoptimizePath([...destructuredInitPath, UnknownKey]);
|
|
7262
|
-
}
|
|
7263
6975
|
deoptimizeCache() {
|
|
7264
|
-
if (this.propertyKey === this.dynamicPropertyKey)
|
|
7265
|
-
return;
|
|
7266
6976
|
const { expressionsToBeDeoptimized, object } = this;
|
|
7267
6977
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
7268
|
-
this.
|
|
6978
|
+
this.propertyKey = UnknownKey;
|
|
7269
6979
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
7270
|
-
if (this.included) {
|
|
7271
|
-
object.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
7272
|
-
}
|
|
7273
6980
|
for (const expression of expressionsToBeDeoptimized) {
|
|
7274
6981
|
expression.deoptimizeCache();
|
|
7275
6982
|
}
|
|
@@ -7280,13 +6987,11 @@ class MemberExpression extends NodeBase {
|
|
|
7280
6987
|
if (this.variable) {
|
|
7281
6988
|
this.variable.deoptimizePath(path);
|
|
7282
6989
|
}
|
|
7283
|
-
else if (!this.isUndefined) {
|
|
7284
|
-
const
|
|
6990
|
+
else if (!this.isUndefined && path.length < MAX_PATH_DEPTH) {
|
|
6991
|
+
const propertyKey = this.getPropertyKey();
|
|
7285
6992
|
this.object.deoptimizePath([
|
|
7286
6993
|
propertyKey === UnknownKey ? UnknownNonAccessorKey : propertyKey,
|
|
7287
|
-
...
|
|
7288
|
-
? path
|
|
7289
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
6994
|
+
...path
|
|
7290
6995
|
]);
|
|
7291
6996
|
}
|
|
7292
6997
|
}
|
|
@@ -7297,11 +7002,9 @@ class MemberExpression extends NodeBase {
|
|
|
7297
7002
|
if (this.isUndefined) {
|
|
7298
7003
|
return undefined;
|
|
7299
7004
|
}
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7304
|
-
return this.object.getLiteralValueAtPath([propertyKey, ...path], recursionTracker, origin);
|
|
7005
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7006
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7007
|
+
return this.object.getLiteralValueAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
7305
7008
|
}
|
|
7306
7009
|
return UnknownValue;
|
|
7307
7010
|
}
|
|
@@ -7321,11 +7024,9 @@ class MemberExpression extends NodeBase {
|
|
|
7321
7024
|
if (this.isUndefined) {
|
|
7322
7025
|
return [UNDEFINED_EXPRESSION, false];
|
|
7323
7026
|
}
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7328
|
-
return this.object.getReturnExpressionWhenCalledAtPath([propertyKey, ...path], interaction, recursionTracker, origin);
|
|
7027
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7028
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7029
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
7329
7030
|
}
|
|
7330
7031
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
7331
7032
|
}
|
|
@@ -7371,45 +7072,14 @@ class MemberExpression extends NodeBase {
|
|
|
7371
7072
|
return true;
|
|
7372
7073
|
}
|
|
7373
7074
|
if (path.length < MAX_PATH_DEPTH) {
|
|
7374
|
-
return this.object.hasEffectsOnInteractionAtPath([this.
|
|
7075
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey(), ...path], interaction, context);
|
|
7375
7076
|
}
|
|
7376
7077
|
return true;
|
|
7377
7078
|
}
|
|
7378
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
7379
|
-
return (destructuredInitPath.length > 0 &&
|
|
7380
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7381
|
-
}
|
|
7382
7079
|
include(context, includeChildrenRecursively) {
|
|
7383
|
-
if (!this.included)
|
|
7384
|
-
this.includeNode(context);
|
|
7385
|
-
this.object.include(context, includeChildrenRecursively);
|
|
7386
|
-
this.property.include(context, includeChildrenRecursively);
|
|
7387
|
-
}
|
|
7388
|
-
includeNode(context) {
|
|
7389
|
-
this.included = true;
|
|
7390
7080
|
if (!this.deoptimized)
|
|
7391
7081
|
this.applyDeoptimizations();
|
|
7392
|
-
|
|
7393
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
7394
|
-
}
|
|
7395
|
-
else if (!this.isUndefined) {
|
|
7396
|
-
this.object.includePath([this.propertyKey], context);
|
|
7397
|
-
}
|
|
7398
|
-
}
|
|
7399
|
-
includePath(path, context) {
|
|
7400
|
-
if (!this.included)
|
|
7401
|
-
this.includeNode(context);
|
|
7402
|
-
if (this.variable) {
|
|
7403
|
-
this.variable?.includePath(path, context);
|
|
7404
|
-
}
|
|
7405
|
-
else if (!this.isUndefined) {
|
|
7406
|
-
this.object.includePath([
|
|
7407
|
-
this.propertyKey,
|
|
7408
|
-
...(path.length < MAX_PATH_DEPTH
|
|
7409
|
-
? path
|
|
7410
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
7411
|
-
], context);
|
|
7412
|
-
}
|
|
7082
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7413
7083
|
}
|
|
7414
7084
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
7415
7085
|
if (!this.assignmentDeoptimized)
|
|
@@ -7418,34 +7088,20 @@ class MemberExpression extends NodeBase {
|
|
|
7418
7088
|
this.include(context, includeChildrenRecursively);
|
|
7419
7089
|
}
|
|
7420
7090
|
else {
|
|
7421
|
-
|
|
7422
|
-
this.includeNode(context);
|
|
7423
|
-
this.object.include(context, includeChildrenRecursively);
|
|
7424
|
-
this.property.include(context, includeChildrenRecursively);
|
|
7091
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7425
7092
|
}
|
|
7426
7093
|
}
|
|
7427
|
-
includeCallArguments(context,
|
|
7094
|
+
includeCallArguments(context, parameters) {
|
|
7428
7095
|
if (this.variable) {
|
|
7429
|
-
this.variable.includeCallArguments(context,
|
|
7096
|
+
this.variable.includeCallArguments(context, parameters);
|
|
7430
7097
|
}
|
|
7431
7098
|
else {
|
|
7432
|
-
super.includeCallArguments(context,
|
|
7433
|
-
}
|
|
7434
|
-
}
|
|
7435
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
7436
|
-
if ((this.included ||=
|
|
7437
|
-
destructuredInitPath.length > 0 &&
|
|
7438
|
-
!context.brokenFlow &&
|
|
7439
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext()))) {
|
|
7440
|
-
init.include(context, false);
|
|
7441
|
-
return true;
|
|
7099
|
+
super.includeCallArguments(context, parameters);
|
|
7442
7100
|
}
|
|
7443
|
-
return false;
|
|
7444
7101
|
}
|
|
7445
7102
|
initialise() {
|
|
7446
7103
|
super.initialise();
|
|
7447
|
-
this.
|
|
7448
|
-
this.propertyKey = this.dynamicPropertyKey === null ? UnknownKey : this.dynamicPropertyKey;
|
|
7104
|
+
this.propertyKey = getResolvablePropertyKey(this);
|
|
7449
7105
|
this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
|
|
7450
7106
|
}
|
|
7451
7107
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
@@ -7482,7 +7138,8 @@ class MemberExpression extends NodeBase {
|
|
|
7482
7138
|
this.bound &&
|
|
7483
7139
|
propertyReadSideEffects &&
|
|
7484
7140
|
!(this.variable || this.isUndefined)) {
|
|
7485
|
-
this.
|
|
7141
|
+
const propertyKey = this.getPropertyKey();
|
|
7142
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
7486
7143
|
this.scope.context.requestTreeshakingPass();
|
|
7487
7144
|
}
|
|
7488
7145
|
if (this.variable) {
|
|
@@ -7499,7 +7156,7 @@ class MemberExpression extends NodeBase {
|
|
|
7499
7156
|
this.bound &&
|
|
7500
7157
|
propertyReadSideEffects &&
|
|
7501
7158
|
!(this.variable || this.isUndefined)) {
|
|
7502
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.
|
|
7159
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
7503
7160
|
this.scope.context.requestTreeshakingPass();
|
|
7504
7161
|
}
|
|
7505
7162
|
}
|
|
@@ -7508,24 +7165,24 @@ class MemberExpression extends NodeBase {
|
|
|
7508
7165
|
const variable = this.scope.findVariable(this.object.name);
|
|
7509
7166
|
if (variable.isNamespace) {
|
|
7510
7167
|
if (this.variable) {
|
|
7511
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
7168
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7512
7169
|
}
|
|
7513
7170
|
this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
7514
7171
|
}
|
|
7515
7172
|
}
|
|
7516
7173
|
}
|
|
7517
|
-
|
|
7518
|
-
if (this.
|
|
7519
|
-
this.
|
|
7174
|
+
getPropertyKey() {
|
|
7175
|
+
if (this.propertyKey === null) {
|
|
7176
|
+
this.propertyKey = UnknownKey;
|
|
7520
7177
|
const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7521
|
-
return (this.
|
|
7178
|
+
return (this.propertyKey =
|
|
7522
7179
|
value === SymbolToStringTag
|
|
7523
7180
|
? value
|
|
7524
7181
|
: typeof value === 'symbol'
|
|
7525
7182
|
? UnknownKey
|
|
7526
7183
|
: String(value));
|
|
7527
7184
|
}
|
|
7528
|
-
return this.
|
|
7185
|
+
return this.propertyKey;
|
|
7529
7186
|
}
|
|
7530
7187
|
hasAccessEffect(context) {
|
|
7531
7188
|
const { propertyReadSideEffects } = this.scope.context.options
|
|
@@ -7533,7 +7190,17 @@ class MemberExpression extends NodeBase {
|
|
|
7533
7190
|
return (!(this.variable || this.isUndefined) &&
|
|
7534
7191
|
propertyReadSideEffects &&
|
|
7535
7192
|
(propertyReadSideEffects === 'always' ||
|
|
7536
|
-
this.object.hasEffectsOnInteractionAtPath([this.
|
|
7193
|
+
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
7194
|
+
}
|
|
7195
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
7196
|
+
if (!this.included) {
|
|
7197
|
+
this.included = true;
|
|
7198
|
+
if (this.variable) {
|
|
7199
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7200
|
+
}
|
|
7201
|
+
}
|
|
7202
|
+
this.object.include(context, includeChildrenRecursively);
|
|
7203
|
+
this.property.include(context, includeChildrenRecursively);
|
|
7537
7204
|
}
|
|
7538
7205
|
}
|
|
7539
7206
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -7577,20 +7244,18 @@ class MetaProperty extends NodeBase {
|
|
|
7577
7244
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
7578
7245
|
}
|
|
7579
7246
|
include() {
|
|
7580
|
-
if (!this.included)
|
|
7581
|
-
this.
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
7593
|
-
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
7247
|
+
if (!this.included) {
|
|
7248
|
+
this.included = true;
|
|
7249
|
+
if (this.meta.name === IMPORT) {
|
|
7250
|
+
this.scope.context.addImportMeta(this);
|
|
7251
|
+
const parent = this.parent;
|
|
7252
|
+
const metaProperty = (this.metaProperty =
|
|
7253
|
+
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
7254
|
+
? parent.propertyKey
|
|
7255
|
+
: null);
|
|
7256
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
7257
|
+
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
7258
|
+
}
|
|
7594
7259
|
}
|
|
7595
7260
|
}
|
|
7596
7261
|
}
|
|
@@ -7697,7 +7362,7 @@ class UndefinedVariable extends Variable {
|
|
|
7697
7362
|
|
|
7698
7363
|
class ExportDefaultVariable extends LocalVariable {
|
|
7699
7364
|
constructor(name, exportDefaultDeclaration, context) {
|
|
7700
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration,
|
|
7365
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
7701
7366
|
this.hasId = false;
|
|
7702
7367
|
this.originalId = null;
|
|
7703
7368
|
this.originalVariable = null;
|
|
@@ -7846,8 +7511,8 @@ class NamespaceVariable extends Variable {
|
|
|
7846
7511
|
return (!memberVariable ||
|
|
7847
7512
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
7848
7513
|
}
|
|
7849
|
-
|
|
7850
|
-
super.
|
|
7514
|
+
include() {
|
|
7515
|
+
super.include();
|
|
7851
7516
|
this.context.includeAllExports();
|
|
7852
7517
|
}
|
|
7853
7518
|
prepare(accessedGlobalsByScope) {
|
|
@@ -7940,9 +7605,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
7940
7605
|
getName(getPropertyAccess) {
|
|
7941
7606
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
7942
7607
|
}
|
|
7943
|
-
|
|
7944
|
-
super.
|
|
7945
|
-
this.context.includeVariableInModule(this.syntheticNamespace
|
|
7608
|
+
include() {
|
|
7609
|
+
super.include();
|
|
7610
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
7946
7611
|
}
|
|
7947
7612
|
setRenderNames(baseName, name) {
|
|
7948
7613
|
super.setRenderNames(baseName, name);
|
|
@@ -7973,7 +7638,7 @@ class ExternalChunk {
|
|
|
7973
7638
|
(this.renormalizeRenderPath ? normalize(relative(this.inputBase, this.id)) : this.id));
|
|
7974
7639
|
}
|
|
7975
7640
|
getImportAttributes(snippets) {
|
|
7976
|
-
return (this.importAttributes ||= formatAttributes(this.options.format
|
|
7641
|
+
return (this.importAttributes ||= formatAttributes(['es', 'cjs'].includes(this.options.format) &&
|
|
7977
7642
|
this.options.externalImportAttributes &&
|
|
7978
7643
|
this.moduleInfo.attributes, snippets));
|
|
7979
7644
|
}
|
|
@@ -10432,7 +10097,7 @@ function requireParse () {
|
|
|
10432
10097
|
}
|
|
10433
10098
|
|
|
10434
10099
|
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
10435
|
-
const end = rest[1] !==
|
|
10100
|
+
const end = rest[1] !== undefined ? '|$' : '';
|
|
10436
10101
|
|
|
10437
10102
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
10438
10103
|
prior.output = `(?:${prior.output}`;
|
|
@@ -11147,37 +10812,21 @@ class ArrayPattern extends NodeBase {
|
|
|
11147
10812
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
11148
10813
|
}
|
|
11149
10814
|
}
|
|
11150
|
-
declare(kind
|
|
10815
|
+
declare(kind) {
|
|
11151
10816
|
const variables = [];
|
|
11152
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11153
10817
|
for (const element of this.elements) {
|
|
11154
10818
|
if (element !== null) {
|
|
11155
|
-
variables.push(...element.declare(kind,
|
|
10819
|
+
variables.push(...element.declare(kind, UNKNOWN_EXPRESSION));
|
|
11156
10820
|
}
|
|
11157
10821
|
}
|
|
11158
10822
|
return variables;
|
|
11159
10823
|
}
|
|
11160
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11161
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11162
|
-
for (const element of this.elements) {
|
|
11163
|
-
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
11164
|
-
}
|
|
11165
|
-
}
|
|
11166
10824
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
11167
10825
|
deoptimizePath() {
|
|
11168
10826
|
for (const element of this.elements) {
|
|
11169
10827
|
element?.deoptimizePath(EMPTY_PATH);
|
|
11170
10828
|
}
|
|
11171
10829
|
}
|
|
11172
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11173
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11174
|
-
for (const element of this.elements) {
|
|
11175
|
-
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
11176
|
-
return true;
|
|
11177
|
-
}
|
|
11178
|
-
}
|
|
11179
|
-
return false;
|
|
11180
|
-
}
|
|
11181
10830
|
// Patterns are only checked at the empty path at the moment
|
|
11182
10831
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
11183
10832
|
for (const element of this.elements) {
|
|
@@ -11186,38 +10835,12 @@ class ArrayPattern extends NodeBase {
|
|
|
11186
10835
|
}
|
|
11187
10836
|
return false;
|
|
11188
10837
|
}
|
|
11189
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11190
|
-
let included = false;
|
|
11191
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11192
|
-
for (const element of this.elements) {
|
|
11193
|
-
if (element) {
|
|
11194
|
-
element.included ||= included;
|
|
11195
|
-
included =
|
|
11196
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
11197
|
-
}
|
|
11198
|
-
}
|
|
11199
|
-
if (included) {
|
|
11200
|
-
// This is necessary so that if any pattern element is included, all are
|
|
11201
|
-
// included for proper deconflicting
|
|
11202
|
-
for (const element of this.elements) {
|
|
11203
|
-
if (element && !element.included) {
|
|
11204
|
-
element.included = true;
|
|
11205
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init);
|
|
11206
|
-
}
|
|
11207
|
-
}
|
|
11208
|
-
}
|
|
11209
|
-
return (this.included ||= included);
|
|
11210
|
-
}
|
|
11211
10838
|
markDeclarationReached() {
|
|
11212
10839
|
for (const element of this.elements) {
|
|
11213
10840
|
element?.markDeclarationReached();
|
|
11214
10841
|
}
|
|
11215
10842
|
}
|
|
11216
10843
|
}
|
|
11217
|
-
ArrayPattern.prototype.includeNode = onlyIncludeSelf;
|
|
11218
|
-
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
11219
|
-
? destructuredInitPath
|
|
11220
|
-
: [...destructuredInitPath, UnknownInteger];
|
|
11221
10844
|
|
|
11222
10845
|
class ArrowFunctionExpression extends FunctionBase {
|
|
11223
10846
|
constructor() {
|
|
@@ -11234,6 +10857,8 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11234
10857
|
this.scope = new ReturnValueScope(parentScope, false);
|
|
11235
10858
|
}
|
|
11236
10859
|
hasEffects() {
|
|
10860
|
+
if (!this.deoptimized)
|
|
10861
|
+
this.applyDeoptimizations();
|
|
11237
10862
|
return false;
|
|
11238
10863
|
}
|
|
11239
10864
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
@@ -11272,15 +10897,6 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11272
10897
|
}
|
|
11273
10898
|
}
|
|
11274
10899
|
}
|
|
11275
|
-
includeNode(context) {
|
|
11276
|
-
this.included = true;
|
|
11277
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
11278
|
-
for (const parameter of this.params) {
|
|
11279
|
-
if (!(parameter instanceof Identifier)) {
|
|
11280
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
11281
|
-
}
|
|
11282
|
-
}
|
|
11283
|
-
}
|
|
11284
10900
|
getObjectEntity() {
|
|
11285
10901
|
if (this.objectEntity !== null) {
|
|
11286
10902
|
return this.objectEntity;
|
|
@@ -11300,18 +10916,13 @@ class ObjectPattern extends NodeBase {
|
|
|
11300
10916
|
}
|
|
11301
10917
|
}
|
|
11302
10918
|
}
|
|
11303
|
-
declare(kind,
|
|
10919
|
+
declare(kind, init) {
|
|
11304
10920
|
const variables = [];
|
|
11305
10921
|
for (const property of this.properties) {
|
|
11306
|
-
variables.push(...property.declare(kind,
|
|
10922
|
+
variables.push(...property.declare(kind, init));
|
|
11307
10923
|
}
|
|
11308
10924
|
return variables;
|
|
11309
10925
|
}
|
|
11310
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11311
|
-
for (const property of this.properties) {
|
|
11312
|
-
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
11313
|
-
}
|
|
11314
|
-
}
|
|
11315
10926
|
deoptimizePath(path) {
|
|
11316
10927
|
if (path.length === 0) {
|
|
11317
10928
|
for (const property of this.properties) {
|
|
@@ -11329,46 +10940,12 @@ class ObjectPattern extends NodeBase {
|
|
|
11329
10940
|
}
|
|
11330
10941
|
return false;
|
|
11331
10942
|
}
|
|
11332
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11333
|
-
for (const property of this.properties) {
|
|
11334
|
-
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
11335
|
-
return true;
|
|
11336
|
-
}
|
|
11337
|
-
return false;
|
|
11338
|
-
}
|
|
11339
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11340
|
-
let included = false;
|
|
11341
|
-
for (const property of this.properties) {
|
|
11342
|
-
included =
|
|
11343
|
-
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
11344
|
-
}
|
|
11345
|
-
return (this.included ||= included);
|
|
11346
|
-
}
|
|
11347
10943
|
markDeclarationReached() {
|
|
11348
10944
|
for (const property of this.properties) {
|
|
11349
10945
|
property.markDeclarationReached();
|
|
11350
10946
|
}
|
|
11351
10947
|
}
|
|
11352
|
-
render(code, options) {
|
|
11353
|
-
if (this.properties.length > 0) {
|
|
11354
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
11355
|
-
let lastSeparatorPos = null;
|
|
11356
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
11357
|
-
if (!node.included) {
|
|
11358
|
-
treeshakeNode(node, code, start, end);
|
|
11359
|
-
continue;
|
|
11360
|
-
}
|
|
11361
|
-
lastSeparatorPos = separator;
|
|
11362
|
-
node.render(code, options);
|
|
11363
|
-
}
|
|
11364
|
-
if (lastSeparatorPos) {
|
|
11365
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
11366
|
-
}
|
|
11367
|
-
}
|
|
11368
|
-
}
|
|
11369
10948
|
}
|
|
11370
|
-
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11371
|
-
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11372
10949
|
|
|
11373
10950
|
class AssignmentExpression extends NodeBase {
|
|
11374
10951
|
hasEffects(context) {
|
|
@@ -11377,9 +10954,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
11377
10954
|
this.applyDeoptimizations();
|
|
11378
10955
|
// MemberExpressions do not access the property before assignments if the
|
|
11379
10956
|
// operator is '='.
|
|
11380
|
-
return (right.hasEffects(context) ||
|
|
11381
|
-
left.hasEffectsAsAssignmentTarget(context, operator !== '=') ||
|
|
11382
|
-
this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right));
|
|
10957
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, operator !== '='));
|
|
11383
10958
|
}
|
|
11384
10959
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11385
10960
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -11388,24 +10963,15 @@ class AssignmentExpression extends NodeBase {
|
|
|
11388
10963
|
const { deoptimized, left, right, operator } = this;
|
|
11389
10964
|
if (!deoptimized)
|
|
11390
10965
|
this.applyDeoptimizations();
|
|
11391
|
-
|
|
11392
|
-
this.includeNode(context);
|
|
11393
|
-
const hasEffectsContext = createHasEffectsContext();
|
|
10966
|
+
this.included = true;
|
|
11394
10967
|
if (includeChildrenRecursively ||
|
|
11395
10968
|
operator !== '=' ||
|
|
11396
10969
|
left.included ||
|
|
11397
|
-
left.hasEffectsAsAssignmentTarget(
|
|
11398
|
-
left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right)) {
|
|
10970
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
11399
10971
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
11400
10972
|
}
|
|
11401
10973
|
right.include(context, includeChildrenRecursively);
|
|
11402
10974
|
}
|
|
11403
|
-
includeNode(context) {
|
|
11404
|
-
this.included = true;
|
|
11405
|
-
if (!this.deoptimized)
|
|
11406
|
-
this.applyDeoptimizations();
|
|
11407
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11408
|
-
}
|
|
11409
10975
|
initialise() {
|
|
11410
10976
|
super.initialise();
|
|
11411
10977
|
if (this.left instanceof Identifier) {
|
|
@@ -11466,7 +11032,8 @@ class AssignmentExpression extends NodeBase {
|
|
|
11466
11032
|
}
|
|
11467
11033
|
applyDeoptimizations() {
|
|
11468
11034
|
this.deoptimized = true;
|
|
11469
|
-
this.left.
|
|
11035
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
11036
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
11470
11037
|
this.scope.context.requestTreeshakingPass();
|
|
11471
11038
|
}
|
|
11472
11039
|
}
|
|
@@ -11475,11 +11042,8 @@ class AssignmentPattern extends NodeBase {
|
|
|
11475
11042
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
11476
11043
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
11477
11044
|
}
|
|
11478
|
-
declare(kind,
|
|
11479
|
-
return this.left.declare(kind,
|
|
11480
|
-
}
|
|
11481
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11482
|
-
this.left.deoptimizeAssignment(destructuredInitPath, init);
|
|
11045
|
+
declare(kind, init) {
|
|
11046
|
+
return this.left.declare(kind, init);
|
|
11483
11047
|
}
|
|
11484
11048
|
deoptimizePath(path) {
|
|
11485
11049
|
if (path.length === 0) {
|
|
@@ -11489,29 +11053,6 @@ class AssignmentPattern extends NodeBase {
|
|
|
11489
11053
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11490
11054
|
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
11491
11055
|
}
|
|
11492
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11493
|
-
return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init);
|
|
11494
|
-
}
|
|
11495
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11496
|
-
let included = this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) ||
|
|
11497
|
-
this.included;
|
|
11498
|
-
if ((included ||= this.right.shouldBeIncluded(context))) {
|
|
11499
|
-
this.right.include(context, false);
|
|
11500
|
-
if (!this.left.included) {
|
|
11501
|
-
this.left.included = true;
|
|
11502
|
-
// Unfortunately, we need to include the left side again now, so that
|
|
11503
|
-
// any declared variables are properly included.
|
|
11504
|
-
this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
11505
|
-
}
|
|
11506
|
-
}
|
|
11507
|
-
return (this.included = included);
|
|
11508
|
-
}
|
|
11509
|
-
includeNode(context) {
|
|
11510
|
-
this.included = true;
|
|
11511
|
-
if (!this.deoptimized)
|
|
11512
|
-
this.applyDeoptimizations();
|
|
11513
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11514
|
-
}
|
|
11515
11056
|
markDeclarationReached() {
|
|
11516
11057
|
this.left.markDeclarationReached();
|
|
11517
11058
|
}
|
|
@@ -11534,34 +11075,22 @@ class AwaitExpression extends NodeBase {
|
|
|
11534
11075
|
return true;
|
|
11535
11076
|
}
|
|
11536
11077
|
include(context, includeChildrenRecursively) {
|
|
11537
|
-
if (!this.included)
|
|
11538
|
-
this.includeNode(context);
|
|
11539
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
11540
|
-
}
|
|
11541
|
-
includeNode(context) {
|
|
11542
|
-
this.included = true;
|
|
11543
11078
|
if (!this.deoptimized)
|
|
11544
11079
|
this.applyDeoptimizations();
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11080
|
+
if (!this.included) {
|
|
11081
|
+
this.included = true;
|
|
11082
|
+
checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
|
|
11083
|
+
let parent = this.parent;
|
|
11084
|
+
do {
|
|
11085
|
+
if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
|
|
11086
|
+
break checkTopLevelAwait;
|
|
11087
|
+
} while ((parent = parent.parent));
|
|
11088
|
+
this.scope.context.usesTopLevelAwait = true;
|
|
11089
|
+
}
|
|
11552
11090
|
}
|
|
11553
|
-
|
|
11554
|
-
this.argument.includePath(THEN_PATH, context);
|
|
11555
|
-
}
|
|
11556
|
-
includePath(path, context) {
|
|
11557
|
-
if (!this.deoptimized)
|
|
11558
|
-
this.applyDeoptimizations();
|
|
11559
|
-
if (!this.included)
|
|
11560
|
-
this.includeNode(context);
|
|
11561
|
-
this.argument.includePath(path, context);
|
|
11091
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
11562
11092
|
}
|
|
11563
11093
|
}
|
|
11564
|
-
const THEN_PATH = ['then'];
|
|
11565
11094
|
|
|
11566
11095
|
const binaryOperators = {
|
|
11567
11096
|
'!=': (left, right) => left != right,
|
|
@@ -11617,12 +11146,6 @@ class BinaryExpression extends NodeBase {
|
|
|
11617
11146
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11618
11147
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
11619
11148
|
}
|
|
11620
|
-
includeNode(context) {
|
|
11621
|
-
this.included = true;
|
|
11622
|
-
if (this.operator === 'in') {
|
|
11623
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11624
|
-
}
|
|
11625
|
-
}
|
|
11626
11149
|
removeAnnotations(code) {
|
|
11627
11150
|
this.left.removeAnnotations(code);
|
|
11628
11151
|
}
|
|
@@ -11631,7 +11154,6 @@ class BinaryExpression extends NodeBase {
|
|
|
11631
11154
|
this.right.render(code, options);
|
|
11632
11155
|
}
|
|
11633
11156
|
}
|
|
11634
|
-
BinaryExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11635
11157
|
|
|
11636
11158
|
class BreakStatement extends NodeBase {
|
|
11637
11159
|
hasEffects(context) {
|
|
@@ -11651,7 +11173,7 @@ class BreakStatement extends NodeBase {
|
|
|
11651
11173
|
include(context) {
|
|
11652
11174
|
this.included = true;
|
|
11653
11175
|
if (this.label) {
|
|
11654
|
-
this.label.include(
|
|
11176
|
+
this.label.include();
|
|
11655
11177
|
context.includedLabels.add(this.label.name);
|
|
11656
11178
|
}
|
|
11657
11179
|
else {
|
|
@@ -11660,8 +11182,6 @@ class BreakStatement extends NodeBase {
|
|
|
11660
11182
|
context.brokenFlow = true;
|
|
11661
11183
|
}
|
|
11662
11184
|
}
|
|
11663
|
-
BreakStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11664
|
-
BreakStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11665
11185
|
|
|
11666
11186
|
function renderCallArguments(code, options, node) {
|
|
11667
11187
|
if (node.arguments.length > 0) {
|
|
@@ -11848,14 +11368,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
11848
11368
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
11849
11369
|
}
|
|
11850
11370
|
include(context, includeChildrenRecursively) {
|
|
11851
|
-
if (!this.
|
|
11852
|
-
this.
|
|
11371
|
+
if (!this.deoptimized)
|
|
11372
|
+
this.applyDeoptimizations();
|
|
11853
11373
|
if (includeChildrenRecursively) {
|
|
11854
|
-
|
|
11855
|
-
for (const argument of this.arguments) {
|
|
11856
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
11857
|
-
argument.include(context, true);
|
|
11858
|
-
}
|
|
11374
|
+
super.include(context, includeChildrenRecursively);
|
|
11859
11375
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
11860
11376
|
this.callee instanceof Identifier &&
|
|
11861
11377
|
this.callee.variable) {
|
|
@@ -11863,24 +11379,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
11863
11379
|
}
|
|
11864
11380
|
}
|
|
11865
11381
|
else {
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
// interaction in includeCallArguments. Including it again can lead to
|
|
11869
|
-
// severe performance problems.
|
|
11870
|
-
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
11871
|
-
this.callee.property.include(context, false);
|
|
11872
|
-
}
|
|
11873
|
-
else {
|
|
11874
|
-
this.callee.include(context, false);
|
|
11875
|
-
}
|
|
11876
|
-
this.callee.includeCallArguments(context, this.interaction);
|
|
11382
|
+
this.included = true;
|
|
11383
|
+
this.callee.include(context, false);
|
|
11877
11384
|
}
|
|
11878
|
-
|
|
11879
|
-
includeNode(context) {
|
|
11880
|
-
this.included = true;
|
|
11881
|
-
if (!this.deoptimized)
|
|
11882
|
-
this.applyDeoptimizations();
|
|
11883
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
11385
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
11884
11386
|
}
|
|
11885
11387
|
initialise() {
|
|
11886
11388
|
super.initialise();
|
|
@@ -11919,14 +11421,13 @@ class CatchClause extends NodeBase {
|
|
|
11919
11421
|
this.type = type;
|
|
11920
11422
|
if (param) {
|
|
11921
11423
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
11922
|
-
this.param.declare('parameter',
|
|
11424
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
11923
11425
|
}
|
|
11924
11426
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
11925
11427
|
return super.parseNode(esTreeNode);
|
|
11926
11428
|
}
|
|
11927
11429
|
}
|
|
11928
11430
|
CatchClause.prototype.preventChildBlockScope = true;
|
|
11929
|
-
CatchClause.prototype.includeNode = onlyIncludeSelf;
|
|
11930
11431
|
|
|
11931
11432
|
class ChainExpression extends NodeBase {
|
|
11932
11433
|
// deoptimizations are not relevant as we are not caching values
|
|
@@ -11938,22 +11439,17 @@ class ChainExpression extends NodeBase {
|
|
|
11938
11439
|
hasEffects(context) {
|
|
11939
11440
|
return this.expression.hasEffectsAsChainElement(context) === true;
|
|
11940
11441
|
}
|
|
11941
|
-
includePath(path, context) {
|
|
11942
|
-
this.included = true;
|
|
11943
|
-
this.expression.includePath(path, context);
|
|
11944
|
-
}
|
|
11945
11442
|
removeAnnotations(code) {
|
|
11946
11443
|
this.expression.removeAnnotations(code);
|
|
11947
11444
|
}
|
|
11445
|
+
applyDeoptimizations() { }
|
|
11948
11446
|
}
|
|
11949
|
-
ChainExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11950
|
-
ChainExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11951
11447
|
|
|
11952
11448
|
class ClassBodyScope extends ChildScope {
|
|
11953
11449
|
constructor(parent, classNode) {
|
|
11954
11450
|
const { context } = parent;
|
|
11955
11451
|
super(parent, context);
|
|
11956
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode,
|
|
11452
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
11957
11453
|
this.instanceScope = new ChildScope(this, context);
|
|
11958
11454
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
11959
11455
|
}
|
|
@@ -11968,7 +11464,7 @@ class ClassBody extends NodeBase {
|
|
|
11968
11464
|
}
|
|
11969
11465
|
include(context, includeChildrenRecursively) {
|
|
11970
11466
|
this.included = true;
|
|
11971
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable
|
|
11467
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
11972
11468
|
for (const definition of this.body) {
|
|
11973
11469
|
definition.include(context, includeChildrenRecursively);
|
|
11974
11470
|
}
|
|
@@ -11981,9 +11477,8 @@ class ClassBody extends NodeBase {
|
|
|
11981
11477
|
}
|
|
11982
11478
|
return super.parseNode(esTreeNode);
|
|
11983
11479
|
}
|
|
11480
|
+
applyDeoptimizations() { }
|
|
11984
11481
|
}
|
|
11985
|
-
ClassBody.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11986
|
-
ClassBody.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11987
11482
|
|
|
11988
11483
|
class ClassExpression extends ClassNode {
|
|
11989
11484
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
@@ -12054,9 +11549,6 @@ class ConditionalExpression extends NodeBase {
|
|
|
12054
11549
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
12055
11550
|
this.usedBranch = null;
|
|
12056
11551
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
12057
|
-
if (this.included) {
|
|
12058
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
12059
|
-
}
|
|
12060
11552
|
const { expressionsToBeDeoptimized } = this;
|
|
12061
11553
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
12062
11554
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -12114,7 +11606,7 @@ class ConditionalExpression extends NodeBase {
|
|
|
12114
11606
|
include(context, includeChildrenRecursively) {
|
|
12115
11607
|
this.included = true;
|
|
12116
11608
|
const usedBranch = this.getUsedBranch();
|
|
12117
|
-
if (
|
|
11609
|
+
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
12118
11610
|
this.test.include(context, includeChildrenRecursively);
|
|
12119
11611
|
this.consequent.include(context, includeChildrenRecursively);
|
|
12120
11612
|
this.alternate.include(context, includeChildrenRecursively);
|
|
@@ -12123,38 +11615,27 @@ class ConditionalExpression extends NodeBase {
|
|
|
12123
11615
|
usedBranch.include(context, includeChildrenRecursively);
|
|
12124
11616
|
}
|
|
12125
11617
|
}
|
|
12126
|
-
|
|
12127
|
-
this.included = true;
|
|
12128
|
-
const usedBranch = this.getUsedBranch();
|
|
12129
|
-
if (usedBranch === null || this.test.shouldBeIncluded(context)) {
|
|
12130
|
-
this.consequent.includePath(path, context);
|
|
12131
|
-
this.alternate.includePath(path, context);
|
|
12132
|
-
}
|
|
12133
|
-
else {
|
|
12134
|
-
usedBranch.includePath(path, context);
|
|
12135
|
-
}
|
|
12136
|
-
}
|
|
12137
|
-
includeCallArguments(context, interaction) {
|
|
11618
|
+
includeCallArguments(context, parameters) {
|
|
12138
11619
|
const usedBranch = this.getUsedBranch();
|
|
12139
11620
|
if (usedBranch) {
|
|
12140
|
-
usedBranch.includeCallArguments(context,
|
|
11621
|
+
usedBranch.includeCallArguments(context, parameters);
|
|
12141
11622
|
}
|
|
12142
11623
|
else {
|
|
12143
|
-
this.consequent.includeCallArguments(context,
|
|
12144
|
-
this.alternate.includeCallArguments(context,
|
|
11624
|
+
this.consequent.includeCallArguments(context, parameters);
|
|
11625
|
+
this.alternate.includeCallArguments(context, parameters);
|
|
12145
11626
|
}
|
|
12146
11627
|
}
|
|
12147
11628
|
removeAnnotations(code) {
|
|
12148
11629
|
this.test.removeAnnotations(code);
|
|
12149
11630
|
}
|
|
12150
11631
|
render(code, options, { isCalleeOfRenderedParent, preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
11632
|
+
const usedBranch = this.getUsedBranch();
|
|
12151
11633
|
if (this.test.included) {
|
|
12152
11634
|
this.test.render(code, options, { renderedSurroundingElement });
|
|
12153
11635
|
this.consequent.render(code, options);
|
|
12154
11636
|
this.alternate.render(code, options);
|
|
12155
11637
|
}
|
|
12156
11638
|
else {
|
|
12157
|
-
const usedBranch = this.getUsedBranch();
|
|
12158
11639
|
const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end);
|
|
12159
11640
|
const inclusionStart = findNonWhiteSpace(code.original, (this.consequent.included
|
|
12160
11641
|
? findFirstOccurrenceOutsideComment(code.original, '?', this.test.end)
|
|
@@ -12186,8 +11667,6 @@ class ConditionalExpression extends NodeBase {
|
|
|
12186
11667
|
: (this.usedBranch = testValue ? this.consequent : this.alternate);
|
|
12187
11668
|
}
|
|
12188
11669
|
}
|
|
12189
|
-
ConditionalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12190
|
-
ConditionalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12191
11670
|
|
|
12192
11671
|
class ContinueStatement extends NodeBase {
|
|
12193
11672
|
hasEffects(context) {
|
|
@@ -12207,7 +11686,7 @@ class ContinueStatement extends NodeBase {
|
|
|
12207
11686
|
include(context) {
|
|
12208
11687
|
this.included = true;
|
|
12209
11688
|
if (this.label) {
|
|
12210
|
-
this.label.include(
|
|
11689
|
+
this.label.include();
|
|
12211
11690
|
context.includedLabels.add(this.label.name);
|
|
12212
11691
|
}
|
|
12213
11692
|
else {
|
|
@@ -12216,15 +11695,12 @@ class ContinueStatement extends NodeBase {
|
|
|
12216
11695
|
context.brokenFlow = true;
|
|
12217
11696
|
}
|
|
12218
11697
|
}
|
|
12219
|
-
ContinueStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12220
|
-
ContinueStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12221
11698
|
|
|
12222
11699
|
class DebuggerStatement extends NodeBase {
|
|
12223
11700
|
hasEffects() {
|
|
12224
11701
|
return true;
|
|
12225
11702
|
}
|
|
12226
11703
|
}
|
|
12227
|
-
DebuggerStatement.prototype.includeNode = onlyIncludeSelf;
|
|
12228
11704
|
|
|
12229
11705
|
class Decorator extends NodeBase {
|
|
12230
11706
|
hasEffects(context) {
|
|
@@ -12232,7 +11708,6 @@ class Decorator extends NodeBase {
|
|
|
12232
11708
|
this.expression.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context));
|
|
12233
11709
|
}
|
|
12234
11710
|
}
|
|
12235
|
-
Decorator.prototype.includeNode = onlyIncludeSelf;
|
|
12236
11711
|
|
|
12237
11712
|
function hasLoopBodyEffects(context, body) {
|
|
12238
11713
|
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
@@ -12272,15 +11747,12 @@ class DoWhileStatement extends NodeBase {
|
|
|
12272
11747
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12273
11748
|
}
|
|
12274
11749
|
}
|
|
12275
|
-
DoWhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12276
|
-
DoWhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12277
11750
|
|
|
12278
11751
|
class EmptyStatement extends NodeBase {
|
|
12279
11752
|
hasEffects() {
|
|
12280
11753
|
return false;
|
|
12281
11754
|
}
|
|
12282
11755
|
}
|
|
12283
|
-
EmptyStatement.prototype.includeNode = onlyIncludeSelf;
|
|
12284
11756
|
|
|
12285
11757
|
class ExportAllDeclaration extends NodeBase {
|
|
12286
11758
|
hasEffects() {
|
|
@@ -12293,10 +11765,9 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
12293
11765
|
render(code, _options, nodeRenderOptions) {
|
|
12294
11766
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
12295
11767
|
}
|
|
11768
|
+
applyDeoptimizations() { }
|
|
12296
11769
|
}
|
|
12297
11770
|
ExportAllDeclaration.prototype.needsBoundaries = true;
|
|
12298
|
-
ExportAllDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12299
|
-
ExportAllDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12300
11771
|
|
|
12301
11772
|
class ExportNamedDeclaration extends NodeBase {
|
|
12302
11773
|
bind() {
|
|
@@ -12323,15 +11794,13 @@ class ExportNamedDeclaration extends NodeBase {
|
|
|
12323
11794
|
this.declaration.render(code, options, { end, start });
|
|
12324
11795
|
}
|
|
12325
11796
|
}
|
|
11797
|
+
applyDeoptimizations() { }
|
|
12326
11798
|
}
|
|
12327
11799
|
ExportNamedDeclaration.prototype.needsBoundaries = true;
|
|
12328
|
-
ExportNamedDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12329
|
-
ExportNamedDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12330
11800
|
|
|
12331
11801
|
class ExportSpecifier extends NodeBase {
|
|
11802
|
+
applyDeoptimizations() { }
|
|
12332
11803
|
}
|
|
12333
|
-
ExportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12334
|
-
ExportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12335
11804
|
|
|
12336
11805
|
class ForInStatement extends NodeBase {
|
|
12337
11806
|
createScope(parentScope) {
|
|
@@ -12349,18 +11818,11 @@ class ForInStatement extends NodeBase {
|
|
|
12349
11818
|
const { body, deoptimized, left, right } = this;
|
|
12350
11819
|
if (!deoptimized)
|
|
12351
11820
|
this.applyDeoptimizations();
|
|
12352
|
-
|
|
12353
|
-
this.includeNode(context);
|
|
11821
|
+
this.included = true;
|
|
12354
11822
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12355
11823
|
right.include(context, includeChildrenRecursively);
|
|
12356
11824
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12357
11825
|
}
|
|
12358
|
-
includeNode(context) {
|
|
12359
|
-
this.included = true;
|
|
12360
|
-
if (!this.deoptimized)
|
|
12361
|
-
this.applyDeoptimizations();
|
|
12362
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12363
|
-
}
|
|
12364
11826
|
initialise() {
|
|
12365
11827
|
super.initialise();
|
|
12366
11828
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -12401,18 +11863,11 @@ class ForOfStatement extends NodeBase {
|
|
|
12401
11863
|
const { body, deoptimized, left, right } = this;
|
|
12402
11864
|
if (!deoptimized)
|
|
12403
11865
|
this.applyDeoptimizations();
|
|
12404
|
-
|
|
12405
|
-
this.includeNode(context);
|
|
11866
|
+
this.included = true;
|
|
12406
11867
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12407
11868
|
right.include(context, includeChildrenRecursively);
|
|
12408
11869
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12409
11870
|
}
|
|
12410
|
-
includeNode(context) {
|
|
12411
|
-
this.included = true;
|
|
12412
|
-
if (!this.deoptimized)
|
|
12413
|
-
this.applyDeoptimizations();
|
|
12414
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12415
|
-
}
|
|
12416
11871
|
initialise() {
|
|
12417
11872
|
super.initialise();
|
|
12418
11873
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -12448,9 +11903,7 @@ class ForStatement extends NodeBase {
|
|
|
12448
11903
|
}
|
|
12449
11904
|
include(context, includeChildrenRecursively) {
|
|
12450
11905
|
this.included = true;
|
|
12451
|
-
this.init?.include(context, includeChildrenRecursively, {
|
|
12452
|
-
asSingleStatement: true
|
|
12453
|
-
});
|
|
11906
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
12454
11907
|
this.test?.include(context, includeChildrenRecursively);
|
|
12455
11908
|
this.update?.include(context, includeChildrenRecursively);
|
|
12456
11909
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
@@ -12462,8 +11915,6 @@ class ForStatement extends NodeBase {
|
|
|
12462
11915
|
this.body.render(code, options);
|
|
12463
11916
|
}
|
|
12464
11917
|
}
|
|
12465
|
-
ForStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12466
|
-
ForStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12467
11918
|
|
|
12468
11919
|
class FunctionExpression extends FunctionNode {
|
|
12469
11920
|
createScope(parentScope) {
|
|
@@ -12495,9 +11946,9 @@ class TrackingScope extends BlockScope {
|
|
|
12495
11946
|
super(...arguments);
|
|
12496
11947
|
this.hoistedDeclarations = [];
|
|
12497
11948
|
}
|
|
12498
|
-
addDeclaration(identifier, context, init,
|
|
11949
|
+
addDeclaration(identifier, context, init, kind) {
|
|
12499
11950
|
this.hoistedDeclarations.push(identifier);
|
|
12500
|
-
return super.addDeclaration(identifier, context, init,
|
|
11951
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
12501
11952
|
}
|
|
12502
11953
|
}
|
|
12503
11954
|
|
|
@@ -12596,6 +12047,7 @@ class IfStatement extends NodeBase {
|
|
|
12596
12047
|
}
|
|
12597
12048
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
12598
12049
|
}
|
|
12050
|
+
applyDeoptimizations() { }
|
|
12599
12051
|
getTestValue() {
|
|
12600
12052
|
if (this.testValue === unset) {
|
|
12601
12053
|
return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
@@ -12664,8 +12116,6 @@ class IfStatement extends NodeBase {
|
|
|
12664
12116
|
return false;
|
|
12665
12117
|
}
|
|
12666
12118
|
}
|
|
12667
|
-
IfStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12668
|
-
IfStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12669
12119
|
|
|
12670
12120
|
class ImportAttribute extends NodeBase {
|
|
12671
12121
|
}
|
|
@@ -12683,15 +12133,13 @@ class ImportDeclaration extends NodeBase {
|
|
|
12683
12133
|
render(code, _options, nodeRenderOptions) {
|
|
12684
12134
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
12685
12135
|
}
|
|
12136
|
+
applyDeoptimizations() { }
|
|
12686
12137
|
}
|
|
12687
12138
|
ImportDeclaration.prototype.needsBoundaries = true;
|
|
12688
|
-
ImportDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12689
|
-
ImportDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12690
12139
|
|
|
12691
12140
|
class ImportDefaultSpecifier extends NodeBase {
|
|
12141
|
+
applyDeoptimizations() { }
|
|
12692
12142
|
}
|
|
12693
|
-
ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12694
|
-
ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12695
12143
|
|
|
12696
12144
|
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
12697
12145
|
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
@@ -12700,33 +12148,28 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
12700
12148
|
class VariableDeclarator extends NodeBase {
|
|
12701
12149
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
12702
12150
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
12703
|
-
this.id.declare(kind,
|
|
12151
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12704
12152
|
}
|
|
12705
12153
|
deoptimizePath(path) {
|
|
12706
12154
|
this.id.deoptimizePath(path);
|
|
12707
12155
|
}
|
|
12708
12156
|
hasEffects(context) {
|
|
12157
|
+
if (!this.deoptimized)
|
|
12158
|
+
this.applyDeoptimizations();
|
|
12709
12159
|
const initEffect = this.init?.hasEffects(context);
|
|
12710
12160
|
this.id.markDeclarationReached();
|
|
12711
|
-
return
|
|
12712
|
-
this.isUsingDeclaration ||
|
|
12713
|
-
this.id.hasEffects(context) ||
|
|
12714
|
-
(this.scope.context.options.treeshake
|
|
12715
|
-
.propertyReadSideEffects &&
|
|
12716
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
12161
|
+
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
12717
12162
|
}
|
|
12718
12163
|
include(context, includeChildrenRecursively) {
|
|
12719
|
-
const { id, init } = this;
|
|
12720
|
-
if (!
|
|
12721
|
-
this.
|
|
12164
|
+
const { deoptimized, id, init } = this;
|
|
12165
|
+
if (!deoptimized)
|
|
12166
|
+
this.applyDeoptimizations();
|
|
12167
|
+
this.included = true;
|
|
12722
12168
|
init?.include(context, includeChildrenRecursively);
|
|
12723
12169
|
id.markDeclarationReached();
|
|
12724
|
-
if (includeChildrenRecursively) {
|
|
12170
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12725
12171
|
id.include(context, includeChildrenRecursively);
|
|
12726
12172
|
}
|
|
12727
|
-
else {
|
|
12728
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
12729
|
-
}
|
|
12730
12173
|
}
|
|
12731
12174
|
removeAnnotations(code) {
|
|
12732
12175
|
this.init?.removeAnnotations(code);
|
|
@@ -12756,8 +12199,8 @@ class VariableDeclarator extends NodeBase {
|
|
|
12756
12199
|
code.appendLeft(end, `${_}=${_}void 0`);
|
|
12757
12200
|
}
|
|
12758
12201
|
}
|
|
12759
|
-
|
|
12760
|
-
this.
|
|
12202
|
+
applyDeoptimizations() {
|
|
12203
|
+
this.deoptimized = true;
|
|
12761
12204
|
const { id, init } = this;
|
|
12762
12205
|
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12763
12206
|
const { name, variable } = id;
|
|
@@ -12769,14 +12212,11 @@ class VariableDeclarator extends NodeBase {
|
|
|
12769
12212
|
}
|
|
12770
12213
|
}
|
|
12771
12214
|
}
|
|
12772
|
-
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12773
12215
|
|
|
12774
12216
|
class ImportExpression extends NodeBase {
|
|
12775
12217
|
constructor() {
|
|
12776
12218
|
super(...arguments);
|
|
12777
12219
|
this.inlineNamespace = null;
|
|
12778
|
-
this.hasUnknownAccessedKey = false;
|
|
12779
|
-
this.accessedPropKey = new Set();
|
|
12780
12220
|
this.attributes = null;
|
|
12781
12221
|
this.mechanism = null;
|
|
12782
12222
|
this.namespaceExportName = undefined;
|
|
@@ -12809,15 +12249,12 @@ class ImportExpression extends NodeBase {
|
|
|
12809
12249
|
if (parent2 instanceof ExpressionStatement) {
|
|
12810
12250
|
return EMPTY_ARRAY;
|
|
12811
12251
|
}
|
|
12812
|
-
// Case 1: const { foo }
|
|
12252
|
+
// Case 1: const { foo } = await import('bar')
|
|
12813
12253
|
if (parent2 instanceof VariableDeclarator) {
|
|
12814
12254
|
const declaration = parent2.id;
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
if (declaration instanceof ObjectPattern) {
|
|
12819
|
-
return getDeterministicObjectDestructure(declaration);
|
|
12820
|
-
}
|
|
12255
|
+
return declaration instanceof ObjectPattern
|
|
12256
|
+
? getDeterministicObjectDestructure(declaration)
|
|
12257
|
+
: undefined;
|
|
12821
12258
|
}
|
|
12822
12259
|
// Case 2: (await import('bar')).foo
|
|
12823
12260
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -12867,29 +12304,12 @@ class ImportExpression extends NodeBase {
|
|
|
12867
12304
|
return true;
|
|
12868
12305
|
}
|
|
12869
12306
|
include(context, includeChildrenRecursively) {
|
|
12870
|
-
if (!this.included)
|
|
12871
|
-
this.
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
includeNode() {
|
|
12875
|
-
this.included = true;
|
|
12876
|
-
this.scope.context.includeDynamicImport(this);
|
|
12877
|
-
this.scope.addAccessedDynamicImport(this);
|
|
12878
|
-
}
|
|
12879
|
-
includePath(path) {
|
|
12880
|
-
if (!this.included)
|
|
12881
|
-
this.includeNode();
|
|
12882
|
-
// Technically, this is not correct as dynamic imports return a Promise.
|
|
12883
|
-
if (this.hasUnknownAccessedKey)
|
|
12884
|
-
return;
|
|
12885
|
-
if (path[0] === UnknownKey) {
|
|
12886
|
-
this.hasUnknownAccessedKey = true;
|
|
12887
|
-
}
|
|
12888
|
-
else if (typeof path[0] === 'string') {
|
|
12889
|
-
this.accessedPropKey.add(path[0]);
|
|
12307
|
+
if (!this.included) {
|
|
12308
|
+
this.included = true;
|
|
12309
|
+
this.scope.context.includeDynamicImport(this);
|
|
12310
|
+
this.scope.addAccessedDynamicImport(this);
|
|
12890
12311
|
}
|
|
12891
|
-
|
|
12892
|
-
this.scope.context.includeDynamicImport(this);
|
|
12312
|
+
this.source.include(context, includeChildrenRecursively);
|
|
12893
12313
|
}
|
|
12894
12314
|
initialise() {
|
|
12895
12315
|
super.initialise();
|
|
@@ -12959,6 +12379,7 @@ class ImportExpression extends NodeBase {
|
|
|
12959
12379
|
setInternalResolution(inlineNamespace) {
|
|
12960
12380
|
this.inlineNamespace = inlineNamespace;
|
|
12961
12381
|
}
|
|
12382
|
+
applyDeoptimizations() { }
|
|
12962
12383
|
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
12963
12384
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
12964
12385
|
{
|
|
@@ -13048,7 +12469,6 @@ class ImportExpression extends NodeBase {
|
|
|
13048
12469
|
return { helper: null, mechanism: null };
|
|
13049
12470
|
}
|
|
13050
12471
|
}
|
|
13051
|
-
ImportExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13052
12472
|
function getInteropHelper(resolution, exportMode, interop) {
|
|
13053
12473
|
return exportMode === 'external'
|
|
13054
12474
|
? namespaceInteropHelpersByInteropType[interop(resolution instanceof ExternalModule ? resolution.id : null)]
|
|
@@ -13072,14 +12492,12 @@ function getDeterministicObjectDestructure(objectPattern) {
|
|
|
13072
12492
|
}
|
|
13073
12493
|
|
|
13074
12494
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
12495
|
+
applyDeoptimizations() { }
|
|
13075
12496
|
}
|
|
13076
|
-
ImportNamespaceSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13077
|
-
ImportNamespaceSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13078
12497
|
|
|
13079
12498
|
class ImportSpecifier extends NodeBase {
|
|
12499
|
+
applyDeoptimizations() { }
|
|
13080
12500
|
}
|
|
13081
|
-
ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13082
|
-
ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13083
12501
|
|
|
13084
12502
|
class JSXIdentifier extends IdentifierBase {
|
|
13085
12503
|
constructor() {
|
|
@@ -13096,29 +12514,6 @@ class JSXIdentifier extends IdentifierBase {
|
|
|
13096
12514
|
this.isNativeElement = true;
|
|
13097
12515
|
}
|
|
13098
12516
|
}
|
|
13099
|
-
include(context) {
|
|
13100
|
-
if (!this.included)
|
|
13101
|
-
this.includeNode(context);
|
|
13102
|
-
}
|
|
13103
|
-
includeNode(context) {
|
|
13104
|
-
this.included = true;
|
|
13105
|
-
if (!this.deoptimized)
|
|
13106
|
-
this.applyDeoptimizations();
|
|
13107
|
-
if (this.variable !== null) {
|
|
13108
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13109
|
-
}
|
|
13110
|
-
}
|
|
13111
|
-
includePath(path, context) {
|
|
13112
|
-
if (!this.included) {
|
|
13113
|
-
this.included = true;
|
|
13114
|
-
if (this.variable !== null) {
|
|
13115
|
-
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
13116
|
-
}
|
|
13117
|
-
}
|
|
13118
|
-
else if (path.length > 0) {
|
|
13119
|
-
this.variable?.includePath(path, context);
|
|
13120
|
-
}
|
|
13121
|
-
}
|
|
13122
12517
|
render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
|
|
13123
12518
|
if (this.variable) {
|
|
13124
12519
|
const name = this.variable.getName(getPropertyAccess, useOriginalName);
|
|
@@ -13180,7 +12575,6 @@ class JSXAttribute extends NodeBase {
|
|
|
13180
12575
|
}
|
|
13181
12576
|
}
|
|
13182
12577
|
}
|
|
13183
|
-
JSXAttribute.prototype.includeNode = onlyIncludeSelf;
|
|
13184
12578
|
|
|
13185
12579
|
class JSXClosingBase extends NodeBase {
|
|
13186
12580
|
render(code, options) {
|
|
@@ -13193,7 +12587,6 @@ class JSXClosingBase extends NodeBase {
|
|
|
13193
12587
|
}
|
|
13194
12588
|
}
|
|
13195
12589
|
}
|
|
13196
|
-
JSXClosingBase.prototype.includeNode = onlyIncludeSelf;
|
|
13197
12590
|
|
|
13198
12591
|
class JSXClosingElement extends JSXClosingBase {
|
|
13199
12592
|
}
|
|
@@ -13214,15 +12607,8 @@ class JSXSpreadAttribute extends NodeBase {
|
|
|
13214
12607
|
|
|
13215
12608
|
class JSXEmptyExpression extends NodeBase {
|
|
13216
12609
|
}
|
|
13217
|
-
JSXEmptyExpression.prototype.includeNode = onlyIncludeSelf;
|
|
13218
12610
|
|
|
13219
12611
|
class JSXExpressionContainer extends NodeBase {
|
|
13220
|
-
includeNode(context) {
|
|
13221
|
-
this.included = true;
|
|
13222
|
-
if (!this.deoptimized)
|
|
13223
|
-
this.applyDeoptimizations();
|
|
13224
|
-
this.expression.includePath(UNKNOWN_PATH, context);
|
|
13225
|
-
}
|
|
13226
12612
|
render(code, options) {
|
|
13227
12613
|
const { mode } = this.scope.context.options.jsx;
|
|
13228
12614
|
if (mode !== 'preserve') {
|
|
@@ -13243,7 +12629,7 @@ function getRenderedJsxChildren(children) {
|
|
|
13243
12629
|
return renderedChildren;
|
|
13244
12630
|
}
|
|
13245
12631
|
|
|
13246
|
-
function getAndIncludeFactoryVariable(factory, preserve, importSource, node
|
|
12632
|
+
function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
13247
12633
|
const [baseName, nestedName] = factory.split('.');
|
|
13248
12634
|
let factoryVariable;
|
|
13249
12635
|
if (importSource) {
|
|
@@ -13251,7 +12637,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
13251
12637
|
if (preserve) {
|
|
13252
12638
|
// This pretends we are accessing an included global variable of the same name
|
|
13253
12639
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
13254
|
-
globalVariable.
|
|
12640
|
+
globalVariable.include();
|
|
13255
12641
|
// This excludes this variable from renaming
|
|
13256
12642
|
factoryVariable.globalName = baseName;
|
|
13257
12643
|
}
|
|
@@ -13259,7 +12645,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
13259
12645
|
else {
|
|
13260
12646
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
13261
12647
|
}
|
|
13262
|
-
node.scope.context.includeVariableInModule(factoryVariable
|
|
12648
|
+
node.scope.context.includeVariableInModule(factoryVariable);
|
|
13263
12649
|
if (factoryVariable instanceof LocalVariable) {
|
|
13264
12650
|
factoryVariable.consolidateInitializers();
|
|
13265
12651
|
factoryVariable.addUsedPlace(node);
|
|
@@ -13282,20 +12668,16 @@ class JSXElementBase extends NodeBase {
|
|
|
13282
12668
|
}
|
|
13283
12669
|
}
|
|
13284
12670
|
include(context, includeChildrenRecursively) {
|
|
13285
|
-
if (!this.included)
|
|
13286
|
-
this.
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
includeNode(context) {
|
|
13292
|
-
this.included = true;
|
|
13293
|
-
const { factory, importSource, mode } = this.jsxMode;
|
|
13294
|
-
if (factory) {
|
|
13295
|
-
this.factory = factory;
|
|
13296
|
-
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this, context);
|
|
12671
|
+
if (!this.included) {
|
|
12672
|
+
const { factory, importSource, mode } = this.jsxMode;
|
|
12673
|
+
if (factory) {
|
|
12674
|
+
this.factory = factory;
|
|
12675
|
+
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
12676
|
+
}
|
|
13297
12677
|
}
|
|
12678
|
+
super.include(context, includeChildrenRecursively);
|
|
13298
12679
|
}
|
|
12680
|
+
applyDeoptimizations() { }
|
|
13299
12681
|
getRenderingMode() {
|
|
13300
12682
|
const jsx = this.scope.context.options.jsx;
|
|
13301
12683
|
const { mode, factory, importSource } = jsx;
|
|
@@ -13333,14 +12715,8 @@ class JSXElementBase extends NodeBase {
|
|
|
13333
12715
|
return { childrenEnd, firstChild, hasMultipleChildren };
|
|
13334
12716
|
}
|
|
13335
12717
|
}
|
|
13336
|
-
JSXElementBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13337
12718
|
|
|
13338
12719
|
class JSXElement extends JSXElementBase {
|
|
13339
|
-
include(context, includeChildrenRecursively) {
|
|
13340
|
-
super.include(context, includeChildrenRecursively);
|
|
13341
|
-
this.openingElement.include(context, includeChildrenRecursively);
|
|
13342
|
-
this.closingElement?.include(context, includeChildrenRecursively);
|
|
13343
|
-
}
|
|
13344
12720
|
render(code, options) {
|
|
13345
12721
|
switch (this.jsxMode.mode) {
|
|
13346
12722
|
case 'classic': {
|
|
@@ -13492,11 +12868,6 @@ class JSXElement extends JSXElementBase {
|
|
|
13492
12868
|
}
|
|
13493
12869
|
|
|
13494
12870
|
class JSXFragment extends JSXElementBase {
|
|
13495
|
-
include(context, includeChildrenRecursively) {
|
|
13496
|
-
super.include(context, includeChildrenRecursively);
|
|
13497
|
-
this.openingFragment.include(context, includeChildrenRecursively);
|
|
13498
|
-
this.closingFragment.include(context, includeChildrenRecursively);
|
|
13499
|
-
}
|
|
13500
12871
|
render(code, options) {
|
|
13501
12872
|
switch (this.jsxMode.mode) {
|
|
13502
12873
|
case 'classic': {
|
|
@@ -13546,22 +12917,10 @@ class JSXFragment extends JSXElementBase {
|
|
|
13546
12917
|
}
|
|
13547
12918
|
|
|
13548
12919
|
class JSXMemberExpression extends NodeBase {
|
|
13549
|
-
includeNode(context) {
|
|
13550
|
-
this.included = true;
|
|
13551
|
-
if (!this.deoptimized)
|
|
13552
|
-
this.applyDeoptimizations();
|
|
13553
|
-
this.object.includePath([this.property.name], context);
|
|
13554
|
-
}
|
|
13555
|
-
includePath(path, context) {
|
|
13556
|
-
if (!this.included)
|
|
13557
|
-
this.includeNode(context);
|
|
13558
|
-
this.object.includePath([this.property.name, ...path], context);
|
|
13559
|
-
}
|
|
13560
12920
|
}
|
|
13561
12921
|
|
|
13562
12922
|
class JSXNamespacedName extends NodeBase {
|
|
13563
12923
|
}
|
|
13564
|
-
JSXNamespacedName.prototype.includeNode = onlyIncludeSelf;
|
|
13565
12924
|
|
|
13566
12925
|
class JSXOpeningElement extends NodeBase {
|
|
13567
12926
|
render(code, options, { jsxMode = this.scope.context.options.jsx.mode } = {}) {
|
|
@@ -13571,7 +12930,6 @@ class JSXOpeningElement extends NodeBase {
|
|
|
13571
12930
|
}
|
|
13572
12931
|
}
|
|
13573
12932
|
}
|
|
13574
|
-
JSXOpeningElement.prototype.includeNode = onlyIncludeSelf;
|
|
13575
12933
|
|
|
13576
12934
|
class JSXOpeningFragment extends NodeBase {
|
|
13577
12935
|
constructor() {
|
|
@@ -13579,22 +12937,22 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13579
12937
|
this.fragment = null;
|
|
13580
12938
|
this.fragmentVariable = null;
|
|
13581
12939
|
}
|
|
13582
|
-
|
|
13583
|
-
this.included
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this, context);
|
|
12940
|
+
include(context, includeChildrenRecursively) {
|
|
12941
|
+
if (!this.included) {
|
|
12942
|
+
const jsx = this.scope.context.options.jsx;
|
|
12943
|
+
if (jsx.mode === 'automatic') {
|
|
12944
|
+
this.fragment = 'Fragment';
|
|
12945
|
+
this.fragmentVariable = getAndIncludeFactoryVariable('Fragment', false, jsx.jsxImportSource, this);
|
|
12946
|
+
}
|
|
12947
|
+
else {
|
|
12948
|
+
const { fragment, importSource, mode } = jsx;
|
|
12949
|
+
if (fragment != null) {
|
|
12950
|
+
this.fragment = fragment;
|
|
12951
|
+
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this);
|
|
12952
|
+
}
|
|
13596
12953
|
}
|
|
13597
12954
|
}
|
|
12955
|
+
super.include(context, includeChildrenRecursively);
|
|
13598
12956
|
}
|
|
13599
12957
|
render(code, options) {
|
|
13600
12958
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -13631,7 +12989,6 @@ class JSXText extends NodeBase {
|
|
|
13631
12989
|
}
|
|
13632
12990
|
}
|
|
13633
12991
|
}
|
|
13634
|
-
JSXText.prototype.includeNode = onlyIncludeSelf;
|
|
13635
12992
|
|
|
13636
12993
|
class LabeledStatement extends NodeBase {
|
|
13637
12994
|
hasEffects(context) {
|
|
@@ -13653,22 +13010,17 @@ class LabeledStatement extends NodeBase {
|
|
|
13653
13010
|
return bodyHasEffects;
|
|
13654
13011
|
}
|
|
13655
13012
|
include(context, includeChildrenRecursively) {
|
|
13656
|
-
|
|
13657
|
-
this.includeNode(context);
|
|
13013
|
+
this.included = true;
|
|
13658
13014
|
const { brokenFlow, includedLabels } = context;
|
|
13659
13015
|
context.includedLabels = new Set();
|
|
13660
13016
|
this.body.include(context, includeChildrenRecursively);
|
|
13661
13017
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
13662
|
-
this.label.include(
|
|
13018
|
+
this.label.include();
|
|
13663
13019
|
context.includedLabels.delete(this.label.name);
|
|
13664
13020
|
context.brokenFlow = brokenFlow;
|
|
13665
13021
|
}
|
|
13666
13022
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
13667
13023
|
}
|
|
13668
|
-
includeNode(context) {
|
|
13669
|
-
this.included = true;
|
|
13670
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
13671
|
-
}
|
|
13672
13024
|
render(code, options) {
|
|
13673
13025
|
if (this.label.included) {
|
|
13674
13026
|
this.label.render(code, options);
|
|
@@ -13679,7 +13031,6 @@ class LabeledStatement extends NodeBase {
|
|
|
13679
13031
|
this.body.render(code, options);
|
|
13680
13032
|
}
|
|
13681
13033
|
}
|
|
13682
|
-
LabeledStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13683
13034
|
|
|
13684
13035
|
class LogicalExpression extends NodeBase {
|
|
13685
13036
|
constructor() {
|
|
@@ -13696,10 +13047,10 @@ class LogicalExpression extends NodeBase {
|
|
|
13696
13047
|
this.flags = setFlag(this.flags, 65536 /* Flag.isBranchResolutionAnalysed */, value);
|
|
13697
13048
|
}
|
|
13698
13049
|
get hasDeoptimizedCache() {
|
|
13699
|
-
return isFlagSet(this.flags,
|
|
13050
|
+
return isFlagSet(this.flags, 16777216 /* Flag.hasDeoptimizedCache */);
|
|
13700
13051
|
}
|
|
13701
13052
|
set hasDeoptimizedCache(value) {
|
|
13702
|
-
this.flags = setFlag(this.flags,
|
|
13053
|
+
this.flags = setFlag(this.flags, 16777216 /* Flag.hasDeoptimizedCache */, value);
|
|
13703
13054
|
}
|
|
13704
13055
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13705
13056
|
this.left.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13712,10 +13063,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13712
13063
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
13713
13064
|
this.usedBranch = null;
|
|
13714
13065
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
13715
|
-
if (this.included) {
|
|
13716
|
-
// As we are not tracking inclusions, we just include everything
|
|
13717
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
13718
|
-
}
|
|
13719
13066
|
}
|
|
13720
13067
|
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
13721
13068
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
@@ -13761,17 +13108,16 @@ class LogicalExpression extends NodeBase {
|
|
|
13761
13108
|
}
|
|
13762
13109
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
13763
13110
|
const usedBranch = this.getUsedBranch();
|
|
13764
|
-
if (usedBranch)
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
];
|
|
13111
|
+
if (!usedBranch)
|
|
13112
|
+
return [
|
|
13113
|
+
new MultiExpression([
|
|
13114
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0],
|
|
13115
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0]
|
|
13116
|
+
]),
|
|
13117
|
+
false
|
|
13118
|
+
];
|
|
13119
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
13120
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
13775
13121
|
}
|
|
13776
13122
|
hasEffects(context) {
|
|
13777
13123
|
if (this.left.hasEffects(context)) {
|
|
@@ -13784,18 +13130,18 @@ class LogicalExpression extends NodeBase {
|
|
|
13784
13130
|
}
|
|
13785
13131
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13786
13132
|
const usedBranch = this.getUsedBranch();
|
|
13787
|
-
if (usedBranch) {
|
|
13788
|
-
return
|
|
13133
|
+
if (!usedBranch) {
|
|
13134
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
13135
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13789
13136
|
}
|
|
13790
|
-
return
|
|
13791
|
-
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13137
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13792
13138
|
}
|
|
13793
13139
|
include(context, includeChildrenRecursively) {
|
|
13794
13140
|
this.included = true;
|
|
13795
13141
|
const usedBranch = this.getUsedBranch();
|
|
13796
13142
|
if (includeChildrenRecursively ||
|
|
13797
|
-
|
|
13798
|
-
|
|
13143
|
+
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
13144
|
+
!usedBranch) {
|
|
13799
13145
|
this.left.include(context, includeChildrenRecursively);
|
|
13800
13146
|
this.right.include(context, includeChildrenRecursively);
|
|
13801
13147
|
}
|
|
@@ -13803,17 +13149,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13803
13149
|
usedBranch.include(context, includeChildrenRecursively);
|
|
13804
13150
|
}
|
|
13805
13151
|
}
|
|
13806
|
-
includePath(path, context) {
|
|
13807
|
-
this.included = true;
|
|
13808
|
-
const usedBranch = this.getUsedBranch();
|
|
13809
|
-
if (!usedBranch || (usedBranch === this.right && this.left.shouldBeIncluded(context))) {
|
|
13810
|
-
this.left.includePath(path, context);
|
|
13811
|
-
this.right.includePath(path, context);
|
|
13812
|
-
}
|
|
13813
|
-
else {
|
|
13814
|
-
usedBranch.includePath(path, context);
|
|
13815
|
-
}
|
|
13816
|
-
}
|
|
13817
13152
|
removeAnnotations(code) {
|
|
13818
13153
|
this.left.removeAnnotations(code);
|
|
13819
13154
|
}
|
|
@@ -13866,8 +13201,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13866
13201
|
return this.usedBranch;
|
|
13867
13202
|
}
|
|
13868
13203
|
}
|
|
13869
|
-
LogicalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13870
|
-
LogicalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13871
13204
|
|
|
13872
13205
|
class NewExpression extends NodeBase {
|
|
13873
13206
|
hasEffects(context) {
|
|
@@ -13887,21 +13220,16 @@ class NewExpression extends NodeBase {
|
|
|
13887
13220
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
13888
13221
|
}
|
|
13889
13222
|
include(context, includeChildrenRecursively) {
|
|
13223
|
+
if (!this.deoptimized)
|
|
13224
|
+
this.applyDeoptimizations();
|
|
13890
13225
|
if (includeChildrenRecursively) {
|
|
13891
13226
|
super.include(context, includeChildrenRecursively);
|
|
13892
13227
|
}
|
|
13893
13228
|
else {
|
|
13894
|
-
|
|
13895
|
-
this.includeNode(context);
|
|
13229
|
+
this.included = true;
|
|
13896
13230
|
this.callee.include(context, false);
|
|
13897
13231
|
}
|
|
13898
|
-
this.callee.includeCallArguments(context, this.
|
|
13899
|
-
}
|
|
13900
|
-
includeNode(context) {
|
|
13901
|
-
this.included = true;
|
|
13902
|
-
if (!this.deoptimized)
|
|
13903
|
-
this.applyDeoptimizations();
|
|
13904
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
13232
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
13905
13233
|
}
|
|
13906
13234
|
initialise() {
|
|
13907
13235
|
super.initialise();
|
|
@@ -13930,7 +13258,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13930
13258
|
constructor() {
|
|
13931
13259
|
super(...arguments);
|
|
13932
13260
|
this.objectEntity = null;
|
|
13933
|
-
this.protoProp = null;
|
|
13934
13261
|
}
|
|
13935
13262
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13936
13263
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13950,43 +13277,15 @@ class ObjectExpression extends NodeBase {
|
|
|
13950
13277
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13951
13278
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13952
13279
|
}
|
|
13953
|
-
include(context, includeChildrenRecursively) {
|
|
13954
|
-
if (!this.included)
|
|
13955
|
-
this.includeNode(context);
|
|
13956
|
-
this.getObjectEntity().include(context, includeChildrenRecursively);
|
|
13957
|
-
this.protoProp?.include(context, includeChildrenRecursively);
|
|
13958
|
-
}
|
|
13959
|
-
includeNode(context) {
|
|
13960
|
-
this.included = true;
|
|
13961
|
-
this.protoProp?.includePath(UNKNOWN_PATH, context);
|
|
13962
|
-
}
|
|
13963
|
-
includePath(path, context) {
|
|
13964
|
-
if (!this.included)
|
|
13965
|
-
this.includeNode(context);
|
|
13966
|
-
this.getObjectEntity().includePath(path, context);
|
|
13967
|
-
}
|
|
13968
13280
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13281
|
+
super.render(code, options);
|
|
13969
13282
|
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13970
13283
|
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
13971
13284
|
code.appendRight(this.start, '(');
|
|
13972
13285
|
code.prependLeft(this.end, ')');
|
|
13973
13286
|
}
|
|
13974
|
-
if (this.properties.length > 0) {
|
|
13975
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
13976
|
-
let lastSeparatorPos = null;
|
|
13977
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
13978
|
-
if (!node.included) {
|
|
13979
|
-
treeshakeNode(node, code, start, end);
|
|
13980
|
-
continue;
|
|
13981
|
-
}
|
|
13982
|
-
lastSeparatorPos = separator;
|
|
13983
|
-
node.render(code, options);
|
|
13984
|
-
}
|
|
13985
|
-
if (lastSeparatorPos) {
|
|
13986
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
13987
|
-
}
|
|
13988
|
-
}
|
|
13989
13287
|
}
|
|
13288
|
+
applyDeoptimizations() { }
|
|
13990
13289
|
getObjectEntity() {
|
|
13991
13290
|
if (this.objectEntity !== null) {
|
|
13992
13291
|
return this.objectEntity;
|
|
@@ -14015,7 +13314,6 @@ class ObjectExpression extends NodeBase {
|
|
|
14015
13314
|
? property.key.name
|
|
14016
13315
|
: String(property.key.value);
|
|
14017
13316
|
if (key === '__proto__' && property.kind === 'init') {
|
|
14018
|
-
this.protoProp = property;
|
|
14019
13317
|
prototype =
|
|
14020
13318
|
property.value instanceof Literal && property.value.value === null
|
|
14021
13319
|
? null
|
|
@@ -14028,7 +13326,6 @@ class ObjectExpression extends NodeBase {
|
|
|
14028
13326
|
return (this.objectEntity = new ObjectEntity(properties, prototype));
|
|
14029
13327
|
}
|
|
14030
13328
|
}
|
|
14031
|
-
ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14032
13329
|
|
|
14033
13330
|
class PanicError extends NodeBase {
|
|
14034
13331
|
initialise() {
|
|
@@ -14055,7 +13352,6 @@ class ParseError extends NodeBase {
|
|
|
14055
13352
|
|
|
14056
13353
|
class PrivateIdentifier extends NodeBase {
|
|
14057
13354
|
}
|
|
14058
|
-
PrivateIdentifier.prototype.includeNode = onlyIncludeSelf;
|
|
14059
13355
|
|
|
14060
13356
|
class Program extends NodeBase {
|
|
14061
13357
|
constructor() {
|
|
@@ -14123,11 +13419,14 @@ class Program extends NodeBase {
|
|
|
14123
13419
|
super.render(code, options);
|
|
14124
13420
|
}
|
|
14125
13421
|
}
|
|
13422
|
+
applyDeoptimizations() { }
|
|
14126
13423
|
}
|
|
14127
|
-
Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14128
|
-
Program.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14129
13424
|
|
|
14130
13425
|
class Property extends MethodBase {
|
|
13426
|
+
constructor() {
|
|
13427
|
+
super(...arguments);
|
|
13428
|
+
this.declarationInit = null;
|
|
13429
|
+
}
|
|
14131
13430
|
//declare method: boolean;
|
|
14132
13431
|
get method() {
|
|
14133
13432
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -14142,41 +13441,17 @@ class Property extends MethodBase {
|
|
|
14142
13441
|
set shorthand(value) {
|
|
14143
13442
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
14144
13443
|
}
|
|
14145
|
-
declare(kind,
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
14149
|
-
this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
|
|
13444
|
+
declare(kind, init) {
|
|
13445
|
+
this.declarationInit = init;
|
|
13446
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
14150
13447
|
}
|
|
14151
13448
|
hasEffects(context) {
|
|
14152
|
-
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
return this.
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
const path = this.getPathInProperty(destructuredInitPath);
|
|
14159
|
-
let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
|
|
14160
|
-
this.included;
|
|
14161
|
-
if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
|
|
14162
|
-
this.key.include(context, false);
|
|
14163
|
-
if (!this.value.included) {
|
|
14164
|
-
this.value.included = true;
|
|
14165
|
-
// Unfortunately, we need to include the value again now, so that any
|
|
14166
|
-
// declared variables are properly included.
|
|
14167
|
-
this.value.includeDestructuredIfNecessary(context, path, init);
|
|
14168
|
-
}
|
|
14169
|
-
}
|
|
14170
|
-
return (this.included = included);
|
|
14171
|
-
}
|
|
14172
|
-
include(context, includeChildrenRecursively) {
|
|
14173
|
-
this.included = true;
|
|
14174
|
-
this.key.include(context, includeChildrenRecursively);
|
|
14175
|
-
this.value.include(context, includeChildrenRecursively);
|
|
14176
|
-
}
|
|
14177
|
-
includePath(path, context) {
|
|
14178
|
-
this.included = true;
|
|
14179
|
-
this.value.includePath(path, context);
|
|
13449
|
+
if (!this.deoptimized)
|
|
13450
|
+
this.applyDeoptimizations();
|
|
13451
|
+
const propertyReadSideEffects = this.scope.context.options.treeshake.propertyReadSideEffects;
|
|
13452
|
+
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
13453
|
+
this.key.hasEffects(context) ||
|
|
13454
|
+
this.value.hasEffects(context));
|
|
14180
13455
|
}
|
|
14181
13456
|
markDeclarationReached() {
|
|
14182
13457
|
this.value.markDeclarationReached();
|
|
@@ -14187,20 +13462,14 @@ class Property extends MethodBase {
|
|
|
14187
13462
|
}
|
|
14188
13463
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
14189
13464
|
}
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
? [...destructuredInitPath, UnknownKey]
|
|
14197
|
-
: this.key instanceof Identifier
|
|
14198
|
-
? [...destructuredInitPath, this.key.name]
|
|
14199
|
-
: [...destructuredInitPath, String(this.key.value)];
|
|
13465
|
+
applyDeoptimizations() {
|
|
13466
|
+
this.deoptimized = true;
|
|
13467
|
+
if (this.declarationInit !== null) {
|
|
13468
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
13469
|
+
this.scope.context.requestTreeshakingPass();
|
|
13470
|
+
}
|
|
14200
13471
|
}
|
|
14201
13472
|
}
|
|
14202
|
-
Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14203
|
-
Property.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14204
13473
|
|
|
14205
13474
|
class PropertyDefinition extends NodeBase {
|
|
14206
13475
|
get computed() {
|
|
@@ -14233,15 +13502,8 @@ class PropertyDefinition extends NodeBase {
|
|
|
14233
13502
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
14234
13503
|
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14235
13504
|
}
|
|
14236
|
-
|
|
14237
|
-
this.included = true;
|
|
14238
|
-
this.value?.includePath(UNKNOWN_PATH, context);
|
|
14239
|
-
for (const decorator of this.decorators) {
|
|
14240
|
-
decorator.includePath(UNKNOWN_PATH, context);
|
|
14241
|
-
}
|
|
14242
|
-
}
|
|
13505
|
+
applyDeoptimizations() { }
|
|
14243
13506
|
}
|
|
14244
|
-
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14245
13507
|
|
|
14246
13508
|
class ReturnStatement extends NodeBase {
|
|
14247
13509
|
hasEffects(context) {
|
|
@@ -14251,15 +13513,10 @@ class ReturnStatement extends NodeBase {
|
|
|
14251
13513
|
return false;
|
|
14252
13514
|
}
|
|
14253
13515
|
include(context, includeChildrenRecursively) {
|
|
14254
|
-
|
|
14255
|
-
this.includeNode(context);
|
|
13516
|
+
this.included = true;
|
|
14256
13517
|
this.argument?.include(context, includeChildrenRecursively);
|
|
14257
13518
|
context.brokenFlow = true;
|
|
14258
13519
|
}
|
|
14259
|
-
includeNode(context) {
|
|
14260
|
-
this.included = true;
|
|
14261
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
14262
|
-
}
|
|
14263
13520
|
initialise() {
|
|
14264
13521
|
super.initialise();
|
|
14265
13522
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
@@ -14273,7 +13530,6 @@ class ReturnStatement extends NodeBase {
|
|
|
14273
13530
|
}
|
|
14274
13531
|
}
|
|
14275
13532
|
}
|
|
14276
|
-
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14277
13533
|
|
|
14278
13534
|
class SequenceExpression extends NodeBase {
|
|
14279
13535
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -14301,15 +13557,10 @@ class SequenceExpression extends NodeBase {
|
|
|
14301
13557
|
for (const expression of this.expressions) {
|
|
14302
13558
|
if (includeChildrenRecursively ||
|
|
14303
13559
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
14304
|
-
expression.shouldBeIncluded(context))
|
|
13560
|
+
expression.shouldBeIncluded(context))
|
|
14305
13561
|
expression.include(context, includeChildrenRecursively);
|
|
14306
|
-
}
|
|
14307
13562
|
}
|
|
14308
13563
|
}
|
|
14309
|
-
includePath(path, context) {
|
|
14310
|
-
this.included = true;
|
|
14311
|
-
this.expressions[this.expressions.length - 1].includePath(path, context);
|
|
14312
|
-
}
|
|
14313
13564
|
removeAnnotations(code) {
|
|
14314
13565
|
this.expressions[0].removeAnnotations(code);
|
|
14315
13566
|
}
|
|
@@ -14344,8 +13595,6 @@ class SequenceExpression extends NodeBase {
|
|
|
14344
13595
|
}
|
|
14345
13596
|
}
|
|
14346
13597
|
}
|
|
14347
|
-
SequenceExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14348
|
-
SequenceExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14349
13598
|
|
|
14350
13599
|
class Super extends NodeBase {
|
|
14351
13600
|
bind() {
|
|
@@ -14357,15 +13606,11 @@ class Super extends NodeBase {
|
|
|
14357
13606
|
deoptimizePath(path) {
|
|
14358
13607
|
this.variable.deoptimizePath(path);
|
|
14359
13608
|
}
|
|
14360
|
-
include(
|
|
14361
|
-
if (!this.included)
|
|
14362
|
-
this.
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
this.included = true;
|
|
14366
|
-
if (!this.deoptimized)
|
|
14367
|
-
this.applyDeoptimizations();
|
|
14368
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13609
|
+
include() {
|
|
13610
|
+
if (!this.included) {
|
|
13611
|
+
this.included = true;
|
|
13612
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
13613
|
+
}
|
|
14369
13614
|
}
|
|
14370
13615
|
}
|
|
14371
13616
|
|
|
@@ -14406,8 +13651,6 @@ class SwitchCase extends NodeBase {
|
|
|
14406
13651
|
}
|
|
14407
13652
|
}
|
|
14408
13653
|
SwitchCase.prototype.needsBoundaries = true;
|
|
14409
|
-
SwitchCase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14410
|
-
SwitchCase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14411
13654
|
|
|
14412
13655
|
class SwitchStatement extends NodeBase {
|
|
14413
13656
|
createScope(parentScope) {
|
|
@@ -14490,8 +13733,6 @@ class SwitchStatement extends NodeBase {
|
|
|
14490
13733
|
}
|
|
14491
13734
|
}
|
|
14492
13735
|
}
|
|
14493
|
-
SwitchStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14494
|
-
SwitchStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14495
13736
|
|
|
14496
13737
|
class TaggedTemplateExpression extends CallExpressionBase {
|
|
14497
13738
|
bind() {
|
|
@@ -14515,8 +13756,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14515
13756
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
14516
13757
|
}
|
|
14517
13758
|
include(context, includeChildrenRecursively) {
|
|
14518
|
-
if (!this.
|
|
14519
|
-
this.
|
|
13759
|
+
if (!this.deoptimized)
|
|
13760
|
+
this.applyDeoptimizations();
|
|
14520
13761
|
if (includeChildrenRecursively) {
|
|
14521
13762
|
super.include(context, includeChildrenRecursively);
|
|
14522
13763
|
}
|
|
@@ -14525,7 +13766,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14525
13766
|
this.tag.include(context, includeChildrenRecursively);
|
|
14526
13767
|
this.quasi.include(context, includeChildrenRecursively);
|
|
14527
13768
|
}
|
|
14528
|
-
this.tag.includeCallArguments(context, this.
|
|
13769
|
+
this.tag.includeCallArguments(context, this.args);
|
|
14529
13770
|
const [returnExpression] = this.getReturnExpression();
|
|
14530
13771
|
if (!returnExpression.included) {
|
|
14531
13772
|
returnExpression.include(context, false);
|
|
@@ -14560,7 +13801,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14560
13801
|
return this.returnExpression;
|
|
14561
13802
|
}
|
|
14562
13803
|
}
|
|
14563
|
-
TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14564
13804
|
|
|
14565
13805
|
class TemplateElement extends NodeBase {
|
|
14566
13806
|
get tail() {
|
|
@@ -14574,13 +13814,15 @@ class TemplateElement extends NodeBase {
|
|
|
14574
13814
|
hasEffects() {
|
|
14575
13815
|
return false;
|
|
14576
13816
|
}
|
|
13817
|
+
include() {
|
|
13818
|
+
this.included = true;
|
|
13819
|
+
}
|
|
14577
13820
|
parseNode(esTreeNode) {
|
|
14578
13821
|
this.value = esTreeNode.value;
|
|
14579
13822
|
return super.parseNode(esTreeNode);
|
|
14580
13823
|
}
|
|
14581
13824
|
render() { }
|
|
14582
13825
|
}
|
|
14583
|
-
TemplateElement.prototype.includeNode = onlyIncludeSelf;
|
|
14584
13826
|
|
|
14585
13827
|
class TemplateLiteral extends NodeBase {
|
|
14586
13828
|
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
@@ -14605,14 +13847,6 @@ class TemplateLiteral extends NodeBase {
|
|
|
14605
13847
|
}
|
|
14606
13848
|
return true;
|
|
14607
13849
|
}
|
|
14608
|
-
includeNode(context) {
|
|
14609
|
-
this.included = true;
|
|
14610
|
-
if (!this.deoptimized)
|
|
14611
|
-
this.applyDeoptimizations();
|
|
14612
|
-
for (const node of this.expressions) {
|
|
14613
|
-
node.includePath(UNKNOWN_PATH, context);
|
|
14614
|
-
}
|
|
14615
|
-
}
|
|
14616
13850
|
render(code, options) {
|
|
14617
13851
|
code.indentExclusionRanges.push([this.start, this.end]);
|
|
14618
13852
|
super.render(code, options);
|
|
@@ -14622,13 +13856,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
14622
13856
|
class ModuleScope extends ChildScope {
|
|
14623
13857
|
constructor(parent, context) {
|
|
14624
13858
|
super(parent, context);
|
|
14625
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION,
|
|
13859
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
14626
13860
|
}
|
|
14627
|
-
addDeclaration(identifier, context, init,
|
|
13861
|
+
addDeclaration(identifier, context, init, kind) {
|
|
14628
13862
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
14629
13863
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
14630
13864
|
}
|
|
14631
|
-
return super.addDeclaration(identifier, context, init,
|
|
13865
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
14632
13866
|
}
|
|
14633
13867
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
14634
13868
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -14673,23 +13907,10 @@ class ThisExpression extends NodeBase {
|
|
|
14673
13907
|
}
|
|
14674
13908
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14675
13909
|
}
|
|
14676
|
-
include(
|
|
14677
|
-
if (!this.included)
|
|
14678
|
-
this.includeNode(context);
|
|
14679
|
-
}
|
|
14680
|
-
includeNode(context) {
|
|
14681
|
-
this.included = true;
|
|
14682
|
-
if (!this.deoptimized)
|
|
14683
|
-
this.applyDeoptimizations();
|
|
14684
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
14685
|
-
}
|
|
14686
|
-
includePath(path, context) {
|
|
13910
|
+
include() {
|
|
14687
13911
|
if (!this.included) {
|
|
14688
13912
|
this.included = true;
|
|
14689
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
14690
|
-
}
|
|
14691
|
-
else if (path.length > 0) {
|
|
14692
|
-
this.variable.includePath(path, context);
|
|
13913
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
14693
13914
|
}
|
|
14694
13915
|
}
|
|
14695
13916
|
initialise() {
|
|
@@ -14717,8 +13938,7 @@ class ThrowStatement extends NodeBase {
|
|
|
14717
13938
|
return true;
|
|
14718
13939
|
}
|
|
14719
13940
|
include(context, includeChildrenRecursively) {
|
|
14720
|
-
|
|
14721
|
-
this.includeNode(context);
|
|
13941
|
+
this.included = true;
|
|
14722
13942
|
this.argument.include(context, includeChildrenRecursively);
|
|
14723
13943
|
context.brokenFlow = true;
|
|
14724
13944
|
}
|
|
@@ -14729,7 +13949,6 @@ class ThrowStatement extends NodeBase {
|
|
|
14729
13949
|
}
|
|
14730
13950
|
}
|
|
14731
13951
|
}
|
|
14732
|
-
ThrowStatement.prototype.includeNode = onlyIncludeSelf;
|
|
14733
13952
|
|
|
14734
13953
|
class TryStatement extends NodeBase {
|
|
14735
13954
|
constructor() {
|
|
@@ -14766,8 +13985,6 @@ class TryStatement extends NodeBase {
|
|
|
14766
13985
|
this.finalizer?.include(context, includeChildrenRecursively);
|
|
14767
13986
|
}
|
|
14768
13987
|
}
|
|
14769
|
-
TryStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14770
|
-
TryStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14771
13988
|
|
|
14772
13989
|
const unaryOperators = {
|
|
14773
13990
|
'!': value => !value,
|
|
@@ -14778,13 +13995,21 @@ const unaryOperators = {
|
|
|
14778
13995
|
void: () => undefined,
|
|
14779
13996
|
'~': value => ~value
|
|
14780
13997
|
};
|
|
13998
|
+
const UNASSIGNED = Symbol('Unassigned');
|
|
14781
13999
|
class UnaryExpression extends NodeBase {
|
|
14000
|
+
constructor() {
|
|
14001
|
+
super(...arguments);
|
|
14002
|
+
this.renderedLiteralValue = UNASSIGNED;
|
|
14003
|
+
}
|
|
14782
14004
|
get prefix() {
|
|
14783
14005
|
return isFlagSet(this.flags, 2097152 /* Flag.prefix */);
|
|
14784
14006
|
}
|
|
14785
14007
|
set prefix(value) {
|
|
14786
14008
|
this.flags = setFlag(this.flags, 2097152 /* Flag.prefix */, value);
|
|
14787
14009
|
}
|
|
14010
|
+
deoptimizeCache() {
|
|
14011
|
+
this.renderedLiteralValue = UnknownValue;
|
|
14012
|
+
}
|
|
14788
14013
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
14789
14014
|
if (path.length > 0)
|
|
14790
14015
|
return UnknownValue;
|
|
@@ -14812,8 +14037,55 @@ class UnaryExpression extends NodeBase {
|
|
|
14812
14037
|
this.scope.context.requestTreeshakingPass();
|
|
14813
14038
|
}
|
|
14814
14039
|
}
|
|
14040
|
+
getRenderedLiteralValue(includeChildrenRecursively) {
|
|
14041
|
+
if (this.renderedLiteralValue !== UNASSIGNED)
|
|
14042
|
+
return this.renderedLiteralValue;
|
|
14043
|
+
return (this.renderedLiteralValue = includeChildrenRecursively
|
|
14044
|
+
? UnknownValue
|
|
14045
|
+
: getSimplifiedLiterals(this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
14046
|
+
}
|
|
14047
|
+
include(context, includeChildrenRecursively, _options) {
|
|
14048
|
+
if (!this.deoptimized)
|
|
14049
|
+
this.applyDeoptimizations();
|
|
14050
|
+
this.included = true;
|
|
14051
|
+
if (typeof this.getRenderedLiteralValue(includeChildrenRecursively) === 'symbol' ||
|
|
14052
|
+
this.argument.shouldBeIncluded(context)) {
|
|
14053
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
14054
|
+
this.renderedLiteralValue = UnknownValue;
|
|
14055
|
+
}
|
|
14056
|
+
}
|
|
14057
|
+
render(code, options) {
|
|
14058
|
+
if (typeof this.renderedLiteralValue === 'symbol') {
|
|
14059
|
+
super.render(code, options);
|
|
14060
|
+
}
|
|
14061
|
+
else {
|
|
14062
|
+
code.overwrite(this.start, this.end, this.renderedLiteralValue);
|
|
14063
|
+
}
|
|
14064
|
+
}
|
|
14065
|
+
}
|
|
14066
|
+
function getSimplifiedLiterals(value) {
|
|
14067
|
+
if (value === undefined || typeof value === 'boolean') {
|
|
14068
|
+
return String(value);
|
|
14069
|
+
}
|
|
14070
|
+
if (typeof value === 'string') {
|
|
14071
|
+
return JSON.stringify(value);
|
|
14072
|
+
}
|
|
14073
|
+
if (typeof value === 'number') {
|
|
14074
|
+
return getSimplifiedNumber(value);
|
|
14075
|
+
}
|
|
14076
|
+
return UnknownValue;
|
|
14077
|
+
}
|
|
14078
|
+
function getSimplifiedNumber(value) {
|
|
14079
|
+
if (Object.is(-0, value)) {
|
|
14080
|
+
return '-0';
|
|
14081
|
+
}
|
|
14082
|
+
const exp = value.toExponential();
|
|
14083
|
+
const [base, exponent] = exp.split('e');
|
|
14084
|
+
const floatLength = base.split('.')[1]?.length || 0;
|
|
14085
|
+
const finalizedExp = `${base.replace('.', '')}e${parseInt(exponent) - floatLength}`;
|
|
14086
|
+
const stringifiedValue = String(value).replace('+', '');
|
|
14087
|
+
return finalizedExp.length < stringifiedValue.length ? finalizedExp : stringifiedValue;
|
|
14815
14088
|
}
|
|
14816
|
-
UnaryExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14817
14089
|
|
|
14818
14090
|
class UpdateExpression extends NodeBase {
|
|
14819
14091
|
hasEffects(context) {
|
|
@@ -14825,8 +14097,9 @@ class UpdateExpression extends NodeBase {
|
|
|
14825
14097
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
14826
14098
|
}
|
|
14827
14099
|
include(context, includeChildrenRecursively) {
|
|
14828
|
-
if (!this.
|
|
14829
|
-
this.
|
|
14100
|
+
if (!this.deoptimized)
|
|
14101
|
+
this.applyDeoptimizations();
|
|
14102
|
+
this.included = true;
|
|
14830
14103
|
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
14831
14104
|
}
|
|
14832
14105
|
initialise() {
|
|
@@ -14865,7 +14138,6 @@ class UpdateExpression extends NodeBase {
|
|
|
14865
14138
|
this.scope.context.requestTreeshakingPass();
|
|
14866
14139
|
}
|
|
14867
14140
|
}
|
|
14868
|
-
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14869
14141
|
|
|
14870
14142
|
function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
|
|
14871
14143
|
for (const declarator of declarations) {
|
|
@@ -14896,9 +14168,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14896
14168
|
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
14897
14169
|
this.included = true;
|
|
14898
14170
|
for (const declarator of this.declarations) {
|
|
14899
|
-
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14171
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14900
14172
|
declarator.include(context, includeChildrenRecursively);
|
|
14901
|
-
}
|
|
14902
14173
|
const { id, init } = declarator;
|
|
14903
14174
|
if (asSingleStatement) {
|
|
14904
14175
|
id.include(context, includeChildrenRecursively);
|
|
@@ -14936,6 +14207,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
14936
14207
|
this.renderReplacedDeclarations(code, options);
|
|
14937
14208
|
}
|
|
14938
14209
|
}
|
|
14210
|
+
applyDeoptimizations() { }
|
|
14939
14211
|
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
14940
14212
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
14941
14213
|
code.remove(this.end - 1, this.end);
|
|
@@ -14978,7 +14250,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14978
14250
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
14979
14251
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
14980
14252
|
if (!node.included) {
|
|
14981
|
-
|
|
14253
|
+
code.remove(start, end);
|
|
14254
|
+
node.removeAnnotations(code);
|
|
14982
14255
|
continue;
|
|
14983
14256
|
}
|
|
14984
14257
|
node.render(code, options);
|
|
@@ -15048,8 +14321,6 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
15048
14321
|
}
|
|
15049
14322
|
return singleSystemExport;
|
|
15050
14323
|
}
|
|
15051
|
-
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15052
|
-
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15053
14324
|
|
|
15054
14325
|
class WhileStatement extends NodeBase {
|
|
15055
14326
|
hasEffects(context) {
|
|
@@ -15063,25 +14334,13 @@ class WhileStatement extends NodeBase {
|
|
|
15063
14334
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
15064
14335
|
}
|
|
15065
14336
|
}
|
|
15066
|
-
WhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15067
|
-
WhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15068
14337
|
|
|
15069
14338
|
class YieldExpression extends NodeBase {
|
|
15070
|
-
applyDeoptimizations() {
|
|
15071
|
-
this.deoptimized = true;
|
|
15072
|
-
this.argument?.deoptimizePath(UNKNOWN_PATH);
|
|
15073
|
-
}
|
|
15074
14339
|
hasEffects(context) {
|
|
15075
14340
|
if (!this.deoptimized)
|
|
15076
14341
|
this.applyDeoptimizations();
|
|
15077
14342
|
return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
|
|
15078
14343
|
}
|
|
15079
|
-
includeNode(context) {
|
|
15080
|
-
this.included = true;
|
|
15081
|
-
if (!this.deoptimized)
|
|
15082
|
-
this.applyDeoptimizations();
|
|
15083
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
15084
|
-
}
|
|
15085
14344
|
render(code, options) {
|
|
15086
14345
|
if (this.argument) {
|
|
15087
14346
|
this.argument.render(code, options, { preventASI: true });
|
|
@@ -15315,7 +14574,7 @@ const bufferParsers = [
|
|
|
15315
14574
|
const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
|
|
15316
14575
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
15317
14576
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
15318
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14577
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15319
14578
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
15320
14579
|
},
|
|
15321
14580
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -15361,7 +14620,7 @@ const bufferParsers = [
|
|
|
15361
14620
|
const parameterPosition = buffer[position];
|
|
15362
14621
|
const parameter = (node.param =
|
|
15363
14622
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
15364
|
-
parameter?.declare('parameter',
|
|
14623
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
15365
14624
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
15366
14625
|
},
|
|
15367
14626
|
function chainExpression(node, position, buffer) {
|
|
@@ -15499,7 +14758,7 @@ const bufferParsers = [
|
|
|
15499
14758
|
node.id =
|
|
15500
14759
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
15501
14760
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15502
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14761
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15503
14762
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15504
14763
|
},
|
|
15505
14764
|
function functionExpression(node, position, buffer) {
|
|
@@ -15512,7 +14771,7 @@ const bufferParsers = [
|
|
|
15512
14771
|
const idPosition = buffer[position + 2];
|
|
15513
14772
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
15514
14773
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15515
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14774
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15516
14775
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15517
14776
|
},
|
|
15518
14777
|
function identifier(node, position, buffer) {
|
|
@@ -15976,8 +15235,8 @@ class ExportShimVariable extends Variable {
|
|
|
15976
15235
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
15977
15236
|
this.module = module;
|
|
15978
15237
|
}
|
|
15979
|
-
|
|
15980
|
-
super.
|
|
15238
|
+
include() {
|
|
15239
|
+
super.include();
|
|
15981
15240
|
this.module.needsExportShim = true;
|
|
15982
15241
|
}
|
|
15983
15242
|
}
|
|
@@ -16675,15 +15934,16 @@ class Module {
|
|
|
16675
15934
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
16676
15935
|
this.graph.needsTreeshakingPass = true;
|
|
16677
15936
|
}
|
|
16678
|
-
const inclusionContext = createInclusionContext();
|
|
16679
15937
|
for (const exportName of this.exports.keys()) {
|
|
16680
15938
|
if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
|
|
16681
15939
|
const variable = this.getVariableForExportName(exportName)[0];
|
|
16682
15940
|
if (!variable) {
|
|
16683
15941
|
return error(logMissingEntryExport(exportName, this.id));
|
|
16684
15942
|
}
|
|
16685
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
16686
15943
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15944
|
+
if (!variable.included) {
|
|
15945
|
+
this.includeVariable(variable);
|
|
15946
|
+
}
|
|
16687
15947
|
}
|
|
16688
15948
|
}
|
|
16689
15949
|
for (const name of this.getReexports()) {
|
|
@@ -16691,7 +15951,7 @@ class Module {
|
|
|
16691
15951
|
if (variable) {
|
|
16692
15952
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16693
15953
|
if (!variable.included) {
|
|
16694
|
-
this.includeVariable(variable
|
|
15954
|
+
this.includeVariable(variable);
|
|
16695
15955
|
}
|
|
16696
15956
|
if (variable instanceof ExternalVariable) {
|
|
16697
15957
|
variable.module.reexported = true;
|
|
@@ -16712,12 +15972,13 @@ class Module {
|
|
|
16712
15972
|
this.graph.needsTreeshakingPass = true;
|
|
16713
15973
|
}
|
|
16714
15974
|
let includeNamespaceMembers = false;
|
|
16715
|
-
const inclusionContext = createInclusionContext();
|
|
16716
15975
|
for (const name of names) {
|
|
16717
15976
|
const variable = this.getVariableForExportName(name)[0];
|
|
16718
15977
|
if (variable) {
|
|
16719
15978
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16720
|
-
|
|
15979
|
+
if (!variable.included) {
|
|
15980
|
+
this.includeVariable(variable);
|
|
15981
|
+
}
|
|
16721
15982
|
}
|
|
16722
15983
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
16723
15984
|
includeNamespaceMembers = true;
|
|
@@ -16818,7 +16079,6 @@ class Module {
|
|
|
16818
16079
|
manualPureFunctions: this.graph.pureFunctions,
|
|
16819
16080
|
module: this,
|
|
16820
16081
|
moduleContext: this.context,
|
|
16821
|
-
newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
|
|
16822
16082
|
options: this.options,
|
|
16823
16083
|
requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
|
|
16824
16084
|
traceExport: (name) => this.getVariableForExportName(name)[0],
|
|
@@ -17159,13 +16419,13 @@ class Module {
|
|
|
17159
16419
|
for (const module of [this, ...this.exportAllModules]) {
|
|
17160
16420
|
if (module instanceof ExternalModule) {
|
|
17161
16421
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
17162
|
-
externalVariable.
|
|
16422
|
+
externalVariable.include();
|
|
17163
16423
|
this.includedImports.add(externalVariable);
|
|
17164
16424
|
externalNamespaces.add(externalVariable);
|
|
17165
16425
|
}
|
|
17166
16426
|
else if (module.info.syntheticNamedExports) {
|
|
17167
16427
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
17168
|
-
syntheticNamespace.
|
|
16428
|
+
syntheticNamespace.include();
|
|
17169
16429
|
this.includedImports.add(syntheticNamespace);
|
|
17170
16430
|
syntheticNamespaces.add(syntheticNamespace);
|
|
17171
16431
|
}
|
|
@@ -17175,9 +16435,7 @@ class Module {
|
|
|
17175
16435
|
includeDynamicImport(node) {
|
|
17176
16436
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
17177
16437
|
if (resolution instanceof Module) {
|
|
17178
|
-
|
|
17179
|
-
resolution.includedDynamicImporters.push(this);
|
|
17180
|
-
}
|
|
16438
|
+
resolution.includedDynamicImporters.push(this);
|
|
17181
16439
|
const importedNames = this.options.treeshake
|
|
17182
16440
|
? node.getDeterministicImportedNames()
|
|
17183
16441
|
: undefined;
|
|
@@ -17189,15 +16447,15 @@ class Module {
|
|
|
17189
16447
|
}
|
|
17190
16448
|
}
|
|
17191
16449
|
}
|
|
17192
|
-
includeVariable(variable
|
|
17193
|
-
const
|
|
17194
|
-
variable.
|
|
17195
|
-
if (included) {
|
|
16450
|
+
includeVariable(variable) {
|
|
16451
|
+
const variableModule = variable.module;
|
|
16452
|
+
if (variable.included) {
|
|
17196
16453
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
17197
16454
|
getAndExtendSideEffectModules(variable, this);
|
|
17198
16455
|
}
|
|
17199
16456
|
}
|
|
17200
16457
|
else {
|
|
16458
|
+
variable.include();
|
|
17201
16459
|
this.graph.needsTreeshakingPass = true;
|
|
17202
16460
|
if (variableModule instanceof Module) {
|
|
17203
16461
|
if (!variableModule.isExecuted) {
|
|
@@ -17214,8 +16472,8 @@ class Module {
|
|
|
17214
16472
|
}
|
|
17215
16473
|
}
|
|
17216
16474
|
}
|
|
17217
|
-
includeVariableInModule(variable
|
|
17218
|
-
this.includeVariable(variable
|
|
16475
|
+
includeVariableInModule(variable) {
|
|
16476
|
+
this.includeVariable(variable);
|
|
17219
16477
|
const variableModule = variable.module;
|
|
17220
16478
|
if (variableModule && variableModule !== this) {
|
|
17221
16479
|
this.includedImports.add(variable);
|
|
@@ -18261,7 +17519,9 @@ class Chunk {
|
|
|
18261
17519
|
}
|
|
18262
17520
|
return [
|
|
18263
17521
|
resolution || '',
|
|
18264
|
-
(
|
|
17522
|
+
(['es', 'cjs'].includes(this.outputOptions.format) &&
|
|
17523
|
+
this.outputOptions.externalImportAttributes) ||
|
|
17524
|
+
null
|
|
18265
17525
|
];
|
|
18266
17526
|
}
|
|
18267
17527
|
getFallbackChunkName() {
|
|
@@ -20114,18 +19374,18 @@ function flru (max) {
|
|
|
20114
19374
|
return {
|
|
20115
19375
|
clear: reset,
|
|
20116
19376
|
has: function (key) {
|
|
20117
|
-
return curr[key] !==
|
|
19377
|
+
return curr[key] !== undefined || prev[key] !== undefined;
|
|
20118
19378
|
},
|
|
20119
19379
|
get: function (key) {
|
|
20120
19380
|
var val = curr[key];
|
|
20121
|
-
if (val !==
|
|
20122
|
-
if ((val=prev[key]) !==
|
|
19381
|
+
if (val !== undefined) return val;
|
|
19382
|
+
if ((val=prev[key]) !== undefined) {
|
|
20123
19383
|
keep(key, val);
|
|
20124
19384
|
return val;
|
|
20125
19385
|
}
|
|
20126
19386
|
},
|
|
20127
19387
|
set: function (key, value) {
|
|
20128
|
-
if (curr[key] !==
|
|
19388
|
+
if (curr[key] !== undefined) {
|
|
20129
19389
|
curr[key] = value;
|
|
20130
19390
|
} else {
|
|
20131
19391
|
keep(key, value);
|
|
@@ -21812,11 +21072,10 @@ class Graph {
|
|
|
21812
21072
|
this.options = options;
|
|
21813
21073
|
this.astLru = flru(5);
|
|
21814
21074
|
this.cachedModules = new Map();
|
|
21815
|
-
this.deoptimizationTracker = new
|
|
21075
|
+
this.deoptimizationTracker = new PathTracker();
|
|
21816
21076
|
this.entryModules = [];
|
|
21817
21077
|
this.modulesById = new Map();
|
|
21818
21078
|
this.needsTreeshakingPass = false;
|
|
21819
|
-
this.newlyIncludedVariableInits = new Set();
|
|
21820
21079
|
this.phase = BuildPhase.LOAD_AND_PARSE;
|
|
21821
21080
|
this.scope = new GlobalScope();
|
|
21822
21081
|
this.watchFiles = Object.create(null);
|
|
@@ -21910,7 +21169,6 @@ class Graph {
|
|
|
21910
21169
|
}
|
|
21911
21170
|
if (this.options.treeshake) {
|
|
21912
21171
|
let treeshakingPass = 1;
|
|
21913
|
-
this.newlyIncludedVariableInits.clear();
|
|
21914
21172
|
do {
|
|
21915
21173
|
timeStart(`treeshaking pass ${treeshakingPass}`, 3);
|
|
21916
21174
|
this.needsTreeshakingPass = false;
|
|
@@ -21935,10 +21193,6 @@ class Graph {
|
|
|
21935
21193
|
}
|
|
21936
21194
|
}
|
|
21937
21195
|
}
|
|
21938
|
-
for (const entity of this.newlyIncludedVariableInits) {
|
|
21939
|
-
this.newlyIncludedVariableInits.delete(entity);
|
|
21940
|
-
entity.include(createInclusionContext(), false);
|
|
21941
|
-
}
|
|
21942
21196
|
timeEnd(`treeshaking pass ${treeshakingPass++}`, 3);
|
|
21943
21197
|
} while (this.needsTreeshakingPass);
|
|
21944
21198
|
}
|
|
@@ -22709,118 +21963,97 @@ function defineConfig(options) {
|
|
|
22709
21963
|
return options;
|
|
22710
21964
|
}
|
|
22711
21965
|
|
|
22712
|
-
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22720
|
-
|
|
22721
|
-
|
|
22722
|
-
|
|
22723
|
-
|
|
22724
|
-
|
|
22725
|
-
|
|
22726
|
-
|
|
22727
|
-
|
|
22728
|
-
|
|
22729
|
-
|
|
22730
|
-
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
22739
|
-
|
|
22740
|
-
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
|
|
22753
|
-
|
|
22754
|
-
|
|
22755
|
-
|
|
22756
|
-
|
|
22757
|
-
|
|
22758
|
-
|
|
22759
|
-
|
|
22760
|
-
|
|
22761
|
-
|
|
22762
|
-
|
|
22763
|
-
|
|
22764
|
-
|
|
22765
|
-
|
|
22766
|
-
|
|
22767
|
-
|
|
22768
|
-
|
|
22769
|
-
|
|
22770
|
-
|
|
22771
|
-
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
blackBright: init(90, 39),
|
|
22792
|
-
redBright: init(91, 39),
|
|
22793
|
-
greenBright: init(92, 39),
|
|
22794
|
-
yellowBright: init(93, 39),
|
|
22795
|
-
blueBright: init(94, 39),
|
|
22796
|
-
magentaBright: init(95, 39),
|
|
22797
|
-
cyanBright: init(96, 39),
|
|
22798
|
-
whiteBright: init(97, 39),
|
|
22799
|
-
bgBlackBright: init(100, 49),
|
|
22800
|
-
bgRedBright: init(101, 49),
|
|
22801
|
-
bgGreenBright: init(102, 49),
|
|
22802
|
-
bgYellowBright: init(103, 49),
|
|
22803
|
-
bgBlueBright: init(104, 49),
|
|
22804
|
-
bgMagentaBright: init(105, 49),
|
|
22805
|
-
bgCyanBright: init(106, 49),
|
|
22806
|
-
bgWhiteBright: init(107, 49),
|
|
22807
|
-
};
|
|
21966
|
+
var picocolors = {exports: {}};
|
|
21967
|
+
|
|
21968
|
+
var hasRequiredPicocolors;
|
|
21969
|
+
|
|
21970
|
+
function requirePicocolors () {
|
|
21971
|
+
if (hasRequiredPicocolors) return picocolors.exports;
|
|
21972
|
+
hasRequiredPicocolors = 1;
|
|
21973
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
21974
|
+
let isColorSupported =
|
|
21975
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
21976
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
21977
|
+
|
|
21978
|
+
let formatter = (open, close, replace = open) =>
|
|
21979
|
+
input => {
|
|
21980
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
21981
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
21982
|
+
};
|
|
21983
|
+
|
|
21984
|
+
let replaceClose = (string, close, replace, index) => {
|
|
21985
|
+
let result = "", cursor = 0;
|
|
21986
|
+
do {
|
|
21987
|
+
result += string.substring(cursor, index) + replace;
|
|
21988
|
+
cursor = index + close.length;
|
|
21989
|
+
index = string.indexOf(close, cursor);
|
|
21990
|
+
} while (~index)
|
|
21991
|
+
return result + string.substring(cursor)
|
|
21992
|
+
};
|
|
21993
|
+
|
|
21994
|
+
let createColors = (enabled = isColorSupported) => {
|
|
21995
|
+
let f = enabled ? formatter : () => String;
|
|
21996
|
+
return {
|
|
21997
|
+
isColorSupported: enabled,
|
|
21998
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
21999
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
22000
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
22001
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
22002
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
22003
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
22004
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
22005
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
22006
|
+
|
|
22007
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
22008
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
22009
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
22010
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
22011
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
22012
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
22013
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
22014
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
22015
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
22016
|
+
|
|
22017
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
22018
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
22019
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
22020
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
22021
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
22022
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
22023
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
22024
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
22025
|
+
|
|
22026
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
22027
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
22028
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
22029
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
22030
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
22031
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
22032
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
22033
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
22034
|
+
|
|
22035
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
22036
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
22037
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
22038
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
22039
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
22040
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
22041
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
22042
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
22043
|
+
}
|
|
22044
|
+
};
|
|
22808
22045
|
|
|
22809
|
-
|
|
22810
|
-
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
(colors, key) => ({ ...colors, [key]: String }),
|
|
22814
|
-
{}
|
|
22815
|
-
);
|
|
22046
|
+
picocolors.exports = createColors();
|
|
22047
|
+
picocolors.exports.createColors = createColors;
|
|
22048
|
+
return picocolors.exports;
|
|
22049
|
+
}
|
|
22816
22050
|
|
|
22817
|
-
|
|
22051
|
+
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
22052
|
+
const pc = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
22818
22053
|
|
|
22819
22054
|
// @see https://no-color.org
|
|
22820
22055
|
// @see https://www.npmjs.com/package/chalk
|
|
22821
|
-
const { bold, cyan, dim, red} = createColors(
|
|
22822
|
-
useColor: env$1.FORCE_COLOR !== '0' && !env$1.NO_COLOR
|
|
22823
|
-
});
|
|
22056
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = pc.createColors(env.FORCE_COLOR !== '0' && !env.NO_COLOR);
|
|
22824
22057
|
|
|
22825
22058
|
// log to stderr to keep `rollup main.js > bundle.js` from breaking
|
|
22826
22059
|
const stderr = (...parameters) => process$1.stderr.write(`${parameters.join('')}\n`);
|