@rollup/wasm-node 4.25.0-0 → 4.25.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 +8 -8
- 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 +772 -877
- package/dist/es/shared/parseAst.js +9 -8
- package/dist/es/shared/watch.js +3 -3
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +3 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +3 -3
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +8 -6
- package/dist/shared/rollup.js +769 -874
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +3 -3
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +24 -24
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.25.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.25.0
|
|
4
|
+
Sat, 09 Nov 2024 08:36:52 GMT - commit 42e587e0e37bc0661aa39fe7ad6f1d7fd33f825c
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, ExpressionStatement as ExpressionStatement$1, logMissingExport, normalize, getImportPath, logMissingNodeBuiltins, logReservedNamespace, error, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, ArrowFunctionExpression as ArrowFunctionExpression$1, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logParseError, logModuleParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, EMPTY_OBJECT, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logCircularReexport, logInvalidFormatForTopLevelAwait, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, warnDeprecation, URL_GENERATEBUNDLE, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, logInvalidExportOptionValue, URL_OUTPUT_INTEROP, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
|
|
12
|
-
import {
|
|
13
|
-
import { parseAsync,
|
|
12
|
+
import { posix, win32, isAbsolute, resolve } from 'path';
|
|
13
|
+
import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
|
|
14
14
|
import process$1, { env as env$1 } 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
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version = "4.25.0
|
|
19
|
+
var version = "4.25.0";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -2038,7 +2038,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
2038
2038
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
2039
2039
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
2040
2040
|
const EntitiesKey = Symbol('Entities');
|
|
2041
|
-
class
|
|
2041
|
+
class PathTracker {
|
|
2042
2042
|
constructor() {
|
|
2043
2043
|
this.entityPaths = Object.create(null, {
|
|
2044
2044
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -2063,14 +2063,14 @@ class EntityPathTracker {
|
|
|
2063
2063
|
getEntities(path) {
|
|
2064
2064
|
let currentPaths = this.entityPaths;
|
|
2065
2065
|
for (const pathSegment of path) {
|
|
2066
|
-
currentPaths = currentPaths[pathSegment]
|
|
2067
|
-
[
|
|
2068
|
-
|
|
2066
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2067
|
+
currentPaths[pathSegment] ||
|
|
2068
|
+
Object.create(null, { [EntitiesKey]: { value: new Set() } });
|
|
2069
2069
|
}
|
|
2070
2070
|
return currentPaths[EntitiesKey];
|
|
2071
2071
|
}
|
|
2072
2072
|
}
|
|
2073
|
-
const SHARED_RECURSION_TRACKER = new
|
|
2073
|
+
const SHARED_RECURSION_TRACKER = new PathTracker();
|
|
2074
2074
|
class DiscriminatedPathTracker {
|
|
2075
2075
|
constructor() {
|
|
2076
2076
|
this.entityPaths = Object.create(null, {
|
|
@@ -2080,9 +2080,9 @@ class DiscriminatedPathTracker {
|
|
|
2080
2080
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
2081
2081
|
let currentPaths = this.entityPaths;
|
|
2082
2082
|
for (const pathSegment of path) {
|
|
2083
|
-
currentPaths = currentPaths[pathSegment]
|
|
2084
|
-
[
|
|
2085
|
-
|
|
2083
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2084
|
+
currentPaths[pathSegment] ||
|
|
2085
|
+
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
2086
2086
|
}
|
|
2087
2087
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
2088
2088
|
if (trackedEntities.has(entity))
|
|
@@ -2091,55 +2091,6 @@ class DiscriminatedPathTracker {
|
|
|
2091
2091
|
return false;
|
|
2092
2092
|
}
|
|
2093
2093
|
}
|
|
2094
|
-
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: EMPTY_OBJECT });
|
|
2095
|
-
class IncludedPathTracker {
|
|
2096
|
-
constructor() {
|
|
2097
|
-
this.includedPaths = null;
|
|
2098
|
-
}
|
|
2099
|
-
includePathAndGetIfIncluded(path) {
|
|
2100
|
-
let included = true;
|
|
2101
|
-
let parent = this;
|
|
2102
|
-
let parentSegment = 'includedPaths';
|
|
2103
|
-
let currentPaths = (this.includedPaths ||=
|
|
2104
|
-
((included = false), Object.create(null)));
|
|
2105
|
-
for (const pathSegment of path) {
|
|
2106
|
-
// This means from here, all paths are included
|
|
2107
|
-
if (currentPaths[UnknownKey]) {
|
|
2108
|
-
return true;
|
|
2109
|
-
}
|
|
2110
|
-
// Including UnknownKey automatically includes all nested paths.
|
|
2111
|
-
// From above, we know that UnknownKey is not included yet.
|
|
2112
|
-
if (typeof pathSegment === 'symbol') {
|
|
2113
|
-
// Hopefully, this saves some memory over just setting
|
|
2114
|
-
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
2115
|
-
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
2116
|
-
return false;
|
|
2117
|
-
}
|
|
2118
|
-
parent = currentPaths;
|
|
2119
|
-
parentSegment = pathSegment;
|
|
2120
|
-
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
2121
|
-
}
|
|
2122
|
-
return included;
|
|
2123
|
-
}
|
|
2124
|
-
includeAllPaths(entity, context, basePath) {
|
|
2125
|
-
const { includedPaths } = this;
|
|
2126
|
-
if (includedPaths) {
|
|
2127
|
-
includeAllPaths(entity, context, basePath, includedPaths);
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
2132
|
-
if (currentPaths[UnknownKey]) {
|
|
2133
|
-
return entity.includePath([...basePath, UnknownKey], context, false);
|
|
2134
|
-
}
|
|
2135
|
-
const keys = Object.keys(currentPaths);
|
|
2136
|
-
if (keys.length === 0) {
|
|
2137
|
-
return entity.includePath(basePath, context, false);
|
|
2138
|
-
}
|
|
2139
|
-
for (const key of keys) {
|
|
2140
|
-
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
2094
|
|
|
2144
2095
|
function isFlagSet(flags, flag) {
|
|
2145
2096
|
return (flags & flag) !== 0;
|
|
@@ -2178,12 +2129,12 @@ class ExpressionEntity {
|
|
|
2178
2129
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2179
2130
|
return true;
|
|
2180
2131
|
}
|
|
2181
|
-
|
|
2132
|
+
include(_context, _includeChildrenRecursively, _options) {
|
|
2182
2133
|
this.included = true;
|
|
2183
2134
|
}
|
|
2184
|
-
includeCallArguments(context,
|
|
2185
|
-
for (const argument of
|
|
2186
|
-
argument
|
|
2135
|
+
includeCallArguments(context, parameters) {
|
|
2136
|
+
for (const argument of parameters) {
|
|
2137
|
+
argument.include(context, false);
|
|
2187
2138
|
}
|
|
2188
2139
|
}
|
|
2189
2140
|
shouldBeIncluded(_context) {
|
|
@@ -2298,9 +2249,9 @@ class Variable extends ExpressionEntity {
|
|
|
2298
2249
|
* has not been included previously. Once a variable is included, it should
|
|
2299
2250
|
* take care all its declarations are included.
|
|
2300
2251
|
*/
|
|
2301
|
-
|
|
2252
|
+
include() {
|
|
2302
2253
|
this.included = true;
|
|
2303
|
-
this.renderedLikeHoisted?.
|
|
2254
|
+
this.renderedLikeHoisted?.include();
|
|
2304
2255
|
}
|
|
2305
2256
|
/**
|
|
2306
2257
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -2332,8 +2283,8 @@ class ExternalVariable extends Variable {
|
|
|
2332
2283
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2333
2284
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2334
2285
|
}
|
|
2335
|
-
|
|
2336
|
-
super.
|
|
2286
|
+
include() {
|
|
2287
|
+
super.include();
|
|
2337
2288
|
this.module.used = true;
|
|
2338
2289
|
}
|
|
2339
2290
|
}
|
|
@@ -2540,208 +2491,6 @@ function markModuleAndImpureDependenciesAsExecuted(baseModule) {
|
|
|
2540
2491
|
|
|
2541
2492
|
const doNothing = () => { };
|
|
2542
2493
|
|
|
2543
|
-
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
2544
|
-
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2545
|
-
}
|
|
2546
|
-
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2547
|
-
getLiteralValueAtPath() {
|
|
2548
|
-
return undefined;
|
|
2549
|
-
}
|
|
2550
|
-
})();
|
|
2551
|
-
const returnsUnknown = {
|
|
2552
|
-
value: {
|
|
2553
|
-
hasEffectsWhenCalled: null,
|
|
2554
|
-
returns: UNKNOWN_EXPRESSION
|
|
2555
|
-
}
|
|
2556
|
-
};
|
|
2557
|
-
const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEntity {
|
|
2558
|
-
getReturnExpressionWhenCalledAtPath(path) {
|
|
2559
|
-
if (path.length === 1) {
|
|
2560
|
-
return getMemberReturnExpressionWhenCalled(literalBooleanMembers, path[0]);
|
|
2561
|
-
}
|
|
2562
|
-
return UNKNOWN_RETURN_EXPRESSION;
|
|
2563
|
-
}
|
|
2564
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
2565
|
-
if (interaction.type === INTERACTION_ACCESSED) {
|
|
2566
|
-
return path.length > 1;
|
|
2567
|
-
}
|
|
2568
|
-
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
2569
|
-
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0], interaction, context);
|
|
2570
|
-
}
|
|
2571
|
-
return true;
|
|
2572
|
-
}
|
|
2573
|
-
})();
|
|
2574
|
-
const returnsBoolean = {
|
|
2575
|
-
value: {
|
|
2576
|
-
hasEffectsWhenCalled: null,
|
|
2577
|
-
returns: UNKNOWN_LITERAL_BOOLEAN
|
|
2578
|
-
}
|
|
2579
|
-
};
|
|
2580
|
-
const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity {
|
|
2581
|
-
getReturnExpressionWhenCalledAtPath(path) {
|
|
2582
|
-
if (path.length === 1) {
|
|
2583
|
-
return getMemberReturnExpressionWhenCalled(literalNumberMembers, path[0]);
|
|
2584
|
-
}
|
|
2585
|
-
return UNKNOWN_RETURN_EXPRESSION;
|
|
2586
|
-
}
|
|
2587
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
2588
|
-
if (interaction.type === INTERACTION_ACCESSED) {
|
|
2589
|
-
return path.length > 1;
|
|
2590
|
-
}
|
|
2591
|
-
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
2592
|
-
return hasMemberEffectWhenCalled(literalNumberMembers, path[0], interaction, context);
|
|
2593
|
-
}
|
|
2594
|
-
return true;
|
|
2595
|
-
}
|
|
2596
|
-
})();
|
|
2597
|
-
const returnsNumber = {
|
|
2598
|
-
value: {
|
|
2599
|
-
hasEffectsWhenCalled: null,
|
|
2600
|
-
returns: UNKNOWN_LITERAL_NUMBER
|
|
2601
|
-
}
|
|
2602
|
-
};
|
|
2603
|
-
const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity {
|
|
2604
|
-
getReturnExpressionWhenCalledAtPath(path) {
|
|
2605
|
-
if (path.length === 1) {
|
|
2606
|
-
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
2607
|
-
}
|
|
2608
|
-
return UNKNOWN_RETURN_EXPRESSION;
|
|
2609
|
-
}
|
|
2610
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
2611
|
-
if (interaction.type === INTERACTION_ACCESSED) {
|
|
2612
|
-
return path.length > 1;
|
|
2613
|
-
}
|
|
2614
|
-
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
2615
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
2616
|
-
}
|
|
2617
|
-
return true;
|
|
2618
|
-
}
|
|
2619
|
-
})();
|
|
2620
|
-
const returnsString = {
|
|
2621
|
-
value: {
|
|
2622
|
-
hasEffectsWhenCalled: null,
|
|
2623
|
-
returns: UNKNOWN_LITERAL_STRING
|
|
2624
|
-
}
|
|
2625
|
-
};
|
|
2626
|
-
const stringReplace = {
|
|
2627
|
-
value: {
|
|
2628
|
-
hasEffectsWhenCalled({ args }, context) {
|
|
2629
|
-
const argument1 = args[2];
|
|
2630
|
-
return (args.length < 3 ||
|
|
2631
|
-
(typeof argument1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
2632
|
-
deoptimizeCache() { }
|
|
2633
|
-
}) === 'symbol' &&
|
|
2634
|
-
argument1.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)));
|
|
2635
|
-
},
|
|
2636
|
-
returns: UNKNOWN_LITERAL_STRING
|
|
2637
|
-
}
|
|
2638
|
-
};
|
|
2639
|
-
const objectMembers = assembleMemberDescriptions({
|
|
2640
|
-
hasOwnProperty: returnsBoolean,
|
|
2641
|
-
isPrototypeOf: returnsBoolean,
|
|
2642
|
-
propertyIsEnumerable: returnsBoolean,
|
|
2643
|
-
toLocaleString: returnsString,
|
|
2644
|
-
toString: returnsString,
|
|
2645
|
-
valueOf: returnsUnknown
|
|
2646
|
-
});
|
|
2647
|
-
const literalBooleanMembers = assembleMemberDescriptions({
|
|
2648
|
-
valueOf: returnsBoolean
|
|
2649
|
-
}, objectMembers);
|
|
2650
|
-
const literalNumberMembers = assembleMemberDescriptions({
|
|
2651
|
-
toExponential: returnsString,
|
|
2652
|
-
toFixed: returnsString,
|
|
2653
|
-
toLocaleString: returnsString,
|
|
2654
|
-
toPrecision: returnsString,
|
|
2655
|
-
valueOf: returnsNumber
|
|
2656
|
-
}, objectMembers);
|
|
2657
|
-
/**
|
|
2658
|
-
* RegExp are stateful when they have the global or sticky flags set.
|
|
2659
|
-
* But if we actually don't use them, the side effect does not matter.
|
|
2660
|
-
* the check logic in `hasEffectsOnInteractionAtPath`.
|
|
2661
|
-
*/
|
|
2662
|
-
const literalRegExpMembers = assembleMemberDescriptions({
|
|
2663
|
-
exec: returnsUnknown,
|
|
2664
|
-
test: returnsBoolean
|
|
2665
|
-
}, objectMembers);
|
|
2666
|
-
const literalStringMembers = assembleMemberDescriptions({
|
|
2667
|
-
anchor: returnsString,
|
|
2668
|
-
at: returnsUnknown,
|
|
2669
|
-
big: returnsString,
|
|
2670
|
-
blink: returnsString,
|
|
2671
|
-
bold: returnsString,
|
|
2672
|
-
charAt: returnsString,
|
|
2673
|
-
charCodeAt: returnsNumber,
|
|
2674
|
-
codePointAt: returnsUnknown,
|
|
2675
|
-
concat: returnsString,
|
|
2676
|
-
endsWith: returnsBoolean,
|
|
2677
|
-
fixed: returnsString,
|
|
2678
|
-
fontcolor: returnsString,
|
|
2679
|
-
fontsize: returnsString,
|
|
2680
|
-
includes: returnsBoolean,
|
|
2681
|
-
indexOf: returnsNumber,
|
|
2682
|
-
italics: returnsString,
|
|
2683
|
-
lastIndexOf: returnsNumber,
|
|
2684
|
-
link: returnsString,
|
|
2685
|
-
localeCompare: returnsNumber,
|
|
2686
|
-
match: returnsUnknown,
|
|
2687
|
-
matchAll: returnsUnknown,
|
|
2688
|
-
normalize: returnsString,
|
|
2689
|
-
padEnd: returnsString,
|
|
2690
|
-
padStart: returnsString,
|
|
2691
|
-
repeat: returnsString,
|
|
2692
|
-
replace: stringReplace,
|
|
2693
|
-
replaceAll: stringReplace,
|
|
2694
|
-
search: returnsNumber,
|
|
2695
|
-
slice: returnsString,
|
|
2696
|
-
small: returnsString,
|
|
2697
|
-
split: returnsUnknown,
|
|
2698
|
-
startsWith: returnsBoolean,
|
|
2699
|
-
strike: returnsString,
|
|
2700
|
-
sub: returnsString,
|
|
2701
|
-
substr: returnsString,
|
|
2702
|
-
substring: returnsString,
|
|
2703
|
-
sup: returnsString,
|
|
2704
|
-
toLocaleLowerCase: returnsString,
|
|
2705
|
-
toLocaleUpperCase: returnsString,
|
|
2706
|
-
toLowerCase: returnsString,
|
|
2707
|
-
toString: returnsString, // overrides the toString() method of the Object object; it does not inherit Object.prototype.toString()
|
|
2708
|
-
toUpperCase: returnsString,
|
|
2709
|
-
trim: returnsString,
|
|
2710
|
-
trimEnd: returnsString,
|
|
2711
|
-
trimLeft: returnsString,
|
|
2712
|
-
trimRight: returnsString,
|
|
2713
|
-
trimStart: returnsString,
|
|
2714
|
-
valueOf: returnsString
|
|
2715
|
-
}, objectMembers);
|
|
2716
|
-
function getLiteralMembersForValue(value) {
|
|
2717
|
-
if (value instanceof RegExp) {
|
|
2718
|
-
return literalRegExpMembers;
|
|
2719
|
-
}
|
|
2720
|
-
switch (typeof value) {
|
|
2721
|
-
case 'boolean': {
|
|
2722
|
-
return literalBooleanMembers;
|
|
2723
|
-
}
|
|
2724
|
-
case 'number': {
|
|
2725
|
-
return literalNumberMembers;
|
|
2726
|
-
}
|
|
2727
|
-
case 'string': {
|
|
2728
|
-
return literalStringMembers;
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
return Object.create(null);
|
|
2732
|
-
}
|
|
2733
|
-
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
2734
|
-
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
2735
|
-
return true;
|
|
2736
|
-
}
|
|
2737
|
-
return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false;
|
|
2738
|
-
}
|
|
2739
|
-
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
2740
|
-
if (typeof memberName !== 'string' || !members[memberName])
|
|
2741
|
-
return UNKNOWN_RETURN_EXPRESSION;
|
|
2742
|
-
return [members[memberName].returns, false];
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
2494
|
// This file is generated by scripts/generate-child-node-keys.js.
|
|
2746
2495
|
// Do not edit this file directly.
|
|
2747
2496
|
const childNodeKeys = {
|
|
@@ -2847,8 +2596,8 @@ function createInclusionContext() {
|
|
|
2847
2596
|
}
|
|
2848
2597
|
function createHasEffectsContext() {
|
|
2849
2598
|
return {
|
|
2850
|
-
accessed: new
|
|
2851
|
-
assigned: new
|
|
2599
|
+
accessed: new PathTracker(),
|
|
2600
|
+
assigned: new PathTracker(),
|
|
2852
2601
|
brokenFlow: false,
|
|
2853
2602
|
called: new DiscriminatedPathTracker(),
|
|
2854
2603
|
hasBreak: false,
|
|
@@ -2934,7 +2683,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
2934
2683
|
return (this.hasEffects(context) ||
|
|
2935
2684
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
2936
2685
|
}
|
|
2937
|
-
|
|
2686
|
+
include(context, includeChildrenRecursively, _options) {
|
|
2938
2687
|
if (!this.deoptimized)
|
|
2939
2688
|
this.applyDeoptimizations();
|
|
2940
2689
|
this.included = true;
|
|
@@ -2944,16 +2693,16 @@ class NodeBase extends ExpressionEntity {
|
|
|
2944
2693
|
continue;
|
|
2945
2694
|
if (Array.isArray(value)) {
|
|
2946
2695
|
for (const child of value) {
|
|
2947
|
-
child?.
|
|
2696
|
+
child?.include(context, includeChildrenRecursively);
|
|
2948
2697
|
}
|
|
2949
2698
|
}
|
|
2950
2699
|
else {
|
|
2951
|
-
value.
|
|
2700
|
+
value.include(context, includeChildrenRecursively);
|
|
2952
2701
|
}
|
|
2953
2702
|
}
|
|
2954
2703
|
}
|
|
2955
2704
|
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
2956
|
-
this.
|
|
2705
|
+
this.include(context, includeChildrenRecursively);
|
|
2957
2706
|
}
|
|
2958
2707
|
/**
|
|
2959
2708
|
* Override to perform special initialisation steps after the scope is
|
|
@@ -2983,11 +2732,13 @@ class NodeBase extends ExpressionEntity {
|
|
|
2983
2732
|
this[key] = value;
|
|
2984
2733
|
}
|
|
2985
2734
|
else if (Array.isArray(value)) {
|
|
2986
|
-
this[key] =
|
|
2735
|
+
this[key] = new Array(value.length);
|
|
2736
|
+
let index = 0;
|
|
2987
2737
|
for (const child of value) {
|
|
2988
|
-
this[key]
|
|
2989
|
-
|
|
2990
|
-
|
|
2738
|
+
this[key][index++] =
|
|
2739
|
+
child === null
|
|
2740
|
+
? null
|
|
2741
|
+
: new (this.scope.context.getNodeConstructor(child.type))(this, this.scope).parseNode(child);
|
|
2991
2742
|
}
|
|
2992
2743
|
}
|
|
2993
2744
|
else {
|
|
@@ -2999,59 +2750,268 @@ class NodeBase extends ExpressionEntity {
|
|
|
2999
2750
|
this.initialise();
|
|
3000
2751
|
return this;
|
|
3001
2752
|
}
|
|
3002
|
-
removeAnnotations(code) {
|
|
3003
|
-
if (this.annotations) {
|
|
3004
|
-
for (const annotation of this.annotations) {
|
|
3005
|
-
code.remove(annotation.start, annotation.end);
|
|
3006
|
-
}
|
|
2753
|
+
removeAnnotations(code) {
|
|
2754
|
+
if (this.annotations) {
|
|
2755
|
+
for (const annotation of this.annotations) {
|
|
2756
|
+
code.remove(annotation.start, annotation.end);
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
render(code, options) {
|
|
2761
|
+
for (const key of childNodeKeys[this.type]) {
|
|
2762
|
+
const value = this[key];
|
|
2763
|
+
if (value === null)
|
|
2764
|
+
continue;
|
|
2765
|
+
if (Array.isArray(value)) {
|
|
2766
|
+
for (const child of value) {
|
|
2767
|
+
child?.render(code, options);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
else {
|
|
2771
|
+
value.render(code, options);
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
setAssignedValue(value) {
|
|
2776
|
+
this.assignmentInteraction = { args: [null, value], type: INTERACTION_ASSIGNED };
|
|
2777
|
+
}
|
|
2778
|
+
shouldBeIncluded(context) {
|
|
2779
|
+
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
2780
|
+
}
|
|
2781
|
+
/**
|
|
2782
|
+
* Just deoptimize everything by default so that when e.g. we do not track
|
|
2783
|
+
* something properly, it is deoptimized.
|
|
2784
|
+
* @protected
|
|
2785
|
+
*/
|
|
2786
|
+
applyDeoptimizations() {
|
|
2787
|
+
this.deoptimized = true;
|
|
2788
|
+
for (const key of childNodeKeys[this.type]) {
|
|
2789
|
+
const value = this[key];
|
|
2790
|
+
if (value === null)
|
|
2791
|
+
continue;
|
|
2792
|
+
if (Array.isArray(value)) {
|
|
2793
|
+
for (const child of value) {
|
|
2794
|
+
child?.deoptimizePath(UNKNOWN_PATH);
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
else {
|
|
2798
|
+
value.deoptimizePath(UNKNOWN_PATH);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
this.scope.context.requestTreeshakingPass();
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
function createChildNodeKeysForNode(esTreeNode) {
|
|
2805
|
+
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
function isObjectExpressionNode(node) {
|
|
2809
|
+
return node instanceof NodeBase && node.type === ObjectExpression$1;
|
|
2810
|
+
}
|
|
2811
|
+
function isPropertyNode(node) {
|
|
2812
|
+
return node.type === Property$1;
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
2816
|
+
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2817
|
+
}
|
|
2818
|
+
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2819
|
+
getLiteralValueAtPath() {
|
|
2820
|
+
return undefined;
|
|
2821
|
+
}
|
|
2822
|
+
})();
|
|
2823
|
+
const returnsUnknown = {
|
|
2824
|
+
value: {
|
|
2825
|
+
hasEffectsWhenCalled: null,
|
|
2826
|
+
returns: UNKNOWN_EXPRESSION
|
|
2827
|
+
}
|
|
2828
|
+
};
|
|
2829
|
+
const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEntity {
|
|
2830
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
2831
|
+
if (path.length === 1) {
|
|
2832
|
+
return getMemberReturnExpressionWhenCalled(literalBooleanMembers, path[0]);
|
|
2833
|
+
}
|
|
2834
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
2835
|
+
}
|
|
2836
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
2837
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
2838
|
+
return path.length > 1;
|
|
2839
|
+
}
|
|
2840
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
2841
|
+
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0], interaction, context);
|
|
2842
|
+
}
|
|
2843
|
+
return true;
|
|
2844
|
+
}
|
|
2845
|
+
})();
|
|
2846
|
+
const returnsBoolean = {
|
|
2847
|
+
value: {
|
|
2848
|
+
hasEffectsWhenCalled: null,
|
|
2849
|
+
returns: UNKNOWN_LITERAL_BOOLEAN
|
|
2850
|
+
}
|
|
2851
|
+
};
|
|
2852
|
+
const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity {
|
|
2853
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
2854
|
+
if (path.length === 1) {
|
|
2855
|
+
return getMemberReturnExpressionWhenCalled(literalNumberMembers, path[0]);
|
|
2856
|
+
}
|
|
2857
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
2858
|
+
}
|
|
2859
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
2860
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
2861
|
+
return path.length > 1;
|
|
2862
|
+
}
|
|
2863
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
2864
|
+
return hasMemberEffectWhenCalled(literalNumberMembers, path[0], interaction, context);
|
|
2865
|
+
}
|
|
2866
|
+
return true;
|
|
2867
|
+
}
|
|
2868
|
+
})();
|
|
2869
|
+
const returnsNumber = {
|
|
2870
|
+
value: {
|
|
2871
|
+
hasEffectsWhenCalled: null,
|
|
2872
|
+
returns: UNKNOWN_LITERAL_NUMBER
|
|
2873
|
+
}
|
|
2874
|
+
};
|
|
2875
|
+
const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity {
|
|
2876
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
2877
|
+
if (path.length === 1) {
|
|
2878
|
+
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
2879
|
+
}
|
|
2880
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
2881
|
+
}
|
|
2882
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
2883
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
2884
|
+
return path.length > 1;
|
|
2885
|
+
}
|
|
2886
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
2887
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
2888
|
+
}
|
|
2889
|
+
return true;
|
|
2890
|
+
}
|
|
2891
|
+
})();
|
|
2892
|
+
const returnsString = {
|
|
2893
|
+
value: {
|
|
2894
|
+
hasEffectsWhenCalled: null,
|
|
2895
|
+
returns: UNKNOWN_LITERAL_STRING
|
|
2896
|
+
}
|
|
2897
|
+
};
|
|
2898
|
+
const stringReplace = {
|
|
2899
|
+
value: {
|
|
2900
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
2901
|
+
const argument1 = args[2];
|
|
2902
|
+
return (args.length < 3 ||
|
|
2903
|
+
(typeof argument1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
2904
|
+
deoptimizeCache() { }
|
|
2905
|
+
}) === 'symbol' &&
|
|
2906
|
+
argument1.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)));
|
|
2907
|
+
},
|
|
2908
|
+
returns: UNKNOWN_LITERAL_STRING
|
|
2909
|
+
}
|
|
2910
|
+
};
|
|
2911
|
+
const objectMembers = assembleMemberDescriptions({
|
|
2912
|
+
hasOwnProperty: returnsBoolean,
|
|
2913
|
+
isPrototypeOf: returnsBoolean,
|
|
2914
|
+
propertyIsEnumerable: returnsBoolean,
|
|
2915
|
+
toLocaleString: returnsString,
|
|
2916
|
+
toString: returnsString,
|
|
2917
|
+
valueOf: returnsUnknown
|
|
2918
|
+
});
|
|
2919
|
+
const literalBooleanMembers = assembleMemberDescriptions({
|
|
2920
|
+
valueOf: returnsBoolean
|
|
2921
|
+
}, objectMembers);
|
|
2922
|
+
const literalNumberMembers = assembleMemberDescriptions({
|
|
2923
|
+
toExponential: returnsString,
|
|
2924
|
+
toFixed: returnsString,
|
|
2925
|
+
toLocaleString: returnsString,
|
|
2926
|
+
toPrecision: returnsString,
|
|
2927
|
+
valueOf: returnsNumber
|
|
2928
|
+
}, objectMembers);
|
|
2929
|
+
/**
|
|
2930
|
+
* RegExp are stateful when they have the global or sticky flags set.
|
|
2931
|
+
* But if we actually don't use them, the side effect does not matter.
|
|
2932
|
+
* the check logic in `hasEffectsOnInteractionAtPath`.
|
|
2933
|
+
*/
|
|
2934
|
+
const literalRegExpMembers = assembleMemberDescriptions({
|
|
2935
|
+
exec: returnsUnknown,
|
|
2936
|
+
test: returnsBoolean
|
|
2937
|
+
}, objectMembers);
|
|
2938
|
+
const literalStringMembers = assembleMemberDescriptions({
|
|
2939
|
+
anchor: returnsString,
|
|
2940
|
+
at: returnsUnknown,
|
|
2941
|
+
big: returnsString,
|
|
2942
|
+
blink: returnsString,
|
|
2943
|
+
bold: returnsString,
|
|
2944
|
+
charAt: returnsString,
|
|
2945
|
+
charCodeAt: returnsNumber,
|
|
2946
|
+
codePointAt: returnsUnknown,
|
|
2947
|
+
concat: returnsString,
|
|
2948
|
+
endsWith: returnsBoolean,
|
|
2949
|
+
fixed: returnsString,
|
|
2950
|
+
fontcolor: returnsString,
|
|
2951
|
+
fontsize: returnsString,
|
|
2952
|
+
includes: returnsBoolean,
|
|
2953
|
+
indexOf: returnsNumber,
|
|
2954
|
+
italics: returnsString,
|
|
2955
|
+
lastIndexOf: returnsNumber,
|
|
2956
|
+
link: returnsString,
|
|
2957
|
+
localeCompare: returnsNumber,
|
|
2958
|
+
match: returnsUnknown,
|
|
2959
|
+
matchAll: returnsUnknown,
|
|
2960
|
+
normalize: returnsString,
|
|
2961
|
+
padEnd: returnsString,
|
|
2962
|
+
padStart: returnsString,
|
|
2963
|
+
repeat: returnsString,
|
|
2964
|
+
replace: stringReplace,
|
|
2965
|
+
replaceAll: stringReplace,
|
|
2966
|
+
search: returnsNumber,
|
|
2967
|
+
slice: returnsString,
|
|
2968
|
+
small: returnsString,
|
|
2969
|
+
split: returnsUnknown,
|
|
2970
|
+
startsWith: returnsBoolean,
|
|
2971
|
+
strike: returnsString,
|
|
2972
|
+
sub: returnsString,
|
|
2973
|
+
substr: returnsString,
|
|
2974
|
+
substring: returnsString,
|
|
2975
|
+
sup: returnsString,
|
|
2976
|
+
toLocaleLowerCase: returnsString,
|
|
2977
|
+
toLocaleUpperCase: returnsString,
|
|
2978
|
+
toLowerCase: returnsString,
|
|
2979
|
+
toString: returnsString, // overrides the toString() method of the Object object; it does not inherit Object.prototype.toString()
|
|
2980
|
+
toUpperCase: returnsString,
|
|
2981
|
+
trim: returnsString,
|
|
2982
|
+
trimEnd: returnsString,
|
|
2983
|
+
trimLeft: returnsString,
|
|
2984
|
+
trimRight: returnsString,
|
|
2985
|
+
trimStart: returnsString,
|
|
2986
|
+
valueOf: returnsString
|
|
2987
|
+
}, objectMembers);
|
|
2988
|
+
function getLiteralMembersForValue(value) {
|
|
2989
|
+
if (value instanceof RegExp) {
|
|
2990
|
+
return literalRegExpMembers;
|
|
2991
|
+
}
|
|
2992
|
+
switch (typeof value) {
|
|
2993
|
+
case 'boolean': {
|
|
2994
|
+
return literalBooleanMembers;
|
|
3007
2995
|
}
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
for (const key of childNodeKeys[this.type]) {
|
|
3011
|
-
const value = this[key];
|
|
3012
|
-
if (value === null)
|
|
3013
|
-
continue;
|
|
3014
|
-
if (Array.isArray(value)) {
|
|
3015
|
-
for (const child of value) {
|
|
3016
|
-
child?.render(code, options);
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
else {
|
|
3020
|
-
value.render(code, options);
|
|
3021
|
-
}
|
|
2996
|
+
case 'number': {
|
|
2997
|
+
return literalNumberMembers;
|
|
3022
2998
|
}
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
this.assignmentInteraction = { args: [null, value], type: INTERACTION_ASSIGNED };
|
|
3026
|
-
}
|
|
3027
|
-
shouldBeIncluded(context) {
|
|
3028
|
-
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
3029
|
-
}
|
|
3030
|
-
/**
|
|
3031
|
-
* Just deoptimize everything by default so that when e.g. we do not track
|
|
3032
|
-
* something properly, it is deoptimized.
|
|
3033
|
-
* @protected
|
|
3034
|
-
*/
|
|
3035
|
-
applyDeoptimizations() {
|
|
3036
|
-
this.deoptimized = true;
|
|
3037
|
-
for (const key of childNodeKeys[this.type]) {
|
|
3038
|
-
const value = this[key];
|
|
3039
|
-
if (value === null)
|
|
3040
|
-
continue;
|
|
3041
|
-
if (Array.isArray(value)) {
|
|
3042
|
-
for (const child of value) {
|
|
3043
|
-
child?.deoptimizePath(UNKNOWN_PATH);
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3046
|
-
else {
|
|
3047
|
-
value.deoptimizePath(UNKNOWN_PATH);
|
|
3048
|
-
}
|
|
2999
|
+
case 'string': {
|
|
3000
|
+
return literalStringMembers;
|
|
3049
3001
|
}
|
|
3050
|
-
this.scope.context.requestTreeshakingPass();
|
|
3051
3002
|
}
|
|
3003
|
+
return Object.create(null);
|
|
3052
3004
|
}
|
|
3053
|
-
function
|
|
3054
|
-
|
|
3005
|
+
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
3006
|
+
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
3007
|
+
return true;
|
|
3008
|
+
}
|
|
3009
|
+
return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false;
|
|
3010
|
+
}
|
|
3011
|
+
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
3012
|
+
if (typeof memberName !== 'string' || !members[memberName])
|
|
3013
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
3014
|
+
return [members[memberName].returns, false];
|
|
3055
3015
|
}
|
|
3056
3016
|
|
|
3057
3017
|
class SpreadElement extends NodeBase {
|
|
@@ -3204,7 +3164,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3204
3164
|
this.unknownIntegerProps = [];
|
|
3205
3165
|
this.unmatchableGetters = [];
|
|
3206
3166
|
this.unmatchablePropertiesAndGetters = [];
|
|
3207
|
-
this.unmatchablePropertiesAndSetters = [];
|
|
3208
3167
|
this.unmatchableSetters = [];
|
|
3209
3168
|
if (Array.isArray(properties)) {
|
|
3210
3169
|
this.buildPropertyMaps(properties);
|
|
@@ -3439,37 +3398,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3439
3398
|
}
|
|
3440
3399
|
return false;
|
|
3441
3400
|
}
|
|
3442
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
3443
|
-
this.included = true;
|
|
3444
|
-
const [key, ...subPath] = path;
|
|
3445
|
-
if (key == null || includeChildrenRecursively) {
|
|
3446
|
-
for (const property of this.allProperties) {
|
|
3447
|
-
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
3448
|
-
property.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
|
-
this.prototypeExpression?.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
3452
|
-
}
|
|
3453
|
-
else {
|
|
3454
|
-
const [includedMembers, includedPath] = typeof key === 'string'
|
|
3455
|
-
? [
|
|
3456
|
-
[
|
|
3457
|
-
...new Set([
|
|
3458
|
-
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
3459
|
-
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
3460
|
-
])
|
|
3461
|
-
],
|
|
3462
|
-
subPath
|
|
3463
|
-
]
|
|
3464
|
-
: [this.allProperties, UNKNOWN_PATH];
|
|
3465
|
-
for (const property of includedMembers) {
|
|
3466
|
-
property.includePath(includedPath, context, includeChildrenRecursively);
|
|
3467
|
-
}
|
|
3468
|
-
this.prototypeExpression?.includePath(path, context, includeChildrenRecursively);
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
3401
|
buildPropertyMaps(properties) {
|
|
3472
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters,
|
|
3402
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3403
|
+
const unmatchablePropertiesAndSetters = [];
|
|
3473
3404
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
3474
3405
|
const { key, kind, property } = properties[index];
|
|
3475
3406
|
allProperties.push(property);
|
|
@@ -4040,7 +3971,29 @@ const knownGlobals = {
|
|
|
4040
3971
|
resolve: O
|
|
4041
3972
|
},
|
|
4042
3973
|
propertyIsEnumerable: O,
|
|
4043
|
-
Proxy:
|
|
3974
|
+
Proxy: {
|
|
3975
|
+
__proto__: null,
|
|
3976
|
+
[ValueProperties]: {
|
|
3977
|
+
deoptimizeArgumentsOnCall: ({ args: [, target, parameter] }) => {
|
|
3978
|
+
if (isObjectExpressionNode(parameter)) {
|
|
3979
|
+
const hasSpreadElement = parameter.properties.some(property => !isPropertyNode(property));
|
|
3980
|
+
if (!hasSpreadElement) {
|
|
3981
|
+
for (const property of parameter.properties) {
|
|
3982
|
+
property.deoptimizeArgumentsOnInteractionAtPath({
|
|
3983
|
+
args: [null, target],
|
|
3984
|
+
type: INTERACTION_CALLED,
|
|
3985
|
+
withNew: false
|
|
3986
|
+
}, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
3987
|
+
}
|
|
3988
|
+
return;
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
target.deoptimizePath(UNKNOWN_PATH);
|
|
3992
|
+
},
|
|
3993
|
+
getLiteralValue: getTruthyLiteralValue,
|
|
3994
|
+
hasEffectsWhenCalled: returnTrue
|
|
3995
|
+
}
|
|
3996
|
+
},
|
|
4044
3997
|
RangeError: PC,
|
|
4045
3998
|
ReferenceError: PC,
|
|
4046
3999
|
Reflect: O,
|
|
@@ -4805,20 +4758,16 @@ class GlobalVariable extends Variable {
|
|
|
4805
4758
|
}
|
|
4806
4759
|
|
|
4807
4760
|
class LocalVariable extends Variable {
|
|
4808
|
-
constructor(name, declarator, init,
|
|
4809
|
-
/** if this is non-empty, the actual init is this path of this.init */
|
|
4810
|
-
initPath, context, kind) {
|
|
4761
|
+
constructor(name, declarator, init, context, kind) {
|
|
4811
4762
|
super(name);
|
|
4812
4763
|
this.init = init;
|
|
4813
|
-
this.initPath = initPath;
|
|
4814
|
-
this.kind = kind;
|
|
4815
4764
|
this.calledFromTryStatement = false;
|
|
4816
4765
|
this.additionalInitializers = null;
|
|
4817
|
-
this.includedPathTracker = new IncludedPathTracker();
|
|
4818
4766
|
this.expressionsToBeDeoptimized = [];
|
|
4819
4767
|
this.declarations = declarator ? [declarator] : [];
|
|
4820
4768
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
4821
4769
|
this.module = context.module;
|
|
4770
|
+
this.kind = kind;
|
|
4822
4771
|
}
|
|
4823
4772
|
addDeclaration(identifier, init) {
|
|
4824
4773
|
this.declarations.push(identifier);
|
|
@@ -4829,6 +4778,7 @@ class LocalVariable extends Variable {
|
|
|
4829
4778
|
for (const initializer of this.additionalInitializers) {
|
|
4830
4779
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
4831
4780
|
}
|
|
4781
|
+
this.additionalInitializers = null;
|
|
4832
4782
|
}
|
|
4833
4783
|
}
|
|
4834
4784
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -4836,7 +4786,7 @@ class LocalVariable extends Variable {
|
|
|
4836
4786
|
deoptimizeInteraction(interaction);
|
|
4837
4787
|
return;
|
|
4838
4788
|
}
|
|
4839
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
4789
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
4840
4790
|
}
|
|
4841
4791
|
deoptimizePath(path) {
|
|
4842
4792
|
if (this.isReassigned ||
|
|
@@ -4850,10 +4800,10 @@ class LocalVariable extends Variable {
|
|
|
4850
4800
|
for (const expression of expressionsToBeDeoptimized) {
|
|
4851
4801
|
expression.deoptimizeCache();
|
|
4852
4802
|
}
|
|
4853
|
-
this.init.deoptimizePath(
|
|
4803
|
+
this.init.deoptimizePath(UNKNOWN_PATH);
|
|
4854
4804
|
}
|
|
4855
4805
|
else {
|
|
4856
|
-
this.init.deoptimizePath(
|
|
4806
|
+
this.init.deoptimizePath(path);
|
|
4857
4807
|
}
|
|
4858
4808
|
}
|
|
4859
4809
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -4862,7 +4812,7 @@ class LocalVariable extends Variable {
|
|
|
4862
4812
|
}
|
|
4863
4813
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4864
4814
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4865
|
-
return this.init.getLiteralValueAtPath(
|
|
4815
|
+
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
4866
4816
|
}, UnknownValue);
|
|
4867
4817
|
}
|
|
4868
4818
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -4871,7 +4821,7 @@ class LocalVariable extends Variable {
|
|
|
4871
4821
|
}
|
|
4872
4822
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4873
4823
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4874
|
-
return this.init.getReturnExpressionWhenCalledAtPath(
|
|
4824
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
4875
4825
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
4876
4826
|
}
|
|
4877
4827
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
@@ -4880,7 +4830,7 @@ class LocalVariable extends Variable {
|
|
|
4880
4830
|
if (this.isReassigned)
|
|
4881
4831
|
return true;
|
|
4882
4832
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
4883
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4833
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
4884
4834
|
}
|
|
4885
4835
|
case INTERACTION_ASSIGNED: {
|
|
4886
4836
|
if (this.included)
|
|
@@ -4890,23 +4840,23 @@ class LocalVariable extends Variable {
|
|
|
4890
4840
|
if (this.isReassigned)
|
|
4891
4841
|
return true;
|
|
4892
4842
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
4893
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4843
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
4894
4844
|
}
|
|
4895
4845
|
case INTERACTION_CALLED: {
|
|
4896
4846
|
if (this.isReassigned)
|
|
4897
4847
|
return true;
|
|
4898
4848
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
4899
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4849
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
4900
4850
|
}
|
|
4901
4851
|
}
|
|
4902
4852
|
}
|
|
4903
|
-
|
|
4904
|
-
if (!this.
|
|
4905
|
-
super.
|
|
4853
|
+
include() {
|
|
4854
|
+
if (!this.included) {
|
|
4855
|
+
super.include();
|
|
4906
4856
|
for (const declaration of this.declarations) {
|
|
4907
4857
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
4908
4858
|
if (!declaration.included)
|
|
4909
|
-
declaration.
|
|
4859
|
+
declaration.include(createInclusionContext(), false);
|
|
4910
4860
|
let node = declaration.parent;
|
|
4911
4861
|
while (!node.included) {
|
|
4912
4862
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
@@ -4917,26 +4867,17 @@ class LocalVariable extends Variable {
|
|
|
4917
4867
|
node = node.parent;
|
|
4918
4868
|
}
|
|
4919
4869
|
}
|
|
4920
|
-
// We need to make sure we include the correct path of the init
|
|
4921
|
-
if (path.length > 0) {
|
|
4922
|
-
this.init.includePath([...this.initPath, ...path], context, false);
|
|
4923
|
-
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context, false));
|
|
4924
|
-
}
|
|
4925
4870
|
}
|
|
4926
4871
|
}
|
|
4927
|
-
includeCallArguments(context,
|
|
4928
|
-
if (this.isReassigned ||
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
// a specific path
|
|
4932
|
-
this.initPath.length > 0) {
|
|
4933
|
-
for (const argument of interaction.args) {
|
|
4934
|
-
argument?.includePath(UNKNOWN_PATH, context, false);
|
|
4872
|
+
includeCallArguments(context, parameters) {
|
|
4873
|
+
if (this.isReassigned || context.includedCallArguments.has(this.init)) {
|
|
4874
|
+
for (const argument of parameters) {
|
|
4875
|
+
argument.include(context, false);
|
|
4935
4876
|
}
|
|
4936
4877
|
}
|
|
4937
4878
|
else {
|
|
4938
4879
|
context.includedCallArguments.add(this.init);
|
|
4939
|
-
this.init.includeCallArguments(context,
|
|
4880
|
+
this.init.includeCallArguments(context, parameters);
|
|
4940
4881
|
context.includedCallArguments.delete(this.init);
|
|
4941
4882
|
}
|
|
4942
4883
|
}
|
|
@@ -5016,21 +4957,18 @@ class IdentifierBase extends NodeBase {
|
|
|
5016
4957
|
}
|
|
5017
4958
|
}
|
|
5018
4959
|
}
|
|
5019
|
-
|
|
4960
|
+
include() {
|
|
5020
4961
|
if (!this.deoptimized)
|
|
5021
4962
|
this.applyDeoptimizations();
|
|
5022
4963
|
if (!this.included) {
|
|
5023
4964
|
this.included = true;
|
|
5024
4965
|
if (this.variable !== null) {
|
|
5025
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
4966
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
5026
4967
|
}
|
|
5027
4968
|
}
|
|
5028
|
-
else if (path.length > 0) {
|
|
5029
|
-
this.variable?.includePath(path, context);
|
|
5030
|
-
}
|
|
5031
4969
|
}
|
|
5032
|
-
includeCallArguments(context,
|
|
5033
|
-
this.variable.includeCallArguments(context,
|
|
4970
|
+
includeCallArguments(context, parameters) {
|
|
4971
|
+
this.variable.includeCallArguments(context, parameters);
|
|
5034
4972
|
}
|
|
5035
4973
|
isPossibleTDZ() {
|
|
5036
4974
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -5130,17 +5068,39 @@ class Identifier extends IdentifierBase {
|
|
|
5130
5068
|
this.isVariableReference = true;
|
|
5131
5069
|
}
|
|
5132
5070
|
}
|
|
5133
|
-
declare(kind,
|
|
5071
|
+
declare(kind, init) {
|
|
5134
5072
|
let variable;
|
|
5135
5073
|
const { treeshake } = this.scope.context.options;
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5074
|
+
switch (kind) {
|
|
5075
|
+
case 'var': {
|
|
5076
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5077
|
+
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
5078
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
5079
|
+
variable.markInitializersForDeoptimization();
|
|
5080
|
+
}
|
|
5081
|
+
break;
|
|
5082
|
+
}
|
|
5083
|
+
case 'function': {
|
|
5084
|
+
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
5085
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5086
|
+
break;
|
|
5087
|
+
}
|
|
5088
|
+
case 'let':
|
|
5089
|
+
case 'const':
|
|
5090
|
+
case 'using':
|
|
5091
|
+
case 'await using':
|
|
5092
|
+
case 'class': {
|
|
5093
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5094
|
+
break;
|
|
5095
|
+
}
|
|
5096
|
+
case 'parameter': {
|
|
5097
|
+
variable = this.scope.addParameterDeclaration(this);
|
|
5098
|
+
break;
|
|
5099
|
+
}
|
|
5100
|
+
/* istanbul ignore next */
|
|
5101
|
+
default: {
|
|
5102
|
+
/* istanbul ignore next */
|
|
5103
|
+
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
5144
5104
|
}
|
|
5145
5105
|
}
|
|
5146
5106
|
return [(this.variable = variable)];
|
|
@@ -5209,17 +5169,18 @@ class Scope {
|
|
|
5209
5169
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
5210
5170
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
5211
5171
|
*/
|
|
5212
|
-
addDeclaration(identifier, context, init,
|
|
5172
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5213
5173
|
const name = identifier.name;
|
|
5214
5174
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5215
5175
|
if (existingVariable) {
|
|
5216
|
-
|
|
5176
|
+
const existingKind = existingVariable.kind;
|
|
5177
|
+
if (kind === 'var' && existingKind === 'var') {
|
|
5217
5178
|
existingVariable.addDeclaration(identifier, init);
|
|
5218
5179
|
return existingVariable;
|
|
5219
5180
|
}
|
|
5220
5181
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5221
5182
|
}
|
|
5222
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5183
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
5223
5184
|
this.variables.set(name, newVariable);
|
|
5224
5185
|
return newVariable;
|
|
5225
5186
|
}
|
|
@@ -5421,7 +5382,7 @@ class BlockScope extends ChildScope {
|
|
|
5421
5382
|
constructor(parent) {
|
|
5422
5383
|
super(parent, parent.context);
|
|
5423
5384
|
}
|
|
5424
|
-
addDeclaration(identifier, context, init,
|
|
5385
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5425
5386
|
if (kind === 'var') {
|
|
5426
5387
|
const name = identifier.name;
|
|
5427
5388
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5433,7 +5394,7 @@ class BlockScope extends ChildScope {
|
|
|
5433
5394
|
}
|
|
5434
5395
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5435
5396
|
}
|
|
5436
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init,
|
|
5397
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
5437
5398
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5438
5399
|
// We cannot call deoptimizePath here.
|
|
5439
5400
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5441,7 +5402,7 @@ class BlockScope extends ChildScope {
|
|
|
5441
5402
|
this.addHoistedVariable(name, declaredVariable);
|
|
5442
5403
|
return declaredVariable;
|
|
5443
5404
|
}
|
|
5444
|
-
return super.addDeclaration(identifier, context, init,
|
|
5405
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
5445
5406
|
}
|
|
5446
5407
|
}
|
|
5447
5408
|
|
|
@@ -5456,11 +5417,11 @@ class StaticBlock extends NodeBase {
|
|
|
5456
5417
|
}
|
|
5457
5418
|
return false;
|
|
5458
5419
|
}
|
|
5459
|
-
|
|
5420
|
+
include(context, includeChildrenRecursively) {
|
|
5460
5421
|
this.included = true;
|
|
5461
5422
|
for (const node of this.body) {
|
|
5462
5423
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
5463
|
-
node.
|
|
5424
|
+
node.include(context, includeChildrenRecursively);
|
|
5464
5425
|
}
|
|
5465
5426
|
}
|
|
5466
5427
|
render(code, options) {
|
|
@@ -5539,22 +5500,22 @@ class ClassNode extends NodeBase {
|
|
|
5539
5500
|
false
|
|
5540
5501
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5541
5502
|
}
|
|
5542
|
-
|
|
5503
|
+
include(context, includeChildrenRecursively) {
|
|
5543
5504
|
if (!this.deoptimized)
|
|
5544
5505
|
this.applyDeoptimizations();
|
|
5545
5506
|
this.included = true;
|
|
5546
|
-
this.superClass?.
|
|
5547
|
-
this.body.
|
|
5507
|
+
this.superClass?.include(context, includeChildrenRecursively);
|
|
5508
|
+
this.body.include(context, includeChildrenRecursively);
|
|
5548
5509
|
for (const decorator of this.decorators)
|
|
5549
|
-
decorator.
|
|
5510
|
+
decorator.include(context, includeChildrenRecursively);
|
|
5550
5511
|
if (this.id) {
|
|
5551
5512
|
this.id.markDeclarationReached();
|
|
5552
|
-
this.id.
|
|
5513
|
+
this.id.include();
|
|
5553
5514
|
}
|
|
5554
5515
|
}
|
|
5555
5516
|
initialise() {
|
|
5556
5517
|
super.initialise();
|
|
5557
|
-
this.id?.declare('class',
|
|
5518
|
+
this.id?.declare('class', this);
|
|
5558
5519
|
for (const method of this.body.body) {
|
|
5559
5520
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
5560
5521
|
this.classConstructor = method;
|
|
@@ -5669,7 +5630,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
5669
5630
|
|
|
5670
5631
|
class ArgumentsVariable extends LocalVariable {
|
|
5671
5632
|
constructor(context) {
|
|
5672
|
-
super('arguments', null, UNKNOWN_EXPRESSION,
|
|
5633
|
+
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
5673
5634
|
this.deoptimizedArguments = [];
|
|
5674
5635
|
}
|
|
5675
5636
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -5683,8 +5644,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5683
5644
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5684
5645
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
5685
5646
|
}
|
|
5686
|
-
|
|
5687
|
-
super.
|
|
5647
|
+
include() {
|
|
5648
|
+
super.include();
|
|
5688
5649
|
for (const argument of this.deoptimizedArguments) {
|
|
5689
5650
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
5690
5651
|
}
|
|
@@ -5695,28 +5656,27 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5695
5656
|
const MAX_TRACKED_INTERACTIONS = 20;
|
|
5696
5657
|
const NO_INTERACTIONS = EMPTY_ARRAY;
|
|
5697
5658
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
5698
|
-
const EMPTY_PATH_TRACKER = new
|
|
5659
|
+
const EMPTY_PATH_TRACKER = new PathTracker();
|
|
5699
5660
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
5700
5661
|
class ParameterVariable extends LocalVariable {
|
|
5701
|
-
constructor(name, declarator,
|
|
5702
|
-
super(name, declarator, UNKNOWN_EXPRESSION,
|
|
5662
|
+
constructor(name, declarator, context) {
|
|
5663
|
+
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
5703
5664
|
this.deoptimizationInteractions = [];
|
|
5704
|
-
this.deoptimizations = new
|
|
5665
|
+
this.deoptimizations = new PathTracker();
|
|
5705
5666
|
this.deoptimizedFields = new Set();
|
|
5706
|
-
this.
|
|
5707
|
-
this.
|
|
5667
|
+
this.entitiesToBeDeoptimized = new Set();
|
|
5668
|
+
this.expressionsUseTheKnownValue = [];
|
|
5708
5669
|
this.knownValue = null;
|
|
5709
5670
|
this.knownValueLiteral = UnknownValue;
|
|
5710
5671
|
this.frozenValue = null;
|
|
5711
5672
|
}
|
|
5712
|
-
|
|
5713
|
-
this.updateKnownValue(entity);
|
|
5673
|
+
addEntityToBeDeoptimized(entity) {
|
|
5714
5674
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
5715
5675
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
5716
5676
|
// the interaction cache at this point provided we keep this optimization
|
|
5717
5677
|
// in mind when adding new interactions
|
|
5718
|
-
if (!this.
|
|
5719
|
-
this.
|
|
5678
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5679
|
+
this.entitiesToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
5720
5680
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
5721
5681
|
deoptimizeInteraction(interaction);
|
|
5722
5682
|
}
|
|
@@ -5726,30 +5686,27 @@ class ParameterVariable extends LocalVariable {
|
|
|
5726
5686
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5727
5687
|
// This means that we already deoptimized all interactions and no longer
|
|
5728
5688
|
// track them
|
|
5729
|
-
entity.deoptimizePath(
|
|
5689
|
+
entity.deoptimizePath(UNKNOWN_PATH);
|
|
5730
5690
|
}
|
|
5731
|
-
else if (!this.
|
|
5732
|
-
this.
|
|
5691
|
+
else if (!this.entitiesToBeDeoptimized.has(entity)) {
|
|
5692
|
+
this.entitiesToBeDeoptimized.add(entity);
|
|
5733
5693
|
for (const field of this.deoptimizedFields) {
|
|
5734
|
-
entity.deoptimizePath([
|
|
5694
|
+
entity.deoptimizePath([field]);
|
|
5735
5695
|
}
|
|
5736
5696
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
5737
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
5697
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5738
5698
|
}
|
|
5739
5699
|
}
|
|
5740
5700
|
}
|
|
5741
|
-
/** This says we should not make assumptions about the value of the parameter.
|
|
5742
|
-
* This is different from deoptimization that will also cause argument values
|
|
5743
|
-
* to be deoptimized. */
|
|
5744
5701
|
markReassigned() {
|
|
5745
5702
|
if (this.isReassigned) {
|
|
5746
5703
|
return;
|
|
5747
5704
|
}
|
|
5748
5705
|
super.markReassigned();
|
|
5749
|
-
for (const expression of this.
|
|
5706
|
+
for (const expression of this.expressionsUseTheKnownValue) {
|
|
5750
5707
|
expression.deoptimizeCache();
|
|
5751
5708
|
}
|
|
5752
|
-
this.
|
|
5709
|
+
this.expressionsUseTheKnownValue = EMPTY_ARRAY;
|
|
5753
5710
|
}
|
|
5754
5711
|
deoptimizeCache() {
|
|
5755
5712
|
this.markReassigned();
|
|
@@ -5766,7 +5723,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5766
5723
|
}
|
|
5767
5724
|
if (this.knownValue === null) {
|
|
5768
5725
|
this.knownValue = argument;
|
|
5769
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
5726
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5770
5727
|
return;
|
|
5771
5728
|
}
|
|
5772
5729
|
// the same literal or identifier, do nothing
|
|
@@ -5782,7 +5739,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5782
5739
|
return;
|
|
5783
5740
|
}
|
|
5784
5741
|
// add tracking for the new argument
|
|
5785
|
-
const newValue = argument.getLiteralValueAtPath(
|
|
5742
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5786
5743
|
if (newValue !== oldValue) {
|
|
5787
5744
|
this.markReassigned();
|
|
5788
5745
|
}
|
|
@@ -5804,25 +5761,20 @@ class ParameterVariable extends LocalVariable {
|
|
|
5804
5761
|
return UnknownValue;
|
|
5805
5762
|
}
|
|
5806
5763
|
const knownValue = this.getKnownValue();
|
|
5807
|
-
this.
|
|
5808
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(
|
|
5764
|
+
this.expressionsUseTheKnownValue.push(origin);
|
|
5765
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
5809
5766
|
}
|
|
5810
5767
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5811
|
-
|
|
5812
|
-
if (this.isReassigned || type === INTERACTION_ASSIGNED) {
|
|
5768
|
+
if (this.isReassigned || interaction.type === INTERACTION_ASSIGNED) {
|
|
5813
5769
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5814
5770
|
}
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
? context.instantiated
|
|
5818
|
-
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
5819
|
-
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
5820
|
-
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
5771
|
+
const knownValue = this.getKnownValue();
|
|
5772
|
+
return knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5821
5773
|
}
|
|
5822
5774
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
5823
5775
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
5824
5776
|
if (path.length >= 2 ||
|
|
5825
|
-
this.
|
|
5777
|
+
this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
5826
5778
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
5827
5779
|
(path.length === 1 &&
|
|
5828
5780
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
@@ -5831,10 +5783,10 @@ class ParameterVariable extends LocalVariable {
|
|
|
5831
5783
|
return;
|
|
5832
5784
|
}
|
|
5833
5785
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
5834
|
-
for (const entity of this.
|
|
5835
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
5786
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
5787
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5836
5788
|
}
|
|
5837
|
-
if (!this.
|
|
5789
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5838
5790
|
this.deoptimizationInteractions.push({
|
|
5839
5791
|
interaction,
|
|
5840
5792
|
path
|
|
@@ -5855,17 +5807,17 @@ class ParameterVariable extends LocalVariable {
|
|
|
5855
5807
|
return;
|
|
5856
5808
|
}
|
|
5857
5809
|
this.deoptimizedFields.add(key);
|
|
5858
|
-
for (const entity of this.
|
|
5810
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
5859
5811
|
// We do not need a recursion tracker here as we already track whether
|
|
5860
5812
|
// this field is deoptimized
|
|
5861
|
-
entity.deoptimizePath([
|
|
5813
|
+
entity.deoptimizePath([key]);
|
|
5862
5814
|
}
|
|
5863
5815
|
if (key === UnknownKey) {
|
|
5864
5816
|
// save some memory
|
|
5865
5817
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
5866
5818
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
5867
5819
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
5868
|
-
this.
|
|
5820
|
+
this.entitiesToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
5869
5821
|
}
|
|
5870
5822
|
}
|
|
5871
5823
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -5880,14 +5832,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
5880
5832
|
}
|
|
5881
5833
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
5882
5834
|
}
|
|
5883
|
-
includeArgumentPaths(entity, context) {
|
|
5884
|
-
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
5885
|
-
}
|
|
5886
5835
|
}
|
|
5887
5836
|
|
|
5888
5837
|
class ThisVariable extends ParameterVariable {
|
|
5889
5838
|
constructor(context) {
|
|
5890
|
-
super('this', null,
|
|
5839
|
+
super('this', null, context);
|
|
5891
5840
|
}
|
|
5892
5841
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5893
5842
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -5899,7 +5848,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5899
5848
|
super(parent, parent.context);
|
|
5900
5849
|
this.parent = parent;
|
|
5901
5850
|
}
|
|
5902
|
-
addDeclaration(identifier, context, init,
|
|
5851
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5903
5852
|
if (kind === 'var') {
|
|
5904
5853
|
const name = identifier.name;
|
|
5905
5854
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5912,7 +5861,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5912
5861
|
// the assignment actually goes to the parameter and the var is
|
|
5913
5862
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
5914
5863
|
// parameter
|
|
5915
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION,
|
|
5864
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
5916
5865
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
5917
5866
|
// names. If we ever implement a logic that splits initialization and
|
|
5918
5867
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -5931,7 +5880,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5931
5880
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5932
5881
|
}
|
|
5933
5882
|
// We only add parameters to parameter scopes
|
|
5934
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init,
|
|
5883
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
5935
5884
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5936
5885
|
// We cannot call deoptimizePath here.
|
|
5937
5886
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5939,7 +5888,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5939
5888
|
this.addHoistedVariable(name, declaredVariable);
|
|
5940
5889
|
return declaredVariable;
|
|
5941
5890
|
}
|
|
5942
|
-
return super.addDeclaration(identifier, context, init,
|
|
5891
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
5943
5892
|
}
|
|
5944
5893
|
}
|
|
5945
5894
|
|
|
@@ -5949,7 +5898,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
5949
5898
|
}
|
|
5950
5899
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
5951
5900
|
// be redeclared, functions and var can redeclare each other
|
|
5952
|
-
addDeclaration(identifier, context, init,
|
|
5901
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5953
5902
|
const name = identifier.name;
|
|
5954
5903
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5955
5904
|
if (existingVariable) {
|
|
@@ -5961,7 +5910,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
5961
5910
|
}
|
|
5962
5911
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5963
5912
|
}
|
|
5964
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5913
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
5965
5914
|
this.variables.set(name, newVariable);
|
|
5966
5915
|
return newVariable;
|
|
5967
5916
|
}
|
|
@@ -5970,21 +5919,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
5970
5919
|
class ParameterScope extends ChildScope {
|
|
5971
5920
|
constructor(parent, isCatchScope) {
|
|
5972
5921
|
super(parent, parent.context);
|
|
5973
|
-
this.hasRest = false;
|
|
5974
5922
|
this.parameters = [];
|
|
5923
|
+
this.hasRest = false;
|
|
5975
5924
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
5976
5925
|
}
|
|
5977
5926
|
/**
|
|
5978
5927
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
5979
5928
|
* order, i.e. from left to right.
|
|
5980
5929
|
*/
|
|
5981
|
-
addParameterDeclaration(identifier
|
|
5930
|
+
addParameterDeclaration(identifier) {
|
|
5982
5931
|
const { name, start } = identifier;
|
|
5983
5932
|
const existingParameter = this.variables.get(name);
|
|
5984
5933
|
if (existingParameter) {
|
|
5985
5934
|
return this.context.error(logDuplicateArgumentNameError(name), start);
|
|
5986
5935
|
}
|
|
5987
|
-
const variable = new ParameterVariable(name, identifier,
|
|
5936
|
+
const variable = new ParameterVariable(name, identifier, this.context);
|
|
5988
5937
|
this.variables.set(name, variable);
|
|
5989
5938
|
// We also add it to the body scope to detect name conflicts with local
|
|
5990
5939
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -6002,54 +5951,43 @@ class ParameterScope extends ChildScope {
|
|
|
6002
5951
|
}
|
|
6003
5952
|
this.hasRest = hasRest;
|
|
6004
5953
|
}
|
|
6005
|
-
includeCallArguments(context,
|
|
5954
|
+
includeCallArguments(context, parameters) {
|
|
6006
5955
|
let calledFromTryStatement = false;
|
|
6007
5956
|
let argumentIncluded = false;
|
|
6008
5957
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
6009
|
-
const
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
argumentIncluded = true;
|
|
6016
|
-
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
6017
|
-
}
|
|
6018
|
-
if (argumentIncluded) {
|
|
6019
|
-
args[argumentIndex].includePath(UNKNOWN_PATH, context, false);
|
|
5958
|
+
for (const checkedArgument of parameters) {
|
|
5959
|
+
if (checkedArgument instanceof SpreadElement) {
|
|
5960
|
+
for (const argument of parameters) {
|
|
5961
|
+
argument.include(context, false);
|
|
5962
|
+
}
|
|
5963
|
+
break;
|
|
6020
5964
|
}
|
|
6021
5965
|
}
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
6026
|
-
const argument = args[index];
|
|
5966
|
+
for (let index = parameters.length - 1; index >= 0; index--) {
|
|
5967
|
+
const parameterVariables = this.parameters[index] || restParameter;
|
|
5968
|
+
const argument = parameters[index];
|
|
6027
5969
|
if (parameterVariables) {
|
|
6028
5970
|
calledFromTryStatement = false;
|
|
6029
5971
|
if (parameterVariables.length === 0) {
|
|
6030
|
-
// handle empty destructuring
|
|
5972
|
+
// handle empty destructuring
|
|
6031
5973
|
argumentIncluded = true;
|
|
6032
5974
|
}
|
|
6033
5975
|
else {
|
|
6034
5976
|
for (const variable of parameterVariables) {
|
|
6035
|
-
if (variable.calledFromTryStatement) {
|
|
6036
|
-
calledFromTryStatement = true;
|
|
6037
|
-
}
|
|
6038
5977
|
if (variable.included) {
|
|
6039
5978
|
argumentIncluded = true;
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
else {
|
|
6044
|
-
variable.includeArgumentPaths(argument, context);
|
|
6045
|
-
}
|
|
5979
|
+
}
|
|
5980
|
+
if (variable.calledFromTryStatement) {
|
|
5981
|
+
calledFromTryStatement = true;
|
|
6046
5982
|
}
|
|
6047
5983
|
}
|
|
6048
5984
|
}
|
|
6049
5985
|
}
|
|
6050
|
-
if (!
|
|
5986
|
+
if (!argumentIncluded && argument.shouldBeIncluded(context)) {
|
|
6051
5987
|
argumentIncluded = true;
|
|
6052
|
-
|
|
5988
|
+
}
|
|
5989
|
+
if (argumentIncluded) {
|
|
5990
|
+
argument.include(context, calledFromTryStatement);
|
|
6053
5991
|
}
|
|
6054
5992
|
}
|
|
6055
5993
|
}
|
|
@@ -6064,61 +6002,11 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6064
6002
|
addReturnExpression(expression) {
|
|
6065
6003
|
this.returnExpressions.push(expression);
|
|
6066
6004
|
}
|
|
6067
|
-
deoptimizeArgumentsOnCall(interaction) {
|
|
6068
|
-
const { parameters } = this;
|
|
6069
|
-
const { args } = interaction;
|
|
6070
|
-
let position = 0;
|
|
6071
|
-
for (; position < args.length - 1; position++) {
|
|
6072
|
-
// Only the "this" argument arg[0] can be null
|
|
6073
|
-
const argument = args[position + 1];
|
|
6074
|
-
if (argument instanceof SpreadElement) {
|
|
6075
|
-
// This deoptimizes the current and remaining parameters and arguments
|
|
6076
|
-
for (; position < parameters.length; position++) {
|
|
6077
|
-
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
6078
|
-
parameters[position].forEach(variable => variable.markReassigned());
|
|
6079
|
-
}
|
|
6080
|
-
break;
|
|
6081
|
-
}
|
|
6082
|
-
if (this.hasRest && position >= parameters.length - 1) {
|
|
6083
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6084
|
-
}
|
|
6085
|
-
else {
|
|
6086
|
-
const variables = parameters[position];
|
|
6087
|
-
if (variables) {
|
|
6088
|
-
for (const variable of variables) {
|
|
6089
|
-
variable.addArgumentValue(argument);
|
|
6090
|
-
}
|
|
6091
|
-
}
|
|
6092
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
6093
|
-
}
|
|
6094
|
-
}
|
|
6095
|
-
for (; position < parameters.length; position++) {
|
|
6096
|
-
for (const variable of parameters[position]) {
|
|
6097
|
-
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
6098
|
-
}
|
|
6099
|
-
}
|
|
6100
|
-
}
|
|
6101
6005
|
getReturnExpression() {
|
|
6102
6006
|
if (this.returnExpression === null)
|
|
6103
6007
|
this.updateReturnExpression();
|
|
6104
6008
|
return this.returnExpression;
|
|
6105
6009
|
}
|
|
6106
|
-
deoptimizeAllParameters() {
|
|
6107
|
-
for (const parameter of this.parameters) {
|
|
6108
|
-
for (const variable of parameter) {
|
|
6109
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
6110
|
-
variable.markReassigned();
|
|
6111
|
-
}
|
|
6112
|
-
}
|
|
6113
|
-
}
|
|
6114
|
-
reassignAllParameters() {
|
|
6115
|
-
for (const parameter of this.parameters) {
|
|
6116
|
-
for (const variable of parameter) {
|
|
6117
|
-
variable.markReassigned();
|
|
6118
|
-
}
|
|
6119
|
-
}
|
|
6120
|
-
}
|
|
6121
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
6122
6010
|
updateReturnExpression() {
|
|
6123
6011
|
if (this.returnExpressions.length === 1) {
|
|
6124
6012
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -6134,26 +6022,24 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6134
6022
|
|
|
6135
6023
|
class FunctionScope extends ReturnValueScope {
|
|
6136
6024
|
constructor(parent) {
|
|
6137
|
-
super(parent, false);
|
|
6138
6025
|
const { context } = parent;
|
|
6026
|
+
super(parent, false);
|
|
6139
6027
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
6140
6028
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
6141
6029
|
}
|
|
6142
6030
|
findLexicalBoundary() {
|
|
6143
6031
|
return this;
|
|
6144
6032
|
}
|
|
6145
|
-
includeCallArguments(context,
|
|
6146
|
-
super.includeCallArguments(context,
|
|
6033
|
+
includeCallArguments(context, parameters) {
|
|
6034
|
+
super.includeCallArguments(context, parameters);
|
|
6147
6035
|
if (this.argumentsVariable.included) {
|
|
6148
|
-
const
|
|
6149
|
-
|
|
6150
|
-
|
|
6036
|
+
for (const argument of parameters) {
|
|
6037
|
+
if (!argument.included) {
|
|
6038
|
+
argument.include(context, false);
|
|
6039
|
+
}
|
|
6151
6040
|
}
|
|
6152
6041
|
}
|
|
6153
6042
|
}
|
|
6154
|
-
addArgumentToBeDeoptimized(argument) {
|
|
6155
|
-
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6156
|
-
}
|
|
6157
6043
|
}
|
|
6158
6044
|
|
|
6159
6045
|
class ExpressionStatement extends NodeBase {
|
|
@@ -6219,7 +6105,7 @@ class BlockStatement extends NodeBase {
|
|
|
6219
6105
|
}
|
|
6220
6106
|
return false;
|
|
6221
6107
|
}
|
|
6222
|
-
|
|
6108
|
+
include(context, includeChildrenRecursively) {
|
|
6223
6109
|
if (!(this.deoptimizeBody && this.directlyIncluded)) {
|
|
6224
6110
|
this.included = true;
|
|
6225
6111
|
this.directlyIncluded = true;
|
|
@@ -6227,7 +6113,7 @@ class BlockStatement extends NodeBase {
|
|
|
6227
6113
|
includeChildrenRecursively = true;
|
|
6228
6114
|
for (const node of this.body) {
|
|
6229
6115
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
6230
|
-
node.
|
|
6116
|
+
node.include(context, includeChildrenRecursively);
|
|
6231
6117
|
}
|
|
6232
6118
|
}
|
|
6233
6119
|
}
|
|
@@ -6256,9 +6142,9 @@ class RestElement extends NodeBase {
|
|
|
6256
6142
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6257
6143
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6258
6144
|
}
|
|
6259
|
-
declare(kind,
|
|
6145
|
+
declare(kind, init) {
|
|
6260
6146
|
this.declarationInit = init;
|
|
6261
|
-
return this.argument.declare(kind,
|
|
6147
|
+
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
6262
6148
|
}
|
|
6263
6149
|
deoptimizePath(path) {
|
|
6264
6150
|
if (path.length === 0) {
|
|
@@ -6269,12 +6155,6 @@ class RestElement extends NodeBase {
|
|
|
6269
6155
|
return (path.length > 0 ||
|
|
6270
6156
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
6271
6157
|
}
|
|
6272
|
-
includePath(_path, context, includeChildrenRecursively) {
|
|
6273
|
-
this.included = true;
|
|
6274
|
-
// This should just include the identifier, its properties should be
|
|
6275
|
-
// included where the variable is used.
|
|
6276
|
-
this.argument.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
6277
|
-
}
|
|
6278
6158
|
markDeclarationReached() {
|
|
6279
6159
|
this.argument.markDeclarationReached();
|
|
6280
6160
|
}
|
|
@@ -6290,8 +6170,8 @@ class RestElement extends NodeBase {
|
|
|
6290
6170
|
class FunctionBase extends NodeBase {
|
|
6291
6171
|
constructor() {
|
|
6292
6172
|
super(...arguments);
|
|
6173
|
+
this.objectEntity = null;
|
|
6293
6174
|
this.parameterVariableValuesDeoptimized = false;
|
|
6294
|
-
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
6295
6175
|
}
|
|
6296
6176
|
get async() {
|
|
6297
6177
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -6311,9 +6191,53 @@ class FunctionBase extends NodeBase {
|
|
|
6311
6191
|
set generator(value) {
|
|
6312
6192
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
6313
6193
|
}
|
|
6194
|
+
updateParameterVariableValues(_arguments) {
|
|
6195
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
6196
|
+
const parameter = this.params[position];
|
|
6197
|
+
if (!(parameter instanceof Identifier)) {
|
|
6198
|
+
continue;
|
|
6199
|
+
}
|
|
6200
|
+
const parameterVariable = parameter.variable;
|
|
6201
|
+
const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
6202
|
+
parameterVariable.updateKnownValue(argument);
|
|
6203
|
+
}
|
|
6204
|
+
}
|
|
6205
|
+
deoptimizeParameterVariableValues() {
|
|
6206
|
+
for (const parameter of this.params) {
|
|
6207
|
+
if (parameter instanceof Identifier) {
|
|
6208
|
+
const parameterVariable = parameter.variable;
|
|
6209
|
+
parameterVariable.markReassigned();
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
}
|
|
6314
6213
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6315
|
-
if (interaction.type === INTERACTION_CALLED
|
|
6316
|
-
this.scope
|
|
6214
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
6215
|
+
const { parameters } = this.scope;
|
|
6216
|
+
const { args } = interaction;
|
|
6217
|
+
let hasRest = false;
|
|
6218
|
+
for (let position = 0; position < args.length - 1; position++) {
|
|
6219
|
+
const parameter = this.params[position];
|
|
6220
|
+
// Only the "this" argument arg[0] can be null
|
|
6221
|
+
const argument = args[position + 1];
|
|
6222
|
+
if (argument instanceof SpreadElement) {
|
|
6223
|
+
this.deoptimizeParameterVariableValues();
|
|
6224
|
+
}
|
|
6225
|
+
if (hasRest || parameter instanceof RestElement) {
|
|
6226
|
+
hasRest = true;
|
|
6227
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6228
|
+
}
|
|
6229
|
+
else if (parameter instanceof Identifier) {
|
|
6230
|
+
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
6231
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6232
|
+
}
|
|
6233
|
+
else if (parameter) {
|
|
6234
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6235
|
+
}
|
|
6236
|
+
else {
|
|
6237
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6238
|
+
}
|
|
6239
|
+
}
|
|
6240
|
+
this.updateParameterVariableValues(args);
|
|
6317
6241
|
}
|
|
6318
6242
|
else {
|
|
6319
6243
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -6325,7 +6249,12 @@ class FunctionBase extends NodeBase {
|
|
|
6325
6249
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
6326
6250
|
// which means the return expression and parameters need to be reassigned
|
|
6327
6251
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
6328
|
-
this.scope.
|
|
6252
|
+
for (const parameterList of this.scope.parameters) {
|
|
6253
|
+
for (const parameter of parameterList) {
|
|
6254
|
+
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
6255
|
+
parameter.markReassigned();
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6329
6258
|
}
|
|
6330
6259
|
}
|
|
6331
6260
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6382,19 +6311,22 @@ class FunctionBase extends NodeBase {
|
|
|
6382
6311
|
}
|
|
6383
6312
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
6384
6313
|
}
|
|
6385
|
-
|
|
6386
|
-
if (!
|
|
6314
|
+
include(context, includeChildrenRecursively) {
|
|
6315
|
+
if (!this.parameterVariableValuesDeoptimized && !this.onlyFunctionCallUsed()) {
|
|
6387
6316
|
this.parameterVariableValuesDeoptimized = true;
|
|
6388
|
-
this.
|
|
6317
|
+
this.deoptimizeParameterVariableValues();
|
|
6389
6318
|
}
|
|
6390
6319
|
if (!this.deoptimized)
|
|
6391
6320
|
this.applyDeoptimizations();
|
|
6392
6321
|
this.included = true;
|
|
6393
6322
|
const { brokenFlow } = context;
|
|
6394
6323
|
context.brokenFlow = false;
|
|
6395
|
-
this.body.
|
|
6324
|
+
this.body.include(context, includeChildrenRecursively);
|
|
6396
6325
|
context.brokenFlow = brokenFlow;
|
|
6397
6326
|
}
|
|
6327
|
+
includeCallArguments(context, parameters) {
|
|
6328
|
+
this.scope.includeCallArguments(context, parameters);
|
|
6329
|
+
}
|
|
6398
6330
|
initialise() {
|
|
6399
6331
|
super.initialise();
|
|
6400
6332
|
if (this.body instanceof BlockStatement) {
|
|
@@ -6416,10 +6348,11 @@ class FunctionBase extends NodeBase {
|
|
|
6416
6348
|
// so that the scope already knows all parameters and can detect conflicts
|
|
6417
6349
|
// when parsing the body.
|
|
6418
6350
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
6419
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
6351
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
6420
6352
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
6421
6353
|
return super.parseNode(esTreeNode);
|
|
6422
6354
|
}
|
|
6355
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
6423
6356
|
applyDeoptimizations() { }
|
|
6424
6357
|
}
|
|
6425
6358
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
@@ -6434,13 +6367,13 @@ class FunctionNode extends FunctionBase {
|
|
|
6434
6367
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
6435
6368
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
6436
6369
|
// constructed entity.
|
|
6437
|
-
this.scope.thisVariable.
|
|
6370
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
|
|
6438
6371
|
}
|
|
6439
6372
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6440
6373
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6441
6374
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
6442
6375
|
// args[0] is the "this" argument
|
|
6443
|
-
this.scope.thisVariable.
|
|
6376
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.args[0]);
|
|
6444
6377
|
}
|
|
6445
6378
|
}
|
|
6446
6379
|
hasEffects(context) {
|
|
@@ -6481,19 +6414,22 @@ class FunctionNode extends FunctionBase {
|
|
|
6481
6414
|
}
|
|
6482
6415
|
return false;
|
|
6483
6416
|
}
|
|
6484
|
-
|
|
6485
|
-
super.
|
|
6486
|
-
this.id?.
|
|
6417
|
+
include(context, includeChildrenRecursively) {
|
|
6418
|
+
super.include(context, includeChildrenRecursively);
|
|
6419
|
+
this.id?.include();
|
|
6487
6420
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
6488
6421
|
for (const parameter of this.params) {
|
|
6489
6422
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
6490
|
-
parameter.
|
|
6423
|
+
parameter.include(context, includeChildrenRecursively);
|
|
6491
6424
|
}
|
|
6492
6425
|
}
|
|
6493
6426
|
}
|
|
6494
6427
|
initialise() {
|
|
6495
6428
|
super.initialise();
|
|
6496
|
-
this.id?.declare('function',
|
|
6429
|
+
this.id?.declare('function', this);
|
|
6430
|
+
}
|
|
6431
|
+
addArgumentToBeDeoptimized(argument) {
|
|
6432
|
+
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6497
6433
|
}
|
|
6498
6434
|
getObjectEntity() {
|
|
6499
6435
|
if (this.objectEntity !== null) {
|
|
@@ -6542,11 +6478,10 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
6542
6478
|
return declarationEnd + generatorStarPos + 1;
|
|
6543
6479
|
}
|
|
6544
6480
|
class ExportDefaultDeclaration extends NodeBase {
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
this.declaration.includePath(path, context, includeChildrenRecursively);
|
|
6481
|
+
include(context, includeChildrenRecursively) {
|
|
6482
|
+
super.include(context, includeChildrenRecursively);
|
|
6548
6483
|
if (includeChildrenRecursively) {
|
|
6549
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
6484
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
6550
6485
|
}
|
|
6551
6486
|
}
|
|
6552
6487
|
initialise() {
|
|
@@ -7119,27 +7054,27 @@ class MemberExpression extends NodeBase {
|
|
|
7119
7054
|
}
|
|
7120
7055
|
return true;
|
|
7121
7056
|
}
|
|
7122
|
-
|
|
7057
|
+
include(context, includeChildrenRecursively) {
|
|
7123
7058
|
if (!this.deoptimized)
|
|
7124
7059
|
this.applyDeoptimizations();
|
|
7125
|
-
this.includeProperties(
|
|
7060
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7126
7061
|
}
|
|
7127
7062
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
7128
7063
|
if (!this.assignmentDeoptimized)
|
|
7129
7064
|
this.applyAssignmentDeoptimization();
|
|
7130
7065
|
if (deoptimizeAccess) {
|
|
7131
|
-
this.
|
|
7066
|
+
this.include(context, includeChildrenRecursively);
|
|
7132
7067
|
}
|
|
7133
7068
|
else {
|
|
7134
|
-
this.includeProperties(
|
|
7069
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7135
7070
|
}
|
|
7136
7071
|
}
|
|
7137
|
-
includeCallArguments(context,
|
|
7072
|
+
includeCallArguments(context, parameters) {
|
|
7138
7073
|
if (this.variable) {
|
|
7139
|
-
this.variable.includeCallArguments(context,
|
|
7074
|
+
this.variable.includeCallArguments(context, parameters);
|
|
7140
7075
|
}
|
|
7141
7076
|
else {
|
|
7142
|
-
super.includeCallArguments(context,
|
|
7077
|
+
super.includeCallArguments(context, parameters);
|
|
7143
7078
|
}
|
|
7144
7079
|
}
|
|
7145
7080
|
initialise() {
|
|
@@ -7208,7 +7143,7 @@ class MemberExpression extends NodeBase {
|
|
|
7208
7143
|
const variable = this.scope.findVariable(this.object.name);
|
|
7209
7144
|
if (variable.isNamespace) {
|
|
7210
7145
|
if (this.variable) {
|
|
7211
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
7146
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7212
7147
|
}
|
|
7213
7148
|
this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
7214
7149
|
}
|
|
@@ -7235,18 +7170,15 @@ class MemberExpression extends NodeBase {
|
|
|
7235
7170
|
(propertyReadSideEffects === 'always' ||
|
|
7236
7171
|
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
7237
7172
|
}
|
|
7238
|
-
includeProperties(
|
|
7173
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
7239
7174
|
if (!this.included) {
|
|
7240
7175
|
this.included = true;
|
|
7241
7176
|
if (this.variable) {
|
|
7242
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
7177
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7243
7178
|
}
|
|
7244
7179
|
}
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
}
|
|
7248
|
-
this.object.includePath(objectPath, context, includeChildrenRecursively);
|
|
7249
|
-
this.property.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7180
|
+
this.object.include(context, includeChildrenRecursively);
|
|
7181
|
+
this.property.include(context, includeChildrenRecursively);
|
|
7250
7182
|
}
|
|
7251
7183
|
}
|
|
7252
7184
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -7289,7 +7221,7 @@ class MetaProperty extends NodeBase {
|
|
|
7289
7221
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
7290
7222
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
7291
7223
|
}
|
|
7292
|
-
|
|
7224
|
+
include() {
|
|
7293
7225
|
if (!this.included) {
|
|
7294
7226
|
this.included = true;
|
|
7295
7227
|
if (this.meta.name === IMPORT) {
|
|
@@ -7408,7 +7340,7 @@ class UndefinedVariable extends Variable {
|
|
|
7408
7340
|
|
|
7409
7341
|
class ExportDefaultVariable extends LocalVariable {
|
|
7410
7342
|
constructor(name, exportDefaultDeclaration, context) {
|
|
7411
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration,
|
|
7343
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
7412
7344
|
this.hasId = false;
|
|
7413
7345
|
this.originalId = null;
|
|
7414
7346
|
this.originalVariable = null;
|
|
@@ -7557,8 +7489,8 @@ class NamespaceVariable extends Variable {
|
|
|
7557
7489
|
return (!memberVariable ||
|
|
7558
7490
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
7559
7491
|
}
|
|
7560
|
-
|
|
7561
|
-
super.
|
|
7492
|
+
include() {
|
|
7493
|
+
super.include();
|
|
7562
7494
|
this.context.includeAllExports();
|
|
7563
7495
|
}
|
|
7564
7496
|
prepare(accessedGlobalsByScope) {
|
|
@@ -7651,9 +7583,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
7651
7583
|
getName(getPropertyAccess) {
|
|
7652
7584
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
7653
7585
|
}
|
|
7654
|
-
|
|
7655
|
-
super.
|
|
7656
|
-
this.context.includeVariableInModule(this.syntheticNamespace
|
|
7586
|
+
include() {
|
|
7587
|
+
super.include();
|
|
7588
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
7657
7589
|
}
|
|
7658
7590
|
setRenderNames(baseName, name) {
|
|
7659
7591
|
super.setRenderNames(baseName, name);
|
|
@@ -8180,14 +8112,16 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
|
|
|
8180
8112
|
}
|
|
8181
8113
|
function getExportBlock(exports, { _, cnst }) {
|
|
8182
8114
|
const exportBlock = [];
|
|
8183
|
-
const exportDeclaration =
|
|
8115
|
+
const exportDeclaration = new Array(exports.length);
|
|
8116
|
+
let index = 0;
|
|
8184
8117
|
for (const specifier of exports) {
|
|
8185
8118
|
if (specifier.expression) {
|
|
8186
8119
|
exportBlock.push(`${cnst} ${specifier.local}${_}=${_}${specifier.expression};`);
|
|
8187
8120
|
}
|
|
8188
|
-
exportDeclaration
|
|
8189
|
-
|
|
8190
|
-
|
|
8121
|
+
exportDeclaration[index++] =
|
|
8122
|
+
specifier.exported === specifier.local
|
|
8123
|
+
? specifier.local
|
|
8124
|
+
: `${specifier.local} as ${stringifyIdentifierIfNeeded(specifier.exported)}`;
|
|
8191
8125
|
}
|
|
8192
8126
|
if (exportDeclaration.length > 0) {
|
|
8193
8127
|
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
@@ -10850,14 +10784,11 @@ class ArrayPattern extends NodeBase {
|
|
|
10850
10784
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
10851
10785
|
}
|
|
10852
10786
|
}
|
|
10853
|
-
declare(kind
|
|
10787
|
+
declare(kind) {
|
|
10854
10788
|
const variables = [];
|
|
10855
|
-
const includedPatternPath = includedInitPath.at(-1) === UnknownKey
|
|
10856
|
-
? includedInitPath
|
|
10857
|
-
: [...includedInitPath, UnknownInteger];
|
|
10858
10789
|
for (const element of this.elements) {
|
|
10859
10790
|
if (element !== null) {
|
|
10860
|
-
variables.push(...element.declare(kind,
|
|
10791
|
+
variables.push(...element.declare(kind, UNKNOWN_EXPRESSION));
|
|
10861
10792
|
}
|
|
10862
10793
|
}
|
|
10863
10794
|
return variables;
|
|
@@ -10930,11 +10861,11 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
10930
10861
|
this.parent.callee === this;
|
|
10931
10862
|
return isIIFE || super.onlyFunctionCallUsed();
|
|
10932
10863
|
}
|
|
10933
|
-
|
|
10934
|
-
super.
|
|
10864
|
+
include(context, includeChildrenRecursively) {
|
|
10865
|
+
super.include(context, includeChildrenRecursively);
|
|
10935
10866
|
for (const parameter of this.params) {
|
|
10936
10867
|
if (!(parameter instanceof Identifier)) {
|
|
10937
|
-
parameter.
|
|
10868
|
+
parameter.include(context, includeChildrenRecursively);
|
|
10938
10869
|
}
|
|
10939
10870
|
}
|
|
10940
10871
|
}
|
|
@@ -10957,10 +10888,10 @@ class ObjectPattern extends NodeBase {
|
|
|
10957
10888
|
}
|
|
10958
10889
|
}
|
|
10959
10890
|
}
|
|
10960
|
-
declare(kind,
|
|
10891
|
+
declare(kind, init) {
|
|
10961
10892
|
const variables = [];
|
|
10962
10893
|
for (const property of this.properties) {
|
|
10963
|
-
variables.push(...property.declare(kind,
|
|
10894
|
+
variables.push(...property.declare(kind, init));
|
|
10964
10895
|
}
|
|
10965
10896
|
return variables;
|
|
10966
10897
|
}
|
|
@@ -10981,22 +10912,11 @@ class ObjectPattern extends NodeBase {
|
|
|
10981
10912
|
}
|
|
10982
10913
|
return false;
|
|
10983
10914
|
}
|
|
10984
|
-
includePath(_path, context, includeChildrenRecursively) {
|
|
10985
|
-
this.included = true;
|
|
10986
|
-
for (const property of this.properties) {
|
|
10987
|
-
// Including a pattern should not deeply include its children as that
|
|
10988
|
-
// would include all children of nested variable references. Their paths
|
|
10989
|
-
// will be included via their usages instead, and we store the path in
|
|
10990
|
-
// the pattern when declaring the variables.
|
|
10991
|
-
property.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
10992
|
-
}
|
|
10993
|
-
}
|
|
10994
10915
|
markDeclarationReached() {
|
|
10995
10916
|
for (const property of this.properties) {
|
|
10996
10917
|
property.markDeclarationReached();
|
|
10997
10918
|
}
|
|
10998
10919
|
}
|
|
10999
|
-
applyDeoptimizations() { }
|
|
11000
10920
|
}
|
|
11001
10921
|
|
|
11002
10922
|
class AssignmentExpression extends NodeBase {
|
|
@@ -11011,7 +10931,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
11011
10931
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11012
10932
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11013
10933
|
}
|
|
11014
|
-
|
|
10934
|
+
include(context, includeChildrenRecursively) {
|
|
11015
10935
|
const { deoptimized, left, right, operator } = this;
|
|
11016
10936
|
if (!deoptimized)
|
|
11017
10937
|
this.applyDeoptimizations();
|
|
@@ -11022,7 +10942,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
11022
10942
|
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
11023
10943
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
11024
10944
|
}
|
|
11025
|
-
right.
|
|
10945
|
+
right.include(context, includeChildrenRecursively);
|
|
11026
10946
|
}
|
|
11027
10947
|
initialise() {
|
|
11028
10948
|
super.initialise();
|
|
@@ -11094,8 +11014,8 @@ class AssignmentPattern extends NodeBase {
|
|
|
11094
11014
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
11095
11015
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
11096
11016
|
}
|
|
11097
|
-
declare(kind,
|
|
11098
|
-
return this.left.declare(kind,
|
|
11017
|
+
declare(kind, init) {
|
|
11018
|
+
return this.left.declare(kind, init);
|
|
11099
11019
|
}
|
|
11100
11020
|
deoptimizePath(path) {
|
|
11101
11021
|
if (path.length === 0) {
|
|
@@ -11126,7 +11046,7 @@ class AwaitExpression extends NodeBase {
|
|
|
11126
11046
|
this.applyDeoptimizations();
|
|
11127
11047
|
return true;
|
|
11128
11048
|
}
|
|
11129
|
-
|
|
11049
|
+
include(context, includeChildrenRecursively) {
|
|
11130
11050
|
if (!this.deoptimized)
|
|
11131
11051
|
this.applyDeoptimizations();
|
|
11132
11052
|
if (!this.included) {
|
|
@@ -11140,7 +11060,7 @@ class AwaitExpression extends NodeBase {
|
|
|
11140
11060
|
this.scope.context.usesTopLevelAwait = true;
|
|
11141
11061
|
}
|
|
11142
11062
|
}
|
|
11143
|
-
this.argument.
|
|
11063
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
11144
11064
|
}
|
|
11145
11065
|
}
|
|
11146
11066
|
|
|
@@ -11222,10 +11142,10 @@ class BreakStatement extends NodeBase {
|
|
|
11222
11142
|
context.brokenFlow = true;
|
|
11223
11143
|
return false;
|
|
11224
11144
|
}
|
|
11225
|
-
|
|
11145
|
+
include(context) {
|
|
11226
11146
|
this.included = true;
|
|
11227
11147
|
if (this.label) {
|
|
11228
|
-
this.label.
|
|
11148
|
+
this.label.include();
|
|
11229
11149
|
context.includedLabels.add(this.label.name);
|
|
11230
11150
|
}
|
|
11231
11151
|
else {
|
|
@@ -11419,11 +11339,11 @@ class CallExpression extends CallExpressionBase {
|
|
|
11419
11339
|
(calleeHasEffects ||
|
|
11420
11340
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
11421
11341
|
}
|
|
11422
|
-
|
|
11342
|
+
include(context, includeChildrenRecursively) {
|
|
11423
11343
|
if (!this.deoptimized)
|
|
11424
11344
|
this.applyDeoptimizations();
|
|
11425
11345
|
if (includeChildrenRecursively) {
|
|
11426
|
-
super.
|
|
11346
|
+
super.include(context, includeChildrenRecursively);
|
|
11427
11347
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
11428
11348
|
this.callee instanceof Identifier &&
|
|
11429
11349
|
this.callee.variable) {
|
|
@@ -11432,18 +11352,9 @@ class CallExpression extends CallExpressionBase {
|
|
|
11432
11352
|
}
|
|
11433
11353
|
else {
|
|
11434
11354
|
this.included = true;
|
|
11435
|
-
|
|
11436
|
-
// object will already be included via the first argument of the
|
|
11437
|
-
// interaction in includeCallArguments. Including it again can lead to
|
|
11438
|
-
// severe performance problems.
|
|
11439
|
-
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
11440
|
-
this.callee.property.includePath(UNKNOWN_PATH, context, false);
|
|
11441
|
-
}
|
|
11442
|
-
else {
|
|
11443
|
-
this.callee.includePath(UNKNOWN_PATH, context, false);
|
|
11444
|
-
}
|
|
11445
|
-
this.callee.includeCallArguments(context, this.interaction);
|
|
11355
|
+
this.callee.include(context, false);
|
|
11446
11356
|
}
|
|
11357
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
11447
11358
|
}
|
|
11448
11359
|
initialise() {
|
|
11449
11360
|
super.initialise();
|
|
@@ -11482,7 +11393,7 @@ class CatchClause extends NodeBase {
|
|
|
11482
11393
|
this.type = type;
|
|
11483
11394
|
if (param) {
|
|
11484
11395
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
11485
|
-
this.param.declare('parameter',
|
|
11396
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
11486
11397
|
}
|
|
11487
11398
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
11488
11399
|
return super.parseNode(esTreeNode);
|
|
@@ -11510,7 +11421,7 @@ class ClassBodyScope extends ChildScope {
|
|
|
11510
11421
|
constructor(parent, classNode) {
|
|
11511
11422
|
const { context } = parent;
|
|
11512
11423
|
super(parent, context);
|
|
11513
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode,
|
|
11424
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
11514
11425
|
this.instanceScope = new ChildScope(this, context);
|
|
11515
11426
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
11516
11427
|
}
|
|
@@ -11523,17 +11434,18 @@ class ClassBody extends NodeBase {
|
|
|
11523
11434
|
createScope(parentScope) {
|
|
11524
11435
|
this.scope = new ClassBodyScope(parentScope, this.parent);
|
|
11525
11436
|
}
|
|
11526
|
-
|
|
11437
|
+
include(context, includeChildrenRecursively) {
|
|
11527
11438
|
this.included = true;
|
|
11528
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable
|
|
11439
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
11529
11440
|
for (const definition of this.body) {
|
|
11530
|
-
definition.
|
|
11441
|
+
definition.include(context, includeChildrenRecursively);
|
|
11531
11442
|
}
|
|
11532
11443
|
}
|
|
11533
11444
|
parseNode(esTreeNode) {
|
|
11534
|
-
const body = (this.body =
|
|
11445
|
+
const body = (this.body = new Array(esTreeNode.body.length));
|
|
11446
|
+
let index = 0;
|
|
11535
11447
|
for (const definition of esTreeNode.body) {
|
|
11536
|
-
body
|
|
11448
|
+
body[index++] = new (this.scope.context.getNodeConstructor(definition.type))(this, definition.static ? this.scope : this.scope.instanceScope).parseNode(definition);
|
|
11537
11449
|
}
|
|
11538
11450
|
return super.parseNode(esTreeNode);
|
|
11539
11451
|
}
|
|
@@ -11650,26 +11562,26 @@ class ConditionalExpression extends NodeBase {
|
|
|
11650
11562
|
}
|
|
11651
11563
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11652
11564
|
}
|
|
11653
|
-
|
|
11565
|
+
include(context, includeChildrenRecursively) {
|
|
11654
11566
|
this.included = true;
|
|
11655
11567
|
const usedBranch = this.getUsedBranch();
|
|
11656
11568
|
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
11657
|
-
this.test.
|
|
11658
|
-
this.consequent.
|
|
11659
|
-
this.alternate.
|
|
11569
|
+
this.test.include(context, includeChildrenRecursively);
|
|
11570
|
+
this.consequent.include(context, includeChildrenRecursively);
|
|
11571
|
+
this.alternate.include(context, includeChildrenRecursively);
|
|
11660
11572
|
}
|
|
11661
11573
|
else {
|
|
11662
|
-
usedBranch.
|
|
11574
|
+
usedBranch.include(context, includeChildrenRecursively);
|
|
11663
11575
|
}
|
|
11664
11576
|
}
|
|
11665
|
-
includeCallArguments(context,
|
|
11577
|
+
includeCallArguments(context, parameters) {
|
|
11666
11578
|
const usedBranch = this.getUsedBranch();
|
|
11667
11579
|
if (usedBranch) {
|
|
11668
|
-
usedBranch.includeCallArguments(context,
|
|
11580
|
+
usedBranch.includeCallArguments(context, parameters);
|
|
11669
11581
|
}
|
|
11670
11582
|
else {
|
|
11671
|
-
this.consequent.includeCallArguments(context,
|
|
11672
|
-
this.alternate.includeCallArguments(context,
|
|
11583
|
+
this.consequent.includeCallArguments(context, parameters);
|
|
11584
|
+
this.alternate.includeCallArguments(context, parameters);
|
|
11673
11585
|
}
|
|
11674
11586
|
}
|
|
11675
11587
|
removeAnnotations(code) {
|
|
@@ -11730,10 +11642,10 @@ class ContinueStatement extends NodeBase {
|
|
|
11730
11642
|
context.brokenFlow = true;
|
|
11731
11643
|
return false;
|
|
11732
11644
|
}
|
|
11733
|
-
|
|
11645
|
+
include(context) {
|
|
11734
11646
|
this.included = true;
|
|
11735
11647
|
if (this.label) {
|
|
11736
|
-
this.label.
|
|
11648
|
+
this.label.include();
|
|
11737
11649
|
context.includedLabels.add(this.label.name);
|
|
11738
11650
|
}
|
|
11739
11651
|
else {
|
|
@@ -11776,7 +11688,7 @@ function includeLoopBody(context, body, includeChildrenRecursively) {
|
|
|
11776
11688
|
const { brokenFlow, hasBreak, hasContinue } = context;
|
|
11777
11689
|
context.hasBreak = false;
|
|
11778
11690
|
context.hasContinue = false;
|
|
11779
|
-
body.
|
|
11691
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
11780
11692
|
context.hasBreak = hasBreak;
|
|
11781
11693
|
context.hasContinue = hasContinue;
|
|
11782
11694
|
context.brokenFlow = brokenFlow;
|
|
@@ -11788,9 +11700,9 @@ class DoWhileStatement extends NodeBase {
|
|
|
11788
11700
|
return true;
|
|
11789
11701
|
return hasLoopBodyEffects(context, this.body);
|
|
11790
11702
|
}
|
|
11791
|
-
|
|
11703
|
+
include(context, includeChildrenRecursively) {
|
|
11792
11704
|
this.included = true;
|
|
11793
|
-
this.test.
|
|
11705
|
+
this.test.include(context, includeChildrenRecursively);
|
|
11794
11706
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
11795
11707
|
}
|
|
11796
11708
|
}
|
|
@@ -11861,13 +11773,13 @@ class ForInStatement extends NodeBase {
|
|
|
11861
11773
|
return true;
|
|
11862
11774
|
return hasLoopBodyEffects(context, body);
|
|
11863
11775
|
}
|
|
11864
|
-
|
|
11776
|
+
include(context, includeChildrenRecursively) {
|
|
11865
11777
|
const { body, deoptimized, left, right } = this;
|
|
11866
11778
|
if (!deoptimized)
|
|
11867
11779
|
this.applyDeoptimizations();
|
|
11868
11780
|
this.included = true;
|
|
11869
11781
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
11870
|
-
right.
|
|
11782
|
+
right.include(context, includeChildrenRecursively);
|
|
11871
11783
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
11872
11784
|
}
|
|
11873
11785
|
initialise() {
|
|
@@ -11906,13 +11818,13 @@ class ForOfStatement extends NodeBase {
|
|
|
11906
11818
|
// Placeholder until proper Symbol.Iterator support
|
|
11907
11819
|
return true;
|
|
11908
11820
|
}
|
|
11909
|
-
|
|
11821
|
+
include(context, includeChildrenRecursively) {
|
|
11910
11822
|
const { body, deoptimized, left, right } = this;
|
|
11911
11823
|
if (!deoptimized)
|
|
11912
11824
|
this.applyDeoptimizations();
|
|
11913
11825
|
this.included = true;
|
|
11914
11826
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
11915
|
-
right.
|
|
11827
|
+
right.include(context, includeChildrenRecursively);
|
|
11916
11828
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
11917
11829
|
}
|
|
11918
11830
|
initialise() {
|
|
@@ -11948,13 +11860,11 @@ class ForStatement extends NodeBase {
|
|
|
11948
11860
|
}
|
|
11949
11861
|
return hasLoopBodyEffects(context, this.body);
|
|
11950
11862
|
}
|
|
11951
|
-
|
|
11863
|
+
include(context, includeChildrenRecursively) {
|
|
11952
11864
|
this.included = true;
|
|
11953
|
-
this.init?.
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
this.test?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
11957
|
-
this.update?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
11865
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
11866
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
11867
|
+
this.update?.include(context, includeChildrenRecursively);
|
|
11958
11868
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
11959
11869
|
}
|
|
11960
11870
|
render(code, options) {
|
|
@@ -11995,9 +11905,9 @@ class TrackingScope extends BlockScope {
|
|
|
11995
11905
|
super(...arguments);
|
|
11996
11906
|
this.hoistedDeclarations = [];
|
|
11997
11907
|
}
|
|
11998
|
-
addDeclaration(identifier, context, init,
|
|
11908
|
+
addDeclaration(identifier, context, init, kind) {
|
|
11999
11909
|
this.hoistedDeclarations.push(identifier);
|
|
12000
|
-
return super.addDeclaration(identifier, context, init,
|
|
11910
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
12001
11911
|
}
|
|
12002
11912
|
}
|
|
12003
11913
|
|
|
@@ -12030,7 +11940,7 @@ class IfStatement extends NodeBase {
|
|
|
12030
11940
|
}
|
|
12031
11941
|
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
12032
11942
|
}
|
|
12033
|
-
|
|
11943
|
+
include(context, includeChildrenRecursively) {
|
|
12034
11944
|
this.included = true;
|
|
12035
11945
|
if (includeChildrenRecursively) {
|
|
12036
11946
|
this.includeRecursively(includeChildrenRecursively, context);
|
|
@@ -12105,31 +12015,31 @@ class IfStatement extends NodeBase {
|
|
|
12105
12015
|
}
|
|
12106
12016
|
includeKnownTest(context, testValue) {
|
|
12107
12017
|
if (this.test.shouldBeIncluded(context)) {
|
|
12108
|
-
this.test.
|
|
12018
|
+
this.test.include(context, false);
|
|
12109
12019
|
}
|
|
12110
12020
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
12111
|
-
this.consequent.
|
|
12021
|
+
this.consequent.include(context, false, { asSingleStatement: true });
|
|
12112
12022
|
}
|
|
12113
12023
|
if (!testValue && this.alternate?.shouldBeIncluded(context)) {
|
|
12114
|
-
this.alternate.
|
|
12024
|
+
this.alternate.include(context, false, { asSingleStatement: true });
|
|
12115
12025
|
}
|
|
12116
12026
|
}
|
|
12117
12027
|
includeRecursively(includeChildrenRecursively, context) {
|
|
12118
|
-
this.test.
|
|
12119
|
-
this.consequent.
|
|
12120
|
-
this.alternate?.
|
|
12028
|
+
this.test.include(context, includeChildrenRecursively);
|
|
12029
|
+
this.consequent.include(context, includeChildrenRecursively);
|
|
12030
|
+
this.alternate?.include(context, includeChildrenRecursively);
|
|
12121
12031
|
}
|
|
12122
12032
|
includeUnknownTest(context) {
|
|
12123
|
-
this.test.
|
|
12033
|
+
this.test.include(context, false);
|
|
12124
12034
|
const { brokenFlow } = context;
|
|
12125
12035
|
let consequentBrokenFlow = false;
|
|
12126
12036
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
12127
|
-
this.consequent.
|
|
12037
|
+
this.consequent.include(context, false, { asSingleStatement: true });
|
|
12128
12038
|
consequentBrokenFlow = context.brokenFlow;
|
|
12129
12039
|
context.brokenFlow = brokenFlow;
|
|
12130
12040
|
}
|
|
12131
12041
|
if (this.alternate?.shouldBeIncluded(context)) {
|
|
12132
|
-
this.alternate.
|
|
12042
|
+
this.alternate.include(context, false, { asSingleStatement: true });
|
|
12133
12043
|
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
12134
12044
|
}
|
|
12135
12045
|
}
|
|
@@ -12197,7 +12107,7 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
12197
12107
|
class VariableDeclarator extends NodeBase {
|
|
12198
12108
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
12199
12109
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
12200
|
-
this.id.declare(kind,
|
|
12110
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12201
12111
|
}
|
|
12202
12112
|
deoptimizePath(path) {
|
|
12203
12113
|
this.id.deoptimizePath(path);
|
|
@@ -12209,15 +12119,15 @@ class VariableDeclarator extends NodeBase {
|
|
|
12209
12119
|
this.id.markDeclarationReached();
|
|
12210
12120
|
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
12211
12121
|
}
|
|
12212
|
-
|
|
12122
|
+
include(context, includeChildrenRecursively) {
|
|
12213
12123
|
const { deoptimized, id, init } = this;
|
|
12214
12124
|
if (!deoptimized)
|
|
12215
12125
|
this.applyDeoptimizations();
|
|
12216
12126
|
this.included = true;
|
|
12217
|
-
init?.
|
|
12127
|
+
init?.include(context, includeChildrenRecursively);
|
|
12218
12128
|
id.markDeclarationReached();
|
|
12219
12129
|
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12220
|
-
id.
|
|
12130
|
+
id.include(context, includeChildrenRecursively);
|
|
12221
12131
|
}
|
|
12222
12132
|
}
|
|
12223
12133
|
removeAnnotations(code) {
|
|
@@ -12266,8 +12176,6 @@ class ImportExpression extends NodeBase {
|
|
|
12266
12176
|
constructor() {
|
|
12267
12177
|
super(...arguments);
|
|
12268
12178
|
this.inlineNamespace = null;
|
|
12269
|
-
this.hasUnknownAccessedKey = false;
|
|
12270
|
-
this.accessedPropKey = new Set();
|
|
12271
12179
|
this.attributes = null;
|
|
12272
12180
|
this.mechanism = null;
|
|
12273
12181
|
this.namespaceExportName = undefined;
|
|
@@ -12300,15 +12208,12 @@ class ImportExpression extends NodeBase {
|
|
|
12300
12208
|
if (parent2 instanceof ExpressionStatement) {
|
|
12301
12209
|
return EMPTY_ARRAY;
|
|
12302
12210
|
}
|
|
12303
|
-
// Case 1: const { foo }
|
|
12211
|
+
// Case 1: const { foo } = await import('bar')
|
|
12304
12212
|
if (parent2 instanceof VariableDeclarator) {
|
|
12305
12213
|
const declaration = parent2.id;
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
if (declaration instanceof ObjectPattern) {
|
|
12310
|
-
return getDeterministicObjectDestructure(declaration);
|
|
12311
|
-
}
|
|
12214
|
+
return declaration instanceof ObjectPattern
|
|
12215
|
+
? getDeterministicObjectDestructure(declaration)
|
|
12216
|
+
: undefined;
|
|
12312
12217
|
}
|
|
12313
12218
|
// Case 2: (await import('bar')).foo
|
|
12314
12219
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -12357,23 +12262,13 @@ class ImportExpression extends NodeBase {
|
|
|
12357
12262
|
hasEffects() {
|
|
12358
12263
|
return true;
|
|
12359
12264
|
}
|
|
12360
|
-
|
|
12265
|
+
include(context, includeChildrenRecursively) {
|
|
12361
12266
|
if (!this.included) {
|
|
12362
12267
|
this.included = true;
|
|
12363
12268
|
this.scope.context.includeDynamicImport(this);
|
|
12364
12269
|
this.scope.addAccessedDynamicImport(this);
|
|
12365
|
-
this.source.includePath(path, context, includeChildrenRecursively);
|
|
12366
|
-
}
|
|
12367
|
-
if (this.hasUnknownAccessedKey)
|
|
12368
|
-
return;
|
|
12369
|
-
if (path[0] === UnknownKey) {
|
|
12370
|
-
this.hasUnknownAccessedKey = true;
|
|
12371
|
-
this.scope.context.includeDynamicImport(this);
|
|
12372
|
-
}
|
|
12373
|
-
else if (typeof path[0] === 'string') {
|
|
12374
|
-
this.accessedPropKey.add(path[0]);
|
|
12375
|
-
this.scope.context.includeDynamicImport(this);
|
|
12376
12270
|
}
|
|
12271
|
+
this.source.include(context, includeChildrenRecursively);
|
|
12377
12272
|
}
|
|
12378
12273
|
initialise() {
|
|
12379
12274
|
super.initialise();
|
|
@@ -12701,7 +12596,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12701
12596
|
if (preserve) {
|
|
12702
12597
|
// This pretends we are accessing an included global variable of the same name
|
|
12703
12598
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
12704
|
-
globalVariable.
|
|
12599
|
+
globalVariable.include();
|
|
12705
12600
|
// This excludes this variable from renaming
|
|
12706
12601
|
factoryVariable.globalName = baseName;
|
|
12707
12602
|
}
|
|
@@ -12709,7 +12604,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12709
12604
|
else {
|
|
12710
12605
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
12711
12606
|
}
|
|
12712
|
-
node.scope.context.includeVariableInModule(factoryVariable
|
|
12607
|
+
node.scope.context.includeVariableInModule(factoryVariable);
|
|
12713
12608
|
if (factoryVariable instanceof LocalVariable) {
|
|
12714
12609
|
factoryVariable.consolidateInitializers();
|
|
12715
12610
|
factoryVariable.addUsedPlace(node);
|
|
@@ -12731,7 +12626,7 @@ class JSXElementBase extends NodeBase {
|
|
|
12731
12626
|
this.scope.context.addImportSource(importSource);
|
|
12732
12627
|
}
|
|
12733
12628
|
}
|
|
12734
|
-
|
|
12629
|
+
include(context, includeChildrenRecursively) {
|
|
12735
12630
|
if (!this.included) {
|
|
12736
12631
|
const { factory, importSource, mode } = this.jsxMode;
|
|
12737
12632
|
if (factory) {
|
|
@@ -12739,7 +12634,7 @@ class JSXElementBase extends NodeBase {
|
|
|
12739
12634
|
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
12740
12635
|
}
|
|
12741
12636
|
}
|
|
12742
|
-
super.
|
|
12637
|
+
super.include(context, includeChildrenRecursively);
|
|
12743
12638
|
}
|
|
12744
12639
|
applyDeoptimizations() { }
|
|
12745
12640
|
getRenderingMode() {
|
|
@@ -13001,7 +12896,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13001
12896
|
this.fragment = null;
|
|
13002
12897
|
this.fragmentVariable = null;
|
|
13003
12898
|
}
|
|
13004
|
-
|
|
12899
|
+
include(context, includeChildrenRecursively) {
|
|
13005
12900
|
if (!this.included) {
|
|
13006
12901
|
const jsx = this.scope.context.options.jsx;
|
|
13007
12902
|
if (jsx.mode === 'automatic') {
|
|
@@ -13016,7 +12911,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13016
12911
|
}
|
|
13017
12912
|
}
|
|
13018
12913
|
}
|
|
13019
|
-
super.
|
|
12914
|
+
super.include(context, includeChildrenRecursively);
|
|
13020
12915
|
}
|
|
13021
12916
|
render(code, options) {
|
|
13022
12917
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -13073,13 +12968,13 @@ class LabeledStatement extends NodeBase {
|
|
|
13073
12968
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
13074
12969
|
return bodyHasEffects;
|
|
13075
12970
|
}
|
|
13076
|
-
|
|
12971
|
+
include(context, includeChildrenRecursively) {
|
|
13077
12972
|
this.included = true;
|
|
13078
12973
|
const { brokenFlow, includedLabels } = context;
|
|
13079
12974
|
context.includedLabels = new Set();
|
|
13080
|
-
this.body.
|
|
12975
|
+
this.body.include(context, includeChildrenRecursively);
|
|
13081
12976
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
13082
|
-
this.label.
|
|
12977
|
+
this.label.include();
|
|
13083
12978
|
context.includedLabels.delete(this.label.name);
|
|
13084
12979
|
context.brokenFlow = brokenFlow;
|
|
13085
12980
|
}
|
|
@@ -13176,17 +13071,17 @@ class LogicalExpression extends NodeBase {
|
|
|
13176
13071
|
}
|
|
13177
13072
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13178
13073
|
}
|
|
13179
|
-
|
|
13074
|
+
include(context, includeChildrenRecursively) {
|
|
13180
13075
|
this.included = true;
|
|
13181
13076
|
const usedBranch = this.getUsedBranch();
|
|
13182
13077
|
if (includeChildrenRecursively ||
|
|
13183
13078
|
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
13184
13079
|
!usedBranch) {
|
|
13185
|
-
this.left.
|
|
13186
|
-
this.right.
|
|
13080
|
+
this.left.include(context, includeChildrenRecursively);
|
|
13081
|
+
this.right.include(context, includeChildrenRecursively);
|
|
13187
13082
|
}
|
|
13188
13083
|
else {
|
|
13189
|
-
usedBranch.
|
|
13084
|
+
usedBranch.include(context, includeChildrenRecursively);
|
|
13190
13085
|
}
|
|
13191
13086
|
}
|
|
13192
13087
|
removeAnnotations(code) {
|
|
@@ -13258,17 +13153,17 @@ class NewExpression extends NodeBase {
|
|
|
13258
13153
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
13259
13154
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
13260
13155
|
}
|
|
13261
|
-
|
|
13156
|
+
include(context, includeChildrenRecursively) {
|
|
13262
13157
|
if (!this.deoptimized)
|
|
13263
13158
|
this.applyDeoptimizations();
|
|
13264
13159
|
if (includeChildrenRecursively) {
|
|
13265
|
-
super.
|
|
13160
|
+
super.include(context, includeChildrenRecursively);
|
|
13266
13161
|
}
|
|
13267
13162
|
else {
|
|
13268
13163
|
this.included = true;
|
|
13269
|
-
this.callee.
|
|
13164
|
+
this.callee.include(context, false);
|
|
13270
13165
|
}
|
|
13271
|
-
this.callee.includeCallArguments(context, this.
|
|
13166
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
13272
13167
|
}
|
|
13273
13168
|
initialise() {
|
|
13274
13169
|
super.initialise();
|
|
@@ -13297,7 +13192,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13297
13192
|
constructor() {
|
|
13298
13193
|
super(...arguments);
|
|
13299
13194
|
this.objectEntity = null;
|
|
13300
|
-
this.protoProp = null;
|
|
13301
13195
|
}
|
|
13302
13196
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13303
13197
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13317,32 +13211,13 @@ class ObjectExpression extends NodeBase {
|
|
|
13317
13211
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13318
13212
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13319
13213
|
}
|
|
13320
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
13321
|
-
this.included = true;
|
|
13322
|
-
this.getObjectEntity().includePath(path, context, includeChildrenRecursively);
|
|
13323
|
-
this.protoProp?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13324
|
-
}
|
|
13325
13214
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13215
|
+
super.render(code, options);
|
|
13326
13216
|
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13327
13217
|
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
13328
13218
|
code.appendRight(this.start, '(');
|
|
13329
13219
|
code.prependLeft(this.end, ')');
|
|
13330
13220
|
}
|
|
13331
|
-
if (this.properties.length > 0) {
|
|
13332
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
13333
|
-
let lastSeparatorPos = null;
|
|
13334
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
13335
|
-
if (!node.included) {
|
|
13336
|
-
treeshakeNode(node, code, start, end);
|
|
13337
|
-
continue;
|
|
13338
|
-
}
|
|
13339
|
-
lastSeparatorPos = separator;
|
|
13340
|
-
node.render(code, options);
|
|
13341
|
-
}
|
|
13342
|
-
if (lastSeparatorPos) {
|
|
13343
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
13344
|
-
}
|
|
13345
|
-
}
|
|
13346
13221
|
}
|
|
13347
13222
|
applyDeoptimizations() { }
|
|
13348
13223
|
getObjectEntity() {
|
|
@@ -13373,7 +13248,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13373
13248
|
? property.key.name
|
|
13374
13249
|
: String(property.key.value);
|
|
13375
13250
|
if (key === '__proto__' && property.kind === 'init') {
|
|
13376
|
-
this.protoProp = property;
|
|
13377
13251
|
prototype =
|
|
13378
13252
|
property.value instanceof Literal && property.value.value === null
|
|
13379
13253
|
? null
|
|
@@ -13440,11 +13314,11 @@ class Program extends NodeBase {
|
|
|
13440
13314
|
}
|
|
13441
13315
|
return false;
|
|
13442
13316
|
}
|
|
13443
|
-
|
|
13317
|
+
include(context, includeChildrenRecursively) {
|
|
13444
13318
|
this.included = true;
|
|
13445
13319
|
for (const node of this.body) {
|
|
13446
13320
|
if (includeChildrenRecursively || node.shouldBeIncluded(context)) {
|
|
13447
|
-
node.
|
|
13321
|
+
node.include(context, includeChildrenRecursively);
|
|
13448
13322
|
}
|
|
13449
13323
|
}
|
|
13450
13324
|
}
|
|
@@ -13483,6 +13357,10 @@ class Program extends NodeBase {
|
|
|
13483
13357
|
}
|
|
13484
13358
|
|
|
13485
13359
|
class Property extends MethodBase {
|
|
13360
|
+
constructor() {
|
|
13361
|
+
super(...arguments);
|
|
13362
|
+
this.declarationInit = null;
|
|
13363
|
+
}
|
|
13486
13364
|
//declare method: boolean;
|
|
13487
13365
|
get method() {
|
|
13488
13366
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -13497,17 +13375,9 @@ class Property extends MethodBase {
|
|
|
13497
13375
|
set shorthand(value) {
|
|
13498
13376
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
13499
13377
|
}
|
|
13500
|
-
declare(kind,
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
: // For now, we only consider static path as we do not know how to
|
|
13504
|
-
// deoptimize the path in the dynamic case.
|
|
13505
|
-
this.computed
|
|
13506
|
-
? [...includedInitPath, UnknownKey]
|
|
13507
|
-
: this.key instanceof Identifier
|
|
13508
|
-
? [...includedInitPath, this.key.name]
|
|
13509
|
-
: [...includedInitPath, String(this.key.value)];
|
|
13510
|
-
return this.value.declare(kind, pathInProperty, init);
|
|
13378
|
+
declare(kind, init) {
|
|
13379
|
+
this.declarationInit = init;
|
|
13380
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
13511
13381
|
}
|
|
13512
13382
|
hasEffects(context) {
|
|
13513
13383
|
if (!this.deoptimized)
|
|
@@ -13517,11 +13387,6 @@ class Property extends MethodBase {
|
|
|
13517
13387
|
this.key.hasEffects(context) ||
|
|
13518
13388
|
this.value.hasEffects(context));
|
|
13519
13389
|
}
|
|
13520
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
13521
|
-
this.included = true;
|
|
13522
|
-
this.key.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
13523
|
-
this.value.includePath(path, context, includeChildrenRecursively);
|
|
13524
|
-
}
|
|
13525
13390
|
markDeclarationReached() {
|
|
13526
13391
|
this.value.markDeclarationReached();
|
|
13527
13392
|
}
|
|
@@ -13531,7 +13396,13 @@ class Property extends MethodBase {
|
|
|
13531
13396
|
}
|
|
13532
13397
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
13533
13398
|
}
|
|
13534
|
-
applyDeoptimizations() {
|
|
13399
|
+
applyDeoptimizations() {
|
|
13400
|
+
this.deoptimized = true;
|
|
13401
|
+
if (this.declarationInit !== null) {
|
|
13402
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
13403
|
+
this.scope.context.requestTreeshakingPass();
|
|
13404
|
+
}
|
|
13405
|
+
}
|
|
13535
13406
|
}
|
|
13536
13407
|
|
|
13537
13408
|
class PropertyDefinition extends NodeBase {
|
|
@@ -13575,9 +13446,9 @@ class ReturnStatement extends NodeBase {
|
|
|
13575
13446
|
context.brokenFlow = true;
|
|
13576
13447
|
return false;
|
|
13577
13448
|
}
|
|
13578
|
-
|
|
13449
|
+
include(context, includeChildrenRecursively) {
|
|
13579
13450
|
this.included = true;
|
|
13580
|
-
this.argument?.
|
|
13451
|
+
this.argument?.include(context, includeChildrenRecursively);
|
|
13581
13452
|
context.brokenFlow = true;
|
|
13582
13453
|
}
|
|
13583
13454
|
initialise() {
|
|
@@ -13614,14 +13485,14 @@ class SequenceExpression extends NodeBase {
|
|
|
13614
13485
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13615
13486
|
return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13616
13487
|
}
|
|
13617
|
-
|
|
13488
|
+
include(context, includeChildrenRecursively) {
|
|
13618
13489
|
this.included = true;
|
|
13619
13490
|
const lastExpression = this.expressions[this.expressions.length - 1];
|
|
13620
13491
|
for (const expression of this.expressions) {
|
|
13621
13492
|
if (includeChildrenRecursively ||
|
|
13622
13493
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
13623
13494
|
expression.shouldBeIncluded(context))
|
|
13624
|
-
expression.
|
|
13495
|
+
expression.include(context, includeChildrenRecursively);
|
|
13625
13496
|
}
|
|
13626
13497
|
}
|
|
13627
13498
|
removeAnnotations(code) {
|
|
@@ -13669,13 +13540,10 @@ class Super extends NodeBase {
|
|
|
13669
13540
|
deoptimizePath(path) {
|
|
13670
13541
|
this.variable.deoptimizePath(path);
|
|
13671
13542
|
}
|
|
13672
|
-
|
|
13543
|
+
include() {
|
|
13673
13544
|
if (!this.included) {
|
|
13674
13545
|
this.included = true;
|
|
13675
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
13676
|
-
}
|
|
13677
|
-
else if (path.length > 0) {
|
|
13678
|
-
this.variable.includePath(path, context);
|
|
13546
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
13679
13547
|
}
|
|
13680
13548
|
}
|
|
13681
13549
|
}
|
|
@@ -13692,12 +13560,12 @@ class SwitchCase extends NodeBase {
|
|
|
13692
13560
|
}
|
|
13693
13561
|
return false;
|
|
13694
13562
|
}
|
|
13695
|
-
|
|
13563
|
+
include(context, includeChildrenRecursively) {
|
|
13696
13564
|
this.included = true;
|
|
13697
|
-
this.test?.
|
|
13565
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
13698
13566
|
for (const node of this.consequent) {
|
|
13699
13567
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
13700
|
-
node.
|
|
13568
|
+
node.include(context, includeChildrenRecursively);
|
|
13701
13569
|
}
|
|
13702
13570
|
}
|
|
13703
13571
|
render(code, options, nodeRenderOptions) {
|
|
@@ -13745,9 +13613,9 @@ class SwitchStatement extends NodeBase {
|
|
|
13745
13613
|
context.hasBreak = hasBreak;
|
|
13746
13614
|
return false;
|
|
13747
13615
|
}
|
|
13748
|
-
|
|
13616
|
+
include(context, includeChildrenRecursively) {
|
|
13749
13617
|
this.included = true;
|
|
13750
|
-
this.discriminant.
|
|
13618
|
+
this.discriminant.include(context, includeChildrenRecursively);
|
|
13751
13619
|
const { brokenFlow, hasBreak } = context;
|
|
13752
13620
|
context.hasBreak = false;
|
|
13753
13621
|
let onlyHasBrokenFlow = true;
|
|
@@ -13764,7 +13632,7 @@ class SwitchStatement extends NodeBase {
|
|
|
13764
13632
|
isCaseIncluded = switchCase.hasEffects(hasEffectsContext);
|
|
13765
13633
|
}
|
|
13766
13634
|
if (isCaseIncluded) {
|
|
13767
|
-
switchCase.
|
|
13635
|
+
switchCase.include(context, includeChildrenRecursively);
|
|
13768
13636
|
onlyHasBrokenFlow &&= context.brokenFlow && !context.hasBreak;
|
|
13769
13637
|
context.hasBreak = false;
|
|
13770
13638
|
context.brokenFlow = brokenFlow;
|
|
@@ -13821,21 +13689,21 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
13821
13689
|
return (this.tag.hasEffects(context) ||
|
|
13822
13690
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
13823
13691
|
}
|
|
13824
|
-
|
|
13692
|
+
include(context, includeChildrenRecursively) {
|
|
13825
13693
|
if (!this.deoptimized)
|
|
13826
13694
|
this.applyDeoptimizations();
|
|
13827
13695
|
if (includeChildrenRecursively) {
|
|
13828
|
-
super.
|
|
13696
|
+
super.include(context, includeChildrenRecursively);
|
|
13829
13697
|
}
|
|
13830
13698
|
else {
|
|
13831
13699
|
this.included = true;
|
|
13832
|
-
this.tag.
|
|
13833
|
-
this.quasi.
|
|
13700
|
+
this.tag.include(context, includeChildrenRecursively);
|
|
13701
|
+
this.quasi.include(context, includeChildrenRecursively);
|
|
13834
13702
|
}
|
|
13835
|
-
this.tag.includeCallArguments(context, this.
|
|
13703
|
+
this.tag.includeCallArguments(context, this.args);
|
|
13836
13704
|
const [returnExpression] = this.getReturnExpression();
|
|
13837
13705
|
if (!returnExpression.included) {
|
|
13838
|
-
returnExpression.
|
|
13706
|
+
returnExpression.include(context, false);
|
|
13839
13707
|
}
|
|
13840
13708
|
}
|
|
13841
13709
|
initialise() {
|
|
@@ -13880,7 +13748,7 @@ class TemplateElement extends NodeBase {
|
|
|
13880
13748
|
hasEffects() {
|
|
13881
13749
|
return false;
|
|
13882
13750
|
}
|
|
13883
|
-
|
|
13751
|
+
include() {
|
|
13884
13752
|
this.included = true;
|
|
13885
13753
|
}
|
|
13886
13754
|
parseNode(esTreeNode) {
|
|
@@ -13922,13 +13790,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
13922
13790
|
class ModuleScope extends ChildScope {
|
|
13923
13791
|
constructor(parent, context) {
|
|
13924
13792
|
super(parent, context);
|
|
13925
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION,
|
|
13793
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
13926
13794
|
}
|
|
13927
|
-
addDeclaration(identifier, context, init,
|
|
13795
|
+
addDeclaration(identifier, context, init, kind) {
|
|
13928
13796
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
13929
13797
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
13930
13798
|
}
|
|
13931
|
-
return super.addDeclaration(identifier, context, init,
|
|
13799
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
13932
13800
|
}
|
|
13933
13801
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
13934
13802
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -13973,13 +13841,10 @@ class ThisExpression extends NodeBase {
|
|
|
13973
13841
|
}
|
|
13974
13842
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13975
13843
|
}
|
|
13976
|
-
|
|
13844
|
+
include() {
|
|
13977
13845
|
if (!this.included) {
|
|
13978
13846
|
this.included = true;
|
|
13979
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
13980
|
-
}
|
|
13981
|
-
else if (path.length > 0) {
|
|
13982
|
-
this.variable.includePath(path, context);
|
|
13847
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
13983
13848
|
}
|
|
13984
13849
|
}
|
|
13985
13850
|
initialise() {
|
|
@@ -14006,9 +13871,9 @@ class ThrowStatement extends NodeBase {
|
|
|
14006
13871
|
hasEffects() {
|
|
14007
13872
|
return true;
|
|
14008
13873
|
}
|
|
14009
|
-
|
|
13874
|
+
include(context, includeChildrenRecursively) {
|
|
14010
13875
|
this.included = true;
|
|
14011
|
-
this.argument.
|
|
13876
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
14012
13877
|
context.brokenFlow = true;
|
|
14013
13878
|
}
|
|
14014
13879
|
render(code, options) {
|
|
@@ -14030,13 +13895,13 @@ class TryStatement extends NodeBase {
|
|
|
14030
13895
|
? this.block.body.length > 0
|
|
14031
13896
|
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
14032
13897
|
}
|
|
14033
|
-
|
|
13898
|
+
include(context, includeChildrenRecursively) {
|
|
14034
13899
|
const tryCatchDeoptimization = this.scope.context.options.treeshake?.tryCatchDeoptimization;
|
|
14035
13900
|
const { brokenFlow, includedLabels } = context;
|
|
14036
13901
|
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
14037
13902
|
this.included = true;
|
|
14038
13903
|
this.directlyIncluded = true;
|
|
14039
|
-
this.block.
|
|
13904
|
+
this.block.include(context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively);
|
|
14040
13905
|
if (includedLabels.size > 0) {
|
|
14041
13906
|
this.includedLabelsAfterBlock = [...includedLabels];
|
|
14042
13907
|
}
|
|
@@ -14048,10 +13913,10 @@ class TryStatement extends NodeBase {
|
|
|
14048
13913
|
}
|
|
14049
13914
|
}
|
|
14050
13915
|
if (this.handler !== null) {
|
|
14051
|
-
this.handler.
|
|
13916
|
+
this.handler.include(context, includeChildrenRecursively);
|
|
14052
13917
|
context.brokenFlow = brokenFlow;
|
|
14053
13918
|
}
|
|
14054
|
-
this.finalizer?.
|
|
13919
|
+
this.finalizer?.include(context, includeChildrenRecursively);
|
|
14055
13920
|
}
|
|
14056
13921
|
}
|
|
14057
13922
|
|
|
@@ -14109,7 +13974,7 @@ class UpdateExpression extends NodeBase {
|
|
|
14109
13974
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
14110
13975
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
14111
13976
|
}
|
|
14112
|
-
|
|
13977
|
+
include(context, includeChildrenRecursively) {
|
|
14113
13978
|
if (!this.deoptimized)
|
|
14114
13979
|
this.applyDeoptimizations();
|
|
14115
13980
|
this.included = true;
|
|
@@ -14178,20 +14043,20 @@ class VariableDeclaration extends NodeBase {
|
|
|
14178
14043
|
hasEffectsOnInteractionAtPath() {
|
|
14179
14044
|
return false;
|
|
14180
14045
|
}
|
|
14181
|
-
|
|
14046
|
+
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
14182
14047
|
this.included = true;
|
|
14183
14048
|
for (const declarator of this.declarations) {
|
|
14184
14049
|
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14185
|
-
declarator.
|
|
14050
|
+
declarator.include(context, includeChildrenRecursively);
|
|
14186
14051
|
const { id, init } = declarator;
|
|
14187
14052
|
if (asSingleStatement) {
|
|
14188
|
-
id.
|
|
14053
|
+
id.include(context, includeChildrenRecursively);
|
|
14189
14054
|
}
|
|
14190
14055
|
if (init &&
|
|
14191
14056
|
id.included &&
|
|
14192
14057
|
!init.included &&
|
|
14193
14058
|
(id instanceof ObjectPattern || id instanceof ArrayPattern)) {
|
|
14194
|
-
init.
|
|
14059
|
+
init.include(context, includeChildrenRecursively);
|
|
14195
14060
|
}
|
|
14196
14061
|
}
|
|
14197
14062
|
}
|
|
@@ -14263,7 +14128,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14263
14128
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
14264
14129
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
14265
14130
|
if (!node.included) {
|
|
14266
|
-
|
|
14131
|
+
code.remove(start, end);
|
|
14132
|
+
node.removeAnnotations(code);
|
|
14267
14133
|
continue;
|
|
14268
14134
|
}
|
|
14269
14135
|
node.render(code, options);
|
|
@@ -14340,9 +14206,9 @@ class WhileStatement extends NodeBase {
|
|
|
14340
14206
|
return true;
|
|
14341
14207
|
return hasLoopBodyEffects(context, this.body);
|
|
14342
14208
|
}
|
|
14343
|
-
|
|
14209
|
+
include(context, includeChildrenRecursively) {
|
|
14344
14210
|
this.included = true;
|
|
14345
|
-
this.test.
|
|
14211
|
+
this.test.include(context, includeChildrenRecursively);
|
|
14346
14212
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
14347
14213
|
}
|
|
14348
14214
|
}
|
|
@@ -14586,7 +14452,7 @@ const bufferParsers = [
|
|
|
14586
14452
|
const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
|
|
14587
14453
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
14588
14454
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
14589
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14455
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14590
14456
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
14591
14457
|
},
|
|
14592
14458
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -14632,7 +14498,7 @@ const bufferParsers = [
|
|
|
14632
14498
|
const parameterPosition = buffer[position];
|
|
14633
14499
|
const parameter = (node.param =
|
|
14634
14500
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
14635
|
-
parameter?.declare('parameter',
|
|
14501
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
14636
14502
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
14637
14503
|
},
|
|
14638
14504
|
function chainExpression(node, position, buffer) {
|
|
@@ -14642,14 +14508,17 @@ const bufferParsers = [
|
|
|
14642
14508
|
function classBody(node, position, buffer) {
|
|
14643
14509
|
const { scope } = node;
|
|
14644
14510
|
const bodyPosition = buffer[position];
|
|
14645
|
-
const body = (node.body = []);
|
|
14646
14511
|
if (bodyPosition) {
|
|
14647
14512
|
const length = buffer[bodyPosition];
|
|
14513
|
+
const body = (node.body = new Array(length));
|
|
14648
14514
|
for (let index = 0; index < length; index++) {
|
|
14649
14515
|
const nodePosition = buffer[bodyPosition + 1 + index];
|
|
14650
|
-
body
|
|
14516
|
+
body[index] = convertNode(node, (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, nodePosition, buffer);
|
|
14651
14517
|
}
|
|
14652
14518
|
}
|
|
14519
|
+
else {
|
|
14520
|
+
node.body = [];
|
|
14521
|
+
}
|
|
14653
14522
|
},
|
|
14654
14523
|
function classDeclaration(node, position, buffer) {
|
|
14655
14524
|
const { scope } = node;
|
|
@@ -14767,7 +14636,7 @@ const bufferParsers = [
|
|
|
14767
14636
|
node.id =
|
|
14768
14637
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
14769
14638
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
14770
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14639
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14771
14640
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
14772
14641
|
},
|
|
14773
14642
|
function functionExpression(node, position, buffer) {
|
|
@@ -14780,7 +14649,7 @@ const bufferParsers = [
|
|
|
14780
14649
|
const idPosition = buffer[position + 2];
|
|
14781
14650
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
14782
14651
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
14783
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14652
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14784
14653
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
14785
14654
|
},
|
|
14786
14655
|
function identifier(node, position, buffer) {
|
|
@@ -15127,10 +14996,10 @@ function convertNodeList(parent, parentScope, position, buffer) {
|
|
|
15127
14996
|
if (position === 0)
|
|
15128
14997
|
return EMPTY_ARRAY;
|
|
15129
14998
|
const length = buffer[position++];
|
|
15130
|
-
const list =
|
|
14999
|
+
const list = new Array(length);
|
|
15131
15000
|
for (let index = 0; index < length; index++) {
|
|
15132
15001
|
const nodePosition = buffer[position++];
|
|
15133
|
-
list
|
|
15002
|
+
list[index] = nodePosition ? convertNode(parent, parentScope, nodePosition, buffer) : null;
|
|
15134
15003
|
}
|
|
15135
15004
|
return list;
|
|
15136
15005
|
}
|
|
@@ -15139,8 +15008,8 @@ class UnknownNode extends NodeBase {
|
|
|
15139
15008
|
hasEffects() {
|
|
15140
15009
|
return true;
|
|
15141
15010
|
}
|
|
15142
|
-
|
|
15143
|
-
super.
|
|
15011
|
+
include(context) {
|
|
15012
|
+
super.include(context, true);
|
|
15144
15013
|
}
|
|
15145
15014
|
}
|
|
15146
15015
|
|
|
@@ -15244,8 +15113,8 @@ class ExportShimVariable extends Variable {
|
|
|
15244
15113
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
15245
15114
|
this.module = module;
|
|
15246
15115
|
}
|
|
15247
|
-
|
|
15248
|
-
super.
|
|
15116
|
+
include() {
|
|
15117
|
+
super.include();
|
|
15249
15118
|
this.module.needsExportShim = true;
|
|
15250
15119
|
}
|
|
15251
15120
|
}
|
|
@@ -15936,7 +15805,7 @@ class Module {
|
|
|
15936
15805
|
include() {
|
|
15937
15806
|
const context = createInclusionContext();
|
|
15938
15807
|
if (this.ast.shouldBeIncluded(context))
|
|
15939
|
-
this.ast.
|
|
15808
|
+
this.ast.include(context, false);
|
|
15940
15809
|
}
|
|
15941
15810
|
includeAllExports(includeNamespaceMembers) {
|
|
15942
15811
|
if (!this.isExecuted) {
|
|
@@ -15950,7 +15819,9 @@ class Module {
|
|
|
15950
15819
|
return error(logMissingEntryExport(exportName, this.id));
|
|
15951
15820
|
}
|
|
15952
15821
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15953
|
-
|
|
15822
|
+
if (!variable.included) {
|
|
15823
|
+
this.includeVariable(variable);
|
|
15824
|
+
}
|
|
15954
15825
|
}
|
|
15955
15826
|
}
|
|
15956
15827
|
for (const name of this.getReexports()) {
|
|
@@ -15958,7 +15829,7 @@ class Module {
|
|
|
15958
15829
|
if (variable) {
|
|
15959
15830
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15960
15831
|
if (!variable.included) {
|
|
15961
|
-
this.includeVariable(variable
|
|
15832
|
+
this.includeVariable(variable);
|
|
15962
15833
|
}
|
|
15963
15834
|
if (variable instanceof ExternalVariable) {
|
|
15964
15835
|
variable.module.reexported = true;
|
|
@@ -15970,7 +15841,7 @@ class Module {
|
|
|
15970
15841
|
}
|
|
15971
15842
|
}
|
|
15972
15843
|
includeAllInBundle() {
|
|
15973
|
-
this.ast.
|
|
15844
|
+
this.ast.include(createInclusionContext(), true);
|
|
15974
15845
|
this.includeAllExports(false);
|
|
15975
15846
|
}
|
|
15976
15847
|
includeExportsByNames(names) {
|
|
@@ -15984,7 +15855,7 @@ class Module {
|
|
|
15984
15855
|
if (variable) {
|
|
15985
15856
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15986
15857
|
if (!variable.included) {
|
|
15987
|
-
this.includeVariable(variable
|
|
15858
|
+
this.includeVariable(variable);
|
|
15988
15859
|
}
|
|
15989
15860
|
}
|
|
15990
15861
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
@@ -16426,13 +16297,13 @@ class Module {
|
|
|
16426
16297
|
for (const module of [this, ...this.exportAllModules]) {
|
|
16427
16298
|
if (module instanceof ExternalModule) {
|
|
16428
16299
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
16429
|
-
externalVariable.
|
|
16300
|
+
externalVariable.include();
|
|
16430
16301
|
this.includedImports.add(externalVariable);
|
|
16431
16302
|
externalNamespaces.add(externalVariable);
|
|
16432
16303
|
}
|
|
16433
16304
|
else if (module.info.syntheticNamedExports) {
|
|
16434
16305
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
16435
|
-
syntheticNamespace.
|
|
16306
|
+
syntheticNamespace.include();
|
|
16436
16307
|
this.includedImports.add(syntheticNamespace);
|
|
16437
16308
|
syntheticNamespaces.add(syntheticNamespace);
|
|
16438
16309
|
}
|
|
@@ -16442,9 +16313,7 @@ class Module {
|
|
|
16442
16313
|
includeDynamicImport(node) {
|
|
16443
16314
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
16444
16315
|
if (resolution instanceof Module) {
|
|
16445
|
-
|
|
16446
|
-
resolution.includedDynamicImporters.push(this);
|
|
16447
|
-
}
|
|
16316
|
+
resolution.includedDynamicImporters.push(this);
|
|
16448
16317
|
const importedNames = this.options.treeshake
|
|
16449
16318
|
? node.getDeterministicImportedNames()
|
|
16450
16319
|
: undefined;
|
|
@@ -16456,7 +16325,7 @@ class Module {
|
|
|
16456
16325
|
}
|
|
16457
16326
|
}
|
|
16458
16327
|
}
|
|
16459
|
-
includeVariable(variable
|
|
16328
|
+
includeVariable(variable) {
|
|
16460
16329
|
const variableModule = variable.module;
|
|
16461
16330
|
if (variable.included) {
|
|
16462
16331
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
@@ -16464,6 +16333,7 @@ class Module {
|
|
|
16464
16333
|
}
|
|
16465
16334
|
}
|
|
16466
16335
|
else {
|
|
16336
|
+
variable.include();
|
|
16467
16337
|
this.graph.needsTreeshakingPass = true;
|
|
16468
16338
|
if (variableModule instanceof Module) {
|
|
16469
16339
|
if (!variableModule.isExecuted) {
|
|
@@ -16479,10 +16349,9 @@ class Module {
|
|
|
16479
16349
|
}
|
|
16480
16350
|
}
|
|
16481
16351
|
}
|
|
16482
|
-
variable.includePath(path, createInclusionContext());
|
|
16483
16352
|
}
|
|
16484
|
-
includeVariableInModule(variable
|
|
16485
|
-
this.includeVariable(variable
|
|
16353
|
+
includeVariableInModule(variable) {
|
|
16354
|
+
this.includeVariable(variable);
|
|
16486
16355
|
const variableModule = variable.module;
|
|
16487
16356
|
if (variableModule && variableModule !== this) {
|
|
16488
16357
|
this.includedImports.add(variable);
|
|
@@ -18123,14 +17992,16 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log
|
|
|
18123
17992
|
return chunkDefinitions;
|
|
18124
17993
|
}
|
|
18125
17994
|
function getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry) {
|
|
18126
|
-
const chunkDefinitions = [];
|
|
18127
17995
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
18128
17996
|
const manualChunkModulesByAlias = Object.create(null);
|
|
18129
17997
|
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
18130
17998
|
addStaticDependenciesToManualChunk(entry, (manualChunkModulesByAlias[alias] ||= []), modulesInManualChunks);
|
|
18131
17999
|
}
|
|
18132
|
-
|
|
18133
|
-
|
|
18000
|
+
const manualChunks = Object.entries(manualChunkModulesByAlias);
|
|
18001
|
+
const chunkDefinitions = new Array(manualChunks.length);
|
|
18002
|
+
let index = 0;
|
|
18003
|
+
for (const [alias, modules] of manualChunks) {
|
|
18004
|
+
chunkDefinitions[index++] = { alias, modules };
|
|
18134
18005
|
}
|
|
18135
18006
|
return { chunkDefinitions, modulesInManualChunks };
|
|
18136
18007
|
}
|
|
@@ -18149,12 +18020,12 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
|
|
|
18149
18020
|
function analyzeModuleGraph(entries) {
|
|
18150
18021
|
const dynamicEntryModules = new Set();
|
|
18151
18022
|
const dependentEntriesByModule = new Map();
|
|
18152
|
-
const dynamicImportModulesByEntry = [];
|
|
18153
18023
|
const allEntriesSet = new Set(entries);
|
|
18024
|
+
const dynamicImportModulesByEntry = new Array(allEntriesSet.size);
|
|
18154
18025
|
let entryIndex = 0;
|
|
18155
18026
|
for (const currentEntry of allEntriesSet) {
|
|
18156
18027
|
const dynamicImportsForCurrentEntry = new Set();
|
|
18157
|
-
dynamicImportModulesByEntry
|
|
18028
|
+
dynamicImportModulesByEntry[entryIndex] = dynamicImportsForCurrentEntry;
|
|
18158
18029
|
const modulesToHandle = new Set([currentEntry]);
|
|
18159
18030
|
for (const module of modulesToHandle) {
|
|
18160
18031
|
getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
|
|
@@ -18199,13 +18070,14 @@ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModules
|
|
|
18199
18070
|
dynamicEntries.add(entryIndex);
|
|
18200
18071
|
}
|
|
18201
18072
|
}
|
|
18202
|
-
const dynamicImportsByEntry =
|
|
18073
|
+
const dynamicImportsByEntry = new Array(dynamicImportModulesByEntry.length);
|
|
18074
|
+
let index = 0;
|
|
18203
18075
|
for (const dynamicImportModules of dynamicImportModulesByEntry) {
|
|
18204
18076
|
const dynamicImports = new Set();
|
|
18205
18077
|
for (const dynamicEntry of dynamicImportModules) {
|
|
18206
18078
|
dynamicImports.add(entryIndexByModule.get(dynamicEntry));
|
|
18207
18079
|
}
|
|
18208
|
-
dynamicImportsByEntry
|
|
18080
|
+
dynamicImportsByEntry[index++] = dynamicImports;
|
|
18209
18081
|
}
|
|
18210
18082
|
return { dynamicEntries, dynamicImportsByEntry };
|
|
18211
18083
|
}
|
|
@@ -18310,9 +18182,10 @@ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry
|
|
|
18310
18182
|
function getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize) {
|
|
18311
18183
|
const chunksBySignature = Object.create(null);
|
|
18312
18184
|
const chunkByModule = new Map();
|
|
18313
|
-
const sizeByAtom =
|
|
18185
|
+
const sizeByAtom = new Array(chunkAtoms.length);
|
|
18314
18186
|
let sideEffectAtoms = 0n;
|
|
18315
18187
|
let atomMask = 1n;
|
|
18188
|
+
let index = 0;
|
|
18316
18189
|
for (const { dependentEntries, modules } of chunkAtoms) {
|
|
18317
18190
|
let chunkSignature = 0n;
|
|
18318
18191
|
let correlatedAtoms = -1n;
|
|
@@ -18350,7 +18223,7 @@ function getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticD
|
|
|
18350
18223
|
if (!pure) {
|
|
18351
18224
|
sideEffectAtoms |= atomMask;
|
|
18352
18225
|
}
|
|
18353
|
-
sizeByAtom
|
|
18226
|
+
sizeByAtom[index++] = atomSize;
|
|
18354
18227
|
chunk.containedAtoms |= atomMask;
|
|
18355
18228
|
chunk.modules.push(...modules);
|
|
18356
18229
|
chunk.pure &&= pure;
|
|
@@ -19120,6 +18993,9 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
19120
18993
|
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
19121
18994
|
let finalSourcemapFileName = null;
|
|
19122
18995
|
if (map) {
|
|
18996
|
+
if (options.sourcemapDebugIds) {
|
|
18997
|
+
updatedCode += calculateDebugIdAndGetComment(updatedCode, map);
|
|
18998
|
+
}
|
|
19123
18999
|
finalSourcemapFileName = sourcemapFileName
|
|
19124
19000
|
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
19125
19001
|
: `${finalFileName}.map`;
|
|
@@ -19132,6 +19008,9 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
19132
19008
|
let updatedCode = hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code;
|
|
19133
19009
|
let finalSourcemapFileName = null;
|
|
19134
19010
|
if (map) {
|
|
19011
|
+
if (options.sourcemapDebugIds) {
|
|
19012
|
+
updatedCode += calculateDebugIdAndGetComment(updatedCode, map);
|
|
19013
|
+
}
|
|
19135
19014
|
finalSourcemapFileName = sourcemapFileName
|
|
19136
19015
|
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
19137
19016
|
: `${fileName}.map`;
|
|
@@ -19159,6 +19038,18 @@ function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, so
|
|
|
19159
19038
|
}
|
|
19160
19039
|
return sourcemap === 'hidden' ? '' : `//# ${SOURCEMAPPING_URL}=${url}\n`;
|
|
19161
19040
|
}
|
|
19041
|
+
function calculateDebugIdAndGetComment(code, map) {
|
|
19042
|
+
const hash = hasherByType.hex(code);
|
|
19043
|
+
const debugId = [
|
|
19044
|
+
hash.slice(0, 8),
|
|
19045
|
+
hash.slice(8, 12),
|
|
19046
|
+
'4' + hash.slice(12, 15),
|
|
19047
|
+
((parseInt(hash.slice(15, 16), 16) & 3) | 8).toString(16) + hash.slice(17, 20),
|
|
19048
|
+
hash.slice(20, 32)
|
|
19049
|
+
].join('-');
|
|
19050
|
+
map.debugId = debugId;
|
|
19051
|
+
return '//# debugId=' + debugId + '\n';
|
|
19052
|
+
}
|
|
19162
19053
|
|
|
19163
19054
|
class Bundle {
|
|
19164
19055
|
constructor(outputOptions, unsetOptions, inputOptions, pluginDriver, graph) {
|
|
@@ -19266,16 +19157,18 @@ class Bundle {
|
|
|
19266
19157
|
const includedModules = getIncludedModules(this.graph.modulesById);
|
|
19267
19158
|
const inputBase = commondir(getAbsoluteEntryModulePaths(includedModules, preserveModules));
|
|
19268
19159
|
const externalChunkByModule = getExternalChunkByModule(this.graph.modulesById, this.outputOptions, inputBase);
|
|
19269
|
-
const
|
|
19270
|
-
const chunkByModule = new Map();
|
|
19271
|
-
for (const { alias, modules } of inlineDynamicImports
|
|
19160
|
+
const executableModule = inlineDynamicImports
|
|
19272
19161
|
? [{ alias: null, modules: includedModules }]
|
|
19273
19162
|
: preserveModules
|
|
19274
19163
|
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
19275
|
-
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize, this.inputOptions.onLog)
|
|
19164
|
+
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize, this.inputOptions.onLog);
|
|
19165
|
+
const chunks = new Array(executableModule.length);
|
|
19166
|
+
const chunkByModule = new Map();
|
|
19167
|
+
let index = 0;
|
|
19168
|
+
for (const { alias, modules } of executableModule) {
|
|
19276
19169
|
sortByExecutionOrder(modules);
|
|
19277
19170
|
const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
|
|
19278
|
-
chunks
|
|
19171
|
+
chunks[index++] = chunk;
|
|
19279
19172
|
}
|
|
19280
19173
|
for (const chunk of chunks) {
|
|
19281
19174
|
chunk.link();
|
|
@@ -21055,7 +20948,7 @@ class Graph {
|
|
|
21055
20948
|
this.options = options;
|
|
21056
20949
|
this.astLru = flru(5);
|
|
21057
20950
|
this.cachedModules = new Map();
|
|
21058
|
-
this.deoptimizationTracker = new
|
|
20951
|
+
this.deoptimizationTracker = new PathTracker();
|
|
21059
20952
|
this.entryModules = [];
|
|
21060
20953
|
this.modulesById = new Map();
|
|
21061
20954
|
this.needsTreeshakingPass = false;
|
|
@@ -21548,6 +21441,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
21548
21441
|
: sanitizeFileName,
|
|
21549
21442
|
sourcemap: config.sourcemap || false,
|
|
21550
21443
|
sourcemapBaseUrl: getSourcemapBaseUrl(config),
|
|
21444
|
+
sourcemapDebugIds: config.sourcemapDebugIds || false,
|
|
21551
21445
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
21552
21446
|
sourcemapFile: config.sourcemapFile,
|
|
21553
21447
|
sourcemapFileNames: getSourcemapFileNames(config, unsetOptions),
|
|
@@ -22259,6 +22153,7 @@ async function mergeOutputOptions(config, overrides, log) {
|
|
|
22259
22153
|
sanitizeFileName: getOption('sanitizeFileName'),
|
|
22260
22154
|
sourcemap: getOption('sourcemap'),
|
|
22261
22155
|
sourcemapBaseUrl: getOption('sourcemapBaseUrl'),
|
|
22156
|
+
sourcemapDebugIds: getOption('sourcemapDebugIds'),
|
|
22262
22157
|
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
|
|
22263
22158
|
sourcemapFile: getOption('sourcemapFile'),
|
|
22264
22159
|
sourcemapFileNames: getOption('sourcemapFileNames'),
|