@rollup/wasm-node 4.30.0 → 4.31.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +1510 -686
- package/dist/es/shared/parseAst.js +3 -3
- package/dist/es/shared/watch.js +6 -6
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +6 -6
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +1506 -682
- package/dist/shared/watch-cli.js +4 -20
- package/dist/shared/watch.js +3 -3
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +1 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.31.0-0
|
|
4
|
+
Tue, 14 Jan 2025 05:57:11 GMT - commit 8c80d5f657f0777d14bd75d446fee3fa4b7639fc
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
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,
|
|
10
|
+
import { EMPTY_OBJECT, 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, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logInvalidFormatForTopLevelAwait, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, logCannotAssignModuleToChunk, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, warnDeprecation, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_TREESHAKE, URL_JSX, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
|
|
12
|
-
import { posix,
|
|
13
|
-
import { parseAsync, xxhashBase64Url, xxhashBase36
|
|
12
|
+
import { posix, isAbsolute, resolve, win32 } from 'path';
|
|
13
|
+
import { parseAsync, xxhashBase16, xxhashBase64Url, xxhashBase36 } from '../../native.js';
|
|
14
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
17
|
|
|
18
|
-
var version = "4.
|
|
18
|
+
var version = "4.31.0-0";
|
|
19
19
|
|
|
20
20
|
const comma = ','.charCodeAt(0);
|
|
21
21
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -1964,71 +1964,6 @@ function renderSystemExportSequenceBeforeExpression(exportedVariable, expression
|
|
|
1964
1964
|
}
|
|
1965
1965
|
}
|
|
1966
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
|
-
|
|
2032
1967
|
function getOrCreate(map, key, init) {
|
|
2033
1968
|
const existing = map.get(key);
|
|
2034
1969
|
if (existing !== undefined) {
|
|
@@ -2059,7 +1994,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
2059
1994
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
2060
1995
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
2061
1996
|
const EntitiesKey = Symbol('Entities');
|
|
2062
|
-
class
|
|
1997
|
+
class EntityPathTracker {
|
|
2063
1998
|
constructor() {
|
|
2064
1999
|
this.entityPaths = Object.create(null, {
|
|
2065
2000
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -2084,14 +2019,14 @@ class PathTracker {
|
|
|
2084
2019
|
getEntities(path) {
|
|
2085
2020
|
let currentPaths = this.entityPaths;
|
|
2086
2021
|
for (const pathSegment of path) {
|
|
2087
|
-
currentPaths = currentPaths[pathSegment]
|
|
2088
|
-
|
|
2089
|
-
|
|
2022
|
+
currentPaths = currentPaths[pathSegment] ||= Object.create(null, {
|
|
2023
|
+
[EntitiesKey]: { value: new Set() }
|
|
2024
|
+
});
|
|
2090
2025
|
}
|
|
2091
2026
|
return currentPaths[EntitiesKey];
|
|
2092
2027
|
}
|
|
2093
2028
|
}
|
|
2094
|
-
const SHARED_RECURSION_TRACKER = new
|
|
2029
|
+
const SHARED_RECURSION_TRACKER = new EntityPathTracker();
|
|
2095
2030
|
class DiscriminatedPathTracker {
|
|
2096
2031
|
constructor() {
|
|
2097
2032
|
this.entityPaths = Object.create(null, {
|
|
@@ -2101,9 +2036,9 @@ class DiscriminatedPathTracker {
|
|
|
2101
2036
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
2102
2037
|
let currentPaths = this.entityPaths;
|
|
2103
2038
|
for (const pathSegment of path) {
|
|
2104
|
-
currentPaths = currentPaths[pathSegment]
|
|
2105
|
-
|
|
2106
|
-
|
|
2039
|
+
currentPaths = currentPaths[pathSegment] ||= Object.create(null, {
|
|
2040
|
+
[EntitiesKey]: { value: new Map() }
|
|
2041
|
+
});
|
|
2107
2042
|
}
|
|
2108
2043
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
2109
2044
|
if (trackedEntities.has(entity))
|
|
@@ -2112,6 +2047,137 @@ class DiscriminatedPathTracker {
|
|
|
2112
2047
|
return false;
|
|
2113
2048
|
}
|
|
2114
2049
|
}
|
|
2050
|
+
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: EMPTY_OBJECT });
|
|
2051
|
+
class IncludedPathTracker {
|
|
2052
|
+
constructor() {
|
|
2053
|
+
this.includedPaths = null;
|
|
2054
|
+
}
|
|
2055
|
+
includePathAndGetIfIncluded(path) {
|
|
2056
|
+
let included = true;
|
|
2057
|
+
let parent = this;
|
|
2058
|
+
let parentSegment = 'includedPaths';
|
|
2059
|
+
let currentPaths = (this.includedPaths ||=
|
|
2060
|
+
((included = false), Object.create(null)));
|
|
2061
|
+
for (const pathSegment of path) {
|
|
2062
|
+
// This means from here, all paths are included
|
|
2063
|
+
if (currentPaths[UnknownKey]) {
|
|
2064
|
+
return true;
|
|
2065
|
+
}
|
|
2066
|
+
// Including UnknownKey automatically includes all nested paths.
|
|
2067
|
+
// From above, we know that UnknownKey is not included yet.
|
|
2068
|
+
if (typeof pathSegment === 'symbol') {
|
|
2069
|
+
// Hopefully, this saves some memory over just setting
|
|
2070
|
+
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
2071
|
+
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
2072
|
+
return false;
|
|
2073
|
+
}
|
|
2074
|
+
parent = currentPaths;
|
|
2075
|
+
parentSegment = pathSegment;
|
|
2076
|
+
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
2077
|
+
}
|
|
2078
|
+
return included;
|
|
2079
|
+
}
|
|
2080
|
+
includeAllPaths(entity, context, basePath) {
|
|
2081
|
+
const { includedPaths } = this;
|
|
2082
|
+
if (includedPaths) {
|
|
2083
|
+
includeAllPaths(entity, context, basePath, includedPaths);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
2088
|
+
if (currentPaths[UnknownKey]) {
|
|
2089
|
+
return entity.includePath([...basePath, UnknownKey], context);
|
|
2090
|
+
}
|
|
2091
|
+
const keys = Object.keys(currentPaths);
|
|
2092
|
+
if (keys.length === 0) {
|
|
2093
|
+
return entity.includePath(basePath, context);
|
|
2094
|
+
}
|
|
2095
|
+
for (const key of keys) {
|
|
2096
|
+
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
/** @import { Node } from 'estree' */
|
|
2101
|
+
|
|
2102
|
+
/**
|
|
2103
|
+
* @param {Node} node
|
|
2104
|
+
* @param {Node} parent
|
|
2105
|
+
* @returns {boolean}
|
|
2106
|
+
*/
|
|
2107
|
+
function is_reference(node, parent) {
|
|
2108
|
+
if (node.type === 'MemberExpression') {
|
|
2109
|
+
return !node.computed && is_reference(node.object, node);
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
if (node.type !== 'Identifier') return false;
|
|
2113
|
+
|
|
2114
|
+
switch (parent?.type) {
|
|
2115
|
+
// disregard `bar` in `foo.bar`
|
|
2116
|
+
case 'MemberExpression':
|
|
2117
|
+
return parent.computed || node === parent.object;
|
|
2118
|
+
|
|
2119
|
+
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
2120
|
+
case 'MethodDefinition':
|
|
2121
|
+
return parent.computed;
|
|
2122
|
+
|
|
2123
|
+
// disregard the `meta` in `import.meta`
|
|
2124
|
+
case 'MetaProperty':
|
|
2125
|
+
return parent.meta === node;
|
|
2126
|
+
|
|
2127
|
+
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
2128
|
+
case 'PropertyDefinition':
|
|
2129
|
+
return parent.computed || node === parent.value;
|
|
2130
|
+
|
|
2131
|
+
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
2132
|
+
case 'Property':
|
|
2133
|
+
return parent.computed || node === parent.value;
|
|
2134
|
+
|
|
2135
|
+
// disregard the `bar` in `export { foo as bar }` or
|
|
2136
|
+
// the foo in `import { foo as bar }`
|
|
2137
|
+
case 'ExportSpecifier':
|
|
2138
|
+
case 'ImportSpecifier':
|
|
2139
|
+
return node === parent.local;
|
|
2140
|
+
|
|
2141
|
+
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
2142
|
+
case 'LabeledStatement':
|
|
2143
|
+
case 'BreakStatement':
|
|
2144
|
+
case 'ContinueStatement':
|
|
2145
|
+
return false;
|
|
2146
|
+
|
|
2147
|
+
default:
|
|
2148
|
+
return true;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
function createInclusionContext() {
|
|
2153
|
+
return {
|
|
2154
|
+
brokenFlow: false,
|
|
2155
|
+
hasBreak: false,
|
|
2156
|
+
hasContinue: false,
|
|
2157
|
+
includedCallArguments: new Set(),
|
|
2158
|
+
includedLabels: new Set()
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
function createHasEffectsContext() {
|
|
2162
|
+
return {
|
|
2163
|
+
accessed: new EntityPathTracker(),
|
|
2164
|
+
assigned: new EntityPathTracker(),
|
|
2165
|
+
brokenFlow: false,
|
|
2166
|
+
called: new DiscriminatedPathTracker(),
|
|
2167
|
+
hasBreak: false,
|
|
2168
|
+
hasContinue: false,
|
|
2169
|
+
ignore: {
|
|
2170
|
+
breaks: false,
|
|
2171
|
+
continues: false,
|
|
2172
|
+
labels: new Set(),
|
|
2173
|
+
returnYield: false,
|
|
2174
|
+
this: false
|
|
2175
|
+
},
|
|
2176
|
+
includedLabels: new Set(),
|
|
2177
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
2178
|
+
replacedVariableInits: new Map()
|
|
2179
|
+
};
|
|
2180
|
+
}
|
|
2115
2181
|
|
|
2116
2182
|
function isFlagSet(flags, flag) {
|
|
2117
2183
|
return (flags & flag) !== 0;
|
|
@@ -2151,12 +2217,25 @@ class ExpressionEntity {
|
|
|
2151
2217
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2152
2218
|
return true;
|
|
2153
2219
|
}
|
|
2154
|
-
include(
|
|
2220
|
+
include(context, _includeChildrenRecursively, _options) {
|
|
2221
|
+
if (!this.included)
|
|
2222
|
+
this.includeNode(context);
|
|
2223
|
+
}
|
|
2224
|
+
includeNode(_context) {
|
|
2155
2225
|
this.included = true;
|
|
2156
2226
|
}
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2227
|
+
includePath(_path, context) {
|
|
2228
|
+
if (!this.included)
|
|
2229
|
+
this.includeNode(context);
|
|
2230
|
+
}
|
|
2231
|
+
/* We are both including and including an unknown path here as the former
|
|
2232
|
+
* ensures that nested nodes are included while the latter ensures that all
|
|
2233
|
+
* paths of the expression are included.
|
|
2234
|
+
* */
|
|
2235
|
+
includeCallArguments(context, interaction) {
|
|
2236
|
+
for (const argument of interaction.args) {
|
|
2237
|
+
argument?.includePath(UNKNOWN_PATH, context);
|
|
2238
|
+
argument?.include(context, false);
|
|
2160
2239
|
}
|
|
2161
2240
|
}
|
|
2162
2241
|
shouldBeIncluded(_context) {
|
|
@@ -2195,6 +2274,19 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
2195
2274
|
withNew: false
|
|
2196
2275
|
};
|
|
2197
2276
|
|
|
2277
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
2278
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
2279
|
+
const pureFunctions = Object.create(null);
|
|
2280
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2281
|
+
let currentFunctions = pureFunctions;
|
|
2282
|
+
for (const pathSegment of functionName.split('.')) {
|
|
2283
|
+
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2284
|
+
}
|
|
2285
|
+
currentFunctions[PureFunctionKey] = true;
|
|
2286
|
+
}
|
|
2287
|
+
return pureFunctions;
|
|
2288
|
+
};
|
|
2289
|
+
|
|
2198
2290
|
class Variable extends ExpressionEntity {
|
|
2199
2291
|
markReassigned() {
|
|
2200
2292
|
this.isReassigned = true;
|
|
@@ -2271,9 +2363,9 @@ class Variable extends ExpressionEntity {
|
|
|
2271
2363
|
* has not been included previously. Once a variable is included, it should
|
|
2272
2364
|
* take care all its declarations are included.
|
|
2273
2365
|
*/
|
|
2274
|
-
|
|
2366
|
+
includePath(path, context) {
|
|
2275
2367
|
this.included = true;
|
|
2276
|
-
this.renderedLikeHoisted?.
|
|
2368
|
+
this.renderedLikeHoisted?.includePath(path, context);
|
|
2277
2369
|
}
|
|
2278
2370
|
/**
|
|
2279
2371
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -2305,8 +2397,8 @@ class ExternalVariable extends Variable {
|
|
|
2305
2397
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2306
2398
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2307
2399
|
}
|
|
2308
|
-
|
|
2309
|
-
super.
|
|
2400
|
+
includePath(path, context) {
|
|
2401
|
+
super.includePath(path, context);
|
|
2310
2402
|
this.module.used = true;
|
|
2311
2403
|
}
|
|
2312
2404
|
}
|
|
@@ -2607,36 +2699,6 @@ const childNodeKeys = {
|
|
|
2607
2699
|
YieldExpression: ['argument']
|
|
2608
2700
|
};
|
|
2609
2701
|
|
|
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
|
-
|
|
2640
2702
|
const INCLUDE_PARAMETERS = 'variables';
|
|
2641
2703
|
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
2642
2704
|
class NodeBase extends ExpressionEntity {
|
|
@@ -2706,9 +2768,8 @@ class NodeBase extends ExpressionEntity {
|
|
|
2706
2768
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
2707
2769
|
}
|
|
2708
2770
|
include(context, includeChildrenRecursively, _options) {
|
|
2709
|
-
if (!this.
|
|
2710
|
-
this.
|
|
2711
|
-
this.included = true;
|
|
2771
|
+
if (!this.included)
|
|
2772
|
+
this.includeNode(context);
|
|
2712
2773
|
for (const key of childNodeKeys[this.type]) {
|
|
2713
2774
|
const value = this[key];
|
|
2714
2775
|
if (value === null)
|
|
@@ -2723,6 +2784,24 @@ class NodeBase extends ExpressionEntity {
|
|
|
2723
2784
|
}
|
|
2724
2785
|
}
|
|
2725
2786
|
}
|
|
2787
|
+
includeNode(context) {
|
|
2788
|
+
this.included = true;
|
|
2789
|
+
if (!this.deoptimized)
|
|
2790
|
+
this.applyDeoptimizations();
|
|
2791
|
+
for (const key of childNodeKeys[this.type]) {
|
|
2792
|
+
const value = this[key];
|
|
2793
|
+
if (value === null)
|
|
2794
|
+
continue;
|
|
2795
|
+
if (Array.isArray(value)) {
|
|
2796
|
+
for (const child of value) {
|
|
2797
|
+
child?.includePath(UNKNOWN_PATH, context);
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
else {
|
|
2801
|
+
value.includePath(UNKNOWN_PATH, context);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2726
2805
|
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
2727
2806
|
this.include(context, includeChildrenRecursively);
|
|
2728
2807
|
}
|
|
@@ -2826,6 +2905,17 @@ class NodeBase extends ExpressionEntity {
|
|
|
2826
2905
|
function createChildNodeKeysForNode(esTreeNode) {
|
|
2827
2906
|
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
2828
2907
|
}
|
|
2908
|
+
function onlyIncludeSelf() {
|
|
2909
|
+
this.included = true;
|
|
2910
|
+
if (!this.deoptimized)
|
|
2911
|
+
this.applyDeoptimizations();
|
|
2912
|
+
}
|
|
2913
|
+
function onlyIncludeSelfNoDeoptimize() {
|
|
2914
|
+
this.included = true;
|
|
2915
|
+
}
|
|
2916
|
+
function doNotDeoptimize() {
|
|
2917
|
+
this.deoptimized = true;
|
|
2918
|
+
}
|
|
2829
2919
|
|
|
2830
2920
|
function isObjectExpressionNode(node) {
|
|
2831
2921
|
return node instanceof NodeBase && node.type === ObjectExpression$1;
|
|
@@ -2838,8 +2928,8 @@ function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions =
|
|
|
2838
2928
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2839
2929
|
}
|
|
2840
2930
|
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2841
|
-
getLiteralValueAtPath() {
|
|
2842
|
-
return undefined;
|
|
2931
|
+
getLiteralValueAtPath(path) {
|
|
2932
|
+
return path.length > 0 ? UnknownValue : undefined;
|
|
2843
2933
|
}
|
|
2844
2934
|
})();
|
|
2845
2935
|
const returnsUnknown = {
|
|
@@ -3036,31 +3126,6 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
3036
3126
|
return [members[memberName].returns, false];
|
|
3037
3127
|
}
|
|
3038
3128
|
|
|
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
|
-
|
|
3064
3129
|
class Method extends ExpressionEntity {
|
|
3065
3130
|
constructor(description) {
|
|
3066
3131
|
super();
|
|
@@ -3186,6 +3251,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3186
3251
|
this.unknownIntegerProps = [];
|
|
3187
3252
|
this.unmatchableGetters = [];
|
|
3188
3253
|
this.unmatchablePropertiesAndGetters = [];
|
|
3254
|
+
this.unmatchablePropertiesAndSetters = [];
|
|
3189
3255
|
this.unmatchableSetters = [];
|
|
3190
3256
|
if (Array.isArray(properties)) {
|
|
3191
3257
|
this.buildPropertyMaps(properties);
|
|
@@ -3342,7 +3408,12 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3342
3408
|
}
|
|
3343
3409
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
3344
3410
|
if (path.length === 0) {
|
|
3345
|
-
|
|
3411
|
+
// This should actually be "UnknownTruthyValue". However, this currently
|
|
3412
|
+
// causes an issue with TypeScript enums in files with moduleSideEffects:
|
|
3413
|
+
// false because we cannot properly track whether a "var" has been
|
|
3414
|
+
// initialized. This should be reverted once we can properly track this.
|
|
3415
|
+
// return UnknownTruthyValue;
|
|
3416
|
+
return UnknownValue;
|
|
3346
3417
|
}
|
|
3347
3418
|
const key = path[0];
|
|
3348
3419
|
const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
|
|
@@ -3420,9 +3491,38 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3420
3491
|
}
|
|
3421
3492
|
return false;
|
|
3422
3493
|
}
|
|
3494
|
+
include(context, includeChildrenRecursively) {
|
|
3495
|
+
this.included = true;
|
|
3496
|
+
for (const property of this.allProperties) {
|
|
3497
|
+
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
3498
|
+
property.include(context, includeChildrenRecursively);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
this.prototypeExpression?.include(context, includeChildrenRecursively);
|
|
3502
|
+
}
|
|
3503
|
+
includePath(path, context) {
|
|
3504
|
+
this.included = true;
|
|
3505
|
+
if (path.length === 0)
|
|
3506
|
+
return;
|
|
3507
|
+
const [key, ...subPath] = path;
|
|
3508
|
+
const [includedMembers, includedPath] = typeof key === 'string'
|
|
3509
|
+
? [
|
|
3510
|
+
[
|
|
3511
|
+
...new Set([
|
|
3512
|
+
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
3513
|
+
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
3514
|
+
])
|
|
3515
|
+
],
|
|
3516
|
+
subPath
|
|
3517
|
+
]
|
|
3518
|
+
: [this.allProperties, UNKNOWN_PATH];
|
|
3519
|
+
for (const property of includedMembers) {
|
|
3520
|
+
property.includePath(includedPath, context);
|
|
3521
|
+
}
|
|
3522
|
+
this.prototypeExpression?.includePath(path, context);
|
|
3523
|
+
}
|
|
3423
3524
|
buildPropertyMaps(properties) {
|
|
3424
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3425
|
-
const unmatchablePropertiesAndSetters = [];
|
|
3525
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchablePropertiesAndSetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3426
3526
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
3427
3527
|
const { key, kind, property } = properties[index];
|
|
3428
3528
|
allProperties.push(property);
|
|
@@ -3692,6 +3792,37 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
|
|
|
3692
3792
|
values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
|
|
3693
3793
|
}, OBJECT_PROTOTYPE, true);
|
|
3694
3794
|
|
|
3795
|
+
class SpreadElement extends NodeBase {
|
|
3796
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
3797
|
+
if (path.length > 0) {
|
|
3798
|
+
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
hasEffects(context) {
|
|
3802
|
+
if (!this.deoptimized)
|
|
3803
|
+
this.applyDeoptimizations();
|
|
3804
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
3805
|
+
.treeshake;
|
|
3806
|
+
return (this.argument.hasEffects(context) ||
|
|
3807
|
+
(propertyReadSideEffects &&
|
|
3808
|
+
(propertyReadSideEffects === 'always' ||
|
|
3809
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
3810
|
+
}
|
|
3811
|
+
includeNode(context) {
|
|
3812
|
+
this.included = true;
|
|
3813
|
+
if (!this.deoptimized)
|
|
3814
|
+
this.applyDeoptimizations();
|
|
3815
|
+
this.argument.includePath(UNKNOWN_PATH, context);
|
|
3816
|
+
}
|
|
3817
|
+
applyDeoptimizations() {
|
|
3818
|
+
this.deoptimized = true;
|
|
3819
|
+
// Only properties of properties of the argument could become subject to reassignment
|
|
3820
|
+
// This will also reassign the return values of iterators
|
|
3821
|
+
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3822
|
+
this.scope.context.requestTreeshakingPass();
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3695
3826
|
class ArrayExpression extends NodeBase {
|
|
3696
3827
|
constructor() {
|
|
3697
3828
|
super(...arguments);
|
|
@@ -3712,6 +3843,16 @@ class ArrayExpression extends NodeBase {
|
|
|
3712
3843
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
3713
3844
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
3714
3845
|
}
|
|
3846
|
+
includeNode(context) {
|
|
3847
|
+
this.included = true;
|
|
3848
|
+
if (!this.deoptimized)
|
|
3849
|
+
this.applyDeoptimizations();
|
|
3850
|
+
for (const element of this.elements) {
|
|
3851
|
+
if (element) {
|
|
3852
|
+
element?.includePath(UNKNOWN_PATH, context);
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3715
3856
|
applyDeoptimizations() {
|
|
3716
3857
|
this.deoptimized = true;
|
|
3717
3858
|
let hasSpread = false;
|
|
@@ -4779,17 +4920,37 @@ class GlobalVariable extends Variable {
|
|
|
4779
4920
|
}
|
|
4780
4921
|
}
|
|
4781
4922
|
|
|
4923
|
+
// To avoid infinite recursions
|
|
4924
|
+
const MAX_PATH_DEPTH = 6;
|
|
4925
|
+
// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at
|
|
4926
|
+
// most MAX_PATH_DEPTH long. The last element is always UnknownKey
|
|
4927
|
+
const limitConcatenatedPathDepth = (path1, path2) => {
|
|
4928
|
+
const { length: length1 } = path1;
|
|
4929
|
+
const { length: length2 } = path2;
|
|
4930
|
+
return length1 === 0
|
|
4931
|
+
? path2
|
|
4932
|
+
: length2 === 0
|
|
4933
|
+
? path1
|
|
4934
|
+
: length1 + length2 > MAX_PATH_DEPTH
|
|
4935
|
+
? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey']
|
|
4936
|
+
: [...path1, ...path2];
|
|
4937
|
+
};
|
|
4938
|
+
|
|
4782
4939
|
class LocalVariable extends Variable {
|
|
4783
|
-
constructor(name, declarator, init,
|
|
4940
|
+
constructor(name, declarator, init,
|
|
4941
|
+
/** if this is non-empty, the actual init is this path of this.init */
|
|
4942
|
+
initPath, context, kind) {
|
|
4784
4943
|
super(name);
|
|
4785
4944
|
this.init = init;
|
|
4945
|
+
this.initPath = initPath;
|
|
4946
|
+
this.kind = kind;
|
|
4786
4947
|
this.calledFromTryStatement = false;
|
|
4787
4948
|
this.additionalInitializers = null;
|
|
4949
|
+
this.includedPathTracker = new IncludedPathTracker();
|
|
4788
4950
|
this.expressionsToBeDeoptimized = [];
|
|
4789
4951
|
this.declarations = declarator ? [declarator] : [];
|
|
4790
4952
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
4791
4953
|
this.module = context.module;
|
|
4792
|
-
this.kind = kind;
|
|
4793
4954
|
}
|
|
4794
4955
|
addDeclaration(identifier, init) {
|
|
4795
4956
|
this.declarations.push(identifier);
|
|
@@ -4800,15 +4961,16 @@ class LocalVariable extends Variable {
|
|
|
4800
4961
|
for (const initializer of this.additionalInitializers) {
|
|
4801
4962
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
4802
4963
|
}
|
|
4803
|
-
this.additionalInitializers = null;
|
|
4804
4964
|
}
|
|
4805
4965
|
}
|
|
4806
4966
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
4807
|
-
if (this.isReassigned) {
|
|
4967
|
+
if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
4808
4968
|
deoptimizeInteraction(interaction);
|
|
4809
4969
|
return;
|
|
4810
4970
|
}
|
|
4811
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () =>
|
|
4971
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4972
|
+
this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], recursionTracker);
|
|
4973
|
+
}, undefined);
|
|
4812
4974
|
}
|
|
4813
4975
|
deoptimizePath(path) {
|
|
4814
4976
|
if (this.isReassigned ||
|
|
@@ -4822,37 +4984,40 @@ class LocalVariable extends Variable {
|
|
|
4822
4984
|
for (const expression of expressionsToBeDeoptimized) {
|
|
4823
4985
|
expression.deoptimizeCache();
|
|
4824
4986
|
}
|
|
4825
|
-
this.init.deoptimizePath(
|
|
4987
|
+
this.init.deoptimizePath([...this.initPath, UnknownKey]);
|
|
4826
4988
|
}
|
|
4827
4989
|
else {
|
|
4828
|
-
this.init.deoptimizePath(path);
|
|
4990
|
+
this.init.deoptimizePath(limitConcatenatedPathDepth(this.initPath, path));
|
|
4829
4991
|
}
|
|
4830
4992
|
}
|
|
4831
4993
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
4832
|
-
if (this.isReassigned) {
|
|
4994
|
+
if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
4833
4995
|
return UnknownValue;
|
|
4834
4996
|
}
|
|
4835
4997
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4836
4998
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4837
|
-
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
4999
|
+
return this.init.getLiteralValueAtPath([...this.initPath, ...path], recursionTracker, origin);
|
|
4838
5000
|
}, UnknownValue);
|
|
4839
5001
|
}
|
|
4840
5002
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
4841
|
-
if (this.isReassigned) {
|
|
5003
|
+
if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
4842
5004
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
4843
5005
|
}
|
|
4844
5006
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4845
5007
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4846
|
-
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
5008
|
+
return this.init.getReturnExpressionWhenCalledAtPath([...this.initPath, ...path], interaction, recursionTracker, origin);
|
|
4847
5009
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
4848
5010
|
}
|
|
4849
5011
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5012
|
+
if (path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5013
|
+
return true;
|
|
5014
|
+
}
|
|
4850
5015
|
switch (interaction.type) {
|
|
4851
5016
|
case INTERACTION_ACCESSED: {
|
|
4852
5017
|
if (this.isReassigned)
|
|
4853
5018
|
return true;
|
|
4854
5019
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
4855
|
-
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5020
|
+
this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
4856
5021
|
}
|
|
4857
5022
|
case INTERACTION_ASSIGNED: {
|
|
4858
5023
|
if (this.included)
|
|
@@ -4862,44 +5027,63 @@ class LocalVariable extends Variable {
|
|
|
4862
5027
|
if (this.isReassigned)
|
|
4863
5028
|
return true;
|
|
4864
5029
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
4865
|
-
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5030
|
+
this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
4866
5031
|
}
|
|
4867
5032
|
case INTERACTION_CALLED: {
|
|
4868
5033
|
if (this.isReassigned)
|
|
4869
5034
|
return true;
|
|
4870
5035
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
4871
|
-
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5036
|
+
this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
4872
5037
|
}
|
|
4873
5038
|
}
|
|
4874
5039
|
}
|
|
4875
|
-
|
|
4876
|
-
if (!this.
|
|
4877
|
-
|
|
5040
|
+
includePath(path, context) {
|
|
5041
|
+
if (!this.includedPathTracker.includePathAndGetIfIncluded(path)) {
|
|
5042
|
+
this.module.scope.context.requestTreeshakingPass();
|
|
5043
|
+
if (!this.included) {
|
|
5044
|
+
// This will reduce the number of tree-shaking passes by eagerly
|
|
5045
|
+
// including inits. By pushing this here instead of directly including
|
|
5046
|
+
// we avoid deep call stacks.
|
|
5047
|
+
this.module.scope.context.newlyIncludedVariableInits.add(this.init);
|
|
5048
|
+
}
|
|
5049
|
+
super.includePath(path, context);
|
|
4878
5050
|
for (const declaration of this.declarations) {
|
|
4879
5051
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
4880
5052
|
if (!declaration.included)
|
|
4881
|
-
declaration.include(
|
|
5053
|
+
declaration.include(context, false);
|
|
4882
5054
|
let node = declaration.parent;
|
|
4883
5055
|
while (!node.included) {
|
|
4884
5056
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
4885
5057
|
// in which case .include() might pull in more dead code
|
|
4886
|
-
node.
|
|
5058
|
+
node.includeNode(context);
|
|
4887
5059
|
if (node.type === Program$1)
|
|
4888
5060
|
break;
|
|
4889
5061
|
node = node.parent;
|
|
4890
5062
|
}
|
|
4891
5063
|
}
|
|
5064
|
+
// We need to make sure we include the correct path of the init
|
|
5065
|
+
if (path.length > 0) {
|
|
5066
|
+
this.init.includePath(limitConcatenatedPathDepth(this.initPath, path), context);
|
|
5067
|
+
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context));
|
|
5068
|
+
}
|
|
4892
5069
|
}
|
|
4893
5070
|
}
|
|
4894
|
-
includeCallArguments(context,
|
|
4895
|
-
if (this.isReassigned ||
|
|
4896
|
-
|
|
4897
|
-
|
|
5071
|
+
includeCallArguments(context, interaction) {
|
|
5072
|
+
if (this.isReassigned ||
|
|
5073
|
+
context.includedCallArguments.has(this.init) ||
|
|
5074
|
+
// This can be removed again once we can include arguments when called at
|
|
5075
|
+
// a specific path
|
|
5076
|
+
this.initPath.length > 0) {
|
|
5077
|
+
for (const argument of interaction.args) {
|
|
5078
|
+
if (argument) {
|
|
5079
|
+
argument.includePath(UNKNOWN_PATH, context);
|
|
5080
|
+
argument.include(context, false);
|
|
5081
|
+
}
|
|
4898
5082
|
}
|
|
4899
5083
|
}
|
|
4900
5084
|
else {
|
|
4901
5085
|
context.includedCallArguments.add(this.init);
|
|
4902
|
-
this.init.includeCallArguments(context,
|
|
5086
|
+
this.init.includeCallArguments(context, interaction);
|
|
4903
5087
|
context.includedCallArguments.delete(this.init);
|
|
4904
5088
|
}
|
|
4905
5089
|
}
|
|
@@ -4979,18 +5163,31 @@ class IdentifierBase extends NodeBase {
|
|
|
4979
5163
|
}
|
|
4980
5164
|
}
|
|
4981
5165
|
}
|
|
4982
|
-
include() {
|
|
5166
|
+
include(context) {
|
|
5167
|
+
if (!this.included)
|
|
5168
|
+
this.includeNode(context);
|
|
5169
|
+
}
|
|
5170
|
+
includeNode(context) {
|
|
5171
|
+
this.included = true;
|
|
4983
5172
|
if (!this.deoptimized)
|
|
4984
5173
|
this.applyDeoptimizations();
|
|
5174
|
+
if (this.variable !== null) {
|
|
5175
|
+
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5176
|
+
}
|
|
5177
|
+
}
|
|
5178
|
+
includePath(path, context) {
|
|
4985
5179
|
if (!this.included) {
|
|
4986
5180
|
this.included = true;
|
|
4987
5181
|
if (this.variable !== null) {
|
|
4988
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
5182
|
+
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
4989
5183
|
}
|
|
4990
5184
|
}
|
|
5185
|
+
else if (path.length > 0) {
|
|
5186
|
+
this.variable?.includePath(path, context);
|
|
5187
|
+
}
|
|
4991
5188
|
}
|
|
4992
|
-
includeCallArguments(context,
|
|
4993
|
-
this.variable.includeCallArguments(context,
|
|
5189
|
+
includeCallArguments(context, interaction) {
|
|
5190
|
+
this.variable.includeCallArguments(context, interaction);
|
|
4994
5191
|
}
|
|
4995
5192
|
isPossibleTDZ() {
|
|
4996
5193
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -5073,11 +5270,40 @@ function closestParentFunctionOrProgram(node) {
|
|
|
5073
5270
|
return node;
|
|
5074
5271
|
}
|
|
5075
5272
|
|
|
5273
|
+
class ObjectMember extends ExpressionEntity {
|
|
5274
|
+
constructor(object, path) {
|
|
5275
|
+
super();
|
|
5276
|
+
this.object = object;
|
|
5277
|
+
this.path = path;
|
|
5278
|
+
}
|
|
5279
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5280
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.path, ...path], recursionTracker);
|
|
5281
|
+
}
|
|
5282
|
+
deoptimizePath(path) {
|
|
5283
|
+
this.object.deoptimizePath([...this.path, ...path]);
|
|
5284
|
+
}
|
|
5285
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5286
|
+
return this.object.getLiteralValueAtPath([...this.path, ...path], recursionTracker, origin);
|
|
5287
|
+
}
|
|
5288
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5289
|
+
return this.object.getReturnExpressionWhenCalledAtPath([...this.path, ...path], interaction, recursionTracker, origin);
|
|
5290
|
+
}
|
|
5291
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5292
|
+
return this.object.hasEffectsOnInteractionAtPath([...this.path, ...path], interaction, context);
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5295
|
+
|
|
5076
5296
|
class Identifier extends IdentifierBase {
|
|
5077
5297
|
constructor() {
|
|
5078
5298
|
super(...arguments);
|
|
5079
5299
|
this.variable = null;
|
|
5080
5300
|
}
|
|
5301
|
+
get isDestructuringDeoptimized() {
|
|
5302
|
+
return isFlagSet(this.flags, 16777216 /* Flag.destructuringDeoptimized */);
|
|
5303
|
+
}
|
|
5304
|
+
set isDestructuringDeoptimized(value) {
|
|
5305
|
+
this.flags = setFlag(this.flags, 16777216 /* Flag.destructuringDeoptimized */, value);
|
|
5306
|
+
}
|
|
5081
5307
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
5082
5308
|
if (exportNamesByVariable.has(this.variable)) {
|
|
5083
5309
|
variables.push(this.variable);
|
|
@@ -5090,43 +5316,53 @@ class Identifier extends IdentifierBase {
|
|
|
5090
5316
|
this.isVariableReference = true;
|
|
5091
5317
|
}
|
|
5092
5318
|
}
|
|
5093
|
-
declare(kind, init) {
|
|
5094
|
-
let variable;
|
|
5095
|
-
const { treeshake } = this.scope.context.options;
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
}
|
|
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}.`);
|
|
5319
|
+
declare(kind, destructuredInitPath, init) {
|
|
5320
|
+
let variable;
|
|
5321
|
+
const { treeshake } = this.scope.context.options;
|
|
5322
|
+
if (kind === 'parameter') {
|
|
5323
|
+
variable = this.scope.addParameterDeclaration(this, destructuredInitPath);
|
|
5324
|
+
}
|
|
5325
|
+
else {
|
|
5326
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, destructuredInitPath, kind);
|
|
5327
|
+
if (kind === 'var' && treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
5328
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
5329
|
+
variable.markInitializersForDeoptimization();
|
|
5126
5330
|
}
|
|
5127
5331
|
}
|
|
5128
5332
|
return [(this.variable = variable)];
|
|
5129
5333
|
}
|
|
5334
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
5335
|
+
this.deoptimizePath(EMPTY_PATH);
|
|
5336
|
+
init.deoptimizePath([...destructuredInitPath, UnknownKey]);
|
|
5337
|
+
}
|
|
5338
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
5339
|
+
return (destructuredInitPath.length > 0 &&
|
|
5340
|
+
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
5341
|
+
}
|
|
5342
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
5343
|
+
if (destructuredInitPath.length > 0 && !this.isDestructuringDeoptimized) {
|
|
5344
|
+
this.isDestructuringDeoptimized = true;
|
|
5345
|
+
init.deoptimizeArgumentsOnInteractionAtPath({
|
|
5346
|
+
args: [new ObjectMember(init, destructuredInitPath.slice(0, -1))],
|
|
5347
|
+
type: INTERACTION_ACCESSED
|
|
5348
|
+
}, destructuredInitPath, SHARED_RECURSION_TRACKER);
|
|
5349
|
+
}
|
|
5350
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
5351
|
+
.treeshake;
|
|
5352
|
+
if ((this.included ||=
|
|
5353
|
+
destructuredInitPath.length > 0 &&
|
|
5354
|
+
!context.brokenFlow &&
|
|
5355
|
+
propertyReadSideEffects &&
|
|
5356
|
+
(propertyReadSideEffects === 'always' ||
|
|
5357
|
+
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext())))) {
|
|
5358
|
+
if (this.variable && !this.variable.included) {
|
|
5359
|
+
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5360
|
+
}
|
|
5361
|
+
init.includePath(destructuredInitPath, context);
|
|
5362
|
+
return true;
|
|
5363
|
+
}
|
|
5364
|
+
return false;
|
|
5365
|
+
}
|
|
5130
5366
|
markDeclarationReached() {
|
|
5131
5367
|
this.variable.initReached = true;
|
|
5132
5368
|
}
|
|
@@ -5191,18 +5427,17 @@ class Scope {
|
|
|
5191
5427
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
5192
5428
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
5193
5429
|
*/
|
|
5194
|
-
addDeclaration(identifier, context, init, kind) {
|
|
5430
|
+
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
5195
5431
|
const name = identifier.name;
|
|
5196
5432
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5197
5433
|
if (existingVariable) {
|
|
5198
|
-
|
|
5199
|
-
if (kind === 'var' && existingKind === 'var') {
|
|
5434
|
+
if (kind === 'var' && existingVariable.kind === 'var') {
|
|
5200
5435
|
existingVariable.addDeclaration(identifier, init);
|
|
5201
5436
|
return existingVariable;
|
|
5202
5437
|
}
|
|
5203
5438
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5204
5439
|
}
|
|
5205
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
5440
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, destructuredInitPath, context, kind);
|
|
5206
5441
|
this.variables.set(name, newVariable);
|
|
5207
5442
|
return newVariable;
|
|
5208
5443
|
}
|
|
@@ -5378,7 +5613,6 @@ class MethodBase extends NodeBase {
|
|
|
5378
5613
|
}
|
|
5379
5614
|
return this.getAccessedValue()[0].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5380
5615
|
}
|
|
5381
|
-
applyDeoptimizations() { }
|
|
5382
5616
|
getAccessedValue() {
|
|
5383
5617
|
if (this.accessedValue === null) {
|
|
5384
5618
|
if (this.kind === 'get') {
|
|
@@ -5392,19 +5626,20 @@ class MethodBase extends NodeBase {
|
|
|
5392
5626
|
return this.accessedValue;
|
|
5393
5627
|
}
|
|
5394
5628
|
}
|
|
5629
|
+
MethodBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5630
|
+
MethodBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5395
5631
|
|
|
5396
5632
|
class MethodDefinition extends MethodBase {
|
|
5397
5633
|
hasEffects(context) {
|
|
5398
5634
|
return super.hasEffects(context) || checkEffectForNodes(this.decorators, context);
|
|
5399
5635
|
}
|
|
5400
|
-
applyDeoptimizations() { }
|
|
5401
5636
|
}
|
|
5402
5637
|
|
|
5403
5638
|
class BlockScope extends ChildScope {
|
|
5404
5639
|
constructor(parent) {
|
|
5405
5640
|
super(parent, parent.context);
|
|
5406
5641
|
}
|
|
5407
|
-
addDeclaration(identifier, context, init, kind) {
|
|
5642
|
+
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
5408
5643
|
if (kind === 'var') {
|
|
5409
5644
|
const name = identifier.name;
|
|
5410
5645
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5416,7 +5651,7 @@ class BlockScope extends ChildScope {
|
|
|
5416
5651
|
}
|
|
5417
5652
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5418
5653
|
}
|
|
5419
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
5654
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
5420
5655
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5421
5656
|
// We cannot call deoptimizePath here.
|
|
5422
5657
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5424,7 +5659,7 @@ class BlockScope extends ChildScope {
|
|
|
5424
5659
|
this.addHoistedVariable(name, declaredVariable);
|
|
5425
5660
|
return declaredVariable;
|
|
5426
5661
|
}
|
|
5427
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
5662
|
+
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
5428
5663
|
}
|
|
5429
5664
|
}
|
|
5430
5665
|
|
|
@@ -5456,33 +5691,12 @@ class StaticBlock extends NodeBase {
|
|
|
5456
5691
|
}
|
|
5457
5692
|
}
|
|
5458
5693
|
}
|
|
5694
|
+
StaticBlock.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5695
|
+
StaticBlock.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5459
5696
|
function isStaticBlock(statement) {
|
|
5460
5697
|
return statement.type === StaticBlock$1;
|
|
5461
5698
|
}
|
|
5462
5699
|
|
|
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
|
-
|
|
5486
5700
|
class ClassNode extends NodeBase {
|
|
5487
5701
|
constructor() {
|
|
5488
5702
|
super(...arguments);
|
|
@@ -5523,21 +5737,20 @@ class ClassNode extends NodeBase {
|
|
|
5523
5737
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5524
5738
|
}
|
|
5525
5739
|
include(context, includeChildrenRecursively) {
|
|
5526
|
-
if (!this.
|
|
5527
|
-
this.
|
|
5528
|
-
this.included = true;
|
|
5740
|
+
if (!this.included)
|
|
5741
|
+
this.includeNode(context);
|
|
5529
5742
|
this.superClass?.include(context, includeChildrenRecursively);
|
|
5530
5743
|
this.body.include(context, includeChildrenRecursively);
|
|
5531
5744
|
for (const decorator of this.decorators)
|
|
5532
5745
|
decorator.include(context, includeChildrenRecursively);
|
|
5533
5746
|
if (this.id) {
|
|
5534
5747
|
this.id.markDeclarationReached();
|
|
5535
|
-
this.id.include();
|
|
5748
|
+
this.id.include(context);
|
|
5536
5749
|
}
|
|
5537
5750
|
}
|
|
5538
5751
|
initialise() {
|
|
5539
5752
|
super.initialise();
|
|
5540
|
-
this.id?.declare('class', this);
|
|
5753
|
+
this.id?.declare('class', EMPTY_PATH, this);
|
|
5541
5754
|
for (const method of this.body.body) {
|
|
5542
5755
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
5543
5756
|
this.classConstructor = method;
|
|
@@ -5595,11 +5808,12 @@ class ClassNode extends NodeBase {
|
|
|
5595
5808
|
staticProperties.unshift({
|
|
5596
5809
|
key: 'prototype',
|
|
5597
5810
|
kind: 'init',
|
|
5598
|
-
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass, 'prototype') : OBJECT_PROTOTYPE)
|
|
5811
|
+
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass, ['prototype']) : OBJECT_PROTOTYPE)
|
|
5599
5812
|
});
|
|
5600
5813
|
return (this.objectEntity = new ObjectEntity(staticProperties, this.superClass || OBJECT_PROTOTYPE));
|
|
5601
5814
|
}
|
|
5602
5815
|
}
|
|
5816
|
+
ClassNode.prototype.includeNode = onlyIncludeSelf;
|
|
5603
5817
|
|
|
5604
5818
|
class ClassDeclaration extends ClassNode {
|
|
5605
5819
|
initialise() {
|
|
@@ -5652,7 +5866,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
5652
5866
|
|
|
5653
5867
|
class ArgumentsVariable extends LocalVariable {
|
|
5654
5868
|
constructor(context) {
|
|
5655
|
-
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
5869
|
+
super('arguments', null, UNKNOWN_EXPRESSION, EMPTY_PATH, context, 'other');
|
|
5656
5870
|
this.deoptimizedArguments = [];
|
|
5657
5871
|
}
|
|
5658
5872
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -5666,8 +5880,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5666
5880
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5667
5881
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
5668
5882
|
}
|
|
5669
|
-
|
|
5670
|
-
super.
|
|
5883
|
+
includePath(path, context) {
|
|
5884
|
+
super.includePath(path, context);
|
|
5671
5885
|
for (const argument of this.deoptimizedArguments) {
|
|
5672
5886
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
5673
5887
|
}
|
|
@@ -5675,30 +5889,31 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5675
5889
|
}
|
|
5676
5890
|
}
|
|
5677
5891
|
|
|
5678
|
-
const MAX_TRACKED_INTERACTIONS =
|
|
5892
|
+
const MAX_TRACKED_INTERACTIONS = 10;
|
|
5893
|
+
const MAX_DEOPTIMIZED_FIELDS = 5;
|
|
5679
5894
|
const NO_INTERACTIONS = EMPTY_ARRAY;
|
|
5680
5895
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
5681
|
-
const EMPTY_PATH_TRACKER = new
|
|
5896
|
+
const EMPTY_PATH_TRACKER = new EntityPathTracker();
|
|
5682
5897
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
5683
5898
|
class ParameterVariable extends LocalVariable {
|
|
5684
|
-
constructor(name, declarator, context) {
|
|
5685
|
-
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
5899
|
+
constructor(name, declarator, argumentPath, context) {
|
|
5900
|
+
super(name, declarator, UNKNOWN_EXPRESSION, argumentPath, context, 'parameter');
|
|
5901
|
+
this.argumentsToBeDeoptimized = new Set();
|
|
5686
5902
|
this.deoptimizationInteractions = [];
|
|
5687
|
-
this.deoptimizations = new
|
|
5903
|
+
this.deoptimizations = new EntityPathTracker();
|
|
5688
5904
|
this.deoptimizedFields = new Set();
|
|
5689
|
-
this.
|
|
5690
|
-
this.expressionsUseTheKnownValue = [];
|
|
5905
|
+
this.expressionsDependingOnKnownValue = [];
|
|
5691
5906
|
this.knownValue = null;
|
|
5692
5907
|
this.knownValueLiteral = UnknownValue;
|
|
5693
|
-
this.frozenValue = null;
|
|
5694
5908
|
}
|
|
5695
|
-
|
|
5909
|
+
addArgumentValue(entity) {
|
|
5910
|
+
this.updateKnownValue(entity);
|
|
5696
5911
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
5697
5912
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
5698
5913
|
// the interaction cache at this point provided we keep this optimization
|
|
5699
5914
|
// in mind when adding new interactions
|
|
5700
|
-
if (!this.
|
|
5701
|
-
this.
|
|
5915
|
+
if (!this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5916
|
+
this.argumentsToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
5702
5917
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
5703
5918
|
deoptimizeInteraction(interaction);
|
|
5704
5919
|
}
|
|
@@ -5708,27 +5923,30 @@ class ParameterVariable extends LocalVariable {
|
|
|
5708
5923
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5709
5924
|
// This means that we already deoptimized all interactions and no longer
|
|
5710
5925
|
// track them
|
|
5711
|
-
entity.deoptimizePath(
|
|
5926
|
+
entity.deoptimizePath([...this.initPath, UnknownKey]);
|
|
5712
5927
|
}
|
|
5713
|
-
else if (!this.
|
|
5714
|
-
this.
|
|
5928
|
+
else if (!this.argumentsToBeDeoptimized.has(entity)) {
|
|
5929
|
+
this.argumentsToBeDeoptimized.add(entity);
|
|
5715
5930
|
for (const field of this.deoptimizedFields) {
|
|
5716
|
-
entity.deoptimizePath([field]);
|
|
5931
|
+
entity.deoptimizePath([...this.initPath, field]);
|
|
5717
5932
|
}
|
|
5718
5933
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
5719
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5934
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
5720
5935
|
}
|
|
5721
5936
|
}
|
|
5722
5937
|
}
|
|
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. */
|
|
5723
5941
|
markReassigned() {
|
|
5724
5942
|
if (this.isReassigned) {
|
|
5725
5943
|
return;
|
|
5726
5944
|
}
|
|
5727
5945
|
super.markReassigned();
|
|
5728
|
-
for (const expression of this.
|
|
5946
|
+
for (const expression of this.expressionsDependingOnKnownValue) {
|
|
5729
5947
|
expression.deoptimizeCache();
|
|
5730
5948
|
}
|
|
5731
|
-
this.
|
|
5949
|
+
this.expressionsDependingOnKnownValue = EMPTY_ARRAY;
|
|
5732
5950
|
}
|
|
5733
5951
|
deoptimizeCache() {
|
|
5734
5952
|
this.markReassigned();
|
|
@@ -5745,7 +5963,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5745
5963
|
}
|
|
5746
5964
|
if (this.knownValue === null) {
|
|
5747
5965
|
this.knownValue = argument;
|
|
5748
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
5966
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(this.initPath, SHARED_RECURSION_TRACKER, this);
|
|
5749
5967
|
return;
|
|
5750
5968
|
}
|
|
5751
5969
|
// the same literal or identifier, do nothing
|
|
@@ -5755,14 +5973,10 @@ class ParameterVariable extends LocalVariable {
|
|
|
5755
5973
|
this.knownValue.variable === argument.variable)) {
|
|
5756
5974
|
return;
|
|
5757
5975
|
}
|
|
5758
|
-
const
|
|
5759
|
-
if (typeof
|
|
5760
|
-
this.
|
|
5761
|
-
|
|
5762
|
-
}
|
|
5763
|
-
// add tracking for the new argument
|
|
5764
|
-
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5765
|
-
if (newValue !== oldValue) {
|
|
5976
|
+
const { knownValueLiteral } = this;
|
|
5977
|
+
if (typeof knownValueLiteral === 'symbol' ||
|
|
5978
|
+
argument.getLiteralValueAtPath(this.initPath, SHARED_RECURSION_TRACKER, this) !==
|
|
5979
|
+
knownValueLiteral) {
|
|
5766
5980
|
this.markReassigned();
|
|
5767
5981
|
}
|
|
5768
5982
|
}
|
|
@@ -5773,42 +5987,47 @@ class ParameterVariable extends LocalVariable {
|
|
|
5773
5987
|
* @returns the frozen value
|
|
5774
5988
|
*/
|
|
5775
5989
|
getKnownValue() {
|
|
5776
|
-
|
|
5777
|
-
this.frozenValue = this.knownValue || UNKNOWN_EXPRESSION;
|
|
5778
|
-
}
|
|
5779
|
-
return this.frozenValue;
|
|
5990
|
+
return this.knownValue || UNKNOWN_EXPRESSION;
|
|
5780
5991
|
}
|
|
5781
5992
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5782
|
-
if (this.isReassigned) {
|
|
5993
|
+
if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5783
5994
|
return UnknownValue;
|
|
5784
5995
|
}
|
|
5785
5996
|
const knownValue = this.getKnownValue();
|
|
5786
|
-
this.
|
|
5787
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
5997
|
+
this.expressionsDependingOnKnownValue.push(origin);
|
|
5998
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath([...this.initPath, ...path], recursionTracker, origin), UnknownValue);
|
|
5788
5999
|
}
|
|
5789
6000
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5790
|
-
|
|
6001
|
+
const { type } = interaction;
|
|
6002
|
+
if (this.isReassigned ||
|
|
6003
|
+
type === INTERACTION_ASSIGNED ||
|
|
6004
|
+
path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5791
6005
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5792
6006
|
}
|
|
5793
|
-
|
|
5794
|
-
|
|
6007
|
+
return (!(type === INTERACTION_CALLED
|
|
6008
|
+
? (interaction.withNew
|
|
6009
|
+
? context.instantiated
|
|
6010
|
+
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
6011
|
+
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
6012
|
+
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
5795
6013
|
}
|
|
5796
6014
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
5797
6015
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
5798
6016
|
if (path.length >= 2 ||
|
|
5799
|
-
this.
|
|
6017
|
+
this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
5800
6018
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
5801
6019
|
(path.length === 1 &&
|
|
5802
6020
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
5803
|
-
(interaction.type === INTERACTION_CALLED && this.deoptimizedFields.has(path[0]))))
|
|
6021
|
+
(interaction.type === INTERACTION_CALLED && this.deoptimizedFields.has(path[0])))) ||
|
|
6022
|
+
this.initPath.length + path.length > MAX_PATH_DEPTH) {
|
|
5804
6023
|
deoptimizeInteraction(interaction);
|
|
5805
6024
|
return;
|
|
5806
6025
|
}
|
|
5807
6026
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
5808
|
-
for (const entity of this.
|
|
5809
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
6027
|
+
for (const entity of this.argumentsToBeDeoptimized) {
|
|
6028
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
5810
6029
|
}
|
|
5811
|
-
if (!this.
|
|
6030
|
+
if (!this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5812
6031
|
this.deoptimizationInteractions.push({
|
|
5813
6032
|
interaction,
|
|
5814
6033
|
path
|
|
@@ -5824,22 +6043,27 @@ class ParameterVariable extends LocalVariable {
|
|
|
5824
6043
|
if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5825
6044
|
return;
|
|
5826
6045
|
}
|
|
5827
|
-
|
|
6046
|
+
let key = path[0];
|
|
5828
6047
|
if (this.deoptimizedFields.has(key)) {
|
|
5829
6048
|
return;
|
|
5830
6049
|
}
|
|
5831
|
-
this.deoptimizedFields.
|
|
5832
|
-
|
|
6050
|
+
if (this.deoptimizedFields.size > MAX_DEOPTIMIZED_FIELDS) {
|
|
6051
|
+
key = UnknownKey;
|
|
6052
|
+
}
|
|
6053
|
+
else {
|
|
6054
|
+
this.deoptimizedFields.add(key);
|
|
6055
|
+
}
|
|
6056
|
+
for (const entity of this.argumentsToBeDeoptimized) {
|
|
5833
6057
|
// We do not need a recursion tracker here as we already track whether
|
|
5834
6058
|
// this field is deoptimized
|
|
5835
|
-
entity.deoptimizePath([key]);
|
|
6059
|
+
entity.deoptimizePath([...this.initPath, key]);
|
|
5836
6060
|
}
|
|
5837
6061
|
if (key === UnknownKey) {
|
|
5838
6062
|
// save some memory
|
|
5839
6063
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
5840
6064
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
5841
6065
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
5842
|
-
this.
|
|
6066
|
+
this.argumentsToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
5843
6067
|
}
|
|
5844
6068
|
}
|
|
5845
6069
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -5854,11 +6078,14 @@ class ParameterVariable extends LocalVariable {
|
|
|
5854
6078
|
}
|
|
5855
6079
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
5856
6080
|
}
|
|
6081
|
+
includeArgumentPaths(entity, context) {
|
|
6082
|
+
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
6083
|
+
}
|
|
5857
6084
|
}
|
|
5858
6085
|
|
|
5859
6086
|
class ThisVariable extends ParameterVariable {
|
|
5860
6087
|
constructor(context) {
|
|
5861
|
-
super('this', null, context);
|
|
6088
|
+
super('this', null, EMPTY_PATH, context);
|
|
5862
6089
|
}
|
|
5863
6090
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5864
6091
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -5870,7 +6097,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5870
6097
|
super(parent, parent.context);
|
|
5871
6098
|
this.parent = parent;
|
|
5872
6099
|
}
|
|
5873
|
-
addDeclaration(identifier, context, init, kind) {
|
|
6100
|
+
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
5874
6101
|
if (kind === 'var') {
|
|
5875
6102
|
const name = identifier.name;
|
|
5876
6103
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5883,7 +6110,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5883
6110
|
// the assignment actually goes to the parameter and the var is
|
|
5884
6111
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
5885
6112
|
// parameter
|
|
5886
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
6113
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, destructuredInitPath, kind);
|
|
5887
6114
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
5888
6115
|
// names. If we ever implement a logic that splits initialization and
|
|
5889
6116
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -5902,7 +6129,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5902
6129
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5903
6130
|
}
|
|
5904
6131
|
// We only add parameters to parameter scopes
|
|
5905
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
6132
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
5906
6133
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5907
6134
|
// We cannot call deoptimizePath here.
|
|
5908
6135
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5910,7 +6137,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5910
6137
|
this.addHoistedVariable(name, declaredVariable);
|
|
5911
6138
|
return declaredVariable;
|
|
5912
6139
|
}
|
|
5913
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
6140
|
+
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
5914
6141
|
}
|
|
5915
6142
|
}
|
|
5916
6143
|
|
|
@@ -5920,7 +6147,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
5920
6147
|
}
|
|
5921
6148
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
5922
6149
|
// be redeclared, functions and var can redeclare each other
|
|
5923
|
-
addDeclaration(identifier, context, init, kind) {
|
|
6150
|
+
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
5924
6151
|
const name = identifier.name;
|
|
5925
6152
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5926
6153
|
if (existingVariable) {
|
|
@@ -5932,7 +6159,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
5932
6159
|
}
|
|
5933
6160
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5934
6161
|
}
|
|
5935
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
6162
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, destructuredInitPath, context, kind);
|
|
5936
6163
|
this.variables.set(name, newVariable);
|
|
5937
6164
|
return newVariable;
|
|
5938
6165
|
}
|
|
@@ -5941,21 +6168,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
5941
6168
|
class ParameterScope extends ChildScope {
|
|
5942
6169
|
constructor(parent, isCatchScope) {
|
|
5943
6170
|
super(parent, parent.context);
|
|
5944
|
-
this.parameters = [];
|
|
5945
6171
|
this.hasRest = false;
|
|
6172
|
+
this.parameters = [];
|
|
5946
6173
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
5947
6174
|
}
|
|
5948
6175
|
/**
|
|
5949
6176
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
5950
6177
|
* order, i.e. from left to right.
|
|
5951
6178
|
*/
|
|
5952
|
-
addParameterDeclaration(identifier) {
|
|
6179
|
+
addParameterDeclaration(identifier, argumentPath) {
|
|
5953
6180
|
const { name, start } = identifier;
|
|
5954
6181
|
const existingParameter = this.variables.get(name);
|
|
5955
6182
|
if (existingParameter) {
|
|
5956
6183
|
return this.context.error(logDuplicateArgumentNameError(name), start);
|
|
5957
6184
|
}
|
|
5958
|
-
const variable = new ParameterVariable(name, identifier, this.context);
|
|
6185
|
+
const variable = new ParameterVariable(name, identifier, argumentPath, this.context);
|
|
5959
6186
|
this.variables.set(name, variable);
|
|
5960
6187
|
// We also add it to the body scope to detect name conflicts with local
|
|
5961
6188
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -5973,42 +6200,56 @@ class ParameterScope extends ChildScope {
|
|
|
5973
6200
|
}
|
|
5974
6201
|
this.hasRest = hasRest;
|
|
5975
6202
|
}
|
|
5976
|
-
includeCallArguments(context,
|
|
6203
|
+
includeCallArguments(context, interaction) {
|
|
5977
6204
|
let calledFromTryStatement = false;
|
|
5978
6205
|
let argumentIncluded = false;
|
|
5979
6206
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
6207
|
+
const { args } = interaction;
|
|
6208
|
+
let lastExplicitlyIncludedIndex = args.length - 1;
|
|
6209
|
+
// If there is a SpreadElement, we need to include all arguments after it
|
|
6210
|
+
// because we no longer know which argument corresponds to which parameter.
|
|
6211
|
+
for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) {
|
|
6212
|
+
const argument = args[argumentIndex];
|
|
6213
|
+
if (argument instanceof SpreadElement && !argumentIncluded) {
|
|
6214
|
+
argumentIncluded = true;
|
|
6215
|
+
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
6216
|
+
}
|
|
6217
|
+
if (argumentIncluded) {
|
|
6218
|
+
argument.includePath(UNKNOWN_PATH, context);
|
|
6219
|
+
argument.include(context, false);
|
|
5986
6220
|
}
|
|
5987
6221
|
}
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
6222
|
+
// Now we go backwards either starting from the last argument or before the
|
|
6223
|
+
// first SpreadElement to ensure all arguments before are included as needed
|
|
6224
|
+
for (let index = lastExplicitlyIncludedIndex; index >= 1; index--) {
|
|
6225
|
+
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
6226
|
+
const argument = args[index];
|
|
5991
6227
|
if (parameterVariables) {
|
|
5992
6228
|
calledFromTryStatement = false;
|
|
5993
6229
|
if (parameterVariables.length === 0) {
|
|
5994
|
-
// handle empty destructuring
|
|
6230
|
+
// handle empty destructuring to avoid destructuring undefined
|
|
5995
6231
|
argumentIncluded = true;
|
|
5996
6232
|
}
|
|
5997
6233
|
else {
|
|
5998
6234
|
for (const variable of parameterVariables) {
|
|
5999
|
-
if (variable.included) {
|
|
6000
|
-
argumentIncluded = true;
|
|
6001
|
-
}
|
|
6002
6235
|
if (variable.calledFromTryStatement) {
|
|
6003
6236
|
calledFromTryStatement = true;
|
|
6004
6237
|
}
|
|
6238
|
+
if (variable.included) {
|
|
6239
|
+
argumentIncluded = true;
|
|
6240
|
+
if (calledFromTryStatement) {
|
|
6241
|
+
argument.include(context, true);
|
|
6242
|
+
}
|
|
6243
|
+
else {
|
|
6244
|
+
variable.includeArgumentPaths(argument, context);
|
|
6245
|
+
argument.include(context, false);
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
6005
6248
|
}
|
|
6006
6249
|
}
|
|
6007
6250
|
}
|
|
6008
|
-
if (!
|
|
6251
|
+
if (!argument.included && (argumentIncluded || argument.shouldBeIncluded(context))) {
|
|
6009
6252
|
argumentIncluded = true;
|
|
6010
|
-
}
|
|
6011
|
-
if (argumentIncluded) {
|
|
6012
6253
|
argument.include(context, calledFromTryStatement);
|
|
6013
6254
|
}
|
|
6014
6255
|
}
|
|
@@ -6024,11 +6265,62 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6024
6265
|
addReturnExpression(expression) {
|
|
6025
6266
|
this.returnExpressions.push(expression);
|
|
6026
6267
|
}
|
|
6268
|
+
deoptimizeArgumentsOnCall(interaction) {
|
|
6269
|
+
const { parameters } = this;
|
|
6270
|
+
const { args } = interaction;
|
|
6271
|
+
let position = 0;
|
|
6272
|
+
for (; position < args.length - 1; position++) {
|
|
6273
|
+
// Only the "this" argument arg[0] can be null
|
|
6274
|
+
const argument = args[position + 1];
|
|
6275
|
+
if (argument instanceof SpreadElement) {
|
|
6276
|
+
// This deoptimizes the current and remaining parameters and arguments
|
|
6277
|
+
for (; position < parameters.length; position++) {
|
|
6278
|
+
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
6279
|
+
parameters[position].forEach(variable => variable.markReassigned());
|
|
6280
|
+
}
|
|
6281
|
+
break;
|
|
6282
|
+
}
|
|
6283
|
+
if (this.hasRest && position >= parameters.length - 1) {
|
|
6284
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6285
|
+
}
|
|
6286
|
+
else {
|
|
6287
|
+
const variables = parameters[position];
|
|
6288
|
+
if (variables) {
|
|
6289
|
+
for (const variable of variables) {
|
|
6290
|
+
variable.addArgumentValue(argument);
|
|
6291
|
+
}
|
|
6292
|
+
}
|
|
6293
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
const nonRestParameterLength = this.hasRest ? parameters.length - 1 : parameters.length;
|
|
6297
|
+
for (; position < nonRestParameterLength; position++) {
|
|
6298
|
+
for (const variable of parameters[position]) {
|
|
6299
|
+
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
6300
|
+
}
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6027
6303
|
getReturnExpression() {
|
|
6028
6304
|
if (this.returnExpression === null)
|
|
6029
6305
|
this.updateReturnExpression();
|
|
6030
6306
|
return this.returnExpression;
|
|
6031
6307
|
}
|
|
6308
|
+
deoptimizeAllParameters() {
|
|
6309
|
+
for (const parameter of this.parameters) {
|
|
6310
|
+
for (const variable of parameter) {
|
|
6311
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
6312
|
+
variable.markReassigned();
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
}
|
|
6316
|
+
reassignAllParameters() {
|
|
6317
|
+
for (const parameter of this.parameters) {
|
|
6318
|
+
for (const variable of parameter) {
|
|
6319
|
+
variable.markReassigned();
|
|
6320
|
+
}
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
6032
6324
|
updateReturnExpression() {
|
|
6033
6325
|
if (this.returnExpressions.length === 1) {
|
|
6034
6326
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -6044,24 +6336,30 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6044
6336
|
|
|
6045
6337
|
class FunctionScope extends ReturnValueScope {
|
|
6046
6338
|
constructor(parent) {
|
|
6047
|
-
const { context } = parent;
|
|
6048
6339
|
super(parent, false);
|
|
6340
|
+
const { context } = parent;
|
|
6049
6341
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
6050
6342
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
6051
6343
|
}
|
|
6052
6344
|
findLexicalBoundary() {
|
|
6053
6345
|
return this;
|
|
6054
6346
|
}
|
|
6055
|
-
includeCallArguments(context,
|
|
6056
|
-
super.includeCallArguments(context,
|
|
6347
|
+
includeCallArguments(context, interaction) {
|
|
6348
|
+
super.includeCallArguments(context, interaction);
|
|
6057
6349
|
if (this.argumentsVariable.included) {
|
|
6058
|
-
|
|
6059
|
-
|
|
6350
|
+
const { args } = interaction;
|
|
6351
|
+
for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) {
|
|
6352
|
+
const argument = args[argumentIndex];
|
|
6353
|
+
if (argument) {
|
|
6354
|
+
argument.includePath(UNKNOWN_PATH, context);
|
|
6060
6355
|
argument.include(context, false);
|
|
6061
6356
|
}
|
|
6062
6357
|
}
|
|
6063
6358
|
}
|
|
6064
6359
|
}
|
|
6360
|
+
addArgumentToBeDeoptimized(argument) {
|
|
6361
|
+
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6362
|
+
}
|
|
6065
6363
|
}
|
|
6066
6364
|
|
|
6067
6365
|
class ExpressionStatement extends NodeBase {
|
|
@@ -6089,8 +6387,9 @@ class ExpressionStatement extends NodeBase {
|
|
|
6089
6387
|
return this.parent.type !== Program$1;
|
|
6090
6388
|
return super.shouldBeIncluded(context);
|
|
6091
6389
|
}
|
|
6092
|
-
applyDeoptimizations() { }
|
|
6093
6390
|
}
|
|
6391
|
+
ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6392
|
+
ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6094
6393
|
|
|
6095
6394
|
class BlockStatement extends NodeBase {
|
|
6096
6395
|
get deoptimizeBody() {
|
|
@@ -6155,6 +6454,8 @@ class BlockStatement extends NodeBase {
|
|
|
6155
6454
|
}
|
|
6156
6455
|
}
|
|
6157
6456
|
}
|
|
6457
|
+
BlockStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6458
|
+
BlockStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6158
6459
|
|
|
6159
6460
|
class RestElement extends NodeBase {
|
|
6160
6461
|
constructor() {
|
|
@@ -6164,9 +6465,12 @@ class RestElement extends NodeBase {
|
|
|
6164
6465
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6165
6466
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6166
6467
|
}
|
|
6167
|
-
declare(kind, init) {
|
|
6468
|
+
declare(kind, destructuredInitPath, init) {
|
|
6168
6469
|
this.declarationInit = init;
|
|
6169
|
-
return this.argument.declare(kind,
|
|
6470
|
+
return this.argument.declare(kind, getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6471
|
+
}
|
|
6472
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
6473
|
+
this.argument.deoptimizeAssignment(getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6170
6474
|
}
|
|
6171
6475
|
deoptimizePath(path) {
|
|
6172
6476
|
if (path.length === 0) {
|
|
@@ -6177,6 +6481,20 @@ class RestElement extends NodeBase {
|
|
|
6177
6481
|
return (path.length > 0 ||
|
|
6178
6482
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
6179
6483
|
}
|
|
6484
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
6485
|
+
return this.argument.hasEffectsWhenDestructuring(context, getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6486
|
+
}
|
|
6487
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
6488
|
+
return (this.included =
|
|
6489
|
+
this.argument.includeDestructuredIfNecessary(context, getIncludedPatternPath$1(destructuredInitPath), init) || this.included);
|
|
6490
|
+
}
|
|
6491
|
+
include(context, includeChildrenRecursively) {
|
|
6492
|
+
if (!this.included)
|
|
6493
|
+
this.includeNode(context);
|
|
6494
|
+
// This should just include the identifier, its properties should be
|
|
6495
|
+
// included where the variable is used.
|
|
6496
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
6497
|
+
}
|
|
6180
6498
|
markDeclarationReached() {
|
|
6181
6499
|
this.argument.markDeclarationReached();
|
|
6182
6500
|
}
|
|
@@ -6188,12 +6506,16 @@ class RestElement extends NodeBase {
|
|
|
6188
6506
|
}
|
|
6189
6507
|
}
|
|
6190
6508
|
}
|
|
6509
|
+
RestElement.prototype.includeNode = onlyIncludeSelf;
|
|
6510
|
+
const getIncludedPatternPath$1 = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
6511
|
+
? destructuredInitPath
|
|
6512
|
+
: [...destructuredInitPath, UnknownKey];
|
|
6191
6513
|
|
|
6192
6514
|
class FunctionBase extends NodeBase {
|
|
6193
6515
|
constructor() {
|
|
6194
6516
|
super(...arguments);
|
|
6195
|
-
this.objectEntity = null;
|
|
6196
6517
|
this.parameterVariableValuesDeoptimized = false;
|
|
6518
|
+
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
6197
6519
|
}
|
|
6198
6520
|
get async() {
|
|
6199
6521
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -6213,53 +6535,15 @@ class FunctionBase extends NodeBase {
|
|
|
6213
6535
|
set generator(value) {
|
|
6214
6536
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
6215
6537
|
}
|
|
6216
|
-
|
|
6217
|
-
|
|
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
|
-
}
|
|
6538
|
+
get hasCachedEffects() {
|
|
6539
|
+
return isFlagSet(this.flags, 67108864 /* Flag.hasEffects */);
|
|
6226
6540
|
}
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
if (parameter instanceof Identifier) {
|
|
6230
|
-
const parameterVariable = parameter.variable;
|
|
6231
|
-
parameterVariable.markReassigned();
|
|
6232
|
-
}
|
|
6233
|
-
}
|
|
6541
|
+
set hasCachedEffects(value) {
|
|
6542
|
+
this.flags = setFlag(this.flags, 67108864 /* Flag.hasEffects */, value);
|
|
6234
6543
|
}
|
|
6235
6544
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6236
|
-
if (interaction.type === INTERACTION_CALLED) {
|
|
6237
|
-
|
|
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);
|
|
6545
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
6546
|
+
this.scope.deoptimizeArgumentsOnCall(interaction);
|
|
6263
6547
|
}
|
|
6264
6548
|
else {
|
|
6265
6549
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -6271,12 +6555,7 @@ class FunctionBase extends NodeBase {
|
|
|
6271
6555
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
6272
6556
|
// which means the return expression and parameters need to be reassigned
|
|
6273
6557
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
6274
|
-
|
|
6275
|
-
for (const parameter of parameterList) {
|
|
6276
|
-
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
6277
|
-
parameter.markReassigned();
|
|
6278
|
-
}
|
|
6279
|
-
}
|
|
6558
|
+
this.scope.deoptimizeAllParameters();
|
|
6280
6559
|
}
|
|
6281
6560
|
}
|
|
6282
6561
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6300,8 +6579,8 @@ class FunctionBase extends NodeBase {
|
|
|
6300
6579
|
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
6301
6580
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6302
6581
|
}
|
|
6303
|
-
if (this.
|
|
6304
|
-
return
|
|
6582
|
+
if (this.hasCachedEffects) {
|
|
6583
|
+
return true;
|
|
6305
6584
|
}
|
|
6306
6585
|
if (this.async) {
|
|
6307
6586
|
const { propertyReadSideEffects } = this.scope.context.options
|
|
@@ -6311,12 +6590,20 @@ class FunctionBase extends NodeBase {
|
|
|
6311
6590
|
(propertyReadSideEffects &&
|
|
6312
6591
|
(propertyReadSideEffects === 'always' ||
|
|
6313
6592
|
returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_ACCESS, context)))) {
|
|
6593
|
+
this.hasCachedEffects = true;
|
|
6314
6594
|
return true;
|
|
6315
6595
|
}
|
|
6316
6596
|
}
|
|
6317
|
-
|
|
6318
|
-
|
|
6597
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
6598
|
+
.treeshake;
|
|
6599
|
+
for (let index = 0; index < this.params.length; index++) {
|
|
6600
|
+
const parameter = this.params[index];
|
|
6601
|
+
if (parameter.hasEffects(context) ||
|
|
6602
|
+
(propertyReadSideEffects &&
|
|
6603
|
+
parameter.hasEffectsWhenDestructuring(context, EMPTY_PATH, interaction.args[index + 1] || UNDEFINED_EXPRESSION))) {
|
|
6604
|
+
this.hasCachedEffects = true;
|
|
6319
6605
|
return true;
|
|
6606
|
+
}
|
|
6320
6607
|
}
|
|
6321
6608
|
return false;
|
|
6322
6609
|
}
|
|
@@ -6334,21 +6621,17 @@ class FunctionBase extends NodeBase {
|
|
|
6334
6621
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
6335
6622
|
}
|
|
6336
6623
|
include(context, includeChildrenRecursively) {
|
|
6337
|
-
if (!this.
|
|
6624
|
+
if (!this.included)
|
|
6625
|
+
this.includeNode(context);
|
|
6626
|
+
if (!(this.parameterVariableValuesDeoptimized || this.onlyFunctionCallUsed())) {
|
|
6338
6627
|
this.parameterVariableValuesDeoptimized = true;
|
|
6339
|
-
this.
|
|
6628
|
+
this.scope.reassignAllParameters();
|
|
6340
6629
|
}
|
|
6341
|
-
if (!this.deoptimized)
|
|
6342
|
-
this.applyDeoptimizations();
|
|
6343
|
-
this.included = true;
|
|
6344
6630
|
const { brokenFlow } = context;
|
|
6345
6631
|
context.brokenFlow = false;
|
|
6346
6632
|
this.body.include(context, includeChildrenRecursively);
|
|
6347
6633
|
context.brokenFlow = brokenFlow;
|
|
6348
6634
|
}
|
|
6349
|
-
includeCallArguments(context, parameters) {
|
|
6350
|
-
this.scope.includeCallArguments(context, parameters);
|
|
6351
|
-
}
|
|
6352
6635
|
initialise() {
|
|
6353
6636
|
super.initialise();
|
|
6354
6637
|
if (this.body instanceof BlockStatement) {
|
|
@@ -6370,14 +6653,14 @@ class FunctionBase extends NodeBase {
|
|
|
6370
6653
|
// so that the scope already knows all parameters and can detect conflicts
|
|
6371
6654
|
// when parsing the body.
|
|
6372
6655
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
6373
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
6656
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
6374
6657
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
6375
6658
|
return super.parseNode(esTreeNode);
|
|
6376
6659
|
}
|
|
6377
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
6378
|
-
applyDeoptimizations() { }
|
|
6379
6660
|
}
|
|
6380
6661
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
6662
|
+
FunctionBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6663
|
+
FunctionBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6381
6664
|
|
|
6382
6665
|
class FunctionNode extends FunctionBase {
|
|
6383
6666
|
constructor() {
|
|
@@ -6389,30 +6672,31 @@ class FunctionNode extends FunctionBase {
|
|
|
6389
6672
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
6390
6673
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
6391
6674
|
// constructed entity.
|
|
6392
|
-
this.scope.thisVariable.
|
|
6675
|
+
this.scope.thisVariable.addArgumentValue(this.constructedEntity);
|
|
6393
6676
|
}
|
|
6394
6677
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6395
6678
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6396
6679
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
6397
6680
|
// args[0] is the "this" argument
|
|
6398
|
-
this.scope.thisVariable.
|
|
6681
|
+
this.scope.thisVariable.addArgumentValue(interaction.args[0]);
|
|
6399
6682
|
}
|
|
6400
6683
|
}
|
|
6401
6684
|
hasEffects(context) {
|
|
6402
|
-
if (!this.deoptimized)
|
|
6403
|
-
this.applyDeoptimizations();
|
|
6404
6685
|
if (this.annotationNoSideEffects) {
|
|
6405
6686
|
return false;
|
|
6406
6687
|
}
|
|
6407
6688
|
return !!this.id?.hasEffects(context);
|
|
6408
6689
|
}
|
|
6409
6690
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6410
|
-
if (
|
|
6411
|
-
|
|
6412
|
-
|
|
6691
|
+
if (this.annotationNoSideEffects &&
|
|
6692
|
+
path.length === 0 &&
|
|
6693
|
+
interaction.type === INTERACTION_CALLED) {
|
|
6413
6694
|
return false;
|
|
6414
6695
|
}
|
|
6415
|
-
if (
|
|
6696
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) {
|
|
6697
|
+
return true;
|
|
6698
|
+
}
|
|
6699
|
+
if (path.length === 0 && interaction.type === INTERACTION_CALLED) {
|
|
6416
6700
|
const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
|
|
6417
6701
|
context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew ? this.constructedEntity : UNKNOWN_EXPRESSION);
|
|
6418
6702
|
const { brokenFlow, ignore, replacedVariableInits } = context;
|
|
@@ -6423,8 +6707,10 @@ class FunctionNode extends FunctionBase {
|
|
|
6423
6707
|
returnYield: true,
|
|
6424
6708
|
this: interaction.withNew
|
|
6425
6709
|
};
|
|
6426
|
-
if (this.body.hasEffects(context))
|
|
6710
|
+
if (this.body.hasEffects(context)) {
|
|
6711
|
+
this.hasCachedEffects = true;
|
|
6427
6712
|
return true;
|
|
6713
|
+
}
|
|
6428
6714
|
context.brokenFlow = brokenFlow;
|
|
6429
6715
|
if (thisInit) {
|
|
6430
6716
|
replacedVariableInits.set(this.scope.thisVariable, thisInit);
|
|
@@ -6438,7 +6724,7 @@ class FunctionNode extends FunctionBase {
|
|
|
6438
6724
|
}
|
|
6439
6725
|
include(context, includeChildrenRecursively) {
|
|
6440
6726
|
super.include(context, includeChildrenRecursively);
|
|
6441
|
-
this.id?.include();
|
|
6727
|
+
this.id?.include(context);
|
|
6442
6728
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
6443
6729
|
for (const parameter of this.params) {
|
|
6444
6730
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
@@ -6446,12 +6732,18 @@ class FunctionNode extends FunctionBase {
|
|
|
6446
6732
|
}
|
|
6447
6733
|
}
|
|
6448
6734
|
}
|
|
6735
|
+
includeNode(context) {
|
|
6736
|
+
this.included = true;
|
|
6737
|
+
const hasArguments = this.scope.argumentsVariable.included;
|
|
6738
|
+
for (const parameter of this.params) {
|
|
6739
|
+
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
6740
|
+
parameter.includePath(UNKNOWN_PATH, context);
|
|
6741
|
+
}
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6449
6744
|
initialise() {
|
|
6450
6745
|
super.initialise();
|
|
6451
|
-
this.id?.declare('function', this);
|
|
6452
|
-
}
|
|
6453
|
-
addArgumentToBeDeoptimized(argument) {
|
|
6454
|
-
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6746
|
+
this.id?.declare('function', EMPTY_PATH, this);
|
|
6455
6747
|
}
|
|
6456
6748
|
getObjectEntity() {
|
|
6457
6749
|
if (this.objectEntity !== null) {
|
|
@@ -6501,11 +6793,16 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
6501
6793
|
}
|
|
6502
6794
|
class ExportDefaultDeclaration extends NodeBase {
|
|
6503
6795
|
include(context, includeChildrenRecursively) {
|
|
6504
|
-
|
|
6796
|
+
this.included = true;
|
|
6797
|
+
this.declaration.include(context, includeChildrenRecursively);
|
|
6505
6798
|
if (includeChildrenRecursively) {
|
|
6506
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
6799
|
+
this.scope.context.includeVariableInModule(this.variable, UNKNOWN_PATH, context);
|
|
6507
6800
|
}
|
|
6508
6801
|
}
|
|
6802
|
+
includePath(path, context) {
|
|
6803
|
+
this.included = true;
|
|
6804
|
+
this.declaration.includePath(path, context);
|
|
6805
|
+
}
|
|
6509
6806
|
initialise() {
|
|
6510
6807
|
super.initialise();
|
|
6511
6808
|
const declaration = this.declaration;
|
|
@@ -6550,7 +6847,6 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6550
6847
|
}
|
|
6551
6848
|
this.declaration.render(code, options);
|
|
6552
6849
|
}
|
|
6553
|
-
applyDeoptimizations() { }
|
|
6554
6850
|
renderNamedDeclaration(code, declarationStart, idInsertPosition, options) {
|
|
6555
6851
|
const { exportNamesByVariable, format, snippets: { getPropertyAccess } } = options;
|
|
6556
6852
|
const name = this.variable.getName(getPropertyAccess);
|
|
@@ -6581,6 +6877,8 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6581
6877
|
}
|
|
6582
6878
|
}
|
|
6583
6879
|
ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
6880
|
+
ExportDefaultDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6881
|
+
ExportDefaultDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6584
6882
|
|
|
6585
6883
|
const needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/;
|
|
6586
6884
|
const quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g;
|
|
@@ -6850,6 +7148,7 @@ class Literal extends NodeBase {
|
|
|
6850
7148
|
}
|
|
6851
7149
|
}
|
|
6852
7150
|
}
|
|
7151
|
+
Literal.prototype.includeNode = onlyIncludeSelf;
|
|
6853
7152
|
|
|
6854
7153
|
function getChainElementLiteralValueAtPath(element, object, path, recursionTracker, origin) {
|
|
6855
7154
|
if ('getLiteralValueAtPathAsChainElement' in object) {
|
|
@@ -6865,8 +7164,6 @@ function getChainElementLiteralValueAtPath(element, object, path, recursionTrack
|
|
|
6865
7164
|
return element.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6866
7165
|
}
|
|
6867
7166
|
|
|
6868
|
-
// To avoid infinite recursions
|
|
6869
|
-
const MAX_PATH_DEPTH = 7;
|
|
6870
7167
|
function getResolvablePropertyKey(memberExpression) {
|
|
6871
7168
|
return memberExpression.computed
|
|
6872
7169
|
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
@@ -6965,18 +7262,27 @@ class MemberExpression extends NodeBase {
|
|
|
6965
7262
|
}
|
|
6966
7263
|
else if (!this.isUndefined) {
|
|
6967
7264
|
if (path.length < MAX_PATH_DEPTH) {
|
|
6968
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.
|
|
7265
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, this.propertyKey === UnknownKey ? UNKNOWN_PATH : [this.propertyKey, ...path], recursionTracker);
|
|
6969
7266
|
}
|
|
6970
7267
|
else {
|
|
6971
7268
|
deoptimizeInteraction(interaction);
|
|
6972
7269
|
}
|
|
6973
7270
|
}
|
|
6974
7271
|
}
|
|
7272
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
7273
|
+
this.deoptimizePath(EMPTY_PATH);
|
|
7274
|
+
init.deoptimizePath([...destructuredInitPath, UnknownKey]);
|
|
7275
|
+
}
|
|
6975
7276
|
deoptimizeCache() {
|
|
7277
|
+
if (this.propertyKey === this.dynamicPropertyKey)
|
|
7278
|
+
return;
|
|
6976
7279
|
const { expressionsToBeDeoptimized, object } = this;
|
|
6977
7280
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
6978
|
-
this.
|
|
7281
|
+
this.dynamicPropertyKey = this.propertyKey;
|
|
6979
7282
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
7283
|
+
if (this.included) {
|
|
7284
|
+
object.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
7285
|
+
}
|
|
6980
7286
|
for (const expression of expressionsToBeDeoptimized) {
|
|
6981
7287
|
expression.deoptimizeCache();
|
|
6982
7288
|
}
|
|
@@ -6987,11 +7293,13 @@ class MemberExpression extends NodeBase {
|
|
|
6987
7293
|
if (this.variable) {
|
|
6988
7294
|
this.variable.deoptimizePath(path);
|
|
6989
7295
|
}
|
|
6990
|
-
else if (!this.isUndefined
|
|
6991
|
-
const propertyKey = this
|
|
7296
|
+
else if (!this.isUndefined) {
|
|
7297
|
+
const { propertyKey } = this;
|
|
6992
7298
|
this.object.deoptimizePath([
|
|
6993
7299
|
propertyKey === UnknownKey ? UnknownNonAccessorKey : propertyKey,
|
|
6994
|
-
...path
|
|
7300
|
+
...(path.length < MAX_PATH_DEPTH
|
|
7301
|
+
? path
|
|
7302
|
+
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
6995
7303
|
]);
|
|
6996
7304
|
}
|
|
6997
7305
|
}
|
|
@@ -7002,9 +7310,11 @@ class MemberExpression extends NodeBase {
|
|
|
7002
7310
|
if (this.isUndefined) {
|
|
7003
7311
|
return undefined;
|
|
7004
7312
|
}
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7313
|
+
const propertyKey = this.getDynamicPropertyKey();
|
|
7314
|
+
if (propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7315
|
+
if (propertyKey !== this.propertyKey)
|
|
7316
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7317
|
+
return this.object.getLiteralValueAtPath([propertyKey, ...path], recursionTracker, origin);
|
|
7008
7318
|
}
|
|
7009
7319
|
return UnknownValue;
|
|
7010
7320
|
}
|
|
@@ -7024,9 +7334,11 @@ class MemberExpression extends NodeBase {
|
|
|
7024
7334
|
if (this.isUndefined) {
|
|
7025
7335
|
return [UNDEFINED_EXPRESSION, false];
|
|
7026
7336
|
}
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7337
|
+
const propertyKey = this.getDynamicPropertyKey();
|
|
7338
|
+
if (propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7339
|
+
if (propertyKey !== this.propertyKey)
|
|
7340
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7341
|
+
return this.object.getReturnExpressionWhenCalledAtPath([propertyKey, ...path], interaction, recursionTracker, origin);
|
|
7030
7342
|
}
|
|
7031
7343
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
7032
7344
|
}
|
|
@@ -7072,14 +7384,45 @@ class MemberExpression extends NodeBase {
|
|
|
7072
7384
|
return true;
|
|
7073
7385
|
}
|
|
7074
7386
|
if (path.length < MAX_PATH_DEPTH) {
|
|
7075
|
-
return this.object.hasEffectsOnInteractionAtPath([this.
|
|
7387
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getDynamicPropertyKey(), ...path], interaction, context);
|
|
7076
7388
|
}
|
|
7077
7389
|
return true;
|
|
7078
7390
|
}
|
|
7391
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
7392
|
+
return (destructuredInitPath.length > 0 &&
|
|
7393
|
+
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7394
|
+
}
|
|
7079
7395
|
include(context, includeChildrenRecursively) {
|
|
7396
|
+
if (!this.included)
|
|
7397
|
+
this.includeNode(context);
|
|
7398
|
+
this.object.include(context, includeChildrenRecursively);
|
|
7399
|
+
this.property.include(context, includeChildrenRecursively);
|
|
7400
|
+
}
|
|
7401
|
+
includeNode(context) {
|
|
7402
|
+
this.included = true;
|
|
7080
7403
|
if (!this.deoptimized)
|
|
7081
7404
|
this.applyDeoptimizations();
|
|
7082
|
-
this.
|
|
7405
|
+
if (this.variable) {
|
|
7406
|
+
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
7407
|
+
}
|
|
7408
|
+
else if (!this.isUndefined) {
|
|
7409
|
+
this.object.includePath([this.propertyKey], context);
|
|
7410
|
+
}
|
|
7411
|
+
}
|
|
7412
|
+
includePath(path, context) {
|
|
7413
|
+
if (!this.included)
|
|
7414
|
+
this.includeNode(context);
|
|
7415
|
+
if (this.variable) {
|
|
7416
|
+
this.variable?.includePath(path, context);
|
|
7417
|
+
}
|
|
7418
|
+
else if (!this.isUndefined) {
|
|
7419
|
+
this.object.includePath([
|
|
7420
|
+
this.propertyKey,
|
|
7421
|
+
...(path.length < MAX_PATH_DEPTH
|
|
7422
|
+
? path
|
|
7423
|
+
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
7424
|
+
], context);
|
|
7425
|
+
}
|
|
7083
7426
|
}
|
|
7084
7427
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
7085
7428
|
if (!this.assignmentDeoptimized)
|
|
@@ -7088,20 +7431,34 @@ class MemberExpression extends NodeBase {
|
|
|
7088
7431
|
this.include(context, includeChildrenRecursively);
|
|
7089
7432
|
}
|
|
7090
7433
|
else {
|
|
7091
|
-
this.
|
|
7434
|
+
if (!this.included)
|
|
7435
|
+
this.includeNode(context);
|
|
7436
|
+
this.object.include(context, includeChildrenRecursively);
|
|
7437
|
+
this.property.include(context, includeChildrenRecursively);
|
|
7092
7438
|
}
|
|
7093
7439
|
}
|
|
7094
|
-
includeCallArguments(context,
|
|
7440
|
+
includeCallArguments(context, interaction) {
|
|
7095
7441
|
if (this.variable) {
|
|
7096
|
-
this.variable.includeCallArguments(context,
|
|
7442
|
+
this.variable.includeCallArguments(context, interaction);
|
|
7097
7443
|
}
|
|
7098
7444
|
else {
|
|
7099
|
-
super.includeCallArguments(context,
|
|
7445
|
+
super.includeCallArguments(context, interaction);
|
|
7446
|
+
}
|
|
7447
|
+
}
|
|
7448
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
7449
|
+
if ((this.included ||=
|
|
7450
|
+
destructuredInitPath.length > 0 &&
|
|
7451
|
+
!context.brokenFlow &&
|
|
7452
|
+
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext()))) {
|
|
7453
|
+
init.include(context, false);
|
|
7454
|
+
return true;
|
|
7100
7455
|
}
|
|
7456
|
+
return false;
|
|
7101
7457
|
}
|
|
7102
7458
|
initialise() {
|
|
7103
7459
|
super.initialise();
|
|
7104
|
-
this.
|
|
7460
|
+
this.dynamicPropertyKey = getResolvablePropertyKey(this);
|
|
7461
|
+
this.propertyKey = this.dynamicPropertyKey === null ? UnknownKey : this.dynamicPropertyKey;
|
|
7105
7462
|
this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
|
|
7106
7463
|
}
|
|
7107
7464
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
@@ -7138,8 +7495,7 @@ class MemberExpression extends NodeBase {
|
|
|
7138
7495
|
this.bound &&
|
|
7139
7496
|
propertyReadSideEffects &&
|
|
7140
7497
|
!(this.variable || this.isUndefined)) {
|
|
7141
|
-
|
|
7142
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
7498
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [this.propertyKey], SHARED_RECURSION_TRACKER);
|
|
7143
7499
|
this.scope.context.requestTreeshakingPass();
|
|
7144
7500
|
}
|
|
7145
7501
|
if (this.variable) {
|
|
@@ -7156,7 +7512,7 @@ class MemberExpression extends NodeBase {
|
|
|
7156
7512
|
this.bound &&
|
|
7157
7513
|
propertyReadSideEffects &&
|
|
7158
7514
|
!(this.variable || this.isUndefined)) {
|
|
7159
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.
|
|
7515
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.propertyKey], SHARED_RECURSION_TRACKER);
|
|
7160
7516
|
this.scope.context.requestTreeshakingPass();
|
|
7161
7517
|
}
|
|
7162
7518
|
}
|
|
@@ -7165,24 +7521,24 @@ class MemberExpression extends NodeBase {
|
|
|
7165
7521
|
const variable = this.scope.findVariable(this.object.name);
|
|
7166
7522
|
if (variable.isNamespace) {
|
|
7167
7523
|
if (this.variable) {
|
|
7168
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
7524
|
+
this.scope.context.includeVariableInModule(this.variable, UNKNOWN_PATH, createInclusionContext());
|
|
7169
7525
|
}
|
|
7170
7526
|
this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
7171
7527
|
}
|
|
7172
7528
|
}
|
|
7173
7529
|
}
|
|
7174
|
-
|
|
7175
|
-
if (this.
|
|
7176
|
-
this.
|
|
7530
|
+
getDynamicPropertyKey() {
|
|
7531
|
+
if (this.dynamicPropertyKey === null) {
|
|
7532
|
+
this.dynamicPropertyKey = this.propertyKey;
|
|
7177
7533
|
const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7178
|
-
return (this.
|
|
7534
|
+
return (this.dynamicPropertyKey =
|
|
7179
7535
|
value === SymbolToStringTag
|
|
7180
7536
|
? value
|
|
7181
7537
|
: typeof value === 'symbol'
|
|
7182
7538
|
? UnknownKey
|
|
7183
7539
|
: String(value));
|
|
7184
7540
|
}
|
|
7185
|
-
return this.
|
|
7541
|
+
return this.dynamicPropertyKey;
|
|
7186
7542
|
}
|
|
7187
7543
|
hasAccessEffect(context) {
|
|
7188
7544
|
const { propertyReadSideEffects } = this.scope.context.options
|
|
@@ -7190,17 +7546,7 @@ class MemberExpression extends NodeBase {
|
|
|
7190
7546
|
return (!(this.variable || this.isUndefined) &&
|
|
7191
7547
|
propertyReadSideEffects &&
|
|
7192
7548
|
(propertyReadSideEffects === 'always' ||
|
|
7193
|
-
this.object.hasEffectsOnInteractionAtPath([this.
|
|
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);
|
|
7549
|
+
this.object.hasEffectsOnInteractionAtPath([this.getDynamicPropertyKey()], this.accessInteraction, context)));
|
|
7204
7550
|
}
|
|
7205
7551
|
}
|
|
7206
7552
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -7244,18 +7590,20 @@ class MetaProperty extends NodeBase {
|
|
|
7244
7590
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
7245
7591
|
}
|
|
7246
7592
|
include() {
|
|
7247
|
-
if (!this.included)
|
|
7248
|
-
this.
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7593
|
+
if (!this.included)
|
|
7594
|
+
this.includeNode();
|
|
7595
|
+
}
|
|
7596
|
+
includeNode() {
|
|
7597
|
+
this.included = true;
|
|
7598
|
+
if (this.meta.name === IMPORT) {
|
|
7599
|
+
this.scope.context.addImportMeta(this);
|
|
7600
|
+
const parent = this.parent;
|
|
7601
|
+
const metaProperty = (this.metaProperty =
|
|
7602
|
+
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
7603
|
+
? parent.propertyKey
|
|
7604
|
+
: null);
|
|
7605
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
7606
|
+
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
7259
7607
|
}
|
|
7260
7608
|
}
|
|
7261
7609
|
}
|
|
@@ -7362,7 +7710,7 @@ class UndefinedVariable extends Variable {
|
|
|
7362
7710
|
|
|
7363
7711
|
class ExportDefaultVariable extends LocalVariable {
|
|
7364
7712
|
constructor(name, exportDefaultDeclaration, context) {
|
|
7365
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
7713
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
|
|
7366
7714
|
this.hasId = false;
|
|
7367
7715
|
this.originalId = null;
|
|
7368
7716
|
this.originalVariable = null;
|
|
@@ -7511,8 +7859,8 @@ class NamespaceVariable extends Variable {
|
|
|
7511
7859
|
return (!memberVariable ||
|
|
7512
7860
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
7513
7861
|
}
|
|
7514
|
-
|
|
7515
|
-
super.
|
|
7862
|
+
includePath(path, context) {
|
|
7863
|
+
super.includePath(path, context);
|
|
7516
7864
|
this.context.includeAllExports();
|
|
7517
7865
|
}
|
|
7518
7866
|
prepare(accessedGlobalsByScope) {
|
|
@@ -7605,9 +7953,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
7605
7953
|
getName(getPropertyAccess) {
|
|
7606
7954
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
7607
7955
|
}
|
|
7608
|
-
|
|
7609
|
-
super.
|
|
7610
|
-
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
7956
|
+
includePath(path, context) {
|
|
7957
|
+
super.includePath(path, context);
|
|
7958
|
+
this.context.includeVariableInModule(this.syntheticNamespace, path, context);
|
|
7611
7959
|
}
|
|
7612
7960
|
setRenderNames(baseName, name) {
|
|
7613
7961
|
super.setRenderNames(baseName, name);
|
|
@@ -10812,21 +11160,37 @@ class ArrayPattern extends NodeBase {
|
|
|
10812
11160
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
10813
11161
|
}
|
|
10814
11162
|
}
|
|
10815
|
-
declare(kind) {
|
|
11163
|
+
declare(kind, destructuredInitPath, init) {
|
|
10816
11164
|
const variables = [];
|
|
11165
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
10817
11166
|
for (const element of this.elements) {
|
|
10818
11167
|
if (element !== null) {
|
|
10819
|
-
variables.push(...element.declare(kind,
|
|
11168
|
+
variables.push(...element.declare(kind, includedPatternPath, init));
|
|
10820
11169
|
}
|
|
10821
11170
|
}
|
|
10822
11171
|
return variables;
|
|
10823
11172
|
}
|
|
11173
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11174
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11175
|
+
for (const element of this.elements) {
|
|
11176
|
+
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
11177
|
+
}
|
|
11178
|
+
}
|
|
10824
11179
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
10825
11180
|
deoptimizePath() {
|
|
10826
11181
|
for (const element of this.elements) {
|
|
10827
11182
|
element?.deoptimizePath(EMPTY_PATH);
|
|
10828
11183
|
}
|
|
10829
11184
|
}
|
|
11185
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11186
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11187
|
+
for (const element of this.elements) {
|
|
11188
|
+
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
11189
|
+
return true;
|
|
11190
|
+
}
|
|
11191
|
+
}
|
|
11192
|
+
return false;
|
|
11193
|
+
}
|
|
10830
11194
|
// Patterns are only checked at the empty path at the moment
|
|
10831
11195
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
10832
11196
|
for (const element of this.elements) {
|
|
@@ -10835,12 +11199,38 @@ class ArrayPattern extends NodeBase {
|
|
|
10835
11199
|
}
|
|
10836
11200
|
return false;
|
|
10837
11201
|
}
|
|
11202
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11203
|
+
let included = false;
|
|
11204
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11205
|
+
for (const element of this.elements) {
|
|
11206
|
+
if (element) {
|
|
11207
|
+
element.included ||= included;
|
|
11208
|
+
included =
|
|
11209
|
+
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
11210
|
+
}
|
|
11211
|
+
}
|
|
11212
|
+
if (included) {
|
|
11213
|
+
// This is necessary so that if any pattern element is included, all are
|
|
11214
|
+
// included for proper deconflicting
|
|
11215
|
+
for (const element of this.elements) {
|
|
11216
|
+
if (element && !element.included) {
|
|
11217
|
+
element.included = true;
|
|
11218
|
+
element.includeDestructuredIfNecessary(context, includedPatternPath, init);
|
|
11219
|
+
}
|
|
11220
|
+
}
|
|
11221
|
+
}
|
|
11222
|
+
return (this.included ||= included);
|
|
11223
|
+
}
|
|
10838
11224
|
markDeclarationReached() {
|
|
10839
11225
|
for (const element of this.elements) {
|
|
10840
11226
|
element?.markDeclarationReached();
|
|
10841
11227
|
}
|
|
10842
11228
|
}
|
|
10843
11229
|
}
|
|
11230
|
+
ArrayPattern.prototype.includeNode = onlyIncludeSelf;
|
|
11231
|
+
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
11232
|
+
? destructuredInitPath
|
|
11233
|
+
: [...destructuredInitPath, UnknownInteger];
|
|
10844
11234
|
|
|
10845
11235
|
class ArrowFunctionExpression extends FunctionBase {
|
|
10846
11236
|
constructor() {
|
|
@@ -10857,17 +11247,17 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
10857
11247
|
this.scope = new ReturnValueScope(parentScope, false);
|
|
10858
11248
|
}
|
|
10859
11249
|
hasEffects() {
|
|
10860
|
-
if (!this.deoptimized)
|
|
10861
|
-
this.applyDeoptimizations();
|
|
10862
11250
|
return false;
|
|
10863
11251
|
}
|
|
10864
11252
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11253
|
+
if (this.annotationNoSideEffects &&
|
|
11254
|
+
path.length === 0 &&
|
|
11255
|
+
interaction.type === INTERACTION_CALLED) {
|
|
11256
|
+
return false;
|
|
11257
|
+
}
|
|
10865
11258
|
if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) {
|
|
10866
11259
|
return true;
|
|
10867
11260
|
}
|
|
10868
|
-
if (this.annotationNoSideEffects) {
|
|
10869
|
-
return false;
|
|
10870
|
-
}
|
|
10871
11261
|
if (interaction.type === INTERACTION_CALLED) {
|
|
10872
11262
|
const { ignore, brokenFlow } = context;
|
|
10873
11263
|
context.ignore = {
|
|
@@ -10897,6 +11287,15 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
10897
11287
|
}
|
|
10898
11288
|
}
|
|
10899
11289
|
}
|
|
11290
|
+
includeNode(context) {
|
|
11291
|
+
this.included = true;
|
|
11292
|
+
this.body.includePath(UNKNOWN_PATH, context);
|
|
11293
|
+
for (const parameter of this.params) {
|
|
11294
|
+
if (!(parameter instanceof Identifier)) {
|
|
11295
|
+
parameter.includePath(UNKNOWN_PATH, context);
|
|
11296
|
+
}
|
|
11297
|
+
}
|
|
11298
|
+
}
|
|
10900
11299
|
getObjectEntity() {
|
|
10901
11300
|
if (this.objectEntity !== null) {
|
|
10902
11301
|
return this.objectEntity;
|
|
@@ -10916,13 +11315,18 @@ class ObjectPattern extends NodeBase {
|
|
|
10916
11315
|
}
|
|
10917
11316
|
}
|
|
10918
11317
|
}
|
|
10919
|
-
declare(kind, init) {
|
|
11318
|
+
declare(kind, destructuredInitPath, init) {
|
|
10920
11319
|
const variables = [];
|
|
10921
11320
|
for (const property of this.properties) {
|
|
10922
|
-
variables.push(...property.declare(kind, init));
|
|
11321
|
+
variables.push(...property.declare(kind, destructuredInitPath, init));
|
|
10923
11322
|
}
|
|
10924
11323
|
return variables;
|
|
10925
11324
|
}
|
|
11325
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11326
|
+
for (const property of this.properties) {
|
|
11327
|
+
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
11328
|
+
}
|
|
11329
|
+
}
|
|
10926
11330
|
deoptimizePath(path) {
|
|
10927
11331
|
if (path.length === 0) {
|
|
10928
11332
|
for (const property of this.properties) {
|
|
@@ -10940,12 +11344,46 @@ class ObjectPattern extends NodeBase {
|
|
|
10940
11344
|
}
|
|
10941
11345
|
return false;
|
|
10942
11346
|
}
|
|
11347
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11348
|
+
for (const property of this.properties) {
|
|
11349
|
+
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
11350
|
+
return true;
|
|
11351
|
+
}
|
|
11352
|
+
return false;
|
|
11353
|
+
}
|
|
11354
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11355
|
+
let included = false;
|
|
11356
|
+
for (const property of this.properties) {
|
|
11357
|
+
included =
|
|
11358
|
+
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
11359
|
+
}
|
|
11360
|
+
return (this.included ||= included);
|
|
11361
|
+
}
|
|
10943
11362
|
markDeclarationReached() {
|
|
10944
11363
|
for (const property of this.properties) {
|
|
10945
11364
|
property.markDeclarationReached();
|
|
10946
11365
|
}
|
|
10947
11366
|
}
|
|
11367
|
+
render(code, options) {
|
|
11368
|
+
if (this.properties.length > 0) {
|
|
11369
|
+
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
11370
|
+
let lastSeparatorPos = null;
|
|
11371
|
+
for (const { node, separator, start, end } of separatedNodes) {
|
|
11372
|
+
if (!node.included) {
|
|
11373
|
+
treeshakeNode(node, code, start, end);
|
|
11374
|
+
continue;
|
|
11375
|
+
}
|
|
11376
|
+
lastSeparatorPos = separator;
|
|
11377
|
+
node.render(code, options);
|
|
11378
|
+
}
|
|
11379
|
+
if (lastSeparatorPos) {
|
|
11380
|
+
code.remove(lastSeparatorPos, this.end - 1);
|
|
11381
|
+
}
|
|
11382
|
+
}
|
|
11383
|
+
}
|
|
10948
11384
|
}
|
|
11385
|
+
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11386
|
+
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
10949
11387
|
|
|
10950
11388
|
class AssignmentExpression extends NodeBase {
|
|
10951
11389
|
hasEffects(context) {
|
|
@@ -10954,7 +11392,9 @@ class AssignmentExpression extends NodeBase {
|
|
|
10954
11392
|
this.applyDeoptimizations();
|
|
10955
11393
|
// MemberExpressions do not access the property before assignments if the
|
|
10956
11394
|
// operator is '='.
|
|
10957
|
-
return (right.hasEffects(context) ||
|
|
11395
|
+
return (right.hasEffects(context) ||
|
|
11396
|
+
left.hasEffectsAsAssignmentTarget(context, operator !== '=') ||
|
|
11397
|
+
this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right));
|
|
10958
11398
|
}
|
|
10959
11399
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10960
11400
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -10963,15 +11403,24 @@ class AssignmentExpression extends NodeBase {
|
|
|
10963
11403
|
const { deoptimized, left, right, operator } = this;
|
|
10964
11404
|
if (!deoptimized)
|
|
10965
11405
|
this.applyDeoptimizations();
|
|
10966
|
-
this.included
|
|
11406
|
+
if (!this.included)
|
|
11407
|
+
this.includeNode(context);
|
|
11408
|
+
const hasEffectsContext = createHasEffectsContext();
|
|
10967
11409
|
if (includeChildrenRecursively ||
|
|
10968
11410
|
operator !== '=' ||
|
|
10969
11411
|
left.included ||
|
|
10970
|
-
left.hasEffectsAsAssignmentTarget(
|
|
11412
|
+
left.hasEffectsAsAssignmentTarget(hasEffectsContext, false) ||
|
|
11413
|
+
left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right)) {
|
|
10971
11414
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
10972
11415
|
}
|
|
10973
11416
|
right.include(context, includeChildrenRecursively);
|
|
10974
11417
|
}
|
|
11418
|
+
includeNode(context) {
|
|
11419
|
+
this.included = true;
|
|
11420
|
+
if (!this.deoptimized)
|
|
11421
|
+
this.applyDeoptimizations();
|
|
11422
|
+
this.right.includePath(UNKNOWN_PATH, context);
|
|
11423
|
+
}
|
|
10975
11424
|
initialise() {
|
|
10976
11425
|
super.initialise();
|
|
10977
11426
|
if (this.left instanceof Identifier) {
|
|
@@ -11032,8 +11481,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
11032
11481
|
}
|
|
11033
11482
|
applyDeoptimizations() {
|
|
11034
11483
|
this.deoptimized = true;
|
|
11035
|
-
this.left.
|
|
11036
|
-
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
11484
|
+
this.left.deoptimizeAssignment(EMPTY_PATH, this.right);
|
|
11037
11485
|
this.scope.context.requestTreeshakingPass();
|
|
11038
11486
|
}
|
|
11039
11487
|
}
|
|
@@ -11042,8 +11490,11 @@ class AssignmentPattern extends NodeBase {
|
|
|
11042
11490
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
11043
11491
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
11044
11492
|
}
|
|
11045
|
-
declare(kind, init) {
|
|
11046
|
-
return this.left.declare(kind, init);
|
|
11493
|
+
declare(kind, destructuredInitPath, init) {
|
|
11494
|
+
return this.left.declare(kind, destructuredInitPath, init);
|
|
11495
|
+
}
|
|
11496
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11497
|
+
this.left.deoptimizeAssignment(destructuredInitPath, init);
|
|
11047
11498
|
}
|
|
11048
11499
|
deoptimizePath(path) {
|
|
11049
11500
|
if (path.length === 0) {
|
|
@@ -11053,6 +11504,29 @@ class AssignmentPattern extends NodeBase {
|
|
|
11053
11504
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11054
11505
|
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
11055
11506
|
}
|
|
11507
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11508
|
+
return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init);
|
|
11509
|
+
}
|
|
11510
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11511
|
+
let included = this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) ||
|
|
11512
|
+
this.included;
|
|
11513
|
+
if ((included ||= this.right.shouldBeIncluded(context))) {
|
|
11514
|
+
this.right.include(context, false);
|
|
11515
|
+
if (!this.left.included) {
|
|
11516
|
+
this.left.included = true;
|
|
11517
|
+
// Unfortunately, we need to include the left side again now, so that
|
|
11518
|
+
// any declared variables are properly included.
|
|
11519
|
+
this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
11520
|
+
}
|
|
11521
|
+
}
|
|
11522
|
+
return (this.included = included);
|
|
11523
|
+
}
|
|
11524
|
+
includeNode(context) {
|
|
11525
|
+
this.included = true;
|
|
11526
|
+
if (!this.deoptimized)
|
|
11527
|
+
this.applyDeoptimizations();
|
|
11528
|
+
this.right.includePath(UNKNOWN_PATH, context);
|
|
11529
|
+
}
|
|
11056
11530
|
markDeclarationReached() {
|
|
11057
11531
|
this.left.markDeclarationReached();
|
|
11058
11532
|
}
|
|
@@ -11075,22 +11549,34 @@ class AwaitExpression extends NodeBase {
|
|
|
11075
11549
|
return true;
|
|
11076
11550
|
}
|
|
11077
11551
|
include(context, includeChildrenRecursively) {
|
|
11552
|
+
if (!this.included)
|
|
11553
|
+
this.includeNode(context);
|
|
11554
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
11555
|
+
}
|
|
11556
|
+
includeNode(context) {
|
|
11557
|
+
this.included = true;
|
|
11078
11558
|
if (!this.deoptimized)
|
|
11079
11559
|
this.applyDeoptimizations();
|
|
11080
|
-
if (!this.
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
|
|
11086
|
-
|
|
11087
|
-
} while ((parent = parent.parent));
|
|
11088
|
-
this.scope.context.usesTopLevelAwait = true;
|
|
11089
|
-
}
|
|
11560
|
+
checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
|
|
11561
|
+
let parent = this.parent;
|
|
11562
|
+
do {
|
|
11563
|
+
if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
|
|
11564
|
+
break checkTopLevelAwait;
|
|
11565
|
+
} while ((parent = parent.parent));
|
|
11566
|
+
this.scope.context.usesTopLevelAwait = true;
|
|
11090
11567
|
}
|
|
11091
|
-
|
|
11568
|
+
// Thenables need to be included
|
|
11569
|
+
this.argument.includePath(THEN_PATH, context);
|
|
11570
|
+
}
|
|
11571
|
+
includePath(path, context) {
|
|
11572
|
+
if (!this.deoptimized)
|
|
11573
|
+
this.applyDeoptimizations();
|
|
11574
|
+
if (!this.included)
|
|
11575
|
+
this.includeNode(context);
|
|
11576
|
+
this.argument.includePath(path, context);
|
|
11092
11577
|
}
|
|
11093
11578
|
}
|
|
11579
|
+
const THEN_PATH = ['then'];
|
|
11094
11580
|
|
|
11095
11581
|
const binaryOperators = {
|
|
11096
11582
|
'!=': (left, right) => left != right,
|
|
@@ -11146,6 +11632,12 @@ class BinaryExpression extends NodeBase {
|
|
|
11146
11632
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11147
11633
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
11148
11634
|
}
|
|
11635
|
+
includeNode(context) {
|
|
11636
|
+
this.included = true;
|
|
11637
|
+
if (this.operator === 'in') {
|
|
11638
|
+
this.right.includePath(UNKNOWN_PATH, context);
|
|
11639
|
+
}
|
|
11640
|
+
}
|
|
11149
11641
|
removeAnnotations(code) {
|
|
11150
11642
|
this.left.removeAnnotations(code);
|
|
11151
11643
|
}
|
|
@@ -11154,6 +11646,7 @@ class BinaryExpression extends NodeBase {
|
|
|
11154
11646
|
this.right.render(code, options);
|
|
11155
11647
|
}
|
|
11156
11648
|
}
|
|
11649
|
+
BinaryExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11157
11650
|
|
|
11158
11651
|
class BreakStatement extends NodeBase {
|
|
11159
11652
|
hasEffects(context) {
|
|
@@ -11173,7 +11666,7 @@ class BreakStatement extends NodeBase {
|
|
|
11173
11666
|
include(context) {
|
|
11174
11667
|
this.included = true;
|
|
11175
11668
|
if (this.label) {
|
|
11176
|
-
this.label.include();
|
|
11669
|
+
this.label.include(context);
|
|
11177
11670
|
context.includedLabels.add(this.label.name);
|
|
11178
11671
|
}
|
|
11179
11672
|
else {
|
|
@@ -11182,6 +11675,8 @@ class BreakStatement extends NodeBase {
|
|
|
11182
11675
|
context.brokenFlow = true;
|
|
11183
11676
|
}
|
|
11184
11677
|
}
|
|
11678
|
+
BreakStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11679
|
+
BreakStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11185
11680
|
|
|
11186
11681
|
function renderCallArguments(code, options, node) {
|
|
11187
11682
|
if (node.arguments.length > 0) {
|
|
@@ -11368,10 +11863,14 @@ class CallExpression extends CallExpressionBase {
|
|
|
11368
11863
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
11369
11864
|
}
|
|
11370
11865
|
include(context, includeChildrenRecursively) {
|
|
11371
|
-
if (!this.
|
|
11372
|
-
this.
|
|
11866
|
+
if (!this.included)
|
|
11867
|
+
this.includeNode(context);
|
|
11373
11868
|
if (includeChildrenRecursively) {
|
|
11374
|
-
|
|
11869
|
+
this.callee.include(context, true);
|
|
11870
|
+
for (const argument of this.arguments) {
|
|
11871
|
+
argument.includePath(UNKNOWN_PATH, context);
|
|
11872
|
+
argument.include(context, true);
|
|
11873
|
+
}
|
|
11375
11874
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
11376
11875
|
this.callee instanceof Identifier &&
|
|
11377
11876
|
this.callee.variable) {
|
|
@@ -11379,10 +11878,24 @@ class CallExpression extends CallExpressionBase {
|
|
|
11379
11878
|
}
|
|
11380
11879
|
}
|
|
11381
11880
|
else {
|
|
11382
|
-
|
|
11383
|
-
|
|
11881
|
+
// If the callee is a member expression and does not have a variable, its
|
|
11882
|
+
// object will already be included via the first argument of the
|
|
11883
|
+
// interaction in includeCallArguments. Including it again can lead to
|
|
11884
|
+
// severe performance problems.
|
|
11885
|
+
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
11886
|
+
this.callee.property.include(context, false);
|
|
11887
|
+
}
|
|
11888
|
+
else {
|
|
11889
|
+
this.callee.include(context, false);
|
|
11890
|
+
}
|
|
11891
|
+
this.callee.includeCallArguments(context, this.interaction);
|
|
11384
11892
|
}
|
|
11385
|
-
|
|
11893
|
+
}
|
|
11894
|
+
includeNode(context) {
|
|
11895
|
+
this.included = true;
|
|
11896
|
+
if (!this.deoptimized)
|
|
11897
|
+
this.applyDeoptimizations();
|
|
11898
|
+
this.callee.includePath(UNKNOWN_PATH, context);
|
|
11386
11899
|
}
|
|
11387
11900
|
initialise() {
|
|
11388
11901
|
super.initialise();
|
|
@@ -11421,13 +11934,14 @@ class CatchClause extends NodeBase {
|
|
|
11421
11934
|
this.type = type;
|
|
11422
11935
|
if (param) {
|
|
11423
11936
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
11424
|
-
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
11937
|
+
this.param.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION);
|
|
11425
11938
|
}
|
|
11426
11939
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
11427
11940
|
return super.parseNode(esTreeNode);
|
|
11428
11941
|
}
|
|
11429
11942
|
}
|
|
11430
11943
|
CatchClause.prototype.preventChildBlockScope = true;
|
|
11944
|
+
CatchClause.prototype.includeNode = onlyIncludeSelf;
|
|
11431
11945
|
|
|
11432
11946
|
class ChainExpression extends NodeBase {
|
|
11433
11947
|
// deoptimizations are not relevant as we are not caching values
|
|
@@ -11439,17 +11953,22 @@ class ChainExpression extends NodeBase {
|
|
|
11439
11953
|
hasEffects(context) {
|
|
11440
11954
|
return this.expression.hasEffectsAsChainElement(context) === true;
|
|
11441
11955
|
}
|
|
11956
|
+
includePath(path, context) {
|
|
11957
|
+
this.included = true;
|
|
11958
|
+
this.expression.includePath(path, context);
|
|
11959
|
+
}
|
|
11442
11960
|
removeAnnotations(code) {
|
|
11443
11961
|
this.expression.removeAnnotations(code);
|
|
11444
11962
|
}
|
|
11445
|
-
applyDeoptimizations() { }
|
|
11446
11963
|
}
|
|
11964
|
+
ChainExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11965
|
+
ChainExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11447
11966
|
|
|
11448
11967
|
class ClassBodyScope extends ChildScope {
|
|
11449
11968
|
constructor(parent, classNode) {
|
|
11450
11969
|
const { context } = parent;
|
|
11451
11970
|
super(parent, context);
|
|
11452
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
11971
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, EMPTY_PATH, context, 'other')));
|
|
11453
11972
|
this.instanceScope = new ChildScope(this, context);
|
|
11454
11973
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
11455
11974
|
}
|
|
@@ -11464,7 +11983,7 @@ class ClassBody extends NodeBase {
|
|
|
11464
11983
|
}
|
|
11465
11984
|
include(context, includeChildrenRecursively) {
|
|
11466
11985
|
this.included = true;
|
|
11467
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
11986
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable, UNKNOWN_PATH, context);
|
|
11468
11987
|
for (const definition of this.body) {
|
|
11469
11988
|
definition.include(context, includeChildrenRecursively);
|
|
11470
11989
|
}
|
|
@@ -11477,8 +11996,9 @@ class ClassBody extends NodeBase {
|
|
|
11477
11996
|
}
|
|
11478
11997
|
return super.parseNode(esTreeNode);
|
|
11479
11998
|
}
|
|
11480
|
-
applyDeoptimizations() { }
|
|
11481
11999
|
}
|
|
12000
|
+
ClassBody.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12001
|
+
ClassBody.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11482
12002
|
|
|
11483
12003
|
class ClassExpression extends ClassNode {
|
|
11484
12004
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
@@ -11549,6 +12069,9 @@ class ConditionalExpression extends NodeBase {
|
|
|
11549
12069
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
11550
12070
|
this.usedBranch = null;
|
|
11551
12071
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
12072
|
+
if (this.included) {
|
|
12073
|
+
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
12074
|
+
}
|
|
11552
12075
|
const { expressionsToBeDeoptimized } = this;
|
|
11553
12076
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
11554
12077
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -11606,7 +12129,7 @@ class ConditionalExpression extends NodeBase {
|
|
|
11606
12129
|
include(context, includeChildrenRecursively) {
|
|
11607
12130
|
this.included = true;
|
|
11608
12131
|
const usedBranch = this.getUsedBranch();
|
|
11609
|
-
if (includeChildrenRecursively || this.test.shouldBeIncluded(context)
|
|
12132
|
+
if (usedBranch === null || includeChildrenRecursively || this.test.shouldBeIncluded(context)) {
|
|
11610
12133
|
this.test.include(context, includeChildrenRecursively);
|
|
11611
12134
|
this.consequent.include(context, includeChildrenRecursively);
|
|
11612
12135
|
this.alternate.include(context, includeChildrenRecursively);
|
|
@@ -11615,27 +12138,38 @@ class ConditionalExpression extends NodeBase {
|
|
|
11615
12138
|
usedBranch.include(context, includeChildrenRecursively);
|
|
11616
12139
|
}
|
|
11617
12140
|
}
|
|
11618
|
-
|
|
12141
|
+
includePath(path, context) {
|
|
12142
|
+
this.included = true;
|
|
12143
|
+
const usedBranch = this.getUsedBranch();
|
|
12144
|
+
if (usedBranch === null || this.test.shouldBeIncluded(context)) {
|
|
12145
|
+
this.consequent.includePath(path, context);
|
|
12146
|
+
this.alternate.includePath(path, context);
|
|
12147
|
+
}
|
|
12148
|
+
else {
|
|
12149
|
+
usedBranch.includePath(path, context);
|
|
12150
|
+
}
|
|
12151
|
+
}
|
|
12152
|
+
includeCallArguments(context, interaction) {
|
|
11619
12153
|
const usedBranch = this.getUsedBranch();
|
|
11620
12154
|
if (usedBranch) {
|
|
11621
|
-
usedBranch.includeCallArguments(context,
|
|
12155
|
+
usedBranch.includeCallArguments(context, interaction);
|
|
11622
12156
|
}
|
|
11623
12157
|
else {
|
|
11624
|
-
this.consequent.includeCallArguments(context,
|
|
11625
|
-
this.alternate.includeCallArguments(context,
|
|
12158
|
+
this.consequent.includeCallArguments(context, interaction);
|
|
12159
|
+
this.alternate.includeCallArguments(context, interaction);
|
|
11626
12160
|
}
|
|
11627
12161
|
}
|
|
11628
12162
|
removeAnnotations(code) {
|
|
11629
12163
|
this.test.removeAnnotations(code);
|
|
11630
12164
|
}
|
|
11631
12165
|
render(code, options, { isCalleeOfRenderedParent, preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
11632
|
-
const usedBranch = this.getUsedBranch();
|
|
11633
12166
|
if (this.test.included) {
|
|
11634
12167
|
this.test.render(code, options, { renderedSurroundingElement });
|
|
11635
12168
|
this.consequent.render(code, options);
|
|
11636
12169
|
this.alternate.render(code, options);
|
|
11637
12170
|
}
|
|
11638
12171
|
else {
|
|
12172
|
+
const usedBranch = this.getUsedBranch();
|
|
11639
12173
|
const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end);
|
|
11640
12174
|
const inclusionStart = findNonWhiteSpace(code.original, (this.consequent.included
|
|
11641
12175
|
? findFirstOccurrenceOutsideComment(code.original, '?', this.test.end)
|
|
@@ -11667,6 +12201,8 @@ class ConditionalExpression extends NodeBase {
|
|
|
11667
12201
|
: (this.usedBranch = testValue ? this.consequent : this.alternate);
|
|
11668
12202
|
}
|
|
11669
12203
|
}
|
|
12204
|
+
ConditionalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12205
|
+
ConditionalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11670
12206
|
|
|
11671
12207
|
class ContinueStatement extends NodeBase {
|
|
11672
12208
|
hasEffects(context) {
|
|
@@ -11686,7 +12222,7 @@ class ContinueStatement extends NodeBase {
|
|
|
11686
12222
|
include(context) {
|
|
11687
12223
|
this.included = true;
|
|
11688
12224
|
if (this.label) {
|
|
11689
|
-
this.label.include();
|
|
12225
|
+
this.label.include(context);
|
|
11690
12226
|
context.includedLabels.add(this.label.name);
|
|
11691
12227
|
}
|
|
11692
12228
|
else {
|
|
@@ -11695,12 +12231,15 @@ class ContinueStatement extends NodeBase {
|
|
|
11695
12231
|
context.brokenFlow = true;
|
|
11696
12232
|
}
|
|
11697
12233
|
}
|
|
12234
|
+
ContinueStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12235
|
+
ContinueStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11698
12236
|
|
|
11699
12237
|
class DebuggerStatement extends NodeBase {
|
|
11700
12238
|
hasEffects() {
|
|
11701
12239
|
return true;
|
|
11702
12240
|
}
|
|
11703
12241
|
}
|
|
12242
|
+
DebuggerStatement.prototype.includeNode = onlyIncludeSelf;
|
|
11704
12243
|
|
|
11705
12244
|
class Decorator extends NodeBase {
|
|
11706
12245
|
hasEffects(context) {
|
|
@@ -11708,6 +12247,7 @@ class Decorator extends NodeBase {
|
|
|
11708
12247
|
this.expression.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context));
|
|
11709
12248
|
}
|
|
11710
12249
|
}
|
|
12250
|
+
Decorator.prototype.includeNode = onlyIncludeSelf;
|
|
11711
12251
|
|
|
11712
12252
|
function hasLoopBodyEffects(context, body) {
|
|
11713
12253
|
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
@@ -11747,12 +12287,15 @@ class DoWhileStatement extends NodeBase {
|
|
|
11747
12287
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
11748
12288
|
}
|
|
11749
12289
|
}
|
|
12290
|
+
DoWhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12291
|
+
DoWhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11750
12292
|
|
|
11751
12293
|
class EmptyStatement extends NodeBase {
|
|
11752
12294
|
hasEffects() {
|
|
11753
12295
|
return false;
|
|
11754
12296
|
}
|
|
11755
12297
|
}
|
|
12298
|
+
EmptyStatement.prototype.includeNode = onlyIncludeSelf;
|
|
11756
12299
|
|
|
11757
12300
|
class ExportAllDeclaration extends NodeBase {
|
|
11758
12301
|
hasEffects() {
|
|
@@ -11765,9 +12308,10 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
11765
12308
|
render(code, _options, nodeRenderOptions) {
|
|
11766
12309
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
11767
12310
|
}
|
|
11768
|
-
applyDeoptimizations() { }
|
|
11769
12311
|
}
|
|
11770
12312
|
ExportAllDeclaration.prototype.needsBoundaries = true;
|
|
12313
|
+
ExportAllDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12314
|
+
ExportAllDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11771
12315
|
|
|
11772
12316
|
class ExportNamedDeclaration extends NodeBase {
|
|
11773
12317
|
bind() {
|
|
@@ -11794,13 +12338,15 @@ class ExportNamedDeclaration extends NodeBase {
|
|
|
11794
12338
|
this.declaration.render(code, options, { end, start });
|
|
11795
12339
|
}
|
|
11796
12340
|
}
|
|
11797
|
-
applyDeoptimizations() { }
|
|
11798
12341
|
}
|
|
11799
12342
|
ExportNamedDeclaration.prototype.needsBoundaries = true;
|
|
12343
|
+
ExportNamedDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12344
|
+
ExportNamedDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11800
12345
|
|
|
11801
12346
|
class ExportSpecifier extends NodeBase {
|
|
11802
|
-
applyDeoptimizations() { }
|
|
11803
12347
|
}
|
|
12348
|
+
ExportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12349
|
+
ExportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11804
12350
|
|
|
11805
12351
|
class ForInStatement extends NodeBase {
|
|
11806
12352
|
createScope(parentScope) {
|
|
@@ -11818,11 +12364,18 @@ class ForInStatement extends NodeBase {
|
|
|
11818
12364
|
const { body, deoptimized, left, right } = this;
|
|
11819
12365
|
if (!deoptimized)
|
|
11820
12366
|
this.applyDeoptimizations();
|
|
11821
|
-
this.included
|
|
12367
|
+
if (!this.included)
|
|
12368
|
+
this.includeNode(context);
|
|
11822
12369
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
11823
12370
|
right.include(context, includeChildrenRecursively);
|
|
11824
12371
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
11825
12372
|
}
|
|
12373
|
+
includeNode(context) {
|
|
12374
|
+
this.included = true;
|
|
12375
|
+
if (!this.deoptimized)
|
|
12376
|
+
this.applyDeoptimizations();
|
|
12377
|
+
this.right.includePath(UNKNOWN_PATH, context);
|
|
12378
|
+
}
|
|
11826
12379
|
initialise() {
|
|
11827
12380
|
super.initialise();
|
|
11828
12381
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -11863,11 +12416,18 @@ class ForOfStatement extends NodeBase {
|
|
|
11863
12416
|
const { body, deoptimized, left, right } = this;
|
|
11864
12417
|
if (!deoptimized)
|
|
11865
12418
|
this.applyDeoptimizations();
|
|
11866
|
-
this.included
|
|
12419
|
+
if (!this.included)
|
|
12420
|
+
this.includeNode(context);
|
|
11867
12421
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
11868
12422
|
right.include(context, includeChildrenRecursively);
|
|
11869
12423
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
11870
12424
|
}
|
|
12425
|
+
includeNode(context) {
|
|
12426
|
+
this.included = true;
|
|
12427
|
+
if (!this.deoptimized)
|
|
12428
|
+
this.applyDeoptimizations();
|
|
12429
|
+
this.right.includePath(UNKNOWN_PATH, context);
|
|
12430
|
+
}
|
|
11871
12431
|
initialise() {
|
|
11872
12432
|
super.initialise();
|
|
11873
12433
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -11903,7 +12463,9 @@ class ForStatement extends NodeBase {
|
|
|
11903
12463
|
}
|
|
11904
12464
|
include(context, includeChildrenRecursively) {
|
|
11905
12465
|
this.included = true;
|
|
11906
|
-
this.init?.include(context, includeChildrenRecursively, {
|
|
12466
|
+
this.init?.include(context, includeChildrenRecursively, {
|
|
12467
|
+
asSingleStatement: true
|
|
12468
|
+
});
|
|
11907
12469
|
this.test?.include(context, includeChildrenRecursively);
|
|
11908
12470
|
this.update?.include(context, includeChildrenRecursively);
|
|
11909
12471
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
@@ -11915,6 +12477,8 @@ class ForStatement extends NodeBase {
|
|
|
11915
12477
|
this.body.render(code, options);
|
|
11916
12478
|
}
|
|
11917
12479
|
}
|
|
12480
|
+
ForStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12481
|
+
ForStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11918
12482
|
|
|
11919
12483
|
class FunctionExpression extends FunctionNode {
|
|
11920
12484
|
createScope(parentScope) {
|
|
@@ -11946,9 +12510,9 @@ class TrackingScope extends BlockScope {
|
|
|
11946
12510
|
super(...arguments);
|
|
11947
12511
|
this.hoistedDeclarations = [];
|
|
11948
12512
|
}
|
|
11949
|
-
addDeclaration(identifier, context, init, kind) {
|
|
12513
|
+
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
11950
12514
|
this.hoistedDeclarations.push(identifier);
|
|
11951
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
12515
|
+
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
11952
12516
|
}
|
|
11953
12517
|
}
|
|
11954
12518
|
|
|
@@ -12047,7 +12611,6 @@ class IfStatement extends NodeBase {
|
|
|
12047
12611
|
}
|
|
12048
12612
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
12049
12613
|
}
|
|
12050
|
-
applyDeoptimizations() { }
|
|
12051
12614
|
getTestValue() {
|
|
12052
12615
|
if (this.testValue === unset) {
|
|
12053
12616
|
return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
@@ -12116,6 +12679,8 @@ class IfStatement extends NodeBase {
|
|
|
12116
12679
|
return false;
|
|
12117
12680
|
}
|
|
12118
12681
|
}
|
|
12682
|
+
IfStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12683
|
+
IfStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12119
12684
|
|
|
12120
12685
|
class ImportAttribute extends NodeBase {
|
|
12121
12686
|
}
|
|
@@ -12133,13 +12698,15 @@ class ImportDeclaration extends NodeBase {
|
|
|
12133
12698
|
render(code, _options, nodeRenderOptions) {
|
|
12134
12699
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
12135
12700
|
}
|
|
12136
|
-
applyDeoptimizations() { }
|
|
12137
12701
|
}
|
|
12138
12702
|
ImportDeclaration.prototype.needsBoundaries = true;
|
|
12703
|
+
ImportDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12704
|
+
ImportDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12139
12705
|
|
|
12140
12706
|
class ImportDefaultSpecifier extends NodeBase {
|
|
12141
|
-
applyDeoptimizations() { }
|
|
12142
12707
|
}
|
|
12708
|
+
ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12709
|
+
ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12143
12710
|
|
|
12144
12711
|
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
12145
12712
|
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
@@ -12148,28 +12715,33 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
12148
12715
|
class VariableDeclarator extends NodeBase {
|
|
12149
12716
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
12150
12717
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
12151
|
-
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12718
|
+
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
12152
12719
|
}
|
|
12153
12720
|
deoptimizePath(path) {
|
|
12154
12721
|
this.id.deoptimizePath(path);
|
|
12155
12722
|
}
|
|
12156
12723
|
hasEffects(context) {
|
|
12157
|
-
if (!this.deoptimized)
|
|
12158
|
-
this.applyDeoptimizations();
|
|
12159
12724
|
const initEffect = this.init?.hasEffects(context);
|
|
12160
12725
|
this.id.markDeclarationReached();
|
|
12161
|
-
return initEffect ||
|
|
12726
|
+
return (initEffect ||
|
|
12727
|
+
this.isUsingDeclaration ||
|
|
12728
|
+
this.id.hasEffects(context) ||
|
|
12729
|
+
(this.scope.context.options.treeshake
|
|
12730
|
+
.propertyReadSideEffects &&
|
|
12731
|
+
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
12162
12732
|
}
|
|
12163
12733
|
include(context, includeChildrenRecursively) {
|
|
12164
|
-
const {
|
|
12165
|
-
if (!
|
|
12166
|
-
this.
|
|
12167
|
-
this.included = true;
|
|
12734
|
+
const { id, init } = this;
|
|
12735
|
+
if (!this.included)
|
|
12736
|
+
this.includeNode();
|
|
12168
12737
|
init?.include(context, includeChildrenRecursively);
|
|
12169
12738
|
id.markDeclarationReached();
|
|
12170
|
-
if (includeChildrenRecursively
|
|
12739
|
+
if (includeChildrenRecursively) {
|
|
12171
12740
|
id.include(context, includeChildrenRecursively);
|
|
12172
12741
|
}
|
|
12742
|
+
else {
|
|
12743
|
+
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
12744
|
+
}
|
|
12173
12745
|
}
|
|
12174
12746
|
removeAnnotations(code) {
|
|
12175
12747
|
this.init?.removeAnnotations(code);
|
|
@@ -12199,8 +12771,8 @@ class VariableDeclarator extends NodeBase {
|
|
|
12199
12771
|
code.appendLeft(end, `${_}=${_}void 0`);
|
|
12200
12772
|
}
|
|
12201
12773
|
}
|
|
12202
|
-
|
|
12203
|
-
this.
|
|
12774
|
+
includeNode() {
|
|
12775
|
+
this.included = true;
|
|
12204
12776
|
const { id, init } = this;
|
|
12205
12777
|
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12206
12778
|
const { name, variable } = id;
|
|
@@ -12212,11 +12784,14 @@ class VariableDeclarator extends NodeBase {
|
|
|
12212
12784
|
}
|
|
12213
12785
|
}
|
|
12214
12786
|
}
|
|
12787
|
+
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12215
12788
|
|
|
12216
12789
|
class ImportExpression extends NodeBase {
|
|
12217
12790
|
constructor() {
|
|
12218
12791
|
super(...arguments);
|
|
12219
12792
|
this.inlineNamespace = null;
|
|
12793
|
+
this.hasUnknownAccessedKey = false;
|
|
12794
|
+
this.accessedPropKey = new Set();
|
|
12220
12795
|
this.attributes = null;
|
|
12221
12796
|
this.mechanism = null;
|
|
12222
12797
|
this.namespaceExportName = undefined;
|
|
@@ -12249,12 +12824,15 @@ class ImportExpression extends NodeBase {
|
|
|
12249
12824
|
if (parent2 instanceof ExpressionStatement) {
|
|
12250
12825
|
return EMPTY_ARRAY;
|
|
12251
12826
|
}
|
|
12252
|
-
// Case 1: const { foo } = await import('bar')
|
|
12827
|
+
// Case 1: const { foo } / module = await import('bar')
|
|
12253
12828
|
if (parent2 instanceof VariableDeclarator) {
|
|
12254
12829
|
const declaration = parent2.id;
|
|
12255
|
-
|
|
12256
|
-
?
|
|
12257
|
-
|
|
12830
|
+
if (declaration instanceof Identifier) {
|
|
12831
|
+
return this.hasUnknownAccessedKey ? undefined : [...this.accessedPropKey];
|
|
12832
|
+
}
|
|
12833
|
+
if (declaration instanceof ObjectPattern) {
|
|
12834
|
+
return getDeterministicObjectDestructure(declaration);
|
|
12835
|
+
}
|
|
12258
12836
|
}
|
|
12259
12837
|
// Case 2: (await import('bar')).foo
|
|
12260
12838
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -12304,13 +12882,30 @@ class ImportExpression extends NodeBase {
|
|
|
12304
12882
|
return true;
|
|
12305
12883
|
}
|
|
12306
12884
|
include(context, includeChildrenRecursively) {
|
|
12307
|
-
if (!this.included)
|
|
12308
|
-
this.
|
|
12309
|
-
this.scope.context.includeDynamicImport(this);
|
|
12310
|
-
this.scope.addAccessedDynamicImport(this);
|
|
12311
|
-
}
|
|
12885
|
+
if (!this.included)
|
|
12886
|
+
this.includeNode();
|
|
12312
12887
|
this.source.include(context, includeChildrenRecursively);
|
|
12313
12888
|
}
|
|
12889
|
+
includeNode() {
|
|
12890
|
+
this.included = true;
|
|
12891
|
+
this.scope.context.includeDynamicImport(this);
|
|
12892
|
+
this.scope.addAccessedDynamicImport(this);
|
|
12893
|
+
}
|
|
12894
|
+
includePath(path) {
|
|
12895
|
+
if (!this.included)
|
|
12896
|
+
this.includeNode();
|
|
12897
|
+
// Technically, this is not correct as dynamic imports return a Promise.
|
|
12898
|
+
if (this.hasUnknownAccessedKey)
|
|
12899
|
+
return;
|
|
12900
|
+
if (path[0] === UnknownKey) {
|
|
12901
|
+
this.hasUnknownAccessedKey = true;
|
|
12902
|
+
}
|
|
12903
|
+
else if (typeof path[0] === 'string') {
|
|
12904
|
+
this.accessedPropKey.add(path[0]);
|
|
12905
|
+
}
|
|
12906
|
+
// Update included paths
|
|
12907
|
+
this.scope.context.includeDynamicImport(this);
|
|
12908
|
+
}
|
|
12314
12909
|
initialise() {
|
|
12315
12910
|
super.initialise();
|
|
12316
12911
|
this.scope.context.addDynamicImport(this);
|
|
@@ -12379,7 +12974,6 @@ class ImportExpression extends NodeBase {
|
|
|
12379
12974
|
setInternalResolution(inlineNamespace) {
|
|
12380
12975
|
this.inlineNamespace = inlineNamespace;
|
|
12381
12976
|
}
|
|
12382
|
-
applyDeoptimizations() { }
|
|
12383
12977
|
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
12384
12978
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
12385
12979
|
{
|
|
@@ -12469,6 +13063,7 @@ class ImportExpression extends NodeBase {
|
|
|
12469
13063
|
return { helper: null, mechanism: null };
|
|
12470
13064
|
}
|
|
12471
13065
|
}
|
|
13066
|
+
ImportExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12472
13067
|
function getInteropHelper(resolution, exportMode, interop) {
|
|
12473
13068
|
return exportMode === 'external'
|
|
12474
13069
|
? namespaceInteropHelpersByInteropType[interop(resolution instanceof ExternalModule ? resolution.id : null)]
|
|
@@ -12492,12 +13087,14 @@ function getDeterministicObjectDestructure(objectPattern) {
|
|
|
12492
13087
|
}
|
|
12493
13088
|
|
|
12494
13089
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
12495
|
-
applyDeoptimizations() { }
|
|
12496
13090
|
}
|
|
13091
|
+
ImportNamespaceSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13092
|
+
ImportNamespaceSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12497
13093
|
|
|
12498
13094
|
class ImportSpecifier extends NodeBase {
|
|
12499
|
-
applyDeoptimizations() { }
|
|
12500
13095
|
}
|
|
13096
|
+
ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13097
|
+
ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12501
13098
|
|
|
12502
13099
|
class JSXIdentifier extends IdentifierBase {
|
|
12503
13100
|
constructor() {
|
|
@@ -12514,6 +13111,29 @@ class JSXIdentifier extends IdentifierBase {
|
|
|
12514
13111
|
this.isNativeElement = true;
|
|
12515
13112
|
}
|
|
12516
13113
|
}
|
|
13114
|
+
include(context) {
|
|
13115
|
+
if (!this.included)
|
|
13116
|
+
this.includeNode(context);
|
|
13117
|
+
}
|
|
13118
|
+
includeNode(context) {
|
|
13119
|
+
this.included = true;
|
|
13120
|
+
if (!this.deoptimized)
|
|
13121
|
+
this.applyDeoptimizations();
|
|
13122
|
+
if (this.variable !== null) {
|
|
13123
|
+
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13124
|
+
}
|
|
13125
|
+
}
|
|
13126
|
+
includePath(path, context) {
|
|
13127
|
+
if (!this.included) {
|
|
13128
|
+
this.included = true;
|
|
13129
|
+
if (this.variable !== null) {
|
|
13130
|
+
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
13131
|
+
}
|
|
13132
|
+
}
|
|
13133
|
+
else if (path.length > 0) {
|
|
13134
|
+
this.variable?.includePath(path, context);
|
|
13135
|
+
}
|
|
13136
|
+
}
|
|
12517
13137
|
render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
|
|
12518
13138
|
if (this.variable) {
|
|
12519
13139
|
const name = this.variable.getName(getPropertyAccess, useOriginalName);
|
|
@@ -12575,6 +13195,7 @@ class JSXAttribute extends NodeBase {
|
|
|
12575
13195
|
}
|
|
12576
13196
|
}
|
|
12577
13197
|
}
|
|
13198
|
+
JSXAttribute.prototype.includeNode = onlyIncludeSelf;
|
|
12578
13199
|
|
|
12579
13200
|
class JSXClosingBase extends NodeBase {
|
|
12580
13201
|
render(code, options) {
|
|
@@ -12587,6 +13208,7 @@ class JSXClosingBase extends NodeBase {
|
|
|
12587
13208
|
}
|
|
12588
13209
|
}
|
|
12589
13210
|
}
|
|
13211
|
+
JSXClosingBase.prototype.includeNode = onlyIncludeSelf;
|
|
12590
13212
|
|
|
12591
13213
|
class JSXClosingElement extends JSXClosingBase {
|
|
12592
13214
|
}
|
|
@@ -12607,8 +13229,15 @@ class JSXSpreadAttribute extends NodeBase {
|
|
|
12607
13229
|
|
|
12608
13230
|
class JSXEmptyExpression extends NodeBase {
|
|
12609
13231
|
}
|
|
13232
|
+
JSXEmptyExpression.prototype.includeNode = onlyIncludeSelf;
|
|
12610
13233
|
|
|
12611
13234
|
class JSXExpressionContainer extends NodeBase {
|
|
13235
|
+
includeNode(context) {
|
|
13236
|
+
this.included = true;
|
|
13237
|
+
if (!this.deoptimized)
|
|
13238
|
+
this.applyDeoptimizations();
|
|
13239
|
+
this.expression.includePath(UNKNOWN_PATH, context);
|
|
13240
|
+
}
|
|
12612
13241
|
render(code, options) {
|
|
12613
13242
|
const { mode } = this.scope.context.options.jsx;
|
|
12614
13243
|
if (mode !== 'preserve') {
|
|
@@ -12629,7 +13258,7 @@ function getRenderedJsxChildren(children) {
|
|
|
12629
13258
|
return renderedChildren;
|
|
12630
13259
|
}
|
|
12631
13260
|
|
|
12632
|
-
function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
13261
|
+
function getAndIncludeFactoryVariable(factory, preserve, importSource, node, context) {
|
|
12633
13262
|
const [baseName, nestedName] = factory.split('.');
|
|
12634
13263
|
let factoryVariable;
|
|
12635
13264
|
if (importSource) {
|
|
@@ -12637,7 +13266,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12637
13266
|
if (preserve) {
|
|
12638
13267
|
// This pretends we are accessing an included global variable of the same name
|
|
12639
13268
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
12640
|
-
globalVariable.
|
|
13269
|
+
globalVariable.includePath(UNKNOWN_PATH, context);
|
|
12641
13270
|
// This excludes this variable from renaming
|
|
12642
13271
|
factoryVariable.globalName = baseName;
|
|
12643
13272
|
}
|
|
@@ -12645,7 +13274,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12645
13274
|
else {
|
|
12646
13275
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
12647
13276
|
}
|
|
12648
|
-
node.scope.context.includeVariableInModule(factoryVariable);
|
|
13277
|
+
node.scope.context.includeVariableInModule(factoryVariable, UNKNOWN_PATH, context);
|
|
12649
13278
|
if (factoryVariable instanceof LocalVariable) {
|
|
12650
13279
|
factoryVariable.consolidateInitializers();
|
|
12651
13280
|
factoryVariable.addUsedPlace(node);
|
|
@@ -12668,16 +13297,20 @@ class JSXElementBase extends NodeBase {
|
|
|
12668
13297
|
}
|
|
12669
13298
|
}
|
|
12670
13299
|
include(context, includeChildrenRecursively) {
|
|
12671
|
-
if (!this.included)
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
13300
|
+
if (!this.included)
|
|
13301
|
+
this.includeNode(context);
|
|
13302
|
+
for (const child of this.children) {
|
|
13303
|
+
child.include(context, includeChildrenRecursively);
|
|
13304
|
+
}
|
|
13305
|
+
}
|
|
13306
|
+
includeNode(context) {
|
|
13307
|
+
this.included = true;
|
|
13308
|
+
const { factory, importSource, mode } = this.jsxMode;
|
|
13309
|
+
if (factory) {
|
|
13310
|
+
this.factory = factory;
|
|
13311
|
+
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this, context);
|
|
12677
13312
|
}
|
|
12678
|
-
super.include(context, includeChildrenRecursively);
|
|
12679
13313
|
}
|
|
12680
|
-
applyDeoptimizations() { }
|
|
12681
13314
|
getRenderingMode() {
|
|
12682
13315
|
const jsx = this.scope.context.options.jsx;
|
|
12683
13316
|
const { mode, factory, importSource } = jsx;
|
|
@@ -12715,8 +13348,14 @@ class JSXElementBase extends NodeBase {
|
|
|
12715
13348
|
return { childrenEnd, firstChild, hasMultipleChildren };
|
|
12716
13349
|
}
|
|
12717
13350
|
}
|
|
13351
|
+
JSXElementBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12718
13352
|
|
|
12719
13353
|
class JSXElement extends JSXElementBase {
|
|
13354
|
+
include(context, includeChildrenRecursively) {
|
|
13355
|
+
super.include(context, includeChildrenRecursively);
|
|
13356
|
+
this.openingElement.include(context, includeChildrenRecursively);
|
|
13357
|
+
this.closingElement?.include(context, includeChildrenRecursively);
|
|
13358
|
+
}
|
|
12720
13359
|
render(code, options) {
|
|
12721
13360
|
switch (this.jsxMode.mode) {
|
|
12722
13361
|
case 'classic': {
|
|
@@ -12868,6 +13507,11 @@ class JSXElement extends JSXElementBase {
|
|
|
12868
13507
|
}
|
|
12869
13508
|
|
|
12870
13509
|
class JSXFragment extends JSXElementBase {
|
|
13510
|
+
include(context, includeChildrenRecursively) {
|
|
13511
|
+
super.include(context, includeChildrenRecursively);
|
|
13512
|
+
this.openingFragment.include(context, includeChildrenRecursively);
|
|
13513
|
+
this.closingFragment.include(context, includeChildrenRecursively);
|
|
13514
|
+
}
|
|
12871
13515
|
render(code, options) {
|
|
12872
13516
|
switch (this.jsxMode.mode) {
|
|
12873
13517
|
case 'classic': {
|
|
@@ -12917,10 +13561,22 @@ class JSXFragment extends JSXElementBase {
|
|
|
12917
13561
|
}
|
|
12918
13562
|
|
|
12919
13563
|
class JSXMemberExpression extends NodeBase {
|
|
13564
|
+
includeNode(context) {
|
|
13565
|
+
this.included = true;
|
|
13566
|
+
if (!this.deoptimized)
|
|
13567
|
+
this.applyDeoptimizations();
|
|
13568
|
+
this.object.includePath([this.property.name], context);
|
|
13569
|
+
}
|
|
13570
|
+
includePath(path, context) {
|
|
13571
|
+
if (!this.included)
|
|
13572
|
+
this.includeNode(context);
|
|
13573
|
+
this.object.includePath([this.property.name, ...path], context);
|
|
13574
|
+
}
|
|
12920
13575
|
}
|
|
12921
13576
|
|
|
12922
13577
|
class JSXNamespacedName extends NodeBase {
|
|
12923
13578
|
}
|
|
13579
|
+
JSXNamespacedName.prototype.includeNode = onlyIncludeSelf;
|
|
12924
13580
|
|
|
12925
13581
|
class JSXOpeningElement extends NodeBase {
|
|
12926
13582
|
render(code, options, { jsxMode = this.scope.context.options.jsx.mode } = {}) {
|
|
@@ -12930,6 +13586,7 @@ class JSXOpeningElement extends NodeBase {
|
|
|
12930
13586
|
}
|
|
12931
13587
|
}
|
|
12932
13588
|
}
|
|
13589
|
+
JSXOpeningElement.prototype.includeNode = onlyIncludeSelf;
|
|
12933
13590
|
|
|
12934
13591
|
class JSXOpeningFragment extends NodeBase {
|
|
12935
13592
|
constructor() {
|
|
@@ -12937,22 +13594,22 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
12937
13594
|
this.fragment = null;
|
|
12938
13595
|
this.fragmentVariable = null;
|
|
12939
13596
|
}
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
13597
|
+
includeNode(context) {
|
|
13598
|
+
this.included = true;
|
|
13599
|
+
if (!this.deoptimized)
|
|
13600
|
+
this.applyDeoptimizations();
|
|
13601
|
+
const jsx = this.scope.context.options.jsx;
|
|
13602
|
+
if (jsx.mode === 'automatic') {
|
|
13603
|
+
this.fragment = 'Fragment';
|
|
13604
|
+
this.fragmentVariable = getAndIncludeFactoryVariable('Fragment', false, jsx.jsxImportSource, this, context);
|
|
13605
|
+
}
|
|
13606
|
+
else {
|
|
13607
|
+
const { fragment, importSource, mode } = jsx;
|
|
13608
|
+
if (fragment != null) {
|
|
13609
|
+
this.fragment = fragment;
|
|
13610
|
+
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this, context);
|
|
12953
13611
|
}
|
|
12954
13612
|
}
|
|
12955
|
-
super.include(context, includeChildrenRecursively);
|
|
12956
13613
|
}
|
|
12957
13614
|
render(code, options) {
|
|
12958
13615
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -12989,6 +13646,7 @@ class JSXText extends NodeBase {
|
|
|
12989
13646
|
}
|
|
12990
13647
|
}
|
|
12991
13648
|
}
|
|
13649
|
+
JSXText.prototype.includeNode = onlyIncludeSelf;
|
|
12992
13650
|
|
|
12993
13651
|
class LabeledStatement extends NodeBase {
|
|
12994
13652
|
hasEffects(context) {
|
|
@@ -13010,17 +13668,22 @@ class LabeledStatement extends NodeBase {
|
|
|
13010
13668
|
return bodyHasEffects;
|
|
13011
13669
|
}
|
|
13012
13670
|
include(context, includeChildrenRecursively) {
|
|
13013
|
-
this.included
|
|
13671
|
+
if (!this.included)
|
|
13672
|
+
this.includeNode(context);
|
|
13014
13673
|
const { brokenFlow, includedLabels } = context;
|
|
13015
13674
|
context.includedLabels = new Set();
|
|
13016
13675
|
this.body.include(context, includeChildrenRecursively);
|
|
13017
13676
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
13018
|
-
this.label.include();
|
|
13677
|
+
this.label.include(context);
|
|
13019
13678
|
context.includedLabels.delete(this.label.name);
|
|
13020
13679
|
context.brokenFlow = brokenFlow;
|
|
13021
13680
|
}
|
|
13022
13681
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
13023
13682
|
}
|
|
13683
|
+
includeNode(context) {
|
|
13684
|
+
this.included = true;
|
|
13685
|
+
this.body.includePath(UNKNOWN_PATH, context);
|
|
13686
|
+
}
|
|
13024
13687
|
render(code, options) {
|
|
13025
13688
|
if (this.label.included) {
|
|
13026
13689
|
this.label.render(code, options);
|
|
@@ -13031,6 +13694,7 @@ class LabeledStatement extends NodeBase {
|
|
|
13031
13694
|
this.body.render(code, options);
|
|
13032
13695
|
}
|
|
13033
13696
|
}
|
|
13697
|
+
LabeledStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13034
13698
|
|
|
13035
13699
|
class LogicalExpression extends NodeBase {
|
|
13036
13700
|
constructor() {
|
|
@@ -13047,10 +13711,10 @@ class LogicalExpression extends NodeBase {
|
|
|
13047
13711
|
this.flags = setFlag(this.flags, 65536 /* Flag.isBranchResolutionAnalysed */, value);
|
|
13048
13712
|
}
|
|
13049
13713
|
get hasDeoptimizedCache() {
|
|
13050
|
-
return isFlagSet(this.flags,
|
|
13714
|
+
return isFlagSet(this.flags, 33554432 /* Flag.hasDeoptimizedCache */);
|
|
13051
13715
|
}
|
|
13052
13716
|
set hasDeoptimizedCache(value) {
|
|
13053
|
-
this.flags = setFlag(this.flags,
|
|
13717
|
+
this.flags = setFlag(this.flags, 33554432 /* Flag.hasDeoptimizedCache */, value);
|
|
13054
13718
|
}
|
|
13055
13719
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13056
13720
|
this.left.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13063,6 +13727,10 @@ class LogicalExpression extends NodeBase {
|
|
|
13063
13727
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
13064
13728
|
this.usedBranch = null;
|
|
13065
13729
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
13730
|
+
if (this.included) {
|
|
13731
|
+
// As we are not tracking inclusions, we just include everything
|
|
13732
|
+
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
13733
|
+
}
|
|
13066
13734
|
}
|
|
13067
13735
|
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
13068
13736
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
@@ -13108,16 +13776,17 @@ class LogicalExpression extends NodeBase {
|
|
|
13108
13776
|
}
|
|
13109
13777
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
13110
13778
|
const usedBranch = this.getUsedBranch();
|
|
13111
|
-
if (
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13779
|
+
if (usedBranch) {
|
|
13780
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
13781
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
13782
|
+
}
|
|
13783
|
+
return [
|
|
13784
|
+
new MultiExpression([
|
|
13785
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0],
|
|
13786
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0]
|
|
13787
|
+
]),
|
|
13788
|
+
false
|
|
13789
|
+
];
|
|
13121
13790
|
}
|
|
13122
13791
|
hasEffects(context) {
|
|
13123
13792
|
if (this.left.hasEffects(context)) {
|
|
@@ -13130,18 +13799,18 @@ class LogicalExpression extends NodeBase {
|
|
|
13130
13799
|
}
|
|
13131
13800
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13132
13801
|
const usedBranch = this.getUsedBranch();
|
|
13133
|
-
if (
|
|
13134
|
-
return
|
|
13135
|
-
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13802
|
+
if (usedBranch) {
|
|
13803
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13136
13804
|
}
|
|
13137
|
-
return
|
|
13805
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
13806
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13138
13807
|
}
|
|
13139
13808
|
include(context, includeChildrenRecursively) {
|
|
13140
13809
|
this.included = true;
|
|
13141
13810
|
const usedBranch = this.getUsedBranch();
|
|
13142
13811
|
if (includeChildrenRecursively ||
|
|
13143
|
-
|
|
13144
|
-
|
|
13812
|
+
!usedBranch ||
|
|
13813
|
+
(usedBranch === this.right && this.left.shouldBeIncluded(context))) {
|
|
13145
13814
|
this.left.include(context, includeChildrenRecursively);
|
|
13146
13815
|
this.right.include(context, includeChildrenRecursively);
|
|
13147
13816
|
}
|
|
@@ -13149,6 +13818,17 @@ class LogicalExpression extends NodeBase {
|
|
|
13149
13818
|
usedBranch.include(context, includeChildrenRecursively);
|
|
13150
13819
|
}
|
|
13151
13820
|
}
|
|
13821
|
+
includePath(path, context) {
|
|
13822
|
+
this.included = true;
|
|
13823
|
+
const usedBranch = this.getUsedBranch();
|
|
13824
|
+
if (!usedBranch || (usedBranch === this.right && this.left.shouldBeIncluded(context))) {
|
|
13825
|
+
this.left.includePath(path, context);
|
|
13826
|
+
this.right.includePath(path, context);
|
|
13827
|
+
}
|
|
13828
|
+
else {
|
|
13829
|
+
usedBranch.includePath(path, context);
|
|
13830
|
+
}
|
|
13831
|
+
}
|
|
13152
13832
|
removeAnnotations(code) {
|
|
13153
13833
|
this.left.removeAnnotations(code);
|
|
13154
13834
|
}
|
|
@@ -13201,6 +13881,8 @@ class LogicalExpression extends NodeBase {
|
|
|
13201
13881
|
return this.usedBranch;
|
|
13202
13882
|
}
|
|
13203
13883
|
}
|
|
13884
|
+
LogicalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13885
|
+
LogicalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13204
13886
|
|
|
13205
13887
|
class NewExpression extends NodeBase {
|
|
13206
13888
|
hasEffects(context) {
|
|
@@ -13220,16 +13902,21 @@ class NewExpression extends NodeBase {
|
|
|
13220
13902
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
13221
13903
|
}
|
|
13222
13904
|
include(context, includeChildrenRecursively) {
|
|
13223
|
-
if (!this.deoptimized)
|
|
13224
|
-
this.applyDeoptimizations();
|
|
13225
13905
|
if (includeChildrenRecursively) {
|
|
13226
13906
|
super.include(context, includeChildrenRecursively);
|
|
13227
13907
|
}
|
|
13228
13908
|
else {
|
|
13229
|
-
this.included
|
|
13909
|
+
if (!this.included)
|
|
13910
|
+
this.includeNode(context);
|
|
13230
13911
|
this.callee.include(context, false);
|
|
13231
13912
|
}
|
|
13232
|
-
this.callee.includeCallArguments(context, this.
|
|
13913
|
+
this.callee.includeCallArguments(context, this.interaction);
|
|
13914
|
+
}
|
|
13915
|
+
includeNode(context) {
|
|
13916
|
+
this.included = true;
|
|
13917
|
+
if (!this.deoptimized)
|
|
13918
|
+
this.applyDeoptimizations();
|
|
13919
|
+
this.callee.includePath(UNKNOWN_PATH, context);
|
|
13233
13920
|
}
|
|
13234
13921
|
initialise() {
|
|
13235
13922
|
super.initialise();
|
|
@@ -13258,6 +13945,7 @@ class ObjectExpression extends NodeBase {
|
|
|
13258
13945
|
constructor() {
|
|
13259
13946
|
super(...arguments);
|
|
13260
13947
|
this.objectEntity = null;
|
|
13948
|
+
this.protoProp = null;
|
|
13261
13949
|
}
|
|
13262
13950
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13263
13951
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13277,15 +13965,43 @@ class ObjectExpression extends NodeBase {
|
|
|
13277
13965
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13278
13966
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13279
13967
|
}
|
|
13968
|
+
include(context, includeChildrenRecursively) {
|
|
13969
|
+
if (!this.included)
|
|
13970
|
+
this.includeNode(context);
|
|
13971
|
+
this.getObjectEntity().include(context, includeChildrenRecursively);
|
|
13972
|
+
this.protoProp?.include(context, includeChildrenRecursively);
|
|
13973
|
+
}
|
|
13974
|
+
includeNode(context) {
|
|
13975
|
+
this.included = true;
|
|
13976
|
+
this.protoProp?.includePath(UNKNOWN_PATH, context);
|
|
13977
|
+
}
|
|
13978
|
+
includePath(path, context) {
|
|
13979
|
+
if (!this.included)
|
|
13980
|
+
this.includeNode(context);
|
|
13981
|
+
this.getObjectEntity().includePath(path, context);
|
|
13982
|
+
}
|
|
13280
13983
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13281
|
-
super.render(code, options);
|
|
13282
13984
|
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13283
13985
|
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
13284
13986
|
code.appendRight(this.start, '(');
|
|
13285
13987
|
code.prependLeft(this.end, ')');
|
|
13286
13988
|
}
|
|
13989
|
+
if (this.properties.length > 0) {
|
|
13990
|
+
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
13991
|
+
let lastSeparatorPos = null;
|
|
13992
|
+
for (const { node, separator, start, end } of separatedNodes) {
|
|
13993
|
+
if (!node.included) {
|
|
13994
|
+
treeshakeNode(node, code, start, end);
|
|
13995
|
+
continue;
|
|
13996
|
+
}
|
|
13997
|
+
lastSeparatorPos = separator;
|
|
13998
|
+
node.render(code, options);
|
|
13999
|
+
}
|
|
14000
|
+
if (lastSeparatorPos) {
|
|
14001
|
+
code.remove(lastSeparatorPos, this.end - 1);
|
|
14002
|
+
}
|
|
14003
|
+
}
|
|
13287
14004
|
}
|
|
13288
|
-
applyDeoptimizations() { }
|
|
13289
14005
|
getObjectEntity() {
|
|
13290
14006
|
if (this.objectEntity !== null) {
|
|
13291
14007
|
return this.objectEntity;
|
|
@@ -13314,6 +14030,7 @@ class ObjectExpression extends NodeBase {
|
|
|
13314
14030
|
? property.key.name
|
|
13315
14031
|
: String(property.key.value);
|
|
13316
14032
|
if (key === '__proto__' && property.kind === 'init') {
|
|
14033
|
+
this.protoProp = property;
|
|
13317
14034
|
prototype =
|
|
13318
14035
|
property.value instanceof Literal && property.value.value === null
|
|
13319
14036
|
? null
|
|
@@ -13326,6 +14043,7 @@ class ObjectExpression extends NodeBase {
|
|
|
13326
14043
|
return (this.objectEntity = new ObjectEntity(properties, prototype));
|
|
13327
14044
|
}
|
|
13328
14045
|
}
|
|
14046
|
+
ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13329
14047
|
|
|
13330
14048
|
class PanicError extends NodeBase {
|
|
13331
14049
|
initialise() {
|
|
@@ -13352,6 +14070,7 @@ class ParseError extends NodeBase {
|
|
|
13352
14070
|
|
|
13353
14071
|
class PrivateIdentifier extends NodeBase {
|
|
13354
14072
|
}
|
|
14073
|
+
PrivateIdentifier.prototype.includeNode = onlyIncludeSelf;
|
|
13355
14074
|
|
|
13356
14075
|
class Program extends NodeBase {
|
|
13357
14076
|
constructor() {
|
|
@@ -13419,14 +14138,11 @@ class Program extends NodeBase {
|
|
|
13419
14138
|
super.render(code, options);
|
|
13420
14139
|
}
|
|
13421
14140
|
}
|
|
13422
|
-
applyDeoptimizations() { }
|
|
13423
14141
|
}
|
|
14142
|
+
Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14143
|
+
Program.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13424
14144
|
|
|
13425
14145
|
class Property extends MethodBase {
|
|
13426
|
-
constructor() {
|
|
13427
|
-
super(...arguments);
|
|
13428
|
-
this.declarationInit = null;
|
|
13429
|
-
}
|
|
13430
14146
|
//declare method: boolean;
|
|
13431
14147
|
get method() {
|
|
13432
14148
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -13441,17 +14157,41 @@ class Property extends MethodBase {
|
|
|
13441
14157
|
set shorthand(value) {
|
|
13442
14158
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
13443
14159
|
}
|
|
13444
|
-
declare(kind, init) {
|
|
13445
|
-
this.
|
|
13446
|
-
|
|
14160
|
+
declare(kind, destructuredInitPath, init) {
|
|
14161
|
+
return this.value.declare(kind, this.getPathInProperty(destructuredInitPath), init);
|
|
14162
|
+
}
|
|
14163
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
14164
|
+
this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
|
|
13447
14165
|
}
|
|
13448
14166
|
hasEffects(context) {
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
return
|
|
13453
|
-
|
|
13454
|
-
|
|
14167
|
+
return this.key.hasEffects(context) || this.value.hasEffects(context);
|
|
14168
|
+
}
|
|
14169
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
14170
|
+
return this.value.hasEffectsWhenDestructuring?.(context, this.getPathInProperty(destructuredInitPath), init);
|
|
14171
|
+
}
|
|
14172
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
14173
|
+
const path = this.getPathInProperty(destructuredInitPath);
|
|
14174
|
+
let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
|
|
14175
|
+
this.included;
|
|
14176
|
+
if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
|
|
14177
|
+
this.key.include(context, false);
|
|
14178
|
+
if (!this.value.included) {
|
|
14179
|
+
this.value.included = true;
|
|
14180
|
+
// Unfortunately, we need to include the value again now, so that any
|
|
14181
|
+
// declared variables are properly included.
|
|
14182
|
+
this.value.includeDestructuredIfNecessary(context, path, init);
|
|
14183
|
+
}
|
|
14184
|
+
}
|
|
14185
|
+
return (this.included = included);
|
|
14186
|
+
}
|
|
14187
|
+
include(context, includeChildrenRecursively) {
|
|
14188
|
+
this.included = true;
|
|
14189
|
+
this.key.include(context, includeChildrenRecursively);
|
|
14190
|
+
this.value.include(context, includeChildrenRecursively);
|
|
14191
|
+
}
|
|
14192
|
+
includePath(path, context) {
|
|
14193
|
+
this.included = true;
|
|
14194
|
+
this.value.includePath(path, context);
|
|
13455
14195
|
}
|
|
13456
14196
|
markDeclarationReached() {
|
|
13457
14197
|
this.value.markDeclarationReached();
|
|
@@ -13462,14 +14202,20 @@ class Property extends MethodBase {
|
|
|
13462
14202
|
}
|
|
13463
14203
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
13464
14204
|
}
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
14205
|
+
getPathInProperty(destructuredInitPath) {
|
|
14206
|
+
return destructuredInitPath.at(-1) === UnknownKey
|
|
14207
|
+
? destructuredInitPath
|
|
14208
|
+
: // For now, we only consider static paths as we do not know how to
|
|
14209
|
+
// deoptimize the path in the dynamic case.
|
|
14210
|
+
this.computed
|
|
14211
|
+
? [...destructuredInitPath, UnknownKey]
|
|
14212
|
+
: this.key instanceof Identifier
|
|
14213
|
+
? [...destructuredInitPath, this.key.name]
|
|
14214
|
+
: [...destructuredInitPath, String(this.key.value)];
|
|
13471
14215
|
}
|
|
13472
14216
|
}
|
|
14217
|
+
Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14218
|
+
Property.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13473
14219
|
|
|
13474
14220
|
class PropertyDefinition extends NodeBase {
|
|
13475
14221
|
get computed() {
|
|
@@ -13502,8 +14248,15 @@ class PropertyDefinition extends NodeBase {
|
|
|
13502
14248
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13503
14249
|
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13504
14250
|
}
|
|
13505
|
-
|
|
14251
|
+
includeNode(context) {
|
|
14252
|
+
this.included = true;
|
|
14253
|
+
this.value?.includePath(UNKNOWN_PATH, context);
|
|
14254
|
+
for (const decorator of this.decorators) {
|
|
14255
|
+
decorator.includePath(UNKNOWN_PATH, context);
|
|
14256
|
+
}
|
|
14257
|
+
}
|
|
13506
14258
|
}
|
|
14259
|
+
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13507
14260
|
|
|
13508
14261
|
class ReturnStatement extends NodeBase {
|
|
13509
14262
|
hasEffects(context) {
|
|
@@ -13513,10 +14266,15 @@ class ReturnStatement extends NodeBase {
|
|
|
13513
14266
|
return false;
|
|
13514
14267
|
}
|
|
13515
14268
|
include(context, includeChildrenRecursively) {
|
|
13516
|
-
this.included
|
|
14269
|
+
if (!this.included)
|
|
14270
|
+
this.includeNode(context);
|
|
13517
14271
|
this.argument?.include(context, includeChildrenRecursively);
|
|
13518
14272
|
context.brokenFlow = true;
|
|
13519
14273
|
}
|
|
14274
|
+
includeNode(context) {
|
|
14275
|
+
this.included = true;
|
|
14276
|
+
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
14277
|
+
}
|
|
13520
14278
|
initialise() {
|
|
13521
14279
|
super.initialise();
|
|
13522
14280
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
@@ -13530,6 +14288,7 @@ class ReturnStatement extends NodeBase {
|
|
|
13530
14288
|
}
|
|
13531
14289
|
}
|
|
13532
14290
|
}
|
|
14291
|
+
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13533
14292
|
|
|
13534
14293
|
class SequenceExpression extends NodeBase {
|
|
13535
14294
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -13557,10 +14316,15 @@ class SequenceExpression extends NodeBase {
|
|
|
13557
14316
|
for (const expression of this.expressions) {
|
|
13558
14317
|
if (includeChildrenRecursively ||
|
|
13559
14318
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
13560
|
-
expression.shouldBeIncluded(context))
|
|
14319
|
+
expression.shouldBeIncluded(context)) {
|
|
13561
14320
|
expression.include(context, includeChildrenRecursively);
|
|
14321
|
+
}
|
|
13562
14322
|
}
|
|
13563
14323
|
}
|
|
14324
|
+
includePath(path, context) {
|
|
14325
|
+
this.included = true;
|
|
14326
|
+
this.expressions[this.expressions.length - 1].includePath(path, context);
|
|
14327
|
+
}
|
|
13564
14328
|
removeAnnotations(code) {
|
|
13565
14329
|
this.expressions[0].removeAnnotations(code);
|
|
13566
14330
|
}
|
|
@@ -13595,6 +14359,8 @@ class SequenceExpression extends NodeBase {
|
|
|
13595
14359
|
}
|
|
13596
14360
|
}
|
|
13597
14361
|
}
|
|
14362
|
+
SequenceExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14363
|
+
SequenceExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13598
14364
|
|
|
13599
14365
|
class Super extends NodeBase {
|
|
13600
14366
|
bind() {
|
|
@@ -13606,11 +14372,15 @@ class Super extends NodeBase {
|
|
|
13606
14372
|
deoptimizePath(path) {
|
|
13607
14373
|
this.variable.deoptimizePath(path);
|
|
13608
14374
|
}
|
|
13609
|
-
include() {
|
|
13610
|
-
if (!this.included)
|
|
13611
|
-
this.
|
|
13612
|
-
|
|
13613
|
-
|
|
14375
|
+
include(context) {
|
|
14376
|
+
if (!this.included)
|
|
14377
|
+
this.includeNode(context);
|
|
14378
|
+
}
|
|
14379
|
+
includeNode(context) {
|
|
14380
|
+
this.included = true;
|
|
14381
|
+
if (!this.deoptimized)
|
|
14382
|
+
this.applyDeoptimizations();
|
|
14383
|
+
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13614
14384
|
}
|
|
13615
14385
|
}
|
|
13616
14386
|
|
|
@@ -13635,22 +14405,24 @@ class SwitchCase extends NodeBase {
|
|
|
13635
14405
|
}
|
|
13636
14406
|
}
|
|
13637
14407
|
render(code, options, nodeRenderOptions) {
|
|
13638
|
-
if (this.
|
|
13639
|
-
|
|
13640
|
-
|
|
14408
|
+
if (this.test) {
|
|
14409
|
+
this.test.render(code, options);
|
|
14410
|
+
if (this.test.start === this.start + 4) {
|
|
14411
|
+
code.prependLeft(this.test.start, ' ');
|
|
13641
14412
|
}
|
|
14413
|
+
}
|
|
14414
|
+
if (this.consequent.length > 0) {
|
|
13642
14415
|
const testEnd = this.test
|
|
13643
14416
|
? this.test.end
|
|
13644
14417
|
: findFirstOccurrenceOutsideComment(code.original, 'default', this.start) + 7;
|
|
13645
14418
|
const consequentStart = findFirstOccurrenceOutsideComment(code.original, ':', testEnd) + 1;
|
|
13646
14419
|
renderStatementList(this.consequent, code, consequentStart, nodeRenderOptions.end, options);
|
|
13647
14420
|
}
|
|
13648
|
-
else {
|
|
13649
|
-
super.render(code, options);
|
|
13650
|
-
}
|
|
13651
14421
|
}
|
|
13652
14422
|
}
|
|
13653
14423
|
SwitchCase.prototype.needsBoundaries = true;
|
|
14424
|
+
SwitchCase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14425
|
+
SwitchCase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13654
14426
|
|
|
13655
14427
|
class SwitchStatement extends NodeBase {
|
|
13656
14428
|
createScope(parentScope) {
|
|
@@ -13733,6 +14505,8 @@ class SwitchStatement extends NodeBase {
|
|
|
13733
14505
|
}
|
|
13734
14506
|
}
|
|
13735
14507
|
}
|
|
14508
|
+
SwitchStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14509
|
+
SwitchStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13736
14510
|
|
|
13737
14511
|
class TaggedTemplateExpression extends CallExpressionBase {
|
|
13738
14512
|
bind() {
|
|
@@ -13756,8 +14530,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
13756
14530
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
13757
14531
|
}
|
|
13758
14532
|
include(context, includeChildrenRecursively) {
|
|
13759
|
-
if (!this.
|
|
13760
|
-
this.
|
|
14533
|
+
if (!this.included)
|
|
14534
|
+
this.includeNode(context);
|
|
13761
14535
|
if (includeChildrenRecursively) {
|
|
13762
14536
|
super.include(context, includeChildrenRecursively);
|
|
13763
14537
|
}
|
|
@@ -13766,7 +14540,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
13766
14540
|
this.tag.include(context, includeChildrenRecursively);
|
|
13767
14541
|
this.quasi.include(context, includeChildrenRecursively);
|
|
13768
14542
|
}
|
|
13769
|
-
this.tag.includeCallArguments(context, this.
|
|
14543
|
+
this.tag.includeCallArguments(context, this.interaction);
|
|
13770
14544
|
const [returnExpression] = this.getReturnExpression();
|
|
13771
14545
|
if (!returnExpression.included) {
|
|
13772
14546
|
returnExpression.include(context, false);
|
|
@@ -13801,6 +14575,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
13801
14575
|
return this.returnExpression;
|
|
13802
14576
|
}
|
|
13803
14577
|
}
|
|
14578
|
+
TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
13804
14579
|
|
|
13805
14580
|
class TemplateElement extends NodeBase {
|
|
13806
14581
|
get tail() {
|
|
@@ -13814,15 +14589,13 @@ class TemplateElement extends NodeBase {
|
|
|
13814
14589
|
hasEffects() {
|
|
13815
14590
|
return false;
|
|
13816
14591
|
}
|
|
13817
|
-
include() {
|
|
13818
|
-
this.included = true;
|
|
13819
|
-
}
|
|
13820
14592
|
parseNode(esTreeNode) {
|
|
13821
14593
|
this.value = esTreeNode.value;
|
|
13822
14594
|
return super.parseNode(esTreeNode);
|
|
13823
14595
|
}
|
|
13824
14596
|
render() { }
|
|
13825
14597
|
}
|
|
14598
|
+
TemplateElement.prototype.includeNode = onlyIncludeSelf;
|
|
13826
14599
|
|
|
13827
14600
|
class TemplateLiteral extends NodeBase {
|
|
13828
14601
|
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
@@ -13847,6 +14620,14 @@ class TemplateLiteral extends NodeBase {
|
|
|
13847
14620
|
}
|
|
13848
14621
|
return true;
|
|
13849
14622
|
}
|
|
14623
|
+
includeNode(context) {
|
|
14624
|
+
this.included = true;
|
|
14625
|
+
if (!this.deoptimized)
|
|
14626
|
+
this.applyDeoptimizations();
|
|
14627
|
+
for (const node of this.expressions) {
|
|
14628
|
+
node.includePath(UNKNOWN_PATH, context);
|
|
14629
|
+
}
|
|
14630
|
+
}
|
|
13850
14631
|
render(code, options) {
|
|
13851
14632
|
code.indentExclusionRanges.push([this.start, this.end]);
|
|
13852
14633
|
super.render(code, options);
|
|
@@ -13856,13 +14637,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
13856
14637
|
class ModuleScope extends ChildScope {
|
|
13857
14638
|
constructor(parent, context) {
|
|
13858
14639
|
super(parent, context);
|
|
13859
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
14640
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
13860
14641
|
}
|
|
13861
|
-
addDeclaration(identifier, context, init, kind) {
|
|
14642
|
+
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
13862
14643
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
13863
14644
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
13864
14645
|
}
|
|
13865
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
14646
|
+
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
13866
14647
|
}
|
|
13867
14648
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
13868
14649
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -13907,10 +14688,23 @@ class ThisExpression extends NodeBase {
|
|
|
13907
14688
|
}
|
|
13908
14689
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13909
14690
|
}
|
|
13910
|
-
include() {
|
|
14691
|
+
include(context) {
|
|
14692
|
+
if (!this.included)
|
|
14693
|
+
this.includeNode(context);
|
|
14694
|
+
}
|
|
14695
|
+
includeNode(context) {
|
|
14696
|
+
this.included = true;
|
|
14697
|
+
if (!this.deoptimized)
|
|
14698
|
+
this.applyDeoptimizations();
|
|
14699
|
+
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
14700
|
+
}
|
|
14701
|
+
includePath(path, context) {
|
|
13911
14702
|
if (!this.included) {
|
|
13912
14703
|
this.included = true;
|
|
13913
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
14704
|
+
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
14705
|
+
}
|
|
14706
|
+
else if (path.length > 0) {
|
|
14707
|
+
this.variable.includePath(path, context);
|
|
13914
14708
|
}
|
|
13915
14709
|
}
|
|
13916
14710
|
initialise() {
|
|
@@ -13938,7 +14732,8 @@ class ThrowStatement extends NodeBase {
|
|
|
13938
14732
|
return true;
|
|
13939
14733
|
}
|
|
13940
14734
|
include(context, includeChildrenRecursively) {
|
|
13941
|
-
this.included
|
|
14735
|
+
if (!this.included)
|
|
14736
|
+
this.includeNode(context);
|
|
13942
14737
|
this.argument.include(context, includeChildrenRecursively);
|
|
13943
14738
|
context.brokenFlow = true;
|
|
13944
14739
|
}
|
|
@@ -13949,6 +14744,7 @@ class ThrowStatement extends NodeBase {
|
|
|
13949
14744
|
}
|
|
13950
14745
|
}
|
|
13951
14746
|
}
|
|
14747
|
+
ThrowStatement.prototype.includeNode = onlyIncludeSelf;
|
|
13952
14748
|
|
|
13953
14749
|
class TryStatement extends NodeBase {
|
|
13954
14750
|
constructor() {
|
|
@@ -13985,6 +14781,8 @@ class TryStatement extends NodeBase {
|
|
|
13985
14781
|
this.finalizer?.include(context, includeChildrenRecursively);
|
|
13986
14782
|
}
|
|
13987
14783
|
}
|
|
14784
|
+
TryStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14785
|
+
TryStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13988
14786
|
|
|
13989
14787
|
const unaryOperators = {
|
|
13990
14788
|
'!': value => !value,
|
|
@@ -14042,7 +14840,7 @@ class UnaryExpression extends NodeBase {
|
|
|
14042
14840
|
return this.renderedLiteralValue;
|
|
14043
14841
|
return (this.renderedLiteralValue = includeChildrenRecursively
|
|
14044
14842
|
? UnknownValue
|
|
14045
|
-
:
|
|
14843
|
+
: getRenderedLiteralValue(this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
14046
14844
|
}
|
|
14047
14845
|
include(context, includeChildrenRecursively, _options) {
|
|
14048
14846
|
if (!this.deoptimized)
|
|
@@ -14059,11 +14857,16 @@ class UnaryExpression extends NodeBase {
|
|
|
14059
14857
|
super.render(code, options);
|
|
14060
14858
|
}
|
|
14061
14859
|
else {
|
|
14062
|
-
|
|
14860
|
+
let value = this.renderedLiteralValue;
|
|
14861
|
+
if (!CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE.test(code.original[this.start - 1])) {
|
|
14862
|
+
value = ` ${value}`;
|
|
14863
|
+
}
|
|
14864
|
+
code.overwrite(this.start, this.end, value);
|
|
14063
14865
|
}
|
|
14064
14866
|
}
|
|
14065
14867
|
}
|
|
14066
|
-
|
|
14868
|
+
const CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE = /[\s([=%&*+-/<>^|,?:;]/;
|
|
14869
|
+
function getRenderedLiteralValue(value) {
|
|
14067
14870
|
if (value === undefined || typeof value === 'boolean') {
|
|
14068
14871
|
return String(value);
|
|
14069
14872
|
}
|
|
@@ -14086,6 +14889,7 @@ function getSimplifiedNumber(value) {
|
|
|
14086
14889
|
const stringifiedValue = String(value).replace('+', '');
|
|
14087
14890
|
return finalizedExp.length < stringifiedValue.length ? finalizedExp : stringifiedValue;
|
|
14088
14891
|
}
|
|
14892
|
+
UnaryExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14089
14893
|
|
|
14090
14894
|
class UpdateExpression extends NodeBase {
|
|
14091
14895
|
hasEffects(context) {
|
|
@@ -14097,9 +14901,8 @@ class UpdateExpression extends NodeBase {
|
|
|
14097
14901
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
14098
14902
|
}
|
|
14099
14903
|
include(context, includeChildrenRecursively) {
|
|
14100
|
-
if (!this.
|
|
14101
|
-
this.
|
|
14102
|
-
this.included = true;
|
|
14904
|
+
if (!this.included)
|
|
14905
|
+
this.includeNode(context);
|
|
14103
14906
|
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
14104
14907
|
}
|
|
14105
14908
|
initialise() {
|
|
@@ -14138,6 +14941,7 @@ class UpdateExpression extends NodeBase {
|
|
|
14138
14941
|
this.scope.context.requestTreeshakingPass();
|
|
14139
14942
|
}
|
|
14140
14943
|
}
|
|
14944
|
+
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14141
14945
|
|
|
14142
14946
|
function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
|
|
14143
14947
|
for (const declarator of declarations) {
|
|
@@ -14168,8 +14972,9 @@ class VariableDeclaration extends NodeBase {
|
|
|
14168
14972
|
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
14169
14973
|
this.included = true;
|
|
14170
14974
|
for (const declarator of this.declarations) {
|
|
14171
|
-
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14975
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) {
|
|
14172
14976
|
declarator.include(context, includeChildrenRecursively);
|
|
14977
|
+
}
|
|
14173
14978
|
const { id, init } = declarator;
|
|
14174
14979
|
if (asSingleStatement) {
|
|
14175
14980
|
id.include(context, includeChildrenRecursively);
|
|
@@ -14207,7 +15012,6 @@ class VariableDeclaration extends NodeBase {
|
|
|
14207
15012
|
this.renderReplacedDeclarations(code, options);
|
|
14208
15013
|
}
|
|
14209
15014
|
}
|
|
14210
|
-
applyDeoptimizations() { }
|
|
14211
15015
|
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
14212
15016
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
14213
15017
|
code.remove(this.end - 1, this.end);
|
|
@@ -14250,8 +15054,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
14250
15054
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
14251
15055
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
14252
15056
|
if (!node.included) {
|
|
14253
|
-
code
|
|
14254
|
-
node.removeAnnotations(code);
|
|
15057
|
+
treeshakeNode(node, code, start, end);
|
|
14255
15058
|
continue;
|
|
14256
15059
|
}
|
|
14257
15060
|
node.render(code, options);
|
|
@@ -14321,6 +15124,8 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
14321
15124
|
}
|
|
14322
15125
|
return singleSystemExport;
|
|
14323
15126
|
}
|
|
15127
|
+
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15128
|
+
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14324
15129
|
|
|
14325
15130
|
class WhileStatement extends NodeBase {
|
|
14326
15131
|
hasEffects(context) {
|
|
@@ -14334,13 +15139,25 @@ class WhileStatement extends NodeBase {
|
|
|
14334
15139
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
14335
15140
|
}
|
|
14336
15141
|
}
|
|
15142
|
+
WhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15143
|
+
WhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14337
15144
|
|
|
14338
15145
|
class YieldExpression extends NodeBase {
|
|
15146
|
+
applyDeoptimizations() {
|
|
15147
|
+
this.deoptimized = true;
|
|
15148
|
+
this.argument?.deoptimizePath(UNKNOWN_PATH);
|
|
15149
|
+
}
|
|
14339
15150
|
hasEffects(context) {
|
|
14340
15151
|
if (!this.deoptimized)
|
|
14341
15152
|
this.applyDeoptimizations();
|
|
14342
15153
|
return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
|
|
14343
15154
|
}
|
|
15155
|
+
includeNode(context) {
|
|
15156
|
+
this.included = true;
|
|
15157
|
+
if (!this.deoptimized)
|
|
15158
|
+
this.applyDeoptimizations();
|
|
15159
|
+
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
15160
|
+
}
|
|
14344
15161
|
render(code, options) {
|
|
14345
15162
|
if (this.argument) {
|
|
14346
15163
|
this.argument.render(code, options, { preventASI: true });
|
|
@@ -14574,7 +15391,7 @@ const bufferParsers = [
|
|
|
14574
15391
|
const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
|
|
14575
15392
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
14576
15393
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
14577
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15394
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14578
15395
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
14579
15396
|
},
|
|
14580
15397
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -14620,7 +15437,7 @@ const bufferParsers = [
|
|
|
14620
15437
|
const parameterPosition = buffer[position];
|
|
14621
15438
|
const parameter = (node.param =
|
|
14622
15439
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
14623
|
-
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
15440
|
+
parameter?.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION);
|
|
14624
15441
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
14625
15442
|
},
|
|
14626
15443
|
function chainExpression(node, position, buffer) {
|
|
@@ -14758,7 +15575,7 @@ const bufferParsers = [
|
|
|
14758
15575
|
node.id =
|
|
14759
15576
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
14760
15577
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
14761
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15578
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14762
15579
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
14763
15580
|
},
|
|
14764
15581
|
function functionExpression(node, position, buffer) {
|
|
@@ -14771,7 +15588,7 @@ const bufferParsers = [
|
|
|
14771
15588
|
const idPosition = buffer[position + 2];
|
|
14772
15589
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
14773
15590
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
14774
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15591
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14775
15592
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
14776
15593
|
},
|
|
14777
15594
|
function identifier(node, position, buffer) {
|
|
@@ -15235,8 +16052,8 @@ class ExportShimVariable extends Variable {
|
|
|
15235
16052
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
15236
16053
|
this.module = module;
|
|
15237
16054
|
}
|
|
15238
|
-
|
|
15239
|
-
super.
|
|
16055
|
+
includePath(path, context) {
|
|
16056
|
+
super.includePath(path, context);
|
|
15240
16057
|
this.module.needsExportShim = true;
|
|
15241
16058
|
}
|
|
15242
16059
|
}
|
|
@@ -15934,16 +16751,15 @@ class Module {
|
|
|
15934
16751
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
15935
16752
|
this.graph.needsTreeshakingPass = true;
|
|
15936
16753
|
}
|
|
16754
|
+
const inclusionContext = createInclusionContext();
|
|
15937
16755
|
for (const exportName of this.exports.keys()) {
|
|
15938
16756
|
if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
|
|
15939
16757
|
const variable = this.getVariableForExportName(exportName)[0];
|
|
15940
16758
|
if (!variable) {
|
|
15941
16759
|
return error(logMissingEntryExport(exportName, this.id));
|
|
15942
16760
|
}
|
|
16761
|
+
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
15943
16762
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15944
|
-
if (!variable.included) {
|
|
15945
|
-
this.includeVariable(variable);
|
|
15946
|
-
}
|
|
15947
16763
|
}
|
|
15948
16764
|
}
|
|
15949
16765
|
for (const name of this.getReexports()) {
|
|
@@ -15951,7 +16767,7 @@ class Module {
|
|
|
15951
16767
|
if (variable) {
|
|
15952
16768
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15953
16769
|
if (!variable.included) {
|
|
15954
|
-
this.includeVariable(variable);
|
|
16770
|
+
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
15955
16771
|
}
|
|
15956
16772
|
if (variable instanceof ExternalVariable) {
|
|
15957
16773
|
variable.module.reexported = true;
|
|
@@ -15972,13 +16788,12 @@ class Module {
|
|
|
15972
16788
|
this.graph.needsTreeshakingPass = true;
|
|
15973
16789
|
}
|
|
15974
16790
|
let includeNamespaceMembers = false;
|
|
16791
|
+
const inclusionContext = createInclusionContext();
|
|
15975
16792
|
for (const name of names) {
|
|
15976
16793
|
const variable = this.getVariableForExportName(name)[0];
|
|
15977
16794
|
if (variable) {
|
|
15978
16795
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15979
|
-
|
|
15980
|
-
this.includeVariable(variable);
|
|
15981
|
-
}
|
|
16796
|
+
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
15982
16797
|
}
|
|
15983
16798
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
15984
16799
|
includeNamespaceMembers = true;
|
|
@@ -16079,6 +16894,7 @@ class Module {
|
|
|
16079
16894
|
manualPureFunctions: this.graph.pureFunctions,
|
|
16080
16895
|
module: this,
|
|
16081
16896
|
moduleContext: this.context,
|
|
16897
|
+
newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
|
|
16082
16898
|
options: this.options,
|
|
16083
16899
|
requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
|
|
16084
16900
|
traceExport: (name) => this.getVariableForExportName(name)[0],
|
|
@@ -16419,13 +17235,13 @@ class Module {
|
|
|
16419
17235
|
for (const module of [this, ...this.exportAllModules]) {
|
|
16420
17236
|
if (module instanceof ExternalModule) {
|
|
16421
17237
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
16422
|
-
externalVariable.
|
|
17238
|
+
externalVariable.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
16423
17239
|
this.includedImports.add(externalVariable);
|
|
16424
17240
|
externalNamespaces.add(externalVariable);
|
|
16425
17241
|
}
|
|
16426
17242
|
else if (module.info.syntheticNamedExports) {
|
|
16427
17243
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
16428
|
-
syntheticNamespace.
|
|
17244
|
+
syntheticNamespace.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
16429
17245
|
this.includedImports.add(syntheticNamespace);
|
|
16430
17246
|
syntheticNamespaces.add(syntheticNamespace);
|
|
16431
17247
|
}
|
|
@@ -16435,7 +17251,9 @@ class Module {
|
|
|
16435
17251
|
includeDynamicImport(node) {
|
|
16436
17252
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
16437
17253
|
if (resolution instanceof Module) {
|
|
16438
|
-
resolution.includedDynamicImporters.
|
|
17254
|
+
if (!resolution.includedDynamicImporters.includes(this)) {
|
|
17255
|
+
resolution.includedDynamicImporters.push(this);
|
|
17256
|
+
}
|
|
16439
17257
|
const importedNames = this.options.treeshake
|
|
16440
17258
|
? node.getDeterministicImportedNames()
|
|
16441
17259
|
: undefined;
|
|
@@ -16447,15 +17265,15 @@ class Module {
|
|
|
16447
17265
|
}
|
|
16448
17266
|
}
|
|
16449
17267
|
}
|
|
16450
|
-
includeVariable(variable) {
|
|
16451
|
-
const variableModule = variable
|
|
16452
|
-
|
|
17268
|
+
includeVariable(variable, path, context) {
|
|
17269
|
+
const { included, module: variableModule } = variable;
|
|
17270
|
+
variable.includePath(path, context);
|
|
17271
|
+
if (included) {
|
|
16453
17272
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
16454
17273
|
getAndExtendSideEffectModules(variable, this);
|
|
16455
17274
|
}
|
|
16456
17275
|
}
|
|
16457
17276
|
else {
|
|
16458
|
-
variable.include();
|
|
16459
17277
|
this.graph.needsTreeshakingPass = true;
|
|
16460
17278
|
if (variableModule instanceof Module) {
|
|
16461
17279
|
if (!variableModule.isExecuted) {
|
|
@@ -16472,8 +17290,8 @@ class Module {
|
|
|
16472
17290
|
}
|
|
16473
17291
|
}
|
|
16474
17292
|
}
|
|
16475
|
-
includeVariableInModule(variable) {
|
|
16476
|
-
this.includeVariable(variable);
|
|
17293
|
+
includeVariableInModule(variable, path, context) {
|
|
17294
|
+
this.includeVariable(variable, path, context);
|
|
16477
17295
|
const variableModule = variable.module;
|
|
16478
17296
|
if (variableModule && variableModule !== this) {
|
|
16479
17297
|
this.includedImports.add(variable);
|
|
@@ -21072,10 +21890,11 @@ class Graph {
|
|
|
21072
21890
|
this.options = options;
|
|
21073
21891
|
this.astLru = flru(5);
|
|
21074
21892
|
this.cachedModules = new Map();
|
|
21075
|
-
this.deoptimizationTracker = new
|
|
21893
|
+
this.deoptimizationTracker = new EntityPathTracker();
|
|
21076
21894
|
this.entryModules = [];
|
|
21077
21895
|
this.modulesById = new Map();
|
|
21078
21896
|
this.needsTreeshakingPass = false;
|
|
21897
|
+
this.newlyIncludedVariableInits = new Set();
|
|
21079
21898
|
this.phase = BuildPhase.LOAD_AND_PARSE;
|
|
21080
21899
|
this.scope = new GlobalScope();
|
|
21081
21900
|
this.watchFiles = Object.create(null);
|
|
@@ -21169,6 +21988,7 @@ class Graph {
|
|
|
21169
21988
|
}
|
|
21170
21989
|
if (this.options.treeshake) {
|
|
21171
21990
|
let treeshakingPass = 1;
|
|
21991
|
+
this.newlyIncludedVariableInits.clear();
|
|
21172
21992
|
do {
|
|
21173
21993
|
timeStart(`treeshaking pass ${treeshakingPass}`, 3);
|
|
21174
21994
|
this.needsTreeshakingPass = false;
|
|
@@ -21181,6 +22001,10 @@ class Graph {
|
|
|
21181
22001
|
else {
|
|
21182
22002
|
module.include();
|
|
21183
22003
|
}
|
|
22004
|
+
for (const entity of this.newlyIncludedVariableInits) {
|
|
22005
|
+
this.newlyIncludedVariableInits.delete(entity);
|
|
22006
|
+
entity.include(createInclusionContext(), false);
|
|
22007
|
+
}
|
|
21184
22008
|
}
|
|
21185
22009
|
}
|
|
21186
22010
|
if (treeshakingPass === 1) {
|
|
@@ -22053,7 +22877,7 @@ const pc = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
|
22053
22877
|
|
|
22054
22878
|
// @see https://no-color.org
|
|
22055
22879
|
// @see https://www.npmjs.com/package/chalk
|
|
22056
|
-
const { bold, cyan, dim,
|
|
22880
|
+
const { bold, cyan, dim, red} = pc.createColors(env.FORCE_COLOR !== '0' && !env.NO_COLOR);
|
|
22057
22881
|
|
|
22058
22882
|
// log to stderr to keep `rollup main.js > bundle.js` from breaking
|
|
22059
22883
|
const stderr = (...parameters) => process$1.stderr.write(`${parameters.join('')}\n`);
|