@rollup/wasm-node 4.68.2 → 4.68.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +1541 -1218
- package/dist/es/shared/parseAst.js +17 -12
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/node-entry.js +2 -2
- package/dist/shared/parseAst.js +12 -2
- package/dist/shared/rollup.js +1540 -1217
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +10 -10
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.68.
|
|
4
|
-
Mon,
|
|
3
|
+
Rollup.js v4.68.4
|
|
4
|
+
Mon, 16 Nov 2026 08:59:19 GMT - commit 9b2de5068e925a3b07bea67c972de21a347af9d9
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, FunctionExpression as FunctionExpression$1, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, ObjectPattern as ObjectPattern$1, ArrayPattern as ArrayPattern$1, BLANK, AssignmentPattern as AssignmentPattern$1, RestElement as RestElement$1, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, UnaryExpression as UnaryExpression$1, ChainExpression as ChainExpression$1, logMissingExport, normalize, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval,
|
|
10
|
+
import { EmptyStatement as EmptyStatement$1, BlockStatement as BlockStatement$1, EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, FunctionExpression as FunctionExpression$1, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, ObjectPattern as ObjectPattern$1, ArrayPattern as ArrayPattern$1, BLANK, AssignmentPattern as AssignmentPattern$1, RestElement as RestElement$1, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, UnaryExpression as UnaryExpression$1, ChainExpression as ChainExpression$1, logMissingExport, normalize, ForOfStatement as ForOfStatement$1, ForInStatement as ForInStatement$1, SwitchCase as SwitchCase$1, ExportNamedDeclaration as ExportNamedDeclaration$1, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, isAbsolute as isAbsolute$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logMissingEntryExport, logSyntheticNamedExportsNeedNamespaceExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logInvalidFormatForTopLevelAwait, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, getDynamicAliasName, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logErrorInHook, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, URL_LOAD, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1, join } from 'node:path';
|
|
12
12
|
import { isAbsolute, posix, win32, resolve } from 'path';
|
|
13
13
|
import { parseAsync, xxhashBase16, xxhashBase64Url, xxhashBase36 } from '../../native.js';
|
|
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.68.
|
|
30
|
+
var version = "4.68.4";
|
|
31
31
|
const pkg = {
|
|
32
32
|
version: version};
|
|
33
33
|
|
|
@@ -2388,6 +2388,37 @@ function renderSystemExportSequenceAfterExpression(exportedVariable, expressionS
|
|
|
2388
2388
|
code.appendLeft(expressionEnd, ')');
|
|
2389
2389
|
}
|
|
2390
2390
|
}
|
|
2391
|
+
function renderSystemExportForLoop(left, body, code, options) {
|
|
2392
|
+
const exportedVariables = [];
|
|
2393
|
+
left.addExportedVariables(exportedVariables, options.exportNamesByVariable);
|
|
2394
|
+
if (exportedVariables.length === 0)
|
|
2395
|
+
return;
|
|
2396
|
+
const { _, getPropertyAccess } = options.snippets;
|
|
2397
|
+
const exportStatement = `${getSystemExportStatement(exportedVariables, options)};`;
|
|
2398
|
+
if (body.type === EmptyStatement$1) {
|
|
2399
|
+
code.overwrite(body.start, body.end, exportStatement);
|
|
2400
|
+
}
|
|
2401
|
+
else if (body.type === BlockStatement$1 &&
|
|
2402
|
+
!scopeShadowsExportedBindings(body.scope, exportedVariables, getPropertyAccess)) {
|
|
2403
|
+
code.prependRight(body.start + 1, `${_}${exportStatement}`);
|
|
2404
|
+
}
|
|
2405
|
+
else {
|
|
2406
|
+
code.prependRight(body.start, `{${_}${exportStatement}${_}`);
|
|
2407
|
+
code.appendLeft(body.end, `${_}}`);
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
function scopeShadowsExportedBindings(scope, exportedVariables, getPropertyAccess) {
|
|
2411
|
+
const referencedNames = new Set(['exports']);
|
|
2412
|
+
for (const variable of exportedVariables) {
|
|
2413
|
+
referencedNames.add(variable.getName(getPropertyAccess));
|
|
2414
|
+
}
|
|
2415
|
+
for (const variable of scope.variables.values()) {
|
|
2416
|
+
if (variable.included && referencedNames.has(variable.getName(getPropertyAccess))) {
|
|
2417
|
+
return true;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
return false;
|
|
2421
|
+
}
|
|
2391
2422
|
function renderSystemExportSequenceBeforeExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options, modifier) {
|
|
2392
2423
|
const { _ } = options.snippets;
|
|
2393
2424
|
code.prependRight(expressionStart, `${getSystemExportStatement([exportedVariable], options, modifier)},${_}`);
|
|
@@ -2864,7 +2895,7 @@ class Variable extends ExpressionEntity {
|
|
|
2864
2895
|
(this.forbiddenNames ||= new Set()).add(name);
|
|
2865
2896
|
}
|
|
2866
2897
|
getBaseVariableName() {
|
|
2867
|
-
return (this.
|
|
2898
|
+
return (this.getNamingVariable()?.getBaseVariableName() ||
|
|
2868
2899
|
this.renderBaseName ||
|
|
2869
2900
|
this.renderName ||
|
|
2870
2901
|
this.name);
|
|
@@ -2876,8 +2907,9 @@ class Variable extends ExpressionEntity {
|
|
|
2876
2907
|
if (useOriginalName?.(this)) {
|
|
2877
2908
|
return this.name;
|
|
2878
2909
|
}
|
|
2879
|
-
|
|
2880
|
-
|
|
2910
|
+
const namingVariable = this.getNamingVariable();
|
|
2911
|
+
if (namingVariable) {
|
|
2912
|
+
return namingVariable.getName(getPropertyAccess, useOriginalName);
|
|
2881
2913
|
}
|
|
2882
2914
|
const name = this.renderName || this.name;
|
|
2883
2915
|
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
@@ -2896,12 +2928,19 @@ class Variable extends ExpressionEntity {
|
|
|
2896
2928
|
this.renderedLikeHoisted?.includePath(path, context);
|
|
2897
2929
|
}
|
|
2898
2930
|
/**
|
|
2899
|
-
* Links
|
|
2900
|
-
*
|
|
2931
|
+
* Links this variable to a hoisted variable. Including this variable then
|
|
2932
|
+
* includes the hoisted variable, and while the hoisted variable renders as an
|
|
2933
|
+
* identifier, this variable renders with its name.
|
|
2901
2934
|
*/
|
|
2902
2935
|
renderLikeHoisted(variable) {
|
|
2903
2936
|
this.renderedLikeHoisted = variable;
|
|
2904
2937
|
}
|
|
2938
|
+
getHoistedVariable() {
|
|
2939
|
+
return this.renderedLikeHoisted;
|
|
2940
|
+
}
|
|
2941
|
+
getNamingVariable() {
|
|
2942
|
+
return this.renderedLikeHoisted?.renderBaseName === null ? this.renderedLikeHoisted : undefined;
|
|
2943
|
+
}
|
|
2905
2944
|
markCalledFromTryStatement() { }
|
|
2906
2945
|
addReassignedValue(_value) { }
|
|
2907
2946
|
setRenderNames(baseName, name) {
|
|
@@ -4401,7 +4440,12 @@ class ArrayExpression extends NodeBase {
|
|
|
4401
4440
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
4402
4441
|
}
|
|
4403
4442
|
deoptimizePath(path) {
|
|
4404
|
-
this.getObjectEntity()
|
|
4443
|
+
const objectEntity = this.getObjectEntity();
|
|
4444
|
+
objectEntity.deoptimizePath(path);
|
|
4445
|
+
// Writing the length can remove elements or add holes
|
|
4446
|
+
if (path.length === 1 && path[0] === 'length') {
|
|
4447
|
+
objectEntity.deoptimizePath(UNKNOWN_INTEGER_PATH);
|
|
4448
|
+
}
|
|
4405
4449
|
}
|
|
4406
4450
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
4407
4451
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
@@ -4484,6 +4528,29 @@ const IMPURE = {
|
|
|
4484
4528
|
getLiteralValue: getUnknownValue,
|
|
4485
4529
|
hasEffectsWhenCalled: returnTrue
|
|
4486
4530
|
};
|
|
4531
|
+
// For functions that return their arguments, the arguments can be mutated via
|
|
4532
|
+
// the return value
|
|
4533
|
+
const deoptimizeArguments = ({ args }) => {
|
|
4534
|
+
for (let index = 1; index < args.length; index++) {
|
|
4535
|
+
args[index]?.deoptimizePath(UNKNOWN_PATH);
|
|
4536
|
+
}
|
|
4537
|
+
};
|
|
4538
|
+
// For functions that return values stored in their arguments (but not the
|
|
4539
|
+
// arguments themselves), those values can be mutated via the return value
|
|
4540
|
+
const UNKNOWN_VALUES_PATH = [UnknownKey, UnknownKey];
|
|
4541
|
+
const deoptimizeArgumentValues = ({ args }) => {
|
|
4542
|
+
for (let index = 1; index < args.length; index++) {
|
|
4543
|
+
args[index]?.deoptimizePath(UNKNOWN_VALUES_PATH);
|
|
4544
|
+
}
|
|
4545
|
+
};
|
|
4546
|
+
const returningArguments = (description) => ({
|
|
4547
|
+
...description,
|
|
4548
|
+
deoptimizeArgumentsOnCall: deoptimizeArguments
|
|
4549
|
+
});
|
|
4550
|
+
const returningArgumentValues = (description) => ({
|
|
4551
|
+
...description,
|
|
4552
|
+
deoptimizeArgumentsOnCall: deoptimizeArgumentValues
|
|
4553
|
+
});
|
|
4487
4554
|
const PURE_WITH_ARRAY = {
|
|
4488
4555
|
deoptimizeArgumentsOnCall: doNothing,
|
|
4489
4556
|
getLiteralValue: getUnknownValue,
|
|
@@ -4503,8 +4570,9 @@ const PURE_WITH_ARRAY_OR_LENGTH = {
|
|
|
4503
4570
|
}) !== 'number');
|
|
4504
4571
|
}
|
|
4505
4572
|
};
|
|
4573
|
+
// Used for Object.entries and Object.values, which return the property values
|
|
4506
4574
|
const GETTER_ACCESS = {
|
|
4507
|
-
deoptimizeArgumentsOnCall:
|
|
4575
|
+
deoptimizeArgumentsOnCall: deoptimizeArgumentValues,
|
|
4508
4576
|
getLiteralValue: getUnknownValue,
|
|
4509
4577
|
hasEffectsWhenCalled({ args }, context) {
|
|
4510
4578
|
const [_thisArgument, firstArgument] = args;
|
|
@@ -4523,17 +4591,60 @@ const PF = {
|
|
|
4523
4591
|
__proto__: null,
|
|
4524
4592
|
[ValueProperties]: PURE
|
|
4525
4593
|
};
|
|
4594
|
+
/* OBJECT THAT RETURNS ITS ARGUMENTS WHEN CALLED */
|
|
4595
|
+
const O_RETURNING_ARGS = {
|
|
4596
|
+
__proto__: null,
|
|
4597
|
+
[ValueProperties]: returningArguments(IMPURE)
|
|
4598
|
+
};
|
|
4599
|
+
/* OBJECT THAT RETURNS VALUES STORED IN ITS ARGUMENTS WHEN CALLED */
|
|
4600
|
+
const O_RETURNING_ARG_VALUES = {
|
|
4601
|
+
__proto__: null,
|
|
4602
|
+
[ValueProperties]: returningArgumentValues(IMPURE)
|
|
4603
|
+
};
|
|
4604
|
+
/* Array.from RETURNS THE VALUES OF THE ITERABLE OR WHATEVER THE MAPPER RETURNS */
|
|
4605
|
+
const ARRAY_FROM = {
|
|
4606
|
+
__proto__: null,
|
|
4607
|
+
[ValueProperties]: {
|
|
4608
|
+
...IMPURE,
|
|
4609
|
+
deoptimizeArgumentsOnCall({ args: [, iterable, ...otherArguments] }) {
|
|
4610
|
+
iterable?.deoptimizePath(UNKNOWN_VALUES_PATH);
|
|
4611
|
+
// The mapper is called by the global, so its return value and its
|
|
4612
|
+
// parameters, as well as the this argument, are no longer tracked.
|
|
4613
|
+
// As spread arguments mean that the mapper and this argument do not
|
|
4614
|
+
// necessarily have a fixed position, we deoptimize all remaining
|
|
4615
|
+
// arguments.
|
|
4616
|
+
for (const argument of otherArguments) {
|
|
4617
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
};
|
|
4622
|
+
/* PURE FUNCTION THAT RETURNS ITS ARGUMENTS */
|
|
4623
|
+
const PF_RETURNING_ARGS = {
|
|
4624
|
+
__proto__: null,
|
|
4625
|
+
[ValueProperties]: returningArguments(PURE)
|
|
4626
|
+
};
|
|
4627
|
+
/* PURE FUNCTION THAT RETURNS VALUES STORED IN ITS ARGUMENTS */
|
|
4628
|
+
const PF_RETURNING_ARG_VALUES = {
|
|
4629
|
+
__proto__: null,
|
|
4630
|
+
[ValueProperties]: returningArgumentValues(PURE)
|
|
4631
|
+
};
|
|
4526
4632
|
/* PURE FUNCTION IF FIRST ARG DOES NOT CONTAIN A GETTER */
|
|
4527
4633
|
const PF_NO_GETTER = {
|
|
4528
4634
|
__proto__: null,
|
|
4529
4635
|
[ValueProperties]: GETTER_ACCESS
|
|
4530
4636
|
};
|
|
4531
4637
|
/* FUNCTION THAT MUTATES FIRST ARG WITHOUT TRIGGERING ACCESSORS */
|
|
4638
|
+
// For defineProperty and defineProperties, the values of the property
|
|
4639
|
+
// descriptors also become reachable via the first argument
|
|
4532
4640
|
const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
4533
4641
|
__proto__: null,
|
|
4534
4642
|
[ValueProperties]: {
|
|
4535
|
-
deoptimizeArgumentsOnCall({ args: [, firstArgument] }) {
|
|
4643
|
+
deoptimizeArgumentsOnCall({ args: [, firstArgument, ...otherArguments] }) {
|
|
4536
4644
|
firstArgument?.deoptimizePath(UNKNOWN_PATH);
|
|
4645
|
+
for (const argument of otherArguments) {
|
|
4646
|
+
argument.deoptimizePath(UNKNOWN_VALUES_PATH);
|
|
4647
|
+
}
|
|
4537
4648
|
},
|
|
4538
4649
|
getLiteralValue: getUnknownValue,
|
|
4539
4650
|
hasEffectsWhenCalled({ args }, context) {
|
|
@@ -4559,6 +4670,18 @@ const PC_WITH_ARRAY = {
|
|
|
4559
4670
|
[ValueProperties]: PURE_WITH_ARRAY,
|
|
4560
4671
|
prototype: O
|
|
4561
4672
|
};
|
|
4673
|
+
/* PURE CONSTRUCTOR WITH ARRAY WHOSE INSTANCES EXPOSE THE VALUES OF THE ARRAY */
|
|
4674
|
+
const PC_WITH_ARRAY_RETURNING_ARG_VALUES = {
|
|
4675
|
+
__proto__: null,
|
|
4676
|
+
[ValueProperties]: returningArgumentValues(PURE_WITH_ARRAY),
|
|
4677
|
+
prototype: O
|
|
4678
|
+
};
|
|
4679
|
+
/* PURE CONSTRUCTOR WHOSE INSTANCES EXPOSE VALUES STORED IN ITS ARGUMENTS */
|
|
4680
|
+
const PC_RETURNING_ARG_VALUES = {
|
|
4681
|
+
__proto__: null,
|
|
4682
|
+
[ValueProperties]: returningArgumentValues(PURE),
|
|
4683
|
+
prototype: O
|
|
4684
|
+
};
|
|
4562
4685
|
const ARRAY_TYPE = {
|
|
4563
4686
|
__proto__: null,
|
|
4564
4687
|
[ValueProperties]: PURE_WITH_ARRAY_OR_LENGTH,
|
|
@@ -4587,10 +4710,10 @@ const knownGlobals = {
|
|
|
4587
4710
|
[ValueProperties]: IMPURE,
|
|
4588
4711
|
Array: {
|
|
4589
4712
|
__proto__: null,
|
|
4590
|
-
[ValueProperties]: IMPURE,
|
|
4591
|
-
from:
|
|
4713
|
+
[ValueProperties]: returningArguments(IMPURE),
|
|
4714
|
+
from: ARRAY_FROM,
|
|
4592
4715
|
isArray: PF,
|
|
4593
|
-
of:
|
|
4716
|
+
of: PF_RETURNING_ARGS,
|
|
4594
4717
|
prototype: O
|
|
4595
4718
|
},
|
|
4596
4719
|
ArrayBuffer: {
|
|
@@ -4599,7 +4722,7 @@ const knownGlobals = {
|
|
|
4599
4722
|
isView: PF,
|
|
4600
4723
|
prototype: O
|
|
4601
4724
|
},
|
|
4602
|
-
AggregateError:
|
|
4725
|
+
AggregateError: PC_WITH_ARRAY_RETURNING_ARG_VALUES,
|
|
4603
4726
|
Atomics: O,
|
|
4604
4727
|
BigInt: C,
|
|
4605
4728
|
BigInt64Array: C,
|
|
@@ -4619,10 +4742,10 @@ const knownGlobals = {
|
|
|
4619
4742
|
decodeURIComponent: PF,
|
|
4620
4743
|
encodeURI: PF,
|
|
4621
4744
|
encodeURIComponent: PF,
|
|
4622
|
-
Error:
|
|
4745
|
+
Error: PC_RETURNING_ARG_VALUES,
|
|
4623
4746
|
escape: PF,
|
|
4624
4747
|
eval: O,
|
|
4625
|
-
EvalError:
|
|
4748
|
+
EvalError: PC_RETURNING_ARG_VALUES,
|
|
4626
4749
|
FinalizationRegistry: C,
|
|
4627
4750
|
Float32Array: ARRAY_TYPE,
|
|
4628
4751
|
Float64Array: ARRAY_TYPE,
|
|
@@ -4636,7 +4759,7 @@ const knownGlobals = {
|
|
|
4636
4759
|
isNaN: PF,
|
|
4637
4760
|
isPrototypeOf: O,
|
|
4638
4761
|
JSON: O,
|
|
4639
|
-
Map:
|
|
4762
|
+
Map: PC_WITH_ARRAY_RETURNING_ARG_VALUES,
|
|
4640
4763
|
Math: {
|
|
4641
4764
|
__proto__: null,
|
|
4642
4765
|
[ValueProperties]: IMPURE,
|
|
@@ -4690,16 +4813,16 @@ const knownGlobals = {
|
|
|
4690
4813
|
},
|
|
4691
4814
|
Object: {
|
|
4692
4815
|
__proto__: null,
|
|
4693
|
-
[ValueProperties]: PURE,
|
|
4694
|
-
create:
|
|
4816
|
+
[ValueProperties]: returningArguments(PURE),
|
|
4817
|
+
create: PF_RETURNING_ARG_VALUES,
|
|
4695
4818
|
// Technically those can throw in certain situations, but we ignore this as
|
|
4696
4819
|
// code that relies on this will hopefully wrap this in a try-catch, which
|
|
4697
4820
|
// deoptimizes everything anyway
|
|
4698
4821
|
defineProperty: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
4699
4822
|
defineProperties: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
4700
4823
|
freeze: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
4701
|
-
getOwnPropertyDescriptor:
|
|
4702
|
-
getOwnPropertyDescriptors:
|
|
4824
|
+
getOwnPropertyDescriptor: PF_RETURNING_ARG_VALUES,
|
|
4825
|
+
getOwnPropertyDescriptors: PF_RETURNING_ARG_VALUES,
|
|
4703
4826
|
getOwnPropertyNames: PF,
|
|
4704
4827
|
getOwnPropertySymbols: PF,
|
|
4705
4828
|
getPrototypeOf: PF,
|
|
@@ -4709,7 +4832,7 @@ const knownGlobals = {
|
|
|
4709
4832
|
isFrozen: PF,
|
|
4710
4833
|
isSealed: PF,
|
|
4711
4834
|
keys: PF,
|
|
4712
|
-
fromEntries:
|
|
4835
|
+
fromEntries: O_RETURNING_ARG_VALUES,
|
|
4713
4836
|
entries: PF_NO_GETTER,
|
|
4714
4837
|
values: PF_NO_GETTER,
|
|
4715
4838
|
prototype: O
|
|
@@ -4719,13 +4842,13 @@ const knownGlobals = {
|
|
|
4719
4842
|
Promise: {
|
|
4720
4843
|
__proto__: null,
|
|
4721
4844
|
[ValueProperties]: IMPURE,
|
|
4722
|
-
all:
|
|
4723
|
-
allSettled:
|
|
4724
|
-
any:
|
|
4845
|
+
all: O_RETURNING_ARG_VALUES,
|
|
4846
|
+
allSettled: O_RETURNING_ARG_VALUES,
|
|
4847
|
+
any: O_RETURNING_ARG_VALUES,
|
|
4725
4848
|
prototype: O,
|
|
4726
|
-
race:
|
|
4727
|
-
reject:
|
|
4728
|
-
resolve:
|
|
4849
|
+
race: O_RETURNING_ARG_VALUES,
|
|
4850
|
+
reject: O_RETURNING_ARGS,
|
|
4851
|
+
resolve: O_RETURNING_ARGS
|
|
4729
4852
|
},
|
|
4730
4853
|
propertyIsEnumerable: O,
|
|
4731
4854
|
Proxy: {
|
|
@@ -4751,11 +4874,11 @@ const knownGlobals = {
|
|
|
4751
4874
|
hasEffectsWhenCalled: returnTrue
|
|
4752
4875
|
}
|
|
4753
4876
|
},
|
|
4754
|
-
RangeError:
|
|
4755
|
-
ReferenceError:
|
|
4877
|
+
RangeError: PC_RETURNING_ARG_VALUES,
|
|
4878
|
+
ReferenceError: PC_RETURNING_ARG_VALUES,
|
|
4756
4879
|
Reflect: O,
|
|
4757
4880
|
RegExp: PC,
|
|
4758
|
-
Set:
|
|
4881
|
+
Set: PC_WITH_ARRAY_RETURNING_ARG_VALUES,
|
|
4759
4882
|
SharedArrayBuffer: C,
|
|
4760
4883
|
String: {
|
|
4761
4884
|
__proto__: null,
|
|
@@ -4776,10 +4899,10 @@ const knownGlobals = {
|
|
|
4776
4899
|
hasInstance: getWellKnownSymbol(SymbolHasInstance),
|
|
4777
4900
|
toStringTag: getWellKnownSymbol(SymbolToStringTag)
|
|
4778
4901
|
},
|
|
4779
|
-
SyntaxError:
|
|
4902
|
+
SyntaxError: PC_RETURNING_ARG_VALUES,
|
|
4780
4903
|
toLocaleString: O,
|
|
4781
4904
|
toString: O,
|
|
4782
|
-
TypeError:
|
|
4905
|
+
TypeError: PC_RETURNING_ARG_VALUES,
|
|
4783
4906
|
Uint16Array: ARRAY_TYPE,
|
|
4784
4907
|
Uint32Array: ARRAY_TYPE,
|
|
4785
4908
|
Uint8Array: ARRAY_TYPE,
|
|
@@ -4787,10 +4910,14 @@ const knownGlobals = {
|
|
|
4787
4910
|
// Technically, this is a global, but it needs special handling
|
|
4788
4911
|
// undefined: ?,
|
|
4789
4912
|
unescape: PF,
|
|
4790
|
-
URIError:
|
|
4913
|
+
URIError: PC_RETURNING_ARG_VALUES,
|
|
4791
4914
|
valueOf: O,
|
|
4792
|
-
WeakMap:
|
|
4793
|
-
WeakRef:
|
|
4915
|
+
WeakMap: PC_WITH_ARRAY_RETURNING_ARG_VALUES,
|
|
4916
|
+
WeakRef: {
|
|
4917
|
+
__proto__: null,
|
|
4918
|
+
[ValueProperties]: returningArguments(IMPURE),
|
|
4919
|
+
prototype: O
|
|
4920
|
+
},
|
|
4794
4921
|
WeakSet: PC_WITH_ARRAY,
|
|
4795
4922
|
// Additional globals shared by Node and Browser that are not strictly part of the language
|
|
4796
4923
|
clearInterval: C,
|
|
@@ -6125,15 +6252,12 @@ class ChildScope extends Scope {
|
|
|
6125
6252
|
}
|
|
6126
6253
|
addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope) {
|
|
6127
6254
|
for (const variable of this.accessedOutsideVariables.values()) {
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
if (format === 'system' && exportNamesByVariable.has(variable)) {
|
|
6135
|
-
usedNames.add('exports');
|
|
6136
|
-
}
|
|
6255
|
+
this.addUsedOutsideVariableName(variable, usedNames, format, exportNamesByVariable);
|
|
6256
|
+
}
|
|
6257
|
+
// Hoisted declarations render their binding here without referencing it.
|
|
6258
|
+
if (this.hoistedVariables) {
|
|
6259
|
+
for (const variable of this.hoistedVariables.values()) {
|
|
6260
|
+
this.addUsedOutsideVariableName(variable, usedNames, format, exportNamesByVariable);
|
|
6137
6261
|
}
|
|
6138
6262
|
}
|
|
6139
6263
|
const accessedGlobals = accessedGlobalsByScope.get(this);
|
|
@@ -6165,6 +6289,17 @@ class ChildScope extends Scope {
|
|
|
6165
6289
|
scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
|
|
6166
6290
|
}
|
|
6167
6291
|
}
|
|
6292
|
+
addUsedOutsideVariableName(variable, usedNames, format, exportNamesByVariable) {
|
|
6293
|
+
if (!variable.included)
|
|
6294
|
+
return;
|
|
6295
|
+
usedNames.add(variable.getBaseVariableName());
|
|
6296
|
+
// In system format, exported variables are assigned via `exports(name, value)`.
|
|
6297
|
+
// Any scope that renders such a variable must treat `exports` as used so that a
|
|
6298
|
+
// nested binding of the same name does not shadow the wrapper's `exports` argument.
|
|
6299
|
+
if (format === 'system' && exportNamesByVariable.has(variable)) {
|
|
6300
|
+
usedNames.add('exports');
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6168
6303
|
findLexicalBoundary() {
|
|
6169
6304
|
return this.parent.findLexicalBoundary();
|
|
6170
6305
|
}
|
|
@@ -6334,11 +6469,13 @@ class BlockScope extends ChildScope {
|
|
|
6334
6469
|
const name = identifier.name;
|
|
6335
6470
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6336
6471
|
if (existingVariable) {
|
|
6337
|
-
if (existingVariable.kind === 'var'
|
|
6338
|
-
(kind === 'var' && existingVariable.kind === 'parameter')) {
|
|
6472
|
+
if (existingVariable.kind === 'var') {
|
|
6339
6473
|
existingVariable.addDeclaration(identifier, init);
|
|
6340
6474
|
return existingVariable;
|
|
6341
6475
|
}
|
|
6476
|
+
if (existingVariable.kind === 'parameter') {
|
|
6477
|
+
return this.parent.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
6478
|
+
}
|
|
6342
6479
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
6343
6480
|
}
|
|
6344
6481
|
const declaredVariable = this.parent.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
@@ -6857,32 +6994,31 @@ class CatchBodyScope extends ChildScope {
|
|
|
6857
6994
|
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
6858
6995
|
if (kind === 'var') {
|
|
6859
6996
|
const name = identifier.name;
|
|
6997
|
+
const parameter = this.parent.variables.get(name);
|
|
6998
|
+
if (isSimpleCatchParameter(parameter)) {
|
|
6999
|
+
// Annex B: a var redeclaring a simple catch parameter is hoisted
|
|
7000
|
+
// without assignment while its initializer assigns the parameter. As
|
|
7001
|
+
// the rendered declaration also declares the hoisted variable, the
|
|
7002
|
+
// parameter renders with the hoisted variable's name, unless that
|
|
7003
|
+
// variable is rendered as an exports member, in which case the
|
|
7004
|
+
// declaration becomes an assignment.
|
|
7005
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, destructuredInitPath, kind);
|
|
7006
|
+
declaredVariable.markInitializersForDeoptimization();
|
|
7007
|
+
parameter.renderLikeHoisted(declaredVariable.getHoistedVariable() ?? declaredVariable);
|
|
7008
|
+
if (!this.isShadowedByInnerCatchParameter(identifier, name)) {
|
|
7009
|
+
parameter.addDeclaration(identifier, init);
|
|
7010
|
+
}
|
|
7011
|
+
return parameter;
|
|
7012
|
+
}
|
|
6860
7013
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6861
7014
|
if (existingVariable) {
|
|
6862
|
-
|
|
6863
|
-
if (existingKind === 'parameter' &&
|
|
6864
|
-
// If this is a destructured parameter, it is forbidden to redeclare
|
|
6865
|
-
existingVariable.declarations[0].parent.type === CatchClause$1) {
|
|
6866
|
-
// If this is a var with the same name as the catch scope parameter,
|
|
6867
|
-
// the assignment actually goes to the parameter and the var is
|
|
6868
|
-
// hoisted without assignment. Locally, it is shadowed by the
|
|
6869
|
-
// parameter
|
|
6870
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, destructuredInitPath, kind);
|
|
6871
|
-
// To avoid the need to rewrite the declaration, we link the variable
|
|
6872
|
-
// names. If we ever implement a logic that splits initialization and
|
|
6873
|
-
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
6874
|
-
// removed again.
|
|
6875
|
-
// We do not need to check whether there already is a linked
|
|
6876
|
-
// variable because then declaredVariable would be that linked
|
|
6877
|
-
// variable.
|
|
6878
|
-
existingVariable.renderLikeHoisted(declaredVariable);
|
|
6879
|
-
this.addHoistedVariable(name, declaredVariable);
|
|
6880
|
-
return declaredVariable;
|
|
6881
|
-
}
|
|
6882
|
-
if (existingKind === 'var') {
|
|
7015
|
+
if (existingVariable.kind === 'var') {
|
|
6883
7016
|
existingVariable.addDeclaration(identifier, init);
|
|
6884
7017
|
return existingVariable;
|
|
6885
7018
|
}
|
|
7019
|
+
if (existingVariable.kind === 'parameter' && existingVariable !== parameter) {
|
|
7020
|
+
return this.parent.parent.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
7021
|
+
}
|
|
6886
7022
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
6887
7023
|
}
|
|
6888
7024
|
// We only add parameters to parameter scopes
|
|
@@ -6896,6 +7032,23 @@ class CatchBodyScope extends ChildScope {
|
|
|
6896
7032
|
}
|
|
6897
7033
|
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
6898
7034
|
}
|
|
7035
|
+
isShadowedByInnerCatchParameter(identifier, name) {
|
|
7036
|
+
let scope = identifier.scope;
|
|
7037
|
+
while (scope !== this) {
|
|
7038
|
+
if (scope instanceof CatchBodyScope) {
|
|
7039
|
+
const parameter = scope.parent.variables.get(name);
|
|
7040
|
+
if (isSimpleCatchParameter(parameter))
|
|
7041
|
+
return true;
|
|
7042
|
+
}
|
|
7043
|
+
scope = scope.parent;
|
|
7044
|
+
}
|
|
7045
|
+
return false;
|
|
7046
|
+
}
|
|
7047
|
+
}
|
|
7048
|
+
function isSimpleCatchParameter(variable) {
|
|
7049
|
+
return (variable?.kind === 'parameter' &&
|
|
7050
|
+
// If this is a destructured parameter, it is forbidden to redeclare
|
|
7051
|
+
variable.declarations[0].parent.type === CatchClause$1);
|
|
6899
7052
|
}
|
|
6900
7053
|
|
|
6901
7054
|
class FunctionBodyScope extends ChildScope {
|
|
@@ -8703,307 +8856,968 @@ const importMetaMechanisms = {
|
|
|
8703
8856
|
umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename', false)} : ${getUrlFromDocument(chunkId, true)})`)
|
|
8704
8857
|
};
|
|
8705
8858
|
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8859
|
+
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
8860
|
+
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
8861
|
+
}
|
|
8862
|
+
function isDeclaredWithoutBinding(variable, exportNamesByVariable) {
|
|
8863
|
+
if (isReassignedExportsMember(variable, exportNamesByVariable))
|
|
8864
|
+
return true;
|
|
8865
|
+
const hoistedVariable = variable.getHoistedVariable();
|
|
8866
|
+
return hoistedVariable !== undefined && hoistedVariable.renderBaseName !== null;
|
|
8867
|
+
}
|
|
8868
|
+
|
|
8869
|
+
function markTopLevelAwait(node) {
|
|
8870
|
+
if (node.scope.context.usesTopLevelAwait)
|
|
8871
|
+
return;
|
|
8872
|
+
let parent = node.parent;
|
|
8873
|
+
do {
|
|
8874
|
+
if (parent instanceof FunctionBase)
|
|
8875
|
+
return;
|
|
8876
|
+
} while ((parent = parent.parent));
|
|
8877
|
+
node.scope.context.usesTopLevelAwait = true;
|
|
8878
|
+
}
|
|
8879
|
+
|
|
8880
|
+
class ArrayPattern extends NodeBase {
|
|
8881
|
+
addExportedVariables(variables, exportNamesByVariable) {
|
|
8882
|
+
for (const element of this.elements) {
|
|
8883
|
+
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
8730
8884
|
}
|
|
8731
8885
|
}
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
else if (!this.areAllMembersDeoptimized) {
|
|
8739
|
-
this.areAllMembersDeoptimized = true;
|
|
8740
|
-
for (const variable of this.module.getExportedVariablesByName().values()) {
|
|
8741
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
8742
|
-
}
|
|
8886
|
+
declare(kind, destructuredInitPath, init) {
|
|
8887
|
+
const variables = [];
|
|
8888
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
8889
|
+
for (const element of this.elements) {
|
|
8890
|
+
if (element !== null) {
|
|
8891
|
+
variables.push(...element.declare(kind, includedPatternPath, init));
|
|
8743
8892
|
}
|
|
8744
8893
|
}
|
|
8894
|
+
return variables;
|
|
8745
8895
|
}
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8896
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
8897
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
8898
|
+
for (const element of this.elements) {
|
|
8899
|
+
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
8749
8900
|
}
|
|
8750
|
-
return UnknownValue;
|
|
8751
8901
|
}
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
return true;
|
|
8757
|
-
}
|
|
8758
|
-
if (path.length === 1 && type !== INTERACTION_CALLED) {
|
|
8759
|
-
return type === INTERACTION_ASSIGNED;
|
|
8760
|
-
}
|
|
8761
|
-
const key = path[0];
|
|
8762
|
-
if (typeof key !== 'string') {
|
|
8763
|
-
return true;
|
|
8902
|
+
// Patterns can only be deoptimized at the empty path at the moment
|
|
8903
|
+
deoptimizePath() {
|
|
8904
|
+
for (const element of this.elements) {
|
|
8905
|
+
element?.deoptimizePath(EMPTY_PATH);
|
|
8764
8906
|
}
|
|
8765
|
-
const memberVariable = this.getMemberVariable(key);
|
|
8766
|
-
return (!memberVariable ||
|
|
8767
|
-
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
8768
|
-
}
|
|
8769
|
-
includePath(path, context) {
|
|
8770
|
-
super.includePath(path, context);
|
|
8771
|
-
this.includeMemberPath(path, context);
|
|
8772
8907
|
}
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
if (
|
|
8777
|
-
|
|
8778
|
-
if (variable) {
|
|
8779
|
-
this.context.includeVariableInModule(variable, remainingPath, context);
|
|
8780
|
-
}
|
|
8781
|
-
else {
|
|
8782
|
-
this.includeNonExplicitNamespaces();
|
|
8783
|
-
}
|
|
8784
|
-
}
|
|
8785
|
-
else if (name) {
|
|
8786
|
-
this.module.includeAllExports();
|
|
8787
|
-
this.includeNonExplicitNamespaces();
|
|
8908
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
8909
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
8910
|
+
for (const element of this.elements) {
|
|
8911
|
+
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
8912
|
+
return true;
|
|
8788
8913
|
}
|
|
8789
8914
|
}
|
|
8915
|
+
return false;
|
|
8790
8916
|
}
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8917
|
+
// Patterns are only checked at the empty path at the moment
|
|
8918
|
+
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
8919
|
+
for (const element of this.elements) {
|
|
8920
|
+
if (element?.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
8921
|
+
return true;
|
|
8794
8922
|
}
|
|
8923
|
+
return false;
|
|
8795
8924
|
}
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
const
|
|
8799
|
-
const
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
(variable.module &&
|
|
8807
|
-
!variable.module.info.isExternal &&
|
|
8808
|
-
variable.module.execIndex > this.module.execIndex)) {
|
|
8809
|
-
return [
|
|
8810
|
-
null,
|
|
8811
|
-
`get ${stringifyObjectKeyIfNeeded(key)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
|
|
8812
|
-
];
|
|
8925
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
8926
|
+
let included = false;
|
|
8927
|
+
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
8928
|
+
for (const element of [...this.elements].reverse()) {
|
|
8929
|
+
if (element) {
|
|
8930
|
+
if (included && !element.included) {
|
|
8931
|
+
element.includeNode(context);
|
|
8932
|
+
}
|
|
8933
|
+
included =
|
|
8934
|
+
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
8813
8935
|
}
|
|
8814
|
-
return [key, variable.getName(getPropertyAccess)];
|
|
8815
|
-
});
|
|
8816
|
-
members.unshift([null, `__proto__:${_}null`]);
|
|
8817
|
-
let output = getObject(members, { lineBreakIndent: { base: '', t } });
|
|
8818
|
-
if (this.mergedNamespaces.length > 0) {
|
|
8819
|
-
const assignmentArguments = this.mergedNamespaces.map(variable => variable.getName(getPropertyAccess));
|
|
8820
|
-
output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output},${_}[${assignmentArguments.join(`,${_}`)}])`;
|
|
8821
8936
|
}
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8937
|
+
if (!this.included && included) {
|
|
8938
|
+
this.includeNode(context);
|
|
8939
|
+
}
|
|
8940
|
+
return this.included;
|
|
8941
|
+
}
|
|
8942
|
+
render(code, options) {
|
|
8943
|
+
let removedStart = this.start + 1;
|
|
8944
|
+
for (const element of this.elements) {
|
|
8945
|
+
if (!element)
|
|
8946
|
+
continue;
|
|
8947
|
+
if (element.included) {
|
|
8948
|
+
element.render(code, options);
|
|
8949
|
+
removedStart = element.end;
|
|
8826
8950
|
}
|
|
8827
|
-
|
|
8828
|
-
|
|
8951
|
+
else {
|
|
8952
|
+
code.remove(removedStart, this.end - 1);
|
|
8953
|
+
break;
|
|
8829
8954
|
}
|
|
8830
8955
|
}
|
|
8831
|
-
const name = this.getName(getPropertyAccess);
|
|
8832
|
-
output = `${cnst} ${name}${_}=${_}${output};`;
|
|
8833
|
-
if (format === 'system' && exportNamesByVariable.has(this)) {
|
|
8834
|
-
output += `${n}${getSystemExportStatement([this], options)};`;
|
|
8835
|
-
}
|
|
8836
|
-
return output;
|
|
8837
|
-
}
|
|
8838
|
-
renderFirst() {
|
|
8839
|
-
return this.referencedEarly;
|
|
8840
8956
|
}
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
this.referencedEarly = true;
|
|
8848
|
-
break;
|
|
8849
|
-
}
|
|
8957
|
+
setAssignedValue(value) {
|
|
8958
|
+
super.setAssignedValue(value);
|
|
8959
|
+
// Destructuring assigns each target only some subpath of the assigned
|
|
8960
|
+
// value, which is not tracked
|
|
8961
|
+
for (const element of this.elements) {
|
|
8962
|
+
element?.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
8850
8963
|
}
|
|
8851
8964
|
}
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
includeNonExplicitNamespaces() {
|
|
8856
|
-
if (!this.nonExplicitNamespacesIncluded) {
|
|
8857
|
-
this.nonExplicitNamespacesIncluded = true;
|
|
8858
|
-
this.setMergedNamespaces(this.module.includeAndGetAdditionalMergedNamespaces());
|
|
8965
|
+
markDeclarationReached() {
|
|
8966
|
+
for (const element of this.elements) {
|
|
8967
|
+
element?.markDeclarationReached();
|
|
8859
8968
|
}
|
|
8860
8969
|
}
|
|
8861
8970
|
}
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
value(path, context) {
|
|
8867
|
-
namespace.includeMemberPath(path, context);
|
|
8868
|
-
}
|
|
8869
|
-
}
|
|
8870
|
-
});
|
|
8971
|
+
ArrayPattern.prototype.includeNode = onlyIncludeSelf;
|
|
8972
|
+
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
8973
|
+
? destructuredInitPath
|
|
8974
|
+
: [...destructuredInitPath, UnknownInteger];
|
|
8871
8975
|
|
|
8872
|
-
class
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
this.module = context.module;
|
|
8878
|
-
this.syntheticNamespace = syntheticNamespace;
|
|
8879
|
-
}
|
|
8880
|
-
getBaseVariable() {
|
|
8881
|
-
if (this.baseVariable)
|
|
8882
|
-
return this.baseVariable;
|
|
8883
|
-
let baseVariable = this.syntheticNamespace;
|
|
8884
|
-
while (baseVariable instanceof ExportDefaultVariable ||
|
|
8885
|
-
baseVariable instanceof SyntheticNamedExportVariable) {
|
|
8886
|
-
if (baseVariable instanceof ExportDefaultVariable) {
|
|
8887
|
-
const original = baseVariable.getOriginalVariable();
|
|
8888
|
-
if (original === baseVariable)
|
|
8889
|
-
break;
|
|
8890
|
-
baseVariable = original;
|
|
8976
|
+
class ObjectPattern extends NodeBase {
|
|
8977
|
+
addExportedVariables(variables, exportNamesByVariable) {
|
|
8978
|
+
for (const property of this.properties) {
|
|
8979
|
+
if (property.type === Property$1) {
|
|
8980
|
+
property.value.addExportedVariables(variables, exportNamesByVariable);
|
|
8891
8981
|
}
|
|
8892
|
-
|
|
8893
|
-
|
|
8982
|
+
else {
|
|
8983
|
+
property.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
8894
8984
|
}
|
|
8895
8985
|
}
|
|
8896
|
-
return (this.baseVariable = baseVariable);
|
|
8897
|
-
}
|
|
8898
|
-
getBaseVariableName() {
|
|
8899
|
-
return this.syntheticNamespace.getBaseVariableName();
|
|
8900
|
-
}
|
|
8901
|
-
getName(getPropertyAccess) {
|
|
8902
|
-
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
8903
8986
|
}
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8987
|
+
declare(kind, destructuredInitPath, init) {
|
|
8988
|
+
const variables = [];
|
|
8989
|
+
for (const property of this.properties) {
|
|
8990
|
+
variables.push(...property.declare(kind, destructuredInitPath, init));
|
|
8991
|
+
}
|
|
8992
|
+
return variables;
|
|
8907
8993
|
}
|
|
8908
|
-
|
|
8909
|
-
|
|
8994
|
+
deoptimizeAssignment(destructuredInitPath, init) {
|
|
8995
|
+
for (const property of this.properties) {
|
|
8996
|
+
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
8997
|
+
}
|
|
8910
8998
|
}
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
this.defaultVariableName = '';
|
|
8918
|
-
this.namespaceVariableName = '';
|
|
8919
|
-
this.variableName = '';
|
|
8920
|
-
this.fileName = null;
|
|
8921
|
-
this.importAttributes = null;
|
|
8922
|
-
this.id = module.id;
|
|
8923
|
-
this.moduleInfo = module.info;
|
|
8924
|
-
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
8925
|
-
this.suggestedVariableName = module.suggestedVariableName;
|
|
8999
|
+
deoptimizePath(path) {
|
|
9000
|
+
if (path.length === 0) {
|
|
9001
|
+
for (const property of this.properties) {
|
|
9002
|
+
property.deoptimizePath(path);
|
|
9003
|
+
}
|
|
9004
|
+
}
|
|
8926
9005
|
}
|
|
8927
|
-
|
|
8928
|
-
|
|
9006
|
+
hasEffectsOnInteractionAtPath(
|
|
9007
|
+
// At the moment, this is only triggered for assignment left-hand sides,
|
|
9008
|
+
// where the path is empty
|
|
9009
|
+
_path, interaction, context) {
|
|
9010
|
+
for (const property of this.properties) {
|
|
9011
|
+
if (property.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
9012
|
+
return true;
|
|
9013
|
+
}
|
|
9014
|
+
return false;
|
|
8929
9015
|
}
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
9016
|
+
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
9017
|
+
for (const property of this.properties) {
|
|
9018
|
+
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
9019
|
+
return true;
|
|
8933
9020
|
}
|
|
8934
|
-
|
|
8935
|
-
return (this.fileName =
|
|
8936
|
-
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
8937
|
-
(this.renormalizeRenderPath ? normalize(relative(this.inputBase, this.id)) : this.id));
|
|
9021
|
+
return false;
|
|
8938
9022
|
}
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
this.
|
|
8942
|
-
|
|
9023
|
+
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
9024
|
+
if (!this.properties.length)
|
|
9025
|
+
return this.included;
|
|
9026
|
+
const lastProperty = this.properties.at(-1);
|
|
9027
|
+
let included = lastProperty.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
9028
|
+
const lastPropertyIsRestElement = lastProperty.type === RestElement$1;
|
|
9029
|
+
for (const property of this.properties.slice(0, -1)) {
|
|
9030
|
+
if (lastPropertyIsRestElement && included && !property.included) {
|
|
9031
|
+
property.includeNode(context);
|
|
9032
|
+
}
|
|
9033
|
+
included =
|
|
9034
|
+
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
9035
|
+
}
|
|
9036
|
+
if (!this.included && included) {
|
|
9037
|
+
this.includeNode(context);
|
|
9038
|
+
}
|
|
9039
|
+
return this.included;
|
|
8943
9040
|
}
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
9041
|
+
markDeclarationReached() {
|
|
9042
|
+
for (const property of this.properties) {
|
|
9043
|
+
property.markDeclarationReached();
|
|
9044
|
+
}
|
|
8948
9045
|
}
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
9046
|
+
render(code, options) {
|
|
9047
|
+
if (this.properties.length > 0) {
|
|
9048
|
+
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
9049
|
+
let lastSeparatorPos = null;
|
|
9050
|
+
for (const { node, separator, start, end } of separatedNodes) {
|
|
9051
|
+
if (!node.included) {
|
|
9052
|
+
treeshakeNode(node, code, start, end);
|
|
9053
|
+
continue;
|
|
9054
|
+
}
|
|
9055
|
+
lastSeparatorPos = separator;
|
|
9056
|
+
node.render(code, options);
|
|
9057
|
+
}
|
|
9058
|
+
if (lastSeparatorPos) {
|
|
9059
|
+
code.remove(lastSeparatorPos, this.end - 1);
|
|
9060
|
+
}
|
|
9061
|
+
}
|
|
8953
9062
|
}
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
9063
|
+
setAssignedValue(value) {
|
|
9064
|
+
super.setAssignedValue(value);
|
|
9065
|
+
// Destructuring assigns each target only some subpath of the assigned
|
|
9066
|
+
// value, which is not tracked
|
|
9067
|
+
for (const property of this.properties) {
|
|
9068
|
+
property.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
9069
|
+
}
|
|
8957
9070
|
}
|
|
8958
|
-
return null;
|
|
8959
|
-
}
|
|
8960
|
-
|
|
8961
|
-
function removeJsExtension(name) {
|
|
8962
|
-
return name.endsWith('.js') ? name.slice(0, -3) : name;
|
|
8963
9071
|
}
|
|
9072
|
+
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
9073
|
+
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
8964
9074
|
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
9075
|
+
class VariableDeclaration extends NodeBase {
|
|
9076
|
+
addExportedVariables(variables, exportNamesByVariable) {
|
|
9077
|
+
// Only `var` is hoisted to the surrounding scope, so only those bindings can
|
|
9078
|
+
// be the exported ones. `let` and `const` in a loop head are new bindings.
|
|
9079
|
+
if (this.kind !== 'var')
|
|
9080
|
+
return;
|
|
9081
|
+
for (const declarator of this.declarations) {
|
|
9082
|
+
declarator.id.addExportedVariables(variables, exportNamesByVariable);
|
|
9083
|
+
}
|
|
8968
9084
|
}
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
const { _, getFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
8974
|
-
if (!namedExportsMode) {
|
|
8975
|
-
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings, getPropertyAccess)};`;
|
|
9085
|
+
deoptimizePath() {
|
|
9086
|
+
for (const declarator of this.declarations) {
|
|
9087
|
+
declarator.deoptimizePath(EMPTY_PATH);
|
|
9088
|
+
}
|
|
8976
9089
|
}
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
9090
|
+
hasEffectsOnInteractionAtPath() {
|
|
9091
|
+
return false;
|
|
9092
|
+
}
|
|
9093
|
+
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
9094
|
+
this.included = true;
|
|
9095
|
+
for (const declarator of this.declarations) {
|
|
9096
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) {
|
|
9097
|
+
declarator.include(context, includeChildrenRecursively);
|
|
8982
9098
|
}
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
if (exportBlock)
|
|
8987
|
-
exportBlock += n;
|
|
8988
|
-
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
8989
|
-
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(specifier.reexported))},${_}${getGetter(importName, false, t, snippets)});`;
|
|
8990
|
-
}
|
|
8991
|
-
else if (specifier.reexported === '__proto__') {
|
|
8992
|
-
exportBlock +=
|
|
8993
|
-
`Object.defineProperty(exports,${_}"__proto__",${_}{${n}` +
|
|
8994
|
-
`${t}enumerable:${_}true,${n}` +
|
|
8995
|
-
`${t}value:${_}${importName}${n}});`;
|
|
8996
|
-
}
|
|
8997
|
-
else {
|
|
8998
|
-
exportBlock += `exports${getPropertyAccess(unescapeExportName(specifier.reexported))}${_}=${_}${importName};`;
|
|
8999
|
-
}
|
|
9000
|
-
}
|
|
9099
|
+
const { id, init } = declarator;
|
|
9100
|
+
if (asSingleStatement) {
|
|
9101
|
+
id.include(context, includeChildrenRecursively);
|
|
9001
9102
|
}
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9103
|
+
if (init &&
|
|
9104
|
+
id.included &&
|
|
9105
|
+
!init.included &&
|
|
9106
|
+
(id instanceof ObjectPattern || id instanceof ArrayPattern)) {
|
|
9107
|
+
init.include(context, includeChildrenRecursively);
|
|
9108
|
+
}
|
|
9109
|
+
}
|
|
9110
|
+
}
|
|
9111
|
+
initialise() {
|
|
9112
|
+
super.initialise();
|
|
9113
|
+
if (this.kind === 'await using')
|
|
9114
|
+
markTopLevelAwait(this);
|
|
9115
|
+
for (const declarator of this.declarations) {
|
|
9116
|
+
declarator.declareDeclarator(this.kind);
|
|
9117
|
+
}
|
|
9118
|
+
}
|
|
9119
|
+
removeAnnotations(code) {
|
|
9120
|
+
this.declarations[0].removeAnnotations(code);
|
|
9121
|
+
}
|
|
9122
|
+
render(code, options, nodeRenderOptions = BLANK) {
|
|
9123
|
+
// A `var` declaration can be the body of a for-in/of loop. Only the
|
|
9124
|
+
// left-hand side is a loop head. Rewriting that head as a statement
|
|
9125
|
+
// inserts a semicolon and turns `for (var name of ...)` into invalid code.
|
|
9126
|
+
// Exported `var` bindings are updated from the loop body instead.
|
|
9127
|
+
if (this.isForInOfHead()) {
|
|
9128
|
+
this.renderForInOfHead(code, options);
|
|
9129
|
+
return;
|
|
9130
|
+
}
|
|
9131
|
+
if (this.areAllDeclarationsIncludedAndNotExported(options.exportNamesByVariable)) {
|
|
9132
|
+
for (const declarator of this.declarations) {
|
|
9133
|
+
declarator.render(code, options);
|
|
9134
|
+
}
|
|
9135
|
+
if (!nodeRenderOptions.isNoStatement &&
|
|
9136
|
+
code.original.charCodeAt(this.end - 1) !== 59 /*";"*/) {
|
|
9137
|
+
code.appendLeft(this.end, ';');
|
|
9138
|
+
}
|
|
9139
|
+
}
|
|
9140
|
+
else if (this.isInSingleStatementPosition()) {
|
|
9141
|
+
this.renderSingleStatementDeclaration(code, options, nodeRenderOptions.isNoStatement === true);
|
|
9142
|
+
}
|
|
9143
|
+
else {
|
|
9144
|
+
this.renderReplacedDeclarations(code, options, nodeRenderOptions.isNoStatement === true);
|
|
9145
|
+
}
|
|
9146
|
+
}
|
|
9147
|
+
isForInOfHead() {
|
|
9148
|
+
const parent = this.parent;
|
|
9149
|
+
return ((parent.type === ForOfStatement$1 || parent.type === ForInStatement$1) &&
|
|
9150
|
+
parent.left === this);
|
|
9151
|
+
}
|
|
9152
|
+
isInSingleStatementPosition() {
|
|
9153
|
+
const { type } = this.parent;
|
|
9154
|
+
return !(type === Program$1 ||
|
|
9155
|
+
type === BlockStatement$1 ||
|
|
9156
|
+
type === StaticBlock$1 ||
|
|
9157
|
+
type === SwitchCase$1 ||
|
|
9158
|
+
type === ExportNamedDeclaration$1);
|
|
9159
|
+
}
|
|
9160
|
+
renderForInOfHead(code, options) {
|
|
9161
|
+
const declarator = this.declarations[0];
|
|
9162
|
+
if (declarator.id instanceof Identifier &&
|
|
9163
|
+
isDeclaredWithoutBinding(declarator.id.variable, options.exportNamesByVariable)) {
|
|
9164
|
+
// `for (var name of xs)` declares `name`, but a reassigned export is
|
|
9165
|
+
// rendered as `exports.name`, and a catch parameter shadowing one must
|
|
9166
|
+
// stay an assignment. Keeping `var`, or synthesizing `= void 0` because
|
|
9167
|
+
// the declarator has no initializer, is a syntax error.
|
|
9168
|
+
code.remove(this.start, declarator.id.start);
|
|
9169
|
+
declarator.id.render(code, options);
|
|
9170
|
+
return;
|
|
9171
|
+
}
|
|
9172
|
+
for (const eachDeclarator of this.declarations) {
|
|
9173
|
+
eachDeclarator.render(code, options);
|
|
9174
|
+
}
|
|
9175
|
+
}
|
|
9176
|
+
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, omitTrailingSemicolon) {
|
|
9177
|
+
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
9178
|
+
code.remove(this.end - 1, this.end);
|
|
9179
|
+
}
|
|
9180
|
+
// A for-loop initializer is not a statement. The separator after it
|
|
9181
|
+
// belongs to the for statement, so another semicolon makes the head invalid.
|
|
9182
|
+
if (!omitTrailingSemicolon) {
|
|
9183
|
+
separatorString += ';';
|
|
9184
|
+
}
|
|
9185
|
+
if (lastSeparatorPos === null) {
|
|
9186
|
+
if (separatorString) {
|
|
9187
|
+
code.appendLeft(renderedContentEnd, separatorString);
|
|
9188
|
+
}
|
|
9189
|
+
}
|
|
9190
|
+
else {
|
|
9191
|
+
if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
|
|
9192
|
+
(code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
|
|
9193
|
+
code.original.charCodeAt(this.end) === 13) /*"\r"*/) {
|
|
9194
|
+
actualContentEnd--;
|
|
9195
|
+
if (code.original.charCodeAt(actualContentEnd) === 13 /*"\r"*/) {
|
|
9196
|
+
actualContentEnd--;
|
|
9197
|
+
}
|
|
9198
|
+
}
|
|
9199
|
+
if (actualContentEnd === lastSeparatorPos + 1) {
|
|
9200
|
+
code.overwrite(lastSeparatorPos, renderedContentEnd, separatorString);
|
|
9201
|
+
}
|
|
9202
|
+
else {
|
|
9203
|
+
code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
|
|
9204
|
+
code.remove(actualContentEnd, renderedContentEnd);
|
|
9205
|
+
}
|
|
9206
|
+
}
|
|
9207
|
+
if (systemPatternExports.length > 0) {
|
|
9208
|
+
code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
|
|
9209
|
+
}
|
|
9210
|
+
}
|
|
9211
|
+
renderReplacedDeclarations(code, options, omitTrailingSemicolon) {
|
|
9212
|
+
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
|
|
9213
|
+
let actualContentEnd, renderedContentEnd;
|
|
9214
|
+
renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
|
|
9215
|
+
let lastSeparatorPos = renderedContentEnd - 1;
|
|
9216
|
+
code.remove(this.start, lastSeparatorPos);
|
|
9217
|
+
let isInDeclaration = false;
|
|
9218
|
+
let hasRenderedContent = false;
|
|
9219
|
+
let separatorString = '', leadingString, nextSeparatorString;
|
|
9220
|
+
const aggregatedSystemExports = [];
|
|
9221
|
+
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
9222
|
+
const { exportNamesByVariable } = options;
|
|
9223
|
+
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
9224
|
+
if (!node.included) {
|
|
9225
|
+
treeshakeNode(node, code, start, end);
|
|
9226
|
+
continue;
|
|
9227
|
+
}
|
|
9228
|
+
node.render(code, options);
|
|
9229
|
+
leadingString = '';
|
|
9230
|
+
nextSeparatorString = '';
|
|
9231
|
+
const rendersAsAssignment = !node.id.included ||
|
|
9232
|
+
(node.id instanceof Identifier &&
|
|
9233
|
+
isDeclaredWithoutBinding(node.id.variable, exportNamesByVariable));
|
|
9234
|
+
if (rendersAsAssignment) {
|
|
9235
|
+
if (hasRenderedContent) {
|
|
9236
|
+
separatorString += ';';
|
|
9237
|
+
}
|
|
9238
|
+
isInDeclaration = false;
|
|
9239
|
+
}
|
|
9240
|
+
else {
|
|
9241
|
+
if (singleSystemExport && singleSystemExport === node.id.variable) {
|
|
9242
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
|
|
9243
|
+
renderSystemExportExpression(singleSystemExport, findNonWhiteSpace(code.original, operatorPos + 1), separator === null ? contentEnd : separator, code, options);
|
|
9244
|
+
}
|
|
9245
|
+
if (isInDeclaration) {
|
|
9246
|
+
separatorString += ',';
|
|
9247
|
+
}
|
|
9248
|
+
else {
|
|
9249
|
+
if (hasRenderedContent) {
|
|
9250
|
+
separatorString += ';';
|
|
9251
|
+
}
|
|
9252
|
+
leadingString += `${this.kind} `;
|
|
9253
|
+
isInDeclaration = true;
|
|
9254
|
+
}
|
|
9255
|
+
}
|
|
9256
|
+
if (renderedContentEnd === lastSeparatorPos + 1) {
|
|
9257
|
+
code.overwrite(lastSeparatorPos, renderedContentEnd, separatorString + leadingString);
|
|
9258
|
+
}
|
|
9259
|
+
else {
|
|
9260
|
+
code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
|
|
9261
|
+
code.appendLeft(renderedContentEnd, leadingString);
|
|
9262
|
+
}
|
|
9263
|
+
actualContentEnd = contentEnd;
|
|
9264
|
+
renderedContentEnd = end;
|
|
9265
|
+
hasRenderedContent = true;
|
|
9266
|
+
lastSeparatorPos = separator;
|
|
9267
|
+
separatorString = nextSeparatorString;
|
|
9268
|
+
}
|
|
9269
|
+
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options, omitTrailingSemicolon);
|
|
9270
|
+
}
|
|
9271
|
+
renderSingleStatementDeclaration(code, options, omitTrailingSemicolon) {
|
|
9272
|
+
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
|
|
9273
|
+
let actualContentEnd, renderedContentEnd;
|
|
9274
|
+
renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
|
|
9275
|
+
let lastSeparatorPos = renderedContentEnd - 1;
|
|
9276
|
+
code.remove(this.start, lastSeparatorPos);
|
|
9277
|
+
let hasRenderedContent = false;
|
|
9278
|
+
let lastRenderedContentEnd = renderedContentEnd;
|
|
9279
|
+
let separatorString = '';
|
|
9280
|
+
const trailingSystemExports = [];
|
|
9281
|
+
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
9282
|
+
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
9283
|
+
if (!node.included) {
|
|
9284
|
+
treeshakeNode(node, code, start, end);
|
|
9285
|
+
continue;
|
|
9286
|
+
}
|
|
9287
|
+
node.render(code, options);
|
|
9288
|
+
if (options.format === 'system') {
|
|
9289
|
+
this.renderSingleStatementSystemExports(node, separator, contentEnd, code, options, trailingSystemExports);
|
|
9290
|
+
}
|
|
9291
|
+
let leadingString = '';
|
|
9292
|
+
const rendersAsAssignment = node.id instanceof Identifier &&
|
|
9293
|
+
isDeclaredWithoutBinding(node.id.variable, exportNamesByVariable);
|
|
9294
|
+
if (hasRenderedContent) {
|
|
9295
|
+
separatorString = ',';
|
|
9296
|
+
}
|
|
9297
|
+
else if (!rendersAsAssignment) {
|
|
9298
|
+
leadingString = `${this.kind} `;
|
|
9299
|
+
}
|
|
9300
|
+
if (renderedContentEnd === lastSeparatorPos + 1) {
|
|
9301
|
+
code.overwrite(lastSeparatorPos, renderedContentEnd, separatorString + leadingString);
|
|
9302
|
+
}
|
|
9303
|
+
else {
|
|
9304
|
+
code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
|
|
9305
|
+
code.appendLeft(renderedContentEnd, leadingString);
|
|
9306
|
+
}
|
|
9307
|
+
actualContentEnd = contentEnd;
|
|
9308
|
+
renderedContentEnd = end;
|
|
9309
|
+
lastRenderedContentEnd = separator === null ? contentEnd : separator;
|
|
9310
|
+
hasRenderedContent = true;
|
|
9311
|
+
lastSeparatorPos = separator;
|
|
9312
|
+
separatorString = '';
|
|
9313
|
+
}
|
|
9314
|
+
if (trailingSystemExports.length > 0) {
|
|
9315
|
+
const name = trailingSystemExports[0].getName(getPropertyAccess);
|
|
9316
|
+
code.appendLeft(lastRenderedContentEnd, `,${_}${name}${_}=${_}(${getSystemExportStatement(trailingSystemExports, options)},${_}${name})`);
|
|
9317
|
+
}
|
|
9318
|
+
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, [], options, omitTrailingSemicolon);
|
|
9319
|
+
}
|
|
9320
|
+
renderSingleStatementSystemExports(node, separator, contentEnd, code, options, trailingSystemExports) {
|
|
9321
|
+
const { exportNamesByVariable } = options;
|
|
9322
|
+
if (node.id instanceof Identifier) {
|
|
9323
|
+
const variable = node.id.variable;
|
|
9324
|
+
const exportNames = exportNamesByVariable.get(variable);
|
|
9325
|
+
if (!node.init || !exportNames)
|
|
9326
|
+
return;
|
|
9327
|
+
if (exportNames.length === 1) {
|
|
9328
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
|
|
9329
|
+
renderSystemExportExpression(variable, findNonWhiteSpace(code.original, operatorPos + 1), separator === null ? contentEnd : separator, code, options);
|
|
9330
|
+
}
|
|
9331
|
+
else {
|
|
9332
|
+
trailingSystemExports.push(variable);
|
|
9333
|
+
}
|
|
9334
|
+
}
|
|
9335
|
+
else {
|
|
9336
|
+
node.id.addExportedVariables(trailingSystemExports, exportNamesByVariable);
|
|
9337
|
+
}
|
|
9338
|
+
}
|
|
9339
|
+
areAllDeclarationsIncludedAndNotExported(exportNamesByVariable) {
|
|
9340
|
+
if (this.kind === 'await using' || this.kind === 'using') {
|
|
9341
|
+
return true;
|
|
9342
|
+
}
|
|
9343
|
+
for (const declarator of this.declarations) {
|
|
9344
|
+
if (!declarator.id.included)
|
|
9345
|
+
return false;
|
|
9346
|
+
if (declarator.id.type === Identifier$1) {
|
|
9347
|
+
if (exportNamesByVariable.has(declarator.id.variable) ||
|
|
9348
|
+
isDeclaredWithoutBinding(declarator.id.variable, exportNamesByVariable)) {
|
|
9349
|
+
return false;
|
|
9350
|
+
}
|
|
9351
|
+
}
|
|
9352
|
+
else {
|
|
9353
|
+
const exportedVariables = [];
|
|
9354
|
+
declarator.id.addExportedVariables(exportedVariables, exportNamesByVariable);
|
|
9355
|
+
if (exportedVariables.length > 0)
|
|
9356
|
+
return false;
|
|
9357
|
+
}
|
|
9358
|
+
}
|
|
9359
|
+
return true;
|
|
9360
|
+
}
|
|
9361
|
+
}
|
|
9362
|
+
function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
|
|
9363
|
+
let singleSystemExport = null;
|
|
9364
|
+
if (options.format === 'system') {
|
|
9365
|
+
for (const { node } of separatedNodes) {
|
|
9366
|
+
if (node.id instanceof Identifier &&
|
|
9367
|
+
node.init &&
|
|
9368
|
+
aggregatedSystemExports.length === 0 &&
|
|
9369
|
+
options.exportNamesByVariable.get(node.id.variable)?.length === 1) {
|
|
9370
|
+
singleSystemExport = node.id.variable;
|
|
9371
|
+
aggregatedSystemExports.push(singleSystemExport);
|
|
9372
|
+
}
|
|
9373
|
+
else {
|
|
9374
|
+
node.id.addExportedVariables(aggregatedSystemExports, options.exportNamesByVariable);
|
|
9375
|
+
}
|
|
9376
|
+
}
|
|
9377
|
+
if (aggregatedSystemExports.length > 1) {
|
|
9378
|
+
singleSystemExport = null;
|
|
9379
|
+
}
|
|
9380
|
+
else if (singleSystemExport) {
|
|
9381
|
+
aggregatedSystemExports.length = 0;
|
|
9382
|
+
}
|
|
9383
|
+
}
|
|
9384
|
+
return singleSystemExport;
|
|
9385
|
+
}
|
|
9386
|
+
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
9387
|
+
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
9388
|
+
|
|
9389
|
+
class ClassExpression extends ClassNode {
|
|
9390
|
+
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
9391
|
+
super.render(code, options);
|
|
9392
|
+
if (renderedSurroundingElement === ExpressionStatement$1) {
|
|
9393
|
+
code.appendRight(this.start, '(');
|
|
9394
|
+
code.prependLeft(this.end, ')');
|
|
9395
|
+
}
|
|
9396
|
+
}
|
|
9397
|
+
}
|
|
9398
|
+
|
|
9399
|
+
class VariableDeclarator extends NodeBase {
|
|
9400
|
+
declareDeclarator(kind) {
|
|
9401
|
+
this.isUsingDeclaration = kind === 'using';
|
|
9402
|
+
this.isAsyncUsingDeclaration = kind === 'await using';
|
|
9403
|
+
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
9404
|
+
}
|
|
9405
|
+
deoptimizePath(path) {
|
|
9406
|
+
this.id.deoptimizePath(path);
|
|
9407
|
+
}
|
|
9408
|
+
deoptimizeCache() {
|
|
9409
|
+
if (!this.hasDeoptimizedDisposal && this.init) {
|
|
9410
|
+
this.hasDeoptimizedDisposal = true;
|
|
9411
|
+
this.init.deoptimizePath(UNKNOWN_PATH);
|
|
9412
|
+
this.init.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
9413
|
+
this.scope.context.requestTreeshakingPass();
|
|
9414
|
+
}
|
|
9415
|
+
}
|
|
9416
|
+
hasEffects(context) {
|
|
9417
|
+
const initEffect = this.init?.hasEffects(context);
|
|
9418
|
+
this.id.markDeclarationReached();
|
|
9419
|
+
return (initEffect ||
|
|
9420
|
+
this.isUsingDeclaration ||
|
|
9421
|
+
this.isAsyncUsingDeclaration ||
|
|
9422
|
+
this.id.hasEffects(context) ||
|
|
9423
|
+
(this.scope.context.options.treeshake
|
|
9424
|
+
.propertyReadSideEffects &&
|
|
9425
|
+
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
9426
|
+
}
|
|
9427
|
+
include(context, includeChildrenRecursively) {
|
|
9428
|
+
const { id, init } = this;
|
|
9429
|
+
if (!this.included)
|
|
9430
|
+
this.includeNode(context);
|
|
9431
|
+
const { disposalCall, disposalFunction } = this;
|
|
9432
|
+
// Before including init so that newly included receiver paths are included in this pass
|
|
9433
|
+
if (disposalFunction && disposalCall) {
|
|
9434
|
+
disposalFunction.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, disposalCall, context);
|
|
9435
|
+
}
|
|
9436
|
+
init?.include(context, includeChildrenRecursively);
|
|
9437
|
+
id.markDeclarationReached();
|
|
9438
|
+
if (includeChildrenRecursively) {
|
|
9439
|
+
id.include(context, includeChildrenRecursively);
|
|
9440
|
+
}
|
|
9441
|
+
else {
|
|
9442
|
+
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
9443
|
+
}
|
|
9444
|
+
}
|
|
9445
|
+
removeAnnotations(code) {
|
|
9446
|
+
this.init?.removeAnnotations(code);
|
|
9447
|
+
}
|
|
9448
|
+
render(code, options) {
|
|
9449
|
+
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
9450
|
+
const { end, id, init, start } = this;
|
|
9451
|
+
const renderId = id.included || this.isUsingDeclaration || this.isAsyncUsingDeclaration;
|
|
9452
|
+
if (renderId) {
|
|
9453
|
+
id.render(code, options);
|
|
9454
|
+
}
|
|
9455
|
+
else {
|
|
9456
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
9457
|
+
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
9458
|
+
}
|
|
9459
|
+
if (init) {
|
|
9460
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
9461
|
+
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
9462
|
+
if (renderedVariable !== id.name) {
|
|
9463
|
+
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
9464
|
+
}
|
|
9465
|
+
}
|
|
9466
|
+
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
|
|
9467
|
+
}
|
|
9468
|
+
else if (id instanceof Identifier &&
|
|
9469
|
+
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
9470
|
+
code.appendLeft(end, `${_}=${_}void 0`);
|
|
9471
|
+
}
|
|
9472
|
+
}
|
|
9473
|
+
includeNode(context) {
|
|
9474
|
+
this.included = true;
|
|
9475
|
+
const { id, init } = this;
|
|
9476
|
+
if (init) {
|
|
9477
|
+
if (this.isUsingDeclaration || this.isAsyncUsingDeclaration) {
|
|
9478
|
+
const disposalInteractions = {
|
|
9479
|
+
access: { args: [init], type: INTERACTION_ACCESSED },
|
|
9480
|
+
call: { args: [init], type: INTERACTION_CALLED, withNew: false }
|
|
9481
|
+
};
|
|
9482
|
+
if (this.isUsingDeclaration ||
|
|
9483
|
+
!this.includeDisposalMethodAndCheckIfKnownFunction(init, SYMBOL_ASYNC_DISPOSE_PATH, disposalInteractions, context)) {
|
|
9484
|
+
this.includeDisposalMethodAndCheckIfKnownFunction(init, SYMBOL_DISPOSE_PATH, disposalInteractions, context);
|
|
9485
|
+
}
|
|
9486
|
+
this.scope.context.requestTreeshakingPass();
|
|
9487
|
+
}
|
|
9488
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
9489
|
+
const { name, variable } = id;
|
|
9490
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
9491
|
+
if (accessedVariable !== variable) {
|
|
9492
|
+
accessedVariable.forbidName(name);
|
|
9493
|
+
}
|
|
9494
|
+
}
|
|
9495
|
+
}
|
|
9496
|
+
}
|
|
9497
|
+
}
|
|
9498
|
+
includeDisposalMethodAndCheckIfKnownFunction(init, path, { access, call }, context) {
|
|
9499
|
+
init.deoptimizeArgumentsOnInteractionAtPath(access, path, SHARED_RECURSION_TRACKER);
|
|
9500
|
+
const disposalFunction = init.getKnownFunctionAtPath(path, SHARED_RECURSION_TRACKER, this);
|
|
9501
|
+
init.includePath(path, context);
|
|
9502
|
+
if (!disposalFunction) {
|
|
9503
|
+
const disposalValue = init.getLiteralValueAtPath(path, SHARED_RECURSION_TRACKER, this);
|
|
9504
|
+
if (disposalValue !== null && disposalValue !== undefined) {
|
|
9505
|
+
init.deoptimizeArgumentsOnInteractionAtPath(call, path, SHARED_RECURSION_TRACKER);
|
|
9506
|
+
init.includeCallArgumentsWhenCalledAtPath(path, call, context);
|
|
9507
|
+
}
|
|
9508
|
+
return false;
|
|
9509
|
+
}
|
|
9510
|
+
this.disposalFunction = disposalFunction;
|
|
9511
|
+
this.disposalCall = call;
|
|
9512
|
+
disposalFunction.deoptimizeArgumentsOnInteractionAtPath(call, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
9513
|
+
return true;
|
|
9514
|
+
}
|
|
9515
|
+
}
|
|
9516
|
+
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
9517
|
+
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
9518
|
+
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
9519
|
+
|
|
9520
|
+
class NamespaceVariable extends Variable {
|
|
9521
|
+
constructor(context) {
|
|
9522
|
+
super(context.getModuleName());
|
|
9523
|
+
this.areAllMembersDeoptimized = false;
|
|
9524
|
+
this.mergedNamespaces = [];
|
|
9525
|
+
this.nonExplicitNamespacesIncluded = false;
|
|
9526
|
+
this.referencedEarly = false;
|
|
9527
|
+
this.references = [];
|
|
9528
|
+
this.context = context;
|
|
9529
|
+
this.module = context.module;
|
|
9530
|
+
}
|
|
9531
|
+
addReference(identifier) {
|
|
9532
|
+
this.references.push(identifier);
|
|
9533
|
+
this.name = identifier.name;
|
|
9534
|
+
}
|
|
9535
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9536
|
+
if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) {
|
|
9537
|
+
const key = path[0];
|
|
9538
|
+
if (typeof key === 'string') {
|
|
9539
|
+
this.getMemberVariable(key)?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
|
|
9540
|
+
}
|
|
9541
|
+
else {
|
|
9542
|
+
deoptimizeInteraction(interaction);
|
|
9543
|
+
}
|
|
9544
|
+
}
|
|
9545
|
+
}
|
|
9546
|
+
deoptimizePath(path) {
|
|
9547
|
+
if (path.length > 1) {
|
|
9548
|
+
const key = path[0];
|
|
9549
|
+
if (typeof key === 'string') {
|
|
9550
|
+
this.getMemberVariable(key)?.deoptimizePath(path.slice(1));
|
|
9551
|
+
}
|
|
9552
|
+
else if (!this.areAllMembersDeoptimized) {
|
|
9553
|
+
this.areAllMembersDeoptimized = true;
|
|
9554
|
+
for (const variable of this.module.getExportedVariablesByName().values()) {
|
|
9555
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
9556
|
+
}
|
|
9557
|
+
}
|
|
9558
|
+
}
|
|
9559
|
+
}
|
|
9560
|
+
getLiteralValueAtPath(path) {
|
|
9561
|
+
if (path[0] === SymbolToStringTag) {
|
|
9562
|
+
return 'Module';
|
|
9563
|
+
}
|
|
9564
|
+
return UnknownValue;
|
|
9565
|
+
}
|
|
9566
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9567
|
+
const { type } = interaction;
|
|
9568
|
+
if (path.length === 0) {
|
|
9569
|
+
// This can only be a call anyway
|
|
9570
|
+
return true;
|
|
9571
|
+
}
|
|
9572
|
+
if (path.length === 1 && type !== INTERACTION_CALLED) {
|
|
9573
|
+
return type === INTERACTION_ASSIGNED;
|
|
9574
|
+
}
|
|
9575
|
+
const key = path[0];
|
|
9576
|
+
if (typeof key !== 'string') {
|
|
9577
|
+
return true;
|
|
9578
|
+
}
|
|
9579
|
+
const memberVariable = this.getMemberVariable(key);
|
|
9580
|
+
return (!memberVariable ||
|
|
9581
|
+
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
9582
|
+
}
|
|
9583
|
+
includePath(path, context) {
|
|
9584
|
+
super.includePath(path, context);
|
|
9585
|
+
this.includeMemberPath(path, context);
|
|
9586
|
+
}
|
|
9587
|
+
includeMemberPath(path, context) {
|
|
9588
|
+
if (path.length > 0) {
|
|
9589
|
+
const [name, ...remainingPath] = path;
|
|
9590
|
+
if (typeof name === 'string') {
|
|
9591
|
+
const variable = this.getMemberVariable(name);
|
|
9592
|
+
if (variable) {
|
|
9593
|
+
this.context.includeVariableInModule(variable, remainingPath, context);
|
|
9594
|
+
}
|
|
9595
|
+
else {
|
|
9596
|
+
this.includeNonExplicitNamespaces();
|
|
9597
|
+
}
|
|
9598
|
+
}
|
|
9599
|
+
else if (name) {
|
|
9600
|
+
this.module.includeAllExports();
|
|
9601
|
+
this.includeNonExplicitNamespaces();
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
}
|
|
9605
|
+
prepare(accessedGlobalsByScope) {
|
|
9606
|
+
if (this.mergedNamespaces.length > 0) {
|
|
9607
|
+
this.module.scope.addAccessedGlobals([MERGE_NAMESPACES_VARIABLE], accessedGlobalsByScope);
|
|
9608
|
+
}
|
|
9609
|
+
}
|
|
9610
|
+
renderBlock(options) {
|
|
9611
|
+
const { exportNamesByVariable, format, freeze, indent: t, symbols, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
|
|
9612
|
+
const memberVariables = this.module.getExportedVariablesByName();
|
|
9613
|
+
const members = [...memberVariables.entries()]
|
|
9614
|
+
.filter(([name, variable]) => !isNamespaceExportName(name) && variable.included)
|
|
9615
|
+
.map(([name, variable]) => {
|
|
9616
|
+
const key = unescapeExportName(name);
|
|
9617
|
+
if (this.referencedEarly ||
|
|
9618
|
+
variable.isReassigned ||
|
|
9619
|
+
variable === this ||
|
|
9620
|
+
(variable.module &&
|
|
9621
|
+
!variable.module.info.isExternal &&
|
|
9622
|
+
variable.module.execIndex > this.module.execIndex)) {
|
|
9623
|
+
return [
|
|
9624
|
+
null,
|
|
9625
|
+
`get ${stringifyObjectKeyIfNeeded(key)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
|
|
9626
|
+
];
|
|
9627
|
+
}
|
|
9628
|
+
return [key, variable.getName(getPropertyAccess)];
|
|
9629
|
+
});
|
|
9630
|
+
members.unshift([null, `__proto__:${_}null`]);
|
|
9631
|
+
let output = getObject(members, { lineBreakIndent: { base: '', t } });
|
|
9632
|
+
if (this.mergedNamespaces.length > 0) {
|
|
9633
|
+
const assignmentArguments = this.mergedNamespaces.map(variable => variable.getName(getPropertyAccess));
|
|
9634
|
+
output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output},${_}[${assignmentArguments.join(`,${_}`)}])`;
|
|
9635
|
+
}
|
|
9636
|
+
else {
|
|
9637
|
+
// The helper to merge namespaces will also take care of freezing and toStringTag
|
|
9638
|
+
if (symbols) {
|
|
9639
|
+
output = `/*#__PURE__*/Object.defineProperty(${output},${_}Symbol.toStringTag,${_}${getToStringTagValue(getObject)})`;
|
|
9640
|
+
}
|
|
9641
|
+
if (freeze) {
|
|
9642
|
+
output = `/*#__PURE__*/Object.freeze(${output})`;
|
|
9643
|
+
}
|
|
9644
|
+
}
|
|
9645
|
+
const name = this.getName(getPropertyAccess);
|
|
9646
|
+
output = `${cnst} ${name}${_}=${_}${output};`;
|
|
9647
|
+
if (format === 'system' && exportNamesByVariable.has(this)) {
|
|
9648
|
+
output += `${n}${getSystemExportStatement([this], options)};`;
|
|
9649
|
+
}
|
|
9650
|
+
return output;
|
|
9651
|
+
}
|
|
9652
|
+
renderFirst() {
|
|
9653
|
+
return this.referencedEarly;
|
|
9654
|
+
}
|
|
9655
|
+
setMergedNamespaces(mergedNamespaces) {
|
|
9656
|
+
this.mergedNamespaces = mergedNamespaces;
|
|
9657
|
+
const moduleExecIndex = this.context.getModuleExecIndex();
|
|
9658
|
+
for (const identifier of this.references) {
|
|
9659
|
+
const { context } = identifier.scope;
|
|
9660
|
+
if (context.getModuleExecIndex() <= moduleExecIndex) {
|
|
9661
|
+
this.referencedEarly = true;
|
|
9662
|
+
break;
|
|
9663
|
+
}
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
getMemberVariable(name) {
|
|
9667
|
+
return this.module.getExportedVariablesByName().get(escapeExportName(name));
|
|
9668
|
+
}
|
|
9669
|
+
includeNonExplicitNamespaces() {
|
|
9670
|
+
if (!this.nonExplicitNamespacesIncluded) {
|
|
9671
|
+
this.nonExplicitNamespacesIncluded = true;
|
|
9672
|
+
this.setMergedNamespaces(this.module.includeAndGetAdditionalMergedNamespaces());
|
|
9673
|
+
}
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
NamespaceVariable.prototype.isNamespace = true;
|
|
9677
|
+
// This is a proxy that does not include the namespace object when a path is included
|
|
9678
|
+
const getDynamicNamespaceVariable = (namespace) => Object.create(namespace, {
|
|
9679
|
+
includePath: {
|
|
9680
|
+
value(path, context) {
|
|
9681
|
+
namespace.includeMemberPath(path, context);
|
|
9682
|
+
}
|
|
9683
|
+
}
|
|
9684
|
+
});
|
|
9685
|
+
|
|
9686
|
+
class SyntheticNamedExportVariable extends Variable {
|
|
9687
|
+
constructor(context, name, syntheticNamespace) {
|
|
9688
|
+
super(name);
|
|
9689
|
+
this.baseVariable = null;
|
|
9690
|
+
this.context = context;
|
|
9691
|
+
this.module = context.module;
|
|
9692
|
+
this.syntheticNamespace = syntheticNamespace;
|
|
9693
|
+
}
|
|
9694
|
+
getBaseVariable() {
|
|
9695
|
+
if (this.baseVariable)
|
|
9696
|
+
return this.baseVariable;
|
|
9697
|
+
let baseVariable = this.syntheticNamespace;
|
|
9698
|
+
while (baseVariable instanceof ExportDefaultVariable ||
|
|
9699
|
+
baseVariable instanceof SyntheticNamedExportVariable) {
|
|
9700
|
+
if (baseVariable instanceof ExportDefaultVariable) {
|
|
9701
|
+
const original = baseVariable.getOriginalVariable();
|
|
9702
|
+
if (original === baseVariable)
|
|
9703
|
+
break;
|
|
9704
|
+
baseVariable = original;
|
|
9705
|
+
}
|
|
9706
|
+
if (baseVariable instanceof SyntheticNamedExportVariable) {
|
|
9707
|
+
baseVariable = baseVariable.syntheticNamespace;
|
|
9708
|
+
}
|
|
9709
|
+
}
|
|
9710
|
+
return (this.baseVariable = baseVariable);
|
|
9711
|
+
}
|
|
9712
|
+
getBaseVariableName() {
|
|
9713
|
+
return this.syntheticNamespace.getBaseVariableName();
|
|
9714
|
+
}
|
|
9715
|
+
getName(getPropertyAccess) {
|
|
9716
|
+
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
9717
|
+
}
|
|
9718
|
+
includePath(path, context) {
|
|
9719
|
+
super.includePath(path, context);
|
|
9720
|
+
this.context.includeVariableInModule(this.syntheticNamespace, [this.name, ...path], context);
|
|
9721
|
+
}
|
|
9722
|
+
setRenderNames(baseName, name) {
|
|
9723
|
+
super.setRenderNames(baseName, name);
|
|
9724
|
+
}
|
|
9725
|
+
}
|
|
9726
|
+
|
|
9727
|
+
class ExternalChunk {
|
|
9728
|
+
constructor(module, options, inputBase) {
|
|
9729
|
+
this.options = options;
|
|
9730
|
+
this.inputBase = inputBase;
|
|
9731
|
+
this.defaultVariableName = '';
|
|
9732
|
+
this.namespaceVariableName = '';
|
|
9733
|
+
this.variableName = '';
|
|
9734
|
+
this.fileName = null;
|
|
9735
|
+
this.importAttributes = null;
|
|
9736
|
+
this.id = module.id;
|
|
9737
|
+
this.moduleInfo = module.info;
|
|
9738
|
+
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
9739
|
+
this.suggestedVariableName = module.suggestedVariableName;
|
|
9740
|
+
}
|
|
9741
|
+
get moduleSideEffects() {
|
|
9742
|
+
return this.moduleInfo.moduleSideEffects;
|
|
9743
|
+
}
|
|
9744
|
+
getFileName() {
|
|
9745
|
+
if (this.fileName) {
|
|
9746
|
+
return this.fileName;
|
|
9747
|
+
}
|
|
9748
|
+
const { paths } = this.options;
|
|
9749
|
+
return (this.fileName =
|
|
9750
|
+
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
9751
|
+
(this.renormalizeRenderPath ? normalize(relative(this.inputBase, this.id)) : this.id));
|
|
9752
|
+
}
|
|
9753
|
+
getImportAttributes(snippets) {
|
|
9754
|
+
return (this.importAttributes ||= formatAttributes(['es', 'cjs'].includes(this.options.format) &&
|
|
9755
|
+
this.options.externalImportAttributes &&
|
|
9756
|
+
this.moduleInfo.attributes, snippets));
|
|
9757
|
+
}
|
|
9758
|
+
getImportPath(importer) {
|
|
9759
|
+
return escapeId(this.renormalizeRenderPath
|
|
9760
|
+
? getImportPath(importer, this.getFileName(), this.options.format === 'amd', false)
|
|
9761
|
+
: this.getFileName());
|
|
9762
|
+
}
|
|
9763
|
+
}
|
|
9764
|
+
function formatAttributes(attributes, { getObject }) {
|
|
9765
|
+
if (!attributes) {
|
|
9766
|
+
return null;
|
|
9767
|
+
}
|
|
9768
|
+
const assertionEntries = Object.entries(attributes).map(([key, value]) => [key, JSON.stringify(value)]);
|
|
9769
|
+
if (assertionEntries.length > 0) {
|
|
9770
|
+
return getObject(assertionEntries, { lineBreakIndent: null });
|
|
9771
|
+
}
|
|
9772
|
+
return null;
|
|
9773
|
+
}
|
|
9774
|
+
|
|
9775
|
+
function removeJsExtension(name) {
|
|
9776
|
+
return name.endsWith('.js') ? name.slice(0, -3) : name;
|
|
9777
|
+
}
|
|
9778
|
+
|
|
9779
|
+
function getCompleteAmdId(options, chunkId) {
|
|
9780
|
+
if (options.autoId) {
|
|
9781
|
+
return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`;
|
|
9782
|
+
}
|
|
9783
|
+
return options.id ?? '';
|
|
9784
|
+
}
|
|
9785
|
+
|
|
9786
|
+
function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, reexportProtoFromExternal, mechanism = 'return ') {
|
|
9787
|
+
const { _, getFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
9788
|
+
if (!namedExportsMode) {
|
|
9789
|
+
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings, getPropertyAccess)};`;
|
|
9790
|
+
}
|
|
9791
|
+
let exportBlock = '';
|
|
9792
|
+
if (namedExportsMode) {
|
|
9793
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: dependencyNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
9794
|
+
if (!reexports) {
|
|
9795
|
+
continue;
|
|
9796
|
+
}
|
|
9797
|
+
for (const specifier of reexports) {
|
|
9798
|
+
if (specifier.reexported !== '*') {
|
|
9799
|
+
const importName = getReexportedImportName(name, specifier.imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
9800
|
+
if (exportBlock)
|
|
9801
|
+
exportBlock += n;
|
|
9802
|
+
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
9803
|
+
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(specifier.reexported))},${_}${getGetter(importName, false, t, snippets)});`;
|
|
9804
|
+
}
|
|
9805
|
+
else if (specifier.reexported === '__proto__') {
|
|
9806
|
+
exportBlock +=
|
|
9807
|
+
`Object.defineProperty(exports,${_}"__proto__",${_}{${n}` +
|
|
9808
|
+
`${t}enumerable:${_}true,${n}` +
|
|
9809
|
+
`${t}value:${_}${importName}${n}});`;
|
|
9810
|
+
}
|
|
9811
|
+
else {
|
|
9812
|
+
exportBlock += `exports${getPropertyAccess(unescapeExportName(specifier.reexported))}${_}=${_}${importName};`;
|
|
9813
|
+
}
|
|
9814
|
+
}
|
|
9815
|
+
}
|
|
9816
|
+
}
|
|
9817
|
+
}
|
|
9818
|
+
for (const { exported, local, needsLiveBinding } of exports) {
|
|
9819
|
+
const lhs = `exports${getPropertyAccess(unescapeExportName(exported))}`;
|
|
9820
|
+
const rhs = local;
|
|
9007
9821
|
if (lhs !== rhs) {
|
|
9008
9822
|
if (exportBlock)
|
|
9009
9823
|
exportBlock += n;
|
|
@@ -12589,102 +13403,6 @@ const builtins = 'arguments Infinity NaN undefined null true false eval uneval i
|
|
|
12589
13403
|
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
|
12590
13404
|
forbiddenIdentifiers.add('');
|
|
12591
13405
|
|
|
12592
|
-
class ArrayPattern extends NodeBase {
|
|
12593
|
-
addExportedVariables(variables, exportNamesByVariable) {
|
|
12594
|
-
for (const element of this.elements) {
|
|
12595
|
-
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
12596
|
-
}
|
|
12597
|
-
}
|
|
12598
|
-
declare(kind, destructuredInitPath, init) {
|
|
12599
|
-
const variables = [];
|
|
12600
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12601
|
-
for (const element of this.elements) {
|
|
12602
|
-
if (element !== null) {
|
|
12603
|
-
variables.push(...element.declare(kind, includedPatternPath, init));
|
|
12604
|
-
}
|
|
12605
|
-
}
|
|
12606
|
-
return variables;
|
|
12607
|
-
}
|
|
12608
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
12609
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12610
|
-
for (const element of this.elements) {
|
|
12611
|
-
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
12612
|
-
}
|
|
12613
|
-
}
|
|
12614
|
-
// Patterns can only be deoptimized at the empty path at the moment
|
|
12615
|
-
deoptimizePath() {
|
|
12616
|
-
for (const element of this.elements) {
|
|
12617
|
-
element?.deoptimizePath(EMPTY_PATH);
|
|
12618
|
-
}
|
|
12619
|
-
}
|
|
12620
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
12621
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12622
|
-
for (const element of this.elements) {
|
|
12623
|
-
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
12624
|
-
return true;
|
|
12625
|
-
}
|
|
12626
|
-
}
|
|
12627
|
-
return false;
|
|
12628
|
-
}
|
|
12629
|
-
// Patterns are only checked at the empty path at the moment
|
|
12630
|
-
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
12631
|
-
for (const element of this.elements) {
|
|
12632
|
-
if (element?.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
12633
|
-
return true;
|
|
12634
|
-
}
|
|
12635
|
-
return false;
|
|
12636
|
-
}
|
|
12637
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
12638
|
-
let included = false;
|
|
12639
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12640
|
-
for (const element of [...this.elements].reverse()) {
|
|
12641
|
-
if (element) {
|
|
12642
|
-
if (included && !element.included) {
|
|
12643
|
-
element.includeNode(context);
|
|
12644
|
-
}
|
|
12645
|
-
included =
|
|
12646
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
12647
|
-
}
|
|
12648
|
-
}
|
|
12649
|
-
if (!this.included && included) {
|
|
12650
|
-
this.includeNode(context);
|
|
12651
|
-
}
|
|
12652
|
-
return this.included;
|
|
12653
|
-
}
|
|
12654
|
-
render(code, options) {
|
|
12655
|
-
let removedStart = this.start + 1;
|
|
12656
|
-
for (const element of this.elements) {
|
|
12657
|
-
if (!element)
|
|
12658
|
-
continue;
|
|
12659
|
-
if (element.included) {
|
|
12660
|
-
element.render(code, options);
|
|
12661
|
-
removedStart = element.end;
|
|
12662
|
-
}
|
|
12663
|
-
else {
|
|
12664
|
-
code.remove(removedStart, this.end - 1);
|
|
12665
|
-
break;
|
|
12666
|
-
}
|
|
12667
|
-
}
|
|
12668
|
-
}
|
|
12669
|
-
setAssignedValue(value) {
|
|
12670
|
-
super.setAssignedValue(value);
|
|
12671
|
-
// Destructuring assigns each target only some subpath of the assigned
|
|
12672
|
-
// value, which is not tracked
|
|
12673
|
-
for (const element of this.elements) {
|
|
12674
|
-
element?.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
12675
|
-
}
|
|
12676
|
-
}
|
|
12677
|
-
markDeclarationReached() {
|
|
12678
|
-
for (const element of this.elements) {
|
|
12679
|
-
element?.markDeclarationReached();
|
|
12680
|
-
}
|
|
12681
|
-
}
|
|
12682
|
-
}
|
|
12683
|
-
ArrayPattern.prototype.includeNode = onlyIncludeSelf;
|
|
12684
|
-
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
12685
|
-
? destructuredInitPath
|
|
12686
|
-
: [...destructuredInitPath, UnknownInteger];
|
|
12687
|
-
|
|
12688
13406
|
class ArrowFunctionExpression extends FunctionBase {
|
|
12689
13407
|
constructor() {
|
|
12690
13408
|
super(...arguments);
|
|
@@ -12749,112 +13467,13 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
12749
13467
|
}
|
|
12750
13468
|
}
|
|
12751
13469
|
}
|
|
12752
|
-
getObjectEntity() {
|
|
12753
|
-
if (this.objectEntity !== null) {
|
|
12754
|
-
return this.objectEntity;
|
|
12755
|
-
}
|
|
12756
|
-
return (this.objectEntity = new ObjectEntity([], OBJECT_PROTOTYPE));
|
|
12757
|
-
}
|
|
12758
|
-
}
|
|
12759
|
-
|
|
12760
|
-
class ObjectPattern extends NodeBase {
|
|
12761
|
-
addExportedVariables(variables, exportNamesByVariable) {
|
|
12762
|
-
for (const property of this.properties) {
|
|
12763
|
-
if (property.type === Property$1) {
|
|
12764
|
-
property.value.addExportedVariables(variables, exportNamesByVariable);
|
|
12765
|
-
}
|
|
12766
|
-
else {
|
|
12767
|
-
property.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
12768
|
-
}
|
|
12769
|
-
}
|
|
12770
|
-
}
|
|
12771
|
-
declare(kind, destructuredInitPath, init) {
|
|
12772
|
-
const variables = [];
|
|
12773
|
-
for (const property of this.properties) {
|
|
12774
|
-
variables.push(...property.declare(kind, destructuredInitPath, init));
|
|
12775
|
-
}
|
|
12776
|
-
return variables;
|
|
12777
|
-
}
|
|
12778
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
12779
|
-
for (const property of this.properties) {
|
|
12780
|
-
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
12781
|
-
}
|
|
12782
|
-
}
|
|
12783
|
-
deoptimizePath(path) {
|
|
12784
|
-
if (path.length === 0) {
|
|
12785
|
-
for (const property of this.properties) {
|
|
12786
|
-
property.deoptimizePath(path);
|
|
12787
|
-
}
|
|
12788
|
-
}
|
|
12789
|
-
}
|
|
12790
|
-
hasEffectsOnInteractionAtPath(
|
|
12791
|
-
// At the moment, this is only triggered for assignment left-hand sides,
|
|
12792
|
-
// where the path is empty
|
|
12793
|
-
_path, interaction, context) {
|
|
12794
|
-
for (const property of this.properties) {
|
|
12795
|
-
if (property.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
12796
|
-
return true;
|
|
12797
|
-
}
|
|
12798
|
-
return false;
|
|
12799
|
-
}
|
|
12800
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
12801
|
-
for (const property of this.properties) {
|
|
12802
|
-
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
12803
|
-
return true;
|
|
12804
|
-
}
|
|
12805
|
-
return false;
|
|
12806
|
-
}
|
|
12807
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
12808
|
-
if (!this.properties.length)
|
|
12809
|
-
return this.included;
|
|
12810
|
-
const lastProperty = this.properties.at(-1);
|
|
12811
|
-
let included = lastProperty.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
12812
|
-
const lastPropertyIsRestElement = lastProperty.type === RestElement$1;
|
|
12813
|
-
for (const property of this.properties.slice(0, -1)) {
|
|
12814
|
-
if (lastPropertyIsRestElement && included && !property.included) {
|
|
12815
|
-
property.includeNode(context);
|
|
12816
|
-
}
|
|
12817
|
-
included =
|
|
12818
|
-
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
12819
|
-
}
|
|
12820
|
-
if (!this.included && included) {
|
|
12821
|
-
this.includeNode(context);
|
|
12822
|
-
}
|
|
12823
|
-
return this.included;
|
|
12824
|
-
}
|
|
12825
|
-
markDeclarationReached() {
|
|
12826
|
-
for (const property of this.properties) {
|
|
12827
|
-
property.markDeclarationReached();
|
|
12828
|
-
}
|
|
12829
|
-
}
|
|
12830
|
-
render(code, options) {
|
|
12831
|
-
if (this.properties.length > 0) {
|
|
12832
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
12833
|
-
let lastSeparatorPos = null;
|
|
12834
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
12835
|
-
if (!node.included) {
|
|
12836
|
-
treeshakeNode(node, code, start, end);
|
|
12837
|
-
continue;
|
|
12838
|
-
}
|
|
12839
|
-
lastSeparatorPos = separator;
|
|
12840
|
-
node.render(code, options);
|
|
12841
|
-
}
|
|
12842
|
-
if (lastSeparatorPos) {
|
|
12843
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
12844
|
-
}
|
|
12845
|
-
}
|
|
12846
|
-
}
|
|
12847
|
-
setAssignedValue(value) {
|
|
12848
|
-
super.setAssignedValue(value);
|
|
12849
|
-
// Destructuring assigns each target only some subpath of the assigned
|
|
12850
|
-
// value, which is not tracked
|
|
12851
|
-
for (const property of this.properties) {
|
|
12852
|
-
property.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
13470
|
+
getObjectEntity() {
|
|
13471
|
+
if (this.objectEntity !== null) {
|
|
13472
|
+
return this.objectEntity;
|
|
12853
13473
|
}
|
|
13474
|
+
return (this.objectEntity = new ObjectEntity([], OBJECT_PROTOTYPE));
|
|
12854
13475
|
}
|
|
12855
13476
|
}
|
|
12856
|
-
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12857
|
-
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12858
13477
|
|
|
12859
13478
|
class AssignmentExpression extends NodeBase {
|
|
12860
13479
|
constructor() {
|
|
@@ -12945,7 +13564,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
12945
13564
|
const systemPatternExports = [];
|
|
12946
13565
|
left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
|
|
12947
13566
|
if (systemPatternExports.length > 0) {
|
|
12948
|
-
renderSystemExportFunction(systemPatternExports, start, end, renderedSurroundingElement
|
|
13567
|
+
renderSystemExportFunction(systemPatternExports, start, end, systemExportIifeStartsStatement(parent, renderedSurroundingElement, start), code, options);
|
|
12949
13568
|
return;
|
|
12950
13569
|
}
|
|
12951
13570
|
}
|
|
@@ -12964,6 +13583,12 @@ class AssignmentExpression extends NodeBase {
|
|
|
12964
13583
|
this.scope.context.requestTreeshakingPass();
|
|
12965
13584
|
}
|
|
12966
13585
|
}
|
|
13586
|
+
// `function () {}()` is a function declaration at the first token of a statement.
|
|
13587
|
+
// `({ name } = obj)` already starts at `(`, so the inserted function stays an expression.
|
|
13588
|
+
function systemExportIifeStartsStatement(parent, renderedSurroundingElement, expressionStart) {
|
|
13589
|
+
return (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13590
|
+
(parent.type === ExpressionStatement$1 && parent.start === expressionStart));
|
|
13591
|
+
}
|
|
12967
13592
|
|
|
12968
13593
|
class AssignmentPattern extends NodeBase {
|
|
12969
13594
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
@@ -13027,17 +13652,6 @@ class AssignmentPattern extends NodeBase {
|
|
|
13027
13652
|
}
|
|
13028
13653
|
}
|
|
13029
13654
|
|
|
13030
|
-
function markTopLevelAwait(node) {
|
|
13031
|
-
if (node.scope.context.usesTopLevelAwait)
|
|
13032
|
-
return;
|
|
13033
|
-
let parent = node.parent;
|
|
13034
|
-
do {
|
|
13035
|
-
if (parent instanceof FunctionBase)
|
|
13036
|
-
return;
|
|
13037
|
-
} while ((parent = parent.parent));
|
|
13038
|
-
node.scope.context.usesTopLevelAwait = true;
|
|
13039
|
-
}
|
|
13040
|
-
|
|
13041
13655
|
class AwaitExpression extends NodeBase {
|
|
13042
13656
|
deoptimizePath(path) {
|
|
13043
13657
|
this.argument.deoptimizePath(path);
|
|
@@ -13574,16 +14188,6 @@ class ClassBody extends NodeBase {
|
|
|
13574
14188
|
ClassBody.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13575
14189
|
ClassBody.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13576
14190
|
|
|
13577
|
-
class ClassExpression extends ClassNode {
|
|
13578
|
-
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13579
|
-
super.render(code, options);
|
|
13580
|
-
if (renderedSurroundingElement === ExpressionStatement$1) {
|
|
13581
|
-
code.appendRight(this.start, '(');
|
|
13582
|
-
code.prependLeft(this.end, ')');
|
|
13583
|
-
}
|
|
13584
|
-
}
|
|
13585
|
-
}
|
|
13586
|
-
|
|
13587
14191
|
function tryCastLiteralValueToBoolean(literalValue) {
|
|
13588
14192
|
if (typeof literalValue === 'symbol') {
|
|
13589
14193
|
if (literalValue === UnknownFalsyValue) {
|
|
@@ -14002,6 +14606,9 @@ class ForInStatement extends NodeBase {
|
|
|
14002
14606
|
code.prependLeft(this.right.start, ' ');
|
|
14003
14607
|
}
|
|
14004
14608
|
this.body.render(code, options);
|
|
14609
|
+
if (options.format === 'system') {
|
|
14610
|
+
renderSystemExportForLoop(this.left, this.body, code, options);
|
|
14611
|
+
}
|
|
14005
14612
|
}
|
|
14006
14613
|
applyDeoptimizations() {
|
|
14007
14614
|
this.deoptimized = true;
|
|
@@ -14056,6 +14663,9 @@ class ForOfStatement extends NodeBase {
|
|
|
14056
14663
|
code.prependLeft(this.right.start, ' ');
|
|
14057
14664
|
}
|
|
14058
14665
|
this.body.render(code, options);
|
|
14666
|
+
if (options.format === 'system') {
|
|
14667
|
+
renderSystemExportForLoop(this.left, this.body, code, options);
|
|
14668
|
+
}
|
|
14059
14669
|
}
|
|
14060
14670
|
applyDeoptimizations() {
|
|
14061
14671
|
this.deoptimized = true;
|
|
@@ -14267,7 +14877,7 @@ class IfStatement extends NodeBase {
|
|
|
14267
14877
|
const hoistedVariables = [
|
|
14268
14878
|
...new Set(hoistedDeclarations.map(identifier => {
|
|
14269
14879
|
const variable = identifier.variable;
|
|
14270
|
-
return variable
|
|
14880
|
+
return this.shouldHoistVariable(variable) ? variable.getName(getPropertyAccess) : '';
|
|
14271
14881
|
}))
|
|
14272
14882
|
]
|
|
14273
14883
|
.filter(Boolean)
|
|
@@ -14281,6 +14891,11 @@ class IfStatement extends NodeBase {
|
|
|
14281
14891
|
}
|
|
14282
14892
|
}
|
|
14283
14893
|
}
|
|
14894
|
+
shouldHoistVariable(variable) {
|
|
14895
|
+
return (variable.included &&
|
|
14896
|
+
variable.renderBaseName === null &&
|
|
14897
|
+
variable.getHoistedVariable()?.renderBaseName == null);
|
|
14898
|
+
}
|
|
14284
14899
|
shouldKeepAlternateBranch() {
|
|
14285
14900
|
let currentParent = this.parent;
|
|
14286
14901
|
do {
|
|
@@ -15285,7 +15900,7 @@ class LabeledStatement extends NodeBase {
|
|
|
15285
15900
|
this.includeNode(context);
|
|
15286
15901
|
const { brokenFlow, includedLabels } = context;
|
|
15287
15902
|
context.includedLabels = new Set();
|
|
15288
|
-
this.body.include(context, includeChildrenRecursively);
|
|
15903
|
+
this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
15289
15904
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
15290
15905
|
this.label.include(context, includeChildrenRecursively);
|
|
15291
15906
|
context.includedLabels.delete(this.label.name);
|
|
@@ -16114,746 +16729,434 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
16114
16729
|
return true;
|
|
16115
16730
|
}
|
|
16116
16731
|
return (this.tag.hasEffects(context) ||
|
|
16117
|
-
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
16118
|
-
}
|
|
16119
|
-
include(context, includeChildrenRecursively) {
|
|
16120
|
-
if (!this.included)
|
|
16121
|
-
this.includeNode(context);
|
|
16122
|
-
if (includeChildrenRecursively) {
|
|
16123
|
-
super.include(context, true);
|
|
16124
|
-
}
|
|
16125
|
-
else {
|
|
16126
|
-
this.quasi.include(context, false);
|
|
16127
|
-
this.tag.include(context, false);
|
|
16128
|
-
this.tag.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, this.interaction, context);
|
|
16129
|
-
}
|
|
16130
|
-
}
|
|
16131
|
-
initialise() {
|
|
16132
|
-
super.initialise();
|
|
16133
|
-
this.args = [UNKNOWN_EXPRESSION, ...this.quasi.expressions];
|
|
16134
|
-
this.interaction = {
|
|
16135
|
-
args: [
|
|
16136
|
-
this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null,
|
|
16137
|
-
...this.args
|
|
16138
|
-
],
|
|
16139
|
-
type: INTERACTION_CALLED,
|
|
16140
|
-
withNew: false
|
|
16141
|
-
};
|
|
16142
|
-
}
|
|
16143
|
-
render(code, options) {
|
|
16144
|
-
this.tag.render(code, options, { isCalleeOfRenderedParent: true });
|
|
16145
|
-
this.quasi.render(code, options);
|
|
16146
|
-
if (!this.hasCheckedForWarnings && this.tag.type === Identifier$1) {
|
|
16147
|
-
this.hasCheckedForWarnings = true;
|
|
16148
|
-
const name = this.tag.name;
|
|
16149
|
-
const variable = this.scope.findVariable(name);
|
|
16150
|
-
if (variable.isNamespace) {
|
|
16151
|
-
this.scope.context.log(LOGLEVEL_WARN, logCannotCallNamespace(name), this.start);
|
|
16152
|
-
}
|
|
16153
|
-
}
|
|
16154
|
-
}
|
|
16155
|
-
applyDeoptimizations() {
|
|
16156
|
-
this.deoptimized = true;
|
|
16157
|
-
this.tag.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
16158
|
-
this.scope.context.requestTreeshakingPass();
|
|
16159
|
-
}
|
|
16160
|
-
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
16161
|
-
if (this.returnExpression === null) {
|
|
16162
|
-
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
16163
|
-
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
16164
|
-
}
|
|
16165
|
-
return this.returnExpression;
|
|
16166
|
-
}
|
|
16167
|
-
}
|
|
16168
|
-
TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16169
|
-
|
|
16170
|
-
class TemplateElement extends NodeBase {
|
|
16171
|
-
get tail() {
|
|
16172
|
-
return isFlagSet(this.flags, 1048576 /* Flag.tail */);
|
|
16173
|
-
}
|
|
16174
|
-
set tail(value) {
|
|
16175
|
-
this.flags = setFlag(this.flags, 1048576 /* Flag.tail */, value);
|
|
16176
|
-
}
|
|
16177
|
-
// Do not try to bind value
|
|
16178
|
-
bind() { }
|
|
16179
|
-
hasEffects() {
|
|
16180
|
-
return false;
|
|
16181
|
-
}
|
|
16182
|
-
parseNode(esTreeNode) {
|
|
16183
|
-
this.value = esTreeNode.value;
|
|
16184
|
-
return super.parseNode(esTreeNode);
|
|
16185
|
-
}
|
|
16186
|
-
render() { }
|
|
16187
|
-
}
|
|
16188
|
-
TemplateElement.prototype.includeNode = onlyIncludeSelf;
|
|
16189
|
-
|
|
16190
|
-
class TemplateLiteral extends NodeBase {
|
|
16191
|
-
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
16192
|
-
getLiteralValueAtPath(path) {
|
|
16193
|
-
if (path.length > 0 || this.quasis.length !== 1) {
|
|
16194
|
-
return UnknownValue;
|
|
16195
|
-
}
|
|
16196
|
-
return this.quasis[0].value.cooked;
|
|
16197
|
-
}
|
|
16198
|
-
getReturnExpressionWhenCalledAtPath(path) {
|
|
16199
|
-
if (path.length !== 1) {
|
|
16200
|
-
return UNKNOWN_RETURN_EXPRESSION;
|
|
16201
|
-
}
|
|
16202
|
-
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
16203
|
-
}
|
|
16204
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
16205
|
-
if (interaction.type === INTERACTION_ACCESSED) {
|
|
16206
|
-
return path.length > 1;
|
|
16207
|
-
}
|
|
16208
|
-
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
16209
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
16210
|
-
}
|
|
16211
|
-
return true;
|
|
16212
|
-
}
|
|
16213
|
-
includeNode(context) {
|
|
16214
|
-
this.included = true;
|
|
16215
|
-
if (!this.deoptimized)
|
|
16216
|
-
this.applyDeoptimizations();
|
|
16217
|
-
for (const node of this.expressions) {
|
|
16218
|
-
node.includePath(UNKNOWN_PATH, context);
|
|
16219
|
-
}
|
|
16220
|
-
}
|
|
16221
|
-
render(code, options) {
|
|
16222
|
-
this.scope.context.addIndentExclusionRange([this.start, this.end]);
|
|
16223
|
-
super.render(code, options);
|
|
16224
|
-
}
|
|
16225
|
-
}
|
|
16226
|
-
|
|
16227
|
-
class ModuleScope extends ChildScope {
|
|
16228
|
-
constructor(parent, context, importDescriptions) {
|
|
16229
|
-
super(parent, context);
|
|
16230
|
-
this.importDescriptions = importDescriptions;
|
|
16231
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
16232
|
-
}
|
|
16233
|
-
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
16234
|
-
if (this.importDescriptions.has(identifier.name)) {
|
|
16235
|
-
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
16236
|
-
}
|
|
16237
|
-
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
16238
|
-
}
|
|
16239
|
-
addExportDefaultDeclaration(exportDefaultDeclaration, context) {
|
|
16240
|
-
const variable = new ExportDefaultVariable(exportDefaultDeclaration, context);
|
|
16241
|
-
this.variables.set('default', variable);
|
|
16242
|
-
return variable;
|
|
16243
|
-
}
|
|
16244
|
-
addNamespaceMemberAccess() { }
|
|
16245
|
-
deconflict(format, exportNamesByVariable, accessedGlobalsByScope) {
|
|
16246
|
-
// all module level variables are already deconflicted when deconflicting the chunk
|
|
16247
|
-
for (const scope of this.children)
|
|
16248
|
-
scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
|
|
16249
|
-
}
|
|
16250
|
-
findLexicalBoundary() {
|
|
16251
|
-
return this;
|
|
16252
|
-
}
|
|
16253
|
-
findVariable(name) {
|
|
16254
|
-
const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name);
|
|
16255
|
-
if (knownVariable) {
|
|
16256
|
-
return knownVariable;
|
|
16257
|
-
}
|
|
16258
|
-
const variable = this.context.traceVariable(name) || this.parent.findVariable(name);
|
|
16259
|
-
if (variable instanceof GlobalVariable) {
|
|
16260
|
-
this.accessedOutsideVariables.set(name, variable);
|
|
16261
|
-
}
|
|
16262
|
-
return variable;
|
|
16263
|
-
}
|
|
16264
|
-
}
|
|
16265
|
-
|
|
16266
|
-
class ThisExpression extends NodeBase {
|
|
16267
|
-
bind() {
|
|
16268
|
-
this.variable = this.scope.findVariable('this');
|
|
16269
|
-
}
|
|
16270
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
16271
|
-
this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
16272
|
-
}
|
|
16273
|
-
deoptimizePath(path) {
|
|
16274
|
-
this.variable.deoptimizePath(path);
|
|
16275
|
-
}
|
|
16276
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
16277
|
-
if (path.length === 0) {
|
|
16278
|
-
return interaction.type !== INTERACTION_ACCESSED;
|
|
16279
|
-
}
|
|
16280
|
-
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
16281
|
-
}
|
|
16282
|
-
include(context) {
|
|
16283
|
-
if (!this.included)
|
|
16284
|
-
this.includeNode(context);
|
|
16285
|
-
}
|
|
16286
|
-
includeNode(context) {
|
|
16287
|
-
this.included = true;
|
|
16288
|
-
if (!this.deoptimized)
|
|
16289
|
-
this.applyDeoptimizations();
|
|
16290
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
16291
|
-
}
|
|
16292
|
-
includePath(path, context) {
|
|
16293
|
-
if (!this.included) {
|
|
16294
|
-
this.included = true;
|
|
16295
|
-
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
16296
|
-
}
|
|
16297
|
-
else if (path.length > 0) {
|
|
16298
|
-
this.variable.includePath(path, context);
|
|
16299
|
-
}
|
|
16300
|
-
const functionScope = findFunctionScope(this.scope, this.variable);
|
|
16301
|
-
if (functionScope &&
|
|
16302
|
-
functionScope.functionNode.parent instanceof Property &&
|
|
16303
|
-
functionScope.functionNode.parent.parent instanceof ObjectExpression) {
|
|
16304
|
-
functionScope.functionNode.parent.parent.includePath(path, context);
|
|
16305
|
-
}
|
|
16306
|
-
}
|
|
16307
|
-
initialise() {
|
|
16308
|
-
super.initialise();
|
|
16309
|
-
this.alias =
|
|
16310
|
-
this.scope.findLexicalBoundary() instanceof ModuleScope
|
|
16311
|
-
? this.scope.context.moduleContext
|
|
16312
|
-
: null;
|
|
16313
|
-
if (this.alias === 'undefined') {
|
|
16314
|
-
this.scope.context.log(LOGLEVEL_WARN, logThisIsUndefined(), this.start);
|
|
16315
|
-
}
|
|
16316
|
-
}
|
|
16317
|
-
render(code) {
|
|
16318
|
-
if (this.alias !== null) {
|
|
16319
|
-
code.overwrite(this.start, this.end, this.alias, {
|
|
16320
|
-
contentOnly: false,
|
|
16321
|
-
storeName: true
|
|
16322
|
-
});
|
|
16323
|
-
}
|
|
16324
|
-
}
|
|
16325
|
-
}
|
|
16326
|
-
function findFunctionScope(scope, thisVariable) {
|
|
16327
|
-
while (!(scope instanceof FunctionScope && scope.thisVariable === thisVariable)) {
|
|
16328
|
-
if (!(scope instanceof ChildScope)) {
|
|
16329
|
-
return null;
|
|
16330
|
-
}
|
|
16331
|
-
scope = scope.parent;
|
|
16332
|
-
}
|
|
16333
|
-
return scope;
|
|
16334
|
-
}
|
|
16335
|
-
|
|
16336
|
-
class ThrowStatement extends NodeBase {
|
|
16337
|
-
hasEffects() {
|
|
16338
|
-
return true;
|
|
16732
|
+
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
16339
16733
|
}
|
|
16340
16734
|
include(context, includeChildrenRecursively) {
|
|
16341
16735
|
if (!this.included)
|
|
16342
16736
|
this.includeNode(context);
|
|
16343
|
-
|
|
16344
|
-
|
|
16345
|
-
}
|
|
16346
|
-
includeNode(context) {
|
|
16347
|
-
if (!this.included) {
|
|
16348
|
-
this.included = true;
|
|
16349
|
-
this.argument.includePath(UNKNOWN_PATH, context);
|
|
16737
|
+
if (includeChildrenRecursively) {
|
|
16738
|
+
super.include(context, true);
|
|
16350
16739
|
}
|
|
16351
|
-
|
|
16352
|
-
|
|
16353
|
-
|
|
16354
|
-
|
|
16355
|
-
code.prependLeft(this.start + 5, ' ');
|
|
16740
|
+
else {
|
|
16741
|
+
this.quasi.include(context, false);
|
|
16742
|
+
this.tag.include(context, false);
|
|
16743
|
+
this.tag.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, this.interaction, context);
|
|
16356
16744
|
}
|
|
16357
16745
|
}
|
|
16358
|
-
|
|
16359
|
-
|
|
16360
|
-
|
|
16361
|
-
|
|
16362
|
-
|
|
16363
|
-
|
|
16364
|
-
|
|
16365
|
-
|
|
16366
|
-
|
|
16367
|
-
|
|
16368
|
-
|
|
16369
|
-
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
16746
|
+
initialise() {
|
|
16747
|
+
super.initialise();
|
|
16748
|
+
this.args = [UNKNOWN_EXPRESSION, ...this.quasi.expressions];
|
|
16749
|
+
this.interaction = {
|
|
16750
|
+
args: [
|
|
16751
|
+
this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null,
|
|
16752
|
+
...this.args
|
|
16753
|
+
],
|
|
16754
|
+
type: INTERACTION_CALLED,
|
|
16755
|
+
withNew: false
|
|
16756
|
+
};
|
|
16370
16757
|
}
|
|
16371
|
-
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
if (!this.
|
|
16375
|
-
this.
|
|
16376
|
-
|
|
16377
|
-
this.
|
|
16378
|
-
if (
|
|
16379
|
-
this.
|
|
16380
|
-
}
|
|
16381
|
-
context.brokenFlow = brokenFlow;
|
|
16382
|
-
}
|
|
16383
|
-
else if (this.includedLabelsAfterBlock) {
|
|
16384
|
-
for (const label of this.includedLabelsAfterBlock) {
|
|
16385
|
-
includedLabels.add(label);
|
|
16758
|
+
render(code, options) {
|
|
16759
|
+
this.tag.render(code, options, { isCalleeOfRenderedParent: true });
|
|
16760
|
+
this.quasi.render(code, options);
|
|
16761
|
+
if (!this.hasCheckedForWarnings && this.tag.type === Identifier$1) {
|
|
16762
|
+
this.hasCheckedForWarnings = true;
|
|
16763
|
+
const name = this.tag.name;
|
|
16764
|
+
const variable = this.scope.findVariable(name);
|
|
16765
|
+
if (variable.isNamespace) {
|
|
16766
|
+
this.scope.context.log(LOGLEVEL_WARN, logCannotCallNamespace(name), this.start);
|
|
16386
16767
|
}
|
|
16387
16768
|
}
|
|
16388
|
-
|
|
16389
|
-
|
|
16390
|
-
|
|
16769
|
+
}
|
|
16770
|
+
applyDeoptimizations() {
|
|
16771
|
+
this.deoptimized = true;
|
|
16772
|
+
this.tag.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
16773
|
+
this.scope.context.requestTreeshakingPass();
|
|
16774
|
+
}
|
|
16775
|
+
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
16776
|
+
if (this.returnExpression === null) {
|
|
16777
|
+
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
16778
|
+
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
16391
16779
|
}
|
|
16392
|
-
this.
|
|
16780
|
+
return this.returnExpression;
|
|
16393
16781
|
}
|
|
16394
16782
|
}
|
|
16395
|
-
|
|
16396
|
-
TryStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
16783
|
+
TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16397
16784
|
|
|
16398
|
-
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
'-': value => -value,
|
|
16402
|
-
delete: () => UnknownValue,
|
|
16403
|
-
typeof: value => typeof value,
|
|
16404
|
-
void: () => undefined,
|
|
16405
|
-
'~': value => ~value
|
|
16406
|
-
};
|
|
16407
|
-
const UNASSIGNED = Symbol('Unassigned');
|
|
16408
|
-
class UnaryExpression extends NodeBase {
|
|
16409
|
-
constructor() {
|
|
16410
|
-
super(...arguments);
|
|
16411
|
-
this.renderedLiteralValue = UNASSIGNED;
|
|
16785
|
+
class TemplateElement extends NodeBase {
|
|
16786
|
+
get tail() {
|
|
16787
|
+
return isFlagSet(this.flags, 1048576 /* Flag.tail */);
|
|
16412
16788
|
}
|
|
16413
|
-
|
|
16414
|
-
|
|
16789
|
+
set tail(value) {
|
|
16790
|
+
this.flags = setFlag(this.flags, 1048576 /* Flag.tail */, value);
|
|
16415
16791
|
}
|
|
16416
|
-
|
|
16417
|
-
|
|
16792
|
+
// Do not try to bind value
|
|
16793
|
+
bind() { }
|
|
16794
|
+
hasEffects() {
|
|
16795
|
+
return false;
|
|
16418
16796
|
}
|
|
16419
|
-
|
|
16420
|
-
this.
|
|
16797
|
+
parseNode(esTreeNode) {
|
|
16798
|
+
this.value = esTreeNode.value;
|
|
16799
|
+
return super.parseNode(esTreeNode);
|
|
16421
16800
|
}
|
|
16422
|
-
|
|
16423
|
-
|
|
16424
|
-
|
|
16425
|
-
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
|
|
16429
|
-
|
|
16430
|
-
if (argumentValue === UnknownFalsyValue)
|
|
16431
|
-
return true;
|
|
16432
|
-
if (argumentValue === UnknownTruthyValue)
|
|
16433
|
-
return false;
|
|
16434
|
-
}
|
|
16801
|
+
render() { }
|
|
16802
|
+
}
|
|
16803
|
+
TemplateElement.prototype.includeNode = onlyIncludeSelf;
|
|
16804
|
+
|
|
16805
|
+
class TemplateLiteral extends NodeBase {
|
|
16806
|
+
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
16807
|
+
getLiteralValueAtPath(path) {
|
|
16808
|
+
if (path.length > 0 || this.quasis.length !== 1) {
|
|
16435
16809
|
return UnknownValue;
|
|
16436
16810
|
}
|
|
16437
|
-
return
|
|
16438
|
-
}
|
|
16439
|
-
hasEffects(context) {
|
|
16440
|
-
if (!this.deoptimized)
|
|
16441
|
-
this.applyDeoptimizations();
|
|
16442
|
-
if (this.operator === 'typeof' && this.argument instanceof Identifier)
|
|
16443
|
-
return false;
|
|
16444
|
-
return (this.argument.hasEffects(context) ||
|
|
16445
|
-
(this.operator === 'delete' &&
|
|
16446
|
-
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)));
|
|
16447
|
-
}
|
|
16448
|
-
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
16449
|
-
return type !== INTERACTION_ACCESSED || path.length > (this.operator === 'void' ? 0 : 1);
|
|
16811
|
+
return this.quasis[0].value.cooked;
|
|
16450
16812
|
}
|
|
16451
|
-
|
|
16452
|
-
|
|
16453
|
-
|
|
16454
|
-
this.argument.deoptimizePath(EMPTY_PATH);
|
|
16455
|
-
this.scope.context.requestTreeshakingPass();
|
|
16813
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
16814
|
+
if (path.length !== 1) {
|
|
16815
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
16456
16816
|
}
|
|
16817
|
+
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
16457
16818
|
}
|
|
16458
|
-
|
|
16459
|
-
if (
|
|
16460
|
-
return
|
|
16461
|
-
|
|
16462
|
-
|
|
16463
|
-
|
|
16819
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
16820
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
16821
|
+
return path.length > 1;
|
|
16822
|
+
}
|
|
16823
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
16824
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
16825
|
+
}
|
|
16826
|
+
return true;
|
|
16464
16827
|
}
|
|
16465
|
-
|
|
16828
|
+
includeNode(context) {
|
|
16829
|
+
this.included = true;
|
|
16466
16830
|
if (!this.deoptimized)
|
|
16467
16831
|
this.applyDeoptimizations();
|
|
16468
|
-
this.
|
|
16469
|
-
|
|
16470
|
-
const shouldPreserveArgument = this.argument instanceof Identifier && this.argument.variable?.included;
|
|
16471
|
-
if (typeof this.getRenderedLiteralValue(includeChildrenRecursively) === 'symbol' ||
|
|
16472
|
-
this.argument.shouldBeIncluded(context) ||
|
|
16473
|
-
shouldPreserveArgument) {
|
|
16474
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
16475
|
-
this.renderedLiteralValue = UnknownValue;
|
|
16832
|
+
for (const node of this.expressions) {
|
|
16833
|
+
node.includePath(UNKNOWN_PATH, context);
|
|
16476
16834
|
}
|
|
16477
16835
|
}
|
|
16478
16836
|
render(code, options) {
|
|
16479
|
-
|
|
16480
|
-
|
|
16481
|
-
}
|
|
16482
|
-
else {
|
|
16483
|
-
let value = this.renderedLiteralValue;
|
|
16484
|
-
if (!CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE.test(code.original[this.start - 1])) {
|
|
16485
|
-
value = ` ${value}`;
|
|
16486
|
-
}
|
|
16487
|
-
code.overwrite(this.start, this.end, value);
|
|
16488
|
-
}
|
|
16837
|
+
this.scope.context.addIndentExclusionRange([this.start, this.end]);
|
|
16838
|
+
super.render(code, options);
|
|
16489
16839
|
}
|
|
16490
16840
|
}
|
|
16491
|
-
const CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE = /[\s([=%&*+-/<>^|,?:;]/;
|
|
16492
|
-
UnaryExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16493
16841
|
|
|
16494
|
-
class
|
|
16495
|
-
|
|
16496
|
-
|
|
16497
|
-
|
|
16498
|
-
|
|
16842
|
+
class ModuleScope extends ChildScope {
|
|
16843
|
+
constructor(parent, context, importDescriptions) {
|
|
16844
|
+
super(parent, context);
|
|
16845
|
+
this.importDescriptions = importDescriptions;
|
|
16846
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
16499
16847
|
}
|
|
16500
|
-
|
|
16501
|
-
|
|
16848
|
+
addDeclaration(identifier, context, init, destructuredInitPath, kind) {
|
|
16849
|
+
if (this.importDescriptions.has(identifier.name)) {
|
|
16850
|
+
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
16851
|
+
}
|
|
16852
|
+
return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
|
|
16502
16853
|
}
|
|
16503
|
-
|
|
16504
|
-
|
|
16505
|
-
|
|
16506
|
-
|
|
16854
|
+
addExportDefaultDeclaration(exportDefaultDeclaration, context) {
|
|
16855
|
+
const variable = new ExportDefaultVariable(exportDefaultDeclaration, context);
|
|
16856
|
+
this.variables.set('default', variable);
|
|
16857
|
+
return variable;
|
|
16507
16858
|
}
|
|
16508
|
-
|
|
16509
|
-
|
|
16510
|
-
|
|
16859
|
+
addNamespaceMemberAccess() { }
|
|
16860
|
+
deconflict(format, exportNamesByVariable, accessedGlobalsByScope) {
|
|
16861
|
+
// all module level variables are already deconflicted when deconflicting the chunk
|
|
16862
|
+
for (const scope of this.children)
|
|
16863
|
+
scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
|
|
16511
16864
|
}
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
this.argument.render(code, options);
|
|
16515
|
-
if (format === 'system') {
|
|
16516
|
-
const variable = this.argument.variable;
|
|
16517
|
-
const exportNames = exportNamesByVariable.get(variable);
|
|
16518
|
-
if (exportNames) {
|
|
16519
|
-
if (this.prefix) {
|
|
16520
|
-
if (exportNames.length === 1) {
|
|
16521
|
-
renderSystemExportExpression(variable, this.start, this.end, code, options);
|
|
16522
|
-
}
|
|
16523
|
-
else {
|
|
16524
|
-
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
|
|
16525
|
-
}
|
|
16526
|
-
}
|
|
16527
|
-
else {
|
|
16528
|
-
const operator = this.operator[0];
|
|
16529
|
-
renderSystemExportSequenceBeforeExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options, `${_}${operator}${_}1`);
|
|
16530
|
-
}
|
|
16531
|
-
}
|
|
16532
|
-
}
|
|
16865
|
+
findLexicalBoundary() {
|
|
16866
|
+
return this;
|
|
16533
16867
|
}
|
|
16534
|
-
|
|
16535
|
-
this.
|
|
16536
|
-
|
|
16537
|
-
|
|
16538
|
-
const variable = this.scope.findVariable(this.argument.name);
|
|
16539
|
-
variable.markReassigned();
|
|
16868
|
+
findVariable(name) {
|
|
16869
|
+
const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name);
|
|
16870
|
+
if (knownVariable) {
|
|
16871
|
+
return knownVariable;
|
|
16540
16872
|
}
|
|
16541
|
-
this.
|
|
16873
|
+
const variable = this.context.traceVariable(name) || this.parent.findVariable(name);
|
|
16874
|
+
if (variable instanceof GlobalVariable) {
|
|
16875
|
+
this.accessedOutsideVariables.set(name, variable);
|
|
16876
|
+
}
|
|
16877
|
+
return variable;
|
|
16542
16878
|
}
|
|
16543
16879
|
}
|
|
16544
|
-
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16545
|
-
|
|
16546
|
-
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
16547
|
-
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
16548
|
-
}
|
|
16549
16880
|
|
|
16550
|
-
class
|
|
16551
|
-
|
|
16552
|
-
|
|
16553
|
-
|
|
16881
|
+
class ThisExpression extends NodeBase {
|
|
16882
|
+
bind() {
|
|
16883
|
+
this.variable = this.scope.findVariable('this');
|
|
16884
|
+
}
|
|
16885
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
16886
|
+
this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
16887
|
+
}
|
|
16888
|
+
deoptimizePath(path) {
|
|
16889
|
+
this.variable.deoptimizePath(path);
|
|
16890
|
+
}
|
|
16891
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
16892
|
+
if (path.length === 0) {
|
|
16893
|
+
return interaction.type !== INTERACTION_ACCESSED;
|
|
16554
16894
|
}
|
|
16895
|
+
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
16555
16896
|
}
|
|
16556
|
-
|
|
16557
|
-
|
|
16897
|
+
include(context) {
|
|
16898
|
+
if (!this.included)
|
|
16899
|
+
this.includeNode(context);
|
|
16558
16900
|
}
|
|
16559
|
-
|
|
16901
|
+
includeNode(context) {
|
|
16560
16902
|
this.included = true;
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
|
|
16571
|
-
|
|
16572
|
-
|
|
16573
|
-
|
|
16574
|
-
|
|
16903
|
+
if (!this.deoptimized)
|
|
16904
|
+
this.applyDeoptimizations();
|
|
16905
|
+
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
16906
|
+
}
|
|
16907
|
+
includePath(path, context) {
|
|
16908
|
+
if (!this.included) {
|
|
16909
|
+
this.included = true;
|
|
16910
|
+
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
16911
|
+
}
|
|
16912
|
+
else if (path.length > 0) {
|
|
16913
|
+
this.variable.includePath(path, context);
|
|
16914
|
+
}
|
|
16915
|
+
const functionScope = findFunctionScope(this.scope, this.variable);
|
|
16916
|
+
if (functionScope &&
|
|
16917
|
+
functionScope.functionNode.parent instanceof Property &&
|
|
16918
|
+
functionScope.functionNode.parent.parent instanceof ObjectExpression) {
|
|
16919
|
+
functionScope.functionNode.parent.parent.includePath(path, context);
|
|
16575
16920
|
}
|
|
16576
16921
|
}
|
|
16577
16922
|
initialise() {
|
|
16578
16923
|
super.initialise();
|
|
16579
|
-
|
|
16580
|
-
|
|
16581
|
-
|
|
16582
|
-
|
|
16924
|
+
this.alias =
|
|
16925
|
+
this.scope.findLexicalBoundary() instanceof ModuleScope
|
|
16926
|
+
? this.scope.context.moduleContext
|
|
16927
|
+
: null;
|
|
16928
|
+
if (this.alias === 'undefined') {
|
|
16929
|
+
this.scope.context.log(LOGLEVEL_WARN, logThisIsUndefined(), this.start);
|
|
16583
16930
|
}
|
|
16584
16931
|
}
|
|
16585
|
-
|
|
16586
|
-
this.
|
|
16587
|
-
|
|
16588
|
-
|
|
16589
|
-
|
|
16590
|
-
|
|
16591
|
-
declarator.render(code, options);
|
|
16592
|
-
}
|
|
16593
|
-
if (!nodeRenderOptions.isNoStatement &&
|
|
16594
|
-
code.original.charCodeAt(this.end - 1) !== 59 /*";"*/) {
|
|
16595
|
-
code.appendLeft(this.end, ';');
|
|
16596
|
-
}
|
|
16597
|
-
}
|
|
16598
|
-
else {
|
|
16599
|
-
this.renderReplacedDeclarations(code, options);
|
|
16932
|
+
render(code) {
|
|
16933
|
+
if (this.alias !== null) {
|
|
16934
|
+
code.overwrite(this.start, this.end, this.alias, {
|
|
16935
|
+
contentOnly: false,
|
|
16936
|
+
storeName: true
|
|
16937
|
+
});
|
|
16600
16938
|
}
|
|
16601
16939
|
}
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
if (lastSeparatorPos === null) {
|
|
16608
|
-
code.appendLeft(renderedContentEnd, separatorString);
|
|
16609
|
-
}
|
|
16610
|
-
else {
|
|
16611
|
-
if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
|
|
16612
|
-
(code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
|
|
16613
|
-
code.original.charCodeAt(this.end) === 13) /*"\r"*/) {
|
|
16614
|
-
actualContentEnd--;
|
|
16615
|
-
if (code.original.charCodeAt(actualContentEnd) === 13 /*"\r"*/) {
|
|
16616
|
-
actualContentEnd--;
|
|
16617
|
-
}
|
|
16618
|
-
}
|
|
16619
|
-
if (actualContentEnd === lastSeparatorPos + 1) {
|
|
16620
|
-
code.overwrite(lastSeparatorPos, renderedContentEnd, separatorString);
|
|
16621
|
-
}
|
|
16622
|
-
else {
|
|
16623
|
-
code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
|
|
16624
|
-
code.remove(actualContentEnd, renderedContentEnd);
|
|
16625
|
-
}
|
|
16626
|
-
}
|
|
16627
|
-
if (systemPatternExports.length > 0) {
|
|
16628
|
-
code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
|
|
16940
|
+
}
|
|
16941
|
+
function findFunctionScope(scope, thisVariable) {
|
|
16942
|
+
while (!(scope instanceof FunctionScope && scope.thisVariable === thisVariable)) {
|
|
16943
|
+
if (!(scope instanceof ChildScope)) {
|
|
16944
|
+
return null;
|
|
16629
16945
|
}
|
|
16946
|
+
scope = scope.parent;
|
|
16630
16947
|
}
|
|
16631
|
-
|
|
16632
|
-
|
|
16633
|
-
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
|
|
16637
|
-
let isInDeclaration = false;
|
|
16638
|
-
let hasRenderedContent = false;
|
|
16639
|
-
let separatorString = '', leadingString, nextSeparatorString;
|
|
16640
|
-
const aggregatedSystemExports = [];
|
|
16641
|
-
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
16642
|
-
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
16643
|
-
if (!node.included) {
|
|
16644
|
-
treeshakeNode(node, code, start, end);
|
|
16645
|
-
continue;
|
|
16646
|
-
}
|
|
16647
|
-
node.render(code, options);
|
|
16648
|
-
leadingString = '';
|
|
16649
|
-
nextSeparatorString = '';
|
|
16650
|
-
if (!node.id.included ||
|
|
16651
|
-
(node.id instanceof Identifier &&
|
|
16652
|
-
isReassignedExportsMember(node.id.variable, options.exportNamesByVariable))) {
|
|
16653
|
-
if (hasRenderedContent) {
|
|
16654
|
-
separatorString += ';';
|
|
16655
|
-
}
|
|
16656
|
-
isInDeclaration = false;
|
|
16657
|
-
}
|
|
16658
|
-
else {
|
|
16659
|
-
if (singleSystemExport && singleSystemExport === node.id.variable) {
|
|
16660
|
-
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end);
|
|
16661
|
-
renderSystemExportExpression(singleSystemExport, findNonWhiteSpace(code.original, operatorPos + 1), separator === null ? contentEnd : separator, code, options);
|
|
16662
|
-
}
|
|
16663
|
-
if (isInDeclaration) {
|
|
16664
|
-
separatorString += ',';
|
|
16665
|
-
}
|
|
16666
|
-
else {
|
|
16667
|
-
if (hasRenderedContent) {
|
|
16668
|
-
separatorString += ';';
|
|
16669
|
-
}
|
|
16670
|
-
leadingString += `${this.kind} `;
|
|
16671
|
-
isInDeclaration = true;
|
|
16672
|
-
}
|
|
16673
|
-
}
|
|
16674
|
-
if (renderedContentEnd === lastSeparatorPos + 1) {
|
|
16675
|
-
code.overwrite(lastSeparatorPos, renderedContentEnd, separatorString + leadingString);
|
|
16676
|
-
}
|
|
16677
|
-
else {
|
|
16678
|
-
code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
|
|
16679
|
-
code.appendLeft(renderedContentEnd, leadingString);
|
|
16680
|
-
}
|
|
16681
|
-
actualContentEnd = contentEnd;
|
|
16682
|
-
renderedContentEnd = end;
|
|
16683
|
-
hasRenderedContent = true;
|
|
16684
|
-
lastSeparatorPos = separator;
|
|
16685
|
-
separatorString = nextSeparatorString;
|
|
16686
|
-
}
|
|
16687
|
-
this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options);
|
|
16948
|
+
return scope;
|
|
16949
|
+
}
|
|
16950
|
+
|
|
16951
|
+
class ThrowStatement extends NodeBase {
|
|
16952
|
+
hasEffects() {
|
|
16953
|
+
return true;
|
|
16688
16954
|
}
|
|
16689
|
-
|
|
16690
|
-
if (this.
|
|
16691
|
-
|
|
16955
|
+
include(context, includeChildrenRecursively) {
|
|
16956
|
+
if (!this.included)
|
|
16957
|
+
this.includeNode(context);
|
|
16958
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
16959
|
+
context.brokenFlow = true;
|
|
16960
|
+
}
|
|
16961
|
+
includeNode(context) {
|
|
16962
|
+
if (!this.included) {
|
|
16963
|
+
this.included = true;
|
|
16964
|
+
this.argument.includePath(UNKNOWN_PATH, context);
|
|
16692
16965
|
}
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
|
|
16698
|
-
return false;
|
|
16699
|
-
}
|
|
16700
|
-
else {
|
|
16701
|
-
const exportedVariables = [];
|
|
16702
|
-
declarator.id.addExportedVariables(exportedVariables, exportNamesByVariable);
|
|
16703
|
-
if (exportedVariables.length > 0)
|
|
16704
|
-
return false;
|
|
16705
|
-
}
|
|
16966
|
+
}
|
|
16967
|
+
render(code, options) {
|
|
16968
|
+
this.argument.render(code, options, { preventASI: true });
|
|
16969
|
+
if (this.argument.start === this.start + 5 /* 'throw'.length */) {
|
|
16970
|
+
code.prependLeft(this.start + 5, ' ');
|
|
16706
16971
|
}
|
|
16707
|
-
return true;
|
|
16708
16972
|
}
|
|
16709
16973
|
}
|
|
16710
|
-
|
|
16711
|
-
|
|
16712
|
-
|
|
16713
|
-
|
|
16714
|
-
|
|
16715
|
-
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
|
|
16719
|
-
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16974
|
+
|
|
16975
|
+
class TryStatement extends NodeBase {
|
|
16976
|
+
constructor() {
|
|
16977
|
+
super(...arguments);
|
|
16978
|
+
this.directlyIncluded = false;
|
|
16979
|
+
this.includedLabelsAfterBlock = null;
|
|
16980
|
+
}
|
|
16981
|
+
hasEffects(context) {
|
|
16982
|
+
return ((this.scope.context.options.treeshake.tryCatchDeoptimization
|
|
16983
|
+
? this.block.body.length > 0
|
|
16984
|
+
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
16985
|
+
}
|
|
16986
|
+
include(context, includeChildrenRecursively) {
|
|
16987
|
+
const tryCatchDeoptimization = this.scope.context.options.treeshake?.tryCatchDeoptimization;
|
|
16988
|
+
const { brokenFlow, includedLabels } = context;
|
|
16989
|
+
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
16990
|
+
this.included = true;
|
|
16991
|
+
this.directlyIncluded = true;
|
|
16992
|
+
this.block.include(context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively);
|
|
16993
|
+
if (includedLabels.size > 0) {
|
|
16994
|
+
this.includedLabelsAfterBlock = [...includedLabels];
|
|
16723
16995
|
}
|
|
16996
|
+
context.brokenFlow = brokenFlow;
|
|
16724
16997
|
}
|
|
16725
|
-
if (
|
|
16726
|
-
|
|
16998
|
+
else if (this.includedLabelsAfterBlock) {
|
|
16999
|
+
for (const label of this.includedLabelsAfterBlock) {
|
|
17000
|
+
includedLabels.add(label);
|
|
17001
|
+
}
|
|
16727
17002
|
}
|
|
16728
|
-
|
|
16729
|
-
|
|
17003
|
+
if (this.handler !== null) {
|
|
17004
|
+
this.handler.include(context, includeChildrenRecursively);
|
|
17005
|
+
context.brokenFlow = brokenFlow;
|
|
16730
17006
|
}
|
|
17007
|
+
this.finalizer?.include(context, includeChildrenRecursively);
|
|
16731
17008
|
}
|
|
16732
|
-
return singleSystemExport;
|
|
16733
17009
|
}
|
|
16734
|
-
|
|
16735
|
-
|
|
17010
|
+
TryStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
17011
|
+
TryStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
16736
17012
|
|
|
16737
|
-
|
|
16738
|
-
|
|
16739
|
-
|
|
16740
|
-
|
|
16741
|
-
|
|
17013
|
+
const unaryOperators = {
|
|
17014
|
+
'!': value => !value,
|
|
17015
|
+
'+': value => +value,
|
|
17016
|
+
'-': value => -value,
|
|
17017
|
+
delete: () => UnknownValue,
|
|
17018
|
+
typeof: value => typeof value,
|
|
17019
|
+
void: () => undefined,
|
|
17020
|
+
'~': value => ~value
|
|
17021
|
+
};
|
|
17022
|
+
const UNASSIGNED = Symbol('Unassigned');
|
|
17023
|
+
class UnaryExpression extends NodeBase {
|
|
17024
|
+
constructor() {
|
|
17025
|
+
super(...arguments);
|
|
17026
|
+
this.renderedLiteralValue = UNASSIGNED;
|
|
16742
17027
|
}
|
|
16743
|
-
|
|
16744
|
-
this.
|
|
17028
|
+
get prefix() {
|
|
17029
|
+
return isFlagSet(this.flags, 2097152 /* Flag.prefix */);
|
|
17030
|
+
}
|
|
17031
|
+
set prefix(value) {
|
|
17032
|
+
this.flags = setFlag(this.flags, 2097152 /* Flag.prefix */, value);
|
|
16745
17033
|
}
|
|
16746
17034
|
deoptimizeCache() {
|
|
16747
|
-
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
|
|
17035
|
+
this.renderedLiteralValue = UnknownValue;
|
|
17036
|
+
}
|
|
17037
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
17038
|
+
if (path.length > 0)
|
|
17039
|
+
return UnknownValue;
|
|
17040
|
+
const argumentValue = this.argument.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin);
|
|
17041
|
+
if (typeof argumentValue === 'symbol') {
|
|
17042
|
+
if (this.operator === 'void')
|
|
17043
|
+
return undefined;
|
|
17044
|
+
if (this.operator === '!') {
|
|
17045
|
+
if (argumentValue === UnknownFalsyValue)
|
|
17046
|
+
return true;
|
|
17047
|
+
if (argumentValue === UnknownTruthyValue)
|
|
17048
|
+
return false;
|
|
17049
|
+
}
|
|
17050
|
+
return UnknownValue;
|
|
16752
17051
|
}
|
|
17052
|
+
return unaryOperators[this.operator](argumentValue);
|
|
16753
17053
|
}
|
|
16754
17054
|
hasEffects(context) {
|
|
16755
|
-
|
|
16756
|
-
|
|
16757
|
-
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
this.
|
|
16761
|
-
|
|
16762
|
-
.propertyReadSideEffects &&
|
|
16763
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
17055
|
+
if (!this.deoptimized)
|
|
17056
|
+
this.applyDeoptimizations();
|
|
17057
|
+
if (this.operator === 'typeof' && this.argument instanceof Identifier)
|
|
17058
|
+
return false;
|
|
17059
|
+
return (this.argument.hasEffects(context) ||
|
|
17060
|
+
(this.operator === 'delete' &&
|
|
17061
|
+
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)));
|
|
16764
17062
|
}
|
|
16765
|
-
|
|
16766
|
-
|
|
16767
|
-
|
|
16768
|
-
|
|
16769
|
-
|
|
16770
|
-
|
|
16771
|
-
|
|
16772
|
-
|
|
16773
|
-
}
|
|
16774
|
-
init?.include(context, includeChildrenRecursively);
|
|
16775
|
-
id.markDeclarationReached();
|
|
16776
|
-
if (includeChildrenRecursively) {
|
|
16777
|
-
id.include(context, includeChildrenRecursively);
|
|
16778
|
-
}
|
|
16779
|
-
else {
|
|
16780
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
17063
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
17064
|
+
return type !== INTERACTION_ACCESSED || path.length > (this.operator === 'void' ? 0 : 1);
|
|
17065
|
+
}
|
|
17066
|
+
applyDeoptimizations() {
|
|
17067
|
+
this.deoptimized = true;
|
|
17068
|
+
if (this.operator === 'delete') {
|
|
17069
|
+
this.argument.deoptimizePath(EMPTY_PATH);
|
|
17070
|
+
this.scope.context.requestTreeshakingPass();
|
|
16781
17071
|
}
|
|
16782
17072
|
}
|
|
16783
|
-
|
|
16784
|
-
this.
|
|
17073
|
+
getRenderedLiteralValue(includeChildrenRecursively) {
|
|
17074
|
+
if (this.renderedLiteralValue !== UNASSIGNED)
|
|
17075
|
+
return this.renderedLiteralValue;
|
|
17076
|
+
return (this.renderedLiteralValue = includeChildrenRecursively
|
|
17077
|
+
? UnknownValue
|
|
17078
|
+
: getRenderedLiteralValue(this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
17079
|
+
}
|
|
17080
|
+
include(context, includeChildrenRecursively, _options) {
|
|
17081
|
+
if (!this.deoptimized)
|
|
17082
|
+
this.applyDeoptimizations();
|
|
17083
|
+
this.included = true;
|
|
17084
|
+
// Check if the argument is an identifier that should be preserved as a reference for readability
|
|
17085
|
+
const shouldPreserveArgument = this.argument instanceof Identifier && this.argument.variable?.included;
|
|
17086
|
+
if (typeof this.getRenderedLiteralValue(includeChildrenRecursively) === 'symbol' ||
|
|
17087
|
+
this.argument.shouldBeIncluded(context) ||
|
|
17088
|
+
shouldPreserveArgument) {
|
|
17089
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
17090
|
+
this.renderedLiteralValue = UnknownValue;
|
|
17091
|
+
}
|
|
16785
17092
|
}
|
|
16786
17093
|
render(code, options) {
|
|
16787
|
-
|
|
16788
|
-
|
|
16789
|
-
const renderId = id.included || this.isUsingDeclaration || this.isAsyncUsingDeclaration;
|
|
16790
|
-
if (renderId) {
|
|
16791
|
-
id.render(code, options);
|
|
17094
|
+
if (typeof this.renderedLiteralValue === 'symbol') {
|
|
17095
|
+
super.render(code, options);
|
|
16792
17096
|
}
|
|
16793
17097
|
else {
|
|
16794
|
-
|
|
16795
|
-
|
|
16796
|
-
|
|
16797
|
-
if (init) {
|
|
16798
|
-
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
16799
|
-
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
16800
|
-
if (renderedVariable !== id.name) {
|
|
16801
|
-
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
16802
|
-
}
|
|
17098
|
+
let value = this.renderedLiteralValue;
|
|
17099
|
+
if (!CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE.test(code.original[this.start - 1])) {
|
|
17100
|
+
value = ` ${value}`;
|
|
16803
17101
|
}
|
|
16804
|
-
|
|
16805
|
-
}
|
|
16806
|
-
else if (id instanceof Identifier &&
|
|
16807
|
-
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
16808
|
-
code.appendLeft(end, `${_}=${_}void 0`);
|
|
17102
|
+
code.overwrite(this.start, this.end, value);
|
|
16809
17103
|
}
|
|
16810
17104
|
}
|
|
16811
|
-
|
|
16812
|
-
|
|
16813
|
-
|
|
16814
|
-
|
|
16815
|
-
|
|
16816
|
-
|
|
16817
|
-
|
|
16818
|
-
|
|
16819
|
-
|
|
16820
|
-
|
|
16821
|
-
|
|
16822
|
-
|
|
16823
|
-
|
|
16824
|
-
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
|
|
16829
|
-
|
|
16830
|
-
|
|
17105
|
+
}
|
|
17106
|
+
const CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE = /[\s([=%&*+-/<>^|,?:;]/;
|
|
17107
|
+
UnaryExpression.prototype.includeNode = onlyIncludeSelf;
|
|
17108
|
+
|
|
17109
|
+
class UpdateExpression extends NodeBase {
|
|
17110
|
+
hasEffects(context) {
|
|
17111
|
+
if (!this.deoptimized)
|
|
17112
|
+
this.applyDeoptimizations();
|
|
17113
|
+
return this.argument.hasEffectsAsAssignmentTarget(context, true);
|
|
17114
|
+
}
|
|
17115
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
17116
|
+
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
17117
|
+
}
|
|
17118
|
+
include(context, includeChildrenRecursively) {
|
|
17119
|
+
if (!this.included)
|
|
17120
|
+
this.includeNode(context);
|
|
17121
|
+
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
17122
|
+
}
|
|
17123
|
+
initialise() {
|
|
17124
|
+
super.initialise();
|
|
17125
|
+
this.argument.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
17126
|
+
}
|
|
17127
|
+
render(code, options) {
|
|
17128
|
+
const { exportNamesByVariable, format, snippets: { _ } } = options;
|
|
17129
|
+
this.argument.render(code, options);
|
|
17130
|
+
if (format === 'system') {
|
|
17131
|
+
const variable = this.argument.variable;
|
|
17132
|
+
const exportNames = exportNamesByVariable.get(variable);
|
|
17133
|
+
if (exportNames) {
|
|
17134
|
+
if (this.prefix) {
|
|
17135
|
+
if (exportNames.length === 1) {
|
|
17136
|
+
renderSystemExportExpression(variable, this.start, this.end, code, options);
|
|
17137
|
+
}
|
|
17138
|
+
else {
|
|
17139
|
+
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options);
|
|
16831
17140
|
}
|
|
16832
17141
|
}
|
|
17142
|
+
else {
|
|
17143
|
+
const operator = this.operator[0];
|
|
17144
|
+
renderSystemExportSequenceBeforeExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement$1, code, options, `${_}${operator}${_}1`);
|
|
17145
|
+
}
|
|
16833
17146
|
}
|
|
16834
17147
|
}
|
|
16835
17148
|
}
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
|
|
16842
|
-
if (disposalValue !== null && disposalValue !== undefined) {
|
|
16843
|
-
init.deoptimizeArgumentsOnInteractionAtPath(call, path, SHARED_RECURSION_TRACKER);
|
|
16844
|
-
init.includeCallArgumentsWhenCalledAtPath(path, call, context);
|
|
16845
|
-
}
|
|
16846
|
-
return false;
|
|
17149
|
+
applyDeoptimizations() {
|
|
17150
|
+
this.deoptimized = true;
|
|
17151
|
+
this.argument.deoptimizePath(EMPTY_PATH);
|
|
17152
|
+
if (this.argument instanceof Identifier) {
|
|
17153
|
+
const variable = this.scope.findVariable(this.argument.name);
|
|
17154
|
+
variable.markReassigned();
|
|
16847
17155
|
}
|
|
16848
|
-
this.
|
|
16849
|
-
this.disposalCall = call;
|
|
16850
|
-
disposalFunction.deoptimizeArgumentsOnInteractionAtPath(call, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
16851
|
-
return true;
|
|
17156
|
+
this.scope.context.requestTreeshakingPass();
|
|
16852
17157
|
}
|
|
16853
17158
|
}
|
|
16854
|
-
|
|
16855
|
-
const SYMBOL_DISPOSE_PATH = [SymbolDispose];
|
|
16856
|
-
const SYMBOL_ASYNC_DISPOSE_PATH = [SymbolAsyncDispose];
|
|
17159
|
+
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16857
17160
|
|
|
16858
17161
|
class WhileStatement extends NodeBase {
|
|
16859
17162
|
hasEffects(context) {
|
|
@@ -18252,13 +18555,15 @@ class Module {
|
|
|
18252
18555
|
code: null,
|
|
18253
18556
|
get dynamicallyImportedIdResolutions() {
|
|
18254
18557
|
return dynamicImports
|
|
18255
|
-
.map(({
|
|
18256
|
-
.filter(
|
|
18558
|
+
.map(({ resolution }) => resolution)
|
|
18559
|
+
.filter((resolution) => resolution !== null);
|
|
18257
18560
|
},
|
|
18258
18561
|
get dynamicallyImportedIds() {
|
|
18259
18562
|
// We cannot use this.dynamicDependencies because this is needed before
|
|
18260
18563
|
// dynamicDependencies are populated
|
|
18261
|
-
return dynamicImports
|
|
18564
|
+
return dynamicImports
|
|
18565
|
+
.map(({ resolution }) => resolution?.id)
|
|
18566
|
+
.filter((id) => id != null);
|
|
18262
18567
|
},
|
|
18263
18568
|
get dynamicImporters() {
|
|
18264
18569
|
return dynamicImporters.sort();
|
|
@@ -18817,7 +19122,7 @@ class Module {
|
|
|
18817
19122
|
typeof argument.value === 'string') {
|
|
18818
19123
|
argument = argument.value;
|
|
18819
19124
|
}
|
|
18820
|
-
this.dynamicImports.push({ argument,
|
|
19125
|
+
this.dynamicImports.push({ argument, node, resolution: null });
|
|
18821
19126
|
}
|
|
18822
19127
|
assertUniqueExportName(name, nodeStart) {
|
|
18823
19128
|
if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
|
|
@@ -20151,7 +20456,7 @@ class Chunk {
|
|
|
20151
20456
|
needsLiveBinding: (variable.isReassigned && this.exportNamesByVariable.get(variable).length > 1) ||
|
|
20152
20457
|
// Pattern bindings are plain locals; a trailing assignment
|
|
20153
20458
|
// would lose later reassignments.
|
|
20154
|
-
(variable.isTargetOfAssignment &&
|
|
20459
|
+
(variable.isTargetOfAssignment && cannotBeRenderedAsExportsMember(variable))
|
|
20155
20460
|
});
|
|
20156
20461
|
}
|
|
20157
20462
|
return exports;
|
|
@@ -20593,7 +20898,7 @@ class Chunk {
|
|
|
20593
20898
|
format !== 'system' &&
|
|
20594
20899
|
exportVariable.isReassigned &&
|
|
20595
20900
|
!exportVariable.isId &&
|
|
20596
|
-
!
|
|
20901
|
+
!cannotBeRenderedAsExportsMember(exportVariable)) {
|
|
20597
20902
|
exportVariable.setRenderNames('exports', unescapeExportName(exportName));
|
|
20598
20903
|
}
|
|
20599
20904
|
else if (exportVariable instanceof SyntheticNamedExportVariable) {
|
|
@@ -20679,10 +20984,27 @@ class Chunk {
|
|
|
20679
20984
|
function getChunkNameFromModule(module) {
|
|
20680
20985
|
return getPredefinedChunkNameFromModule(module) ?? getAliasName(module.id);
|
|
20681
20986
|
}
|
|
20987
|
+
function cannotBeRenderedAsExportsMember(variable) {
|
|
20988
|
+
return (isDeclaredInDestructuringPattern(variable) ||
|
|
20989
|
+
isDeclaredInMultiDeclaratorSingleStatement(variable));
|
|
20990
|
+
}
|
|
20682
20991
|
function isDeclaredInDestructuringPattern(variable) {
|
|
20683
20992
|
return (variable instanceof LocalVariable &&
|
|
20684
20993
|
variable.declarations.some(declaration => declaration instanceof Identifier && declaration.isDeclarationInDestructuringPattern()));
|
|
20685
20994
|
}
|
|
20995
|
+
function isDeclaredInMultiDeclaratorSingleStatement(variable) {
|
|
20996
|
+
return (variable instanceof LocalVariable &&
|
|
20997
|
+
variable.declarations.some(declaration => {
|
|
20998
|
+
const declarator = declaration.parent;
|
|
20999
|
+
if (!(declarator instanceof VariableDeclarator) || declarator.id !== declaration) {
|
|
21000
|
+
return false;
|
|
21001
|
+
}
|
|
21002
|
+
const declarationNode = declarator.parent;
|
|
21003
|
+
return (declarationNode instanceof VariableDeclaration &&
|
|
21004
|
+
declarationNode.declarations.length > 1 &&
|
|
21005
|
+
declarationNode.isInSingleStatementPosition());
|
|
21006
|
+
}));
|
|
21007
|
+
}
|
|
20686
21008
|
function getPredefinedChunkNameFromModule(module) {
|
|
20687
21009
|
return (module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? module.chunkNames[0]?.name);
|
|
20688
21010
|
}
|
|
@@ -22471,19 +22793,12 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
|
|
|
22471
22793
|
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes, importerAttributes);
|
|
22472
22794
|
if (pluginResult != null) {
|
|
22473
22795
|
const [resolveIdResult, plugin] = pluginResult;
|
|
22474
|
-
if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) {
|
|
22475
|
-
return {
|
|
22476
|
-
...resolveIdResult,
|
|
22477
|
-
resolvedBy: plugin.name
|
|
22478
|
-
};
|
|
22479
|
-
}
|
|
22480
22796
|
if (typeof resolveIdResult === 'string') {
|
|
22481
|
-
return {
|
|
22482
|
-
id: resolveIdResult,
|
|
22483
|
-
resolvedBy: plugin.name
|
|
22484
|
-
};
|
|
22797
|
+
return { id: resolveIdResult, resolvedBy: plugin.name };
|
|
22485
22798
|
}
|
|
22486
|
-
return resolveIdResult
|
|
22799
|
+
return typeof resolveIdResult === 'object'
|
|
22800
|
+
? withDefaultResolvedBy(resolveIdResult, plugin.name)
|
|
22801
|
+
: resolveIdResult;
|
|
22487
22802
|
}
|
|
22488
22803
|
// external modules (non-entry modules that start with neither '.' or '/')
|
|
22489
22804
|
// are skipped at this stage.
|
|
@@ -22517,6 +22832,11 @@ async function findFile(file, preserveSymlinks, fs) {
|
|
|
22517
22832
|
// suppress
|
|
22518
22833
|
}
|
|
22519
22834
|
}
|
|
22835
|
+
function withDefaultResolvedBy(resolution, pluginName) {
|
|
22836
|
+
return resolution.resolvedBy || !pluginName
|
|
22837
|
+
? resolution
|
|
22838
|
+
: { ...resolution, resolvedBy: pluginName };
|
|
22839
|
+
}
|
|
22520
22840
|
|
|
22521
22841
|
function stripBom(content) {
|
|
22522
22842
|
if (content.charCodeAt(0) === 0xfe_ff) {
|
|
@@ -23224,7 +23544,7 @@ class ModuleLoader {
|
|
|
23224
23544
|
}
|
|
23225
23545
|
else {
|
|
23226
23546
|
dynamicImport.node.shouldIncludeDynamicAttributes = !!resolvedId.external;
|
|
23227
|
-
dynamicImport.
|
|
23547
|
+
dynamicImport.resolution = resolvedId;
|
|
23228
23548
|
}
|
|
23229
23549
|
return [dynamicImport, resolvedId];
|
|
23230
23550
|
});
|
|
@@ -23312,11 +23632,13 @@ class ModuleLoader {
|
|
|
23312
23632
|
: { id: resolveIdResult }, EMPTY_OBJECT), undefined, isEntry, false);
|
|
23313
23633
|
}
|
|
23314
23634
|
async resolveDynamicImport(module, specifier, importer, attributes) {
|
|
23315
|
-
const
|
|
23635
|
+
const pluginResult = await this.pluginDriver.hookFirstAndGetPlugin('resolveDynamicImport', [
|
|
23316
23636
|
specifier,
|
|
23317
23637
|
importer,
|
|
23318
23638
|
{ attributes, importerAttributes: module.info.attributes }
|
|
23319
23639
|
]);
|
|
23640
|
+
const resolution = pluginResult && pluginResult[0];
|
|
23641
|
+
const resolvedBy = resolution ? pluginResult[1].name : undefined;
|
|
23320
23642
|
if (typeof specifier !== 'string') {
|
|
23321
23643
|
if (typeof resolution === 'string') {
|
|
23322
23644
|
return resolution;
|
|
@@ -23324,7 +23646,7 @@ class ModuleLoader {
|
|
|
23324
23646
|
if (!resolution) {
|
|
23325
23647
|
return null;
|
|
23326
23648
|
}
|
|
23327
|
-
return this.getResolvedIdWithDefaults(resolution, attributes);
|
|
23649
|
+
return this.getResolvedIdWithDefaults(withDefaultResolvedBy(resolution, resolvedBy), attributes);
|
|
23328
23650
|
}
|
|
23329
23651
|
if (resolution == null) {
|
|
23330
23652
|
const existingResolution = module.resolvedIds[specifier];
|
|
@@ -23336,7 +23658,8 @@ class ModuleLoader {
|
|
|
23336
23658
|
}
|
|
23337
23659
|
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, attributes, module.info.attributes), specifier, module.id, attributes));
|
|
23338
23660
|
}
|
|
23339
|
-
|
|
23661
|
+
const normalizedResolution = this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier);
|
|
23662
|
+
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(normalizedResolution && withDefaultResolvedBy(normalizedResolution, resolvedBy), attributes), specifier, importer, attributes);
|
|
23340
23663
|
}
|
|
23341
23664
|
}
|
|
23342
23665
|
function normalizeRelativeExternalId(source, importer) {
|