rollup 4.63.0 → 4.63.1
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 +174 -229
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +54 -6
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +54 -6
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +173 -228
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +33 -33
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.63.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.63.1
|
|
4
|
+
Fri, 28 Aug 2026 05:58:50 GMT - commit 78bfef0cb94479566f81012fafa372c84b90bd34
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, Identifier as Identifier$1, FunctionExpression as FunctionExpression$1, ArrowFunctionExpression as ArrowFunctionExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1,
|
|
10
|
+
import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, Identifier as Identifier$1, FunctionExpression as FunctionExpression$1, ArrowFunctionExpression as ArrowFunctionExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, logMissingExport, normalize, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, RestElement as RestElement$1, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logMissingEntryExport, logSyntheticNamedExportsNeedNamespaceExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logInvalidFormatForTopLevelAwait, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, URL_LOAD, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1, join } from 'node:path';
|
|
12
12
|
import { posix, isAbsolute, resolve, win32 } from 'path';
|
|
13
13
|
import { parseAsync, xxhashBase16, xxhashBase64Url, xxhashBase36 } from '../../native.js';
|
|
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.63.
|
|
30
|
+
var version = "4.63.1";
|
|
31
31
|
const pkg = {
|
|
32
32
|
version: version};
|
|
33
33
|
|
|
@@ -2073,17 +2073,8 @@ class ExpressionEntity {
|
|
|
2073
2073
|
return true;
|
|
2074
2074
|
}
|
|
2075
2075
|
}
|
|
2076
|
-
class
|
|
2077
|
-
|
|
2078
|
-
super();
|
|
2079
|
-
this.value = value;
|
|
2080
|
-
this.parent = parent;
|
|
2081
|
-
}
|
|
2082
|
-
getLiteralValueAtPath(path) {
|
|
2083
|
-
return path.length > 0 ? UnknownValue : this.value;
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
const UNKNOWN_EXPRESSION = new LiteralExpression(UnknownValue);
|
|
2076
|
+
const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
|
|
2077
|
+
})();
|
|
2087
2078
|
const UNKNOWN_RETURN_EXPRESSION = [
|
|
2088
2079
|
UNKNOWN_EXPRESSION,
|
|
2089
2080
|
false
|
|
@@ -2815,7 +2806,11 @@ function isExpressionStatementNode(node) {
|
|
|
2815
2806
|
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
2816
2807
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2817
2808
|
}
|
|
2818
|
-
const UNDEFINED_EXPRESSION = new
|
|
2809
|
+
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2810
|
+
getLiteralValueAtPath(path) {
|
|
2811
|
+
return path.length > 0 ? UnknownValue : undefined;
|
|
2812
|
+
}
|
|
2813
|
+
})();
|
|
2819
2814
|
const returnsUnknown = {
|
|
2820
2815
|
value: {
|
|
2821
2816
|
hasEffectsWhenCalled: null,
|
|
@@ -2996,7 +2991,7 @@ function getLiteralMembersForValue(value) {
|
|
|
2996
2991
|
return literalStringMembers;
|
|
2997
2992
|
}
|
|
2998
2993
|
}
|
|
2999
|
-
return
|
|
2994
|
+
return Object.create(null);
|
|
3000
2995
|
}
|
|
3001
2996
|
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
3002
2997
|
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
@@ -3296,8 +3291,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3296
3291
|
// causes an issue with TypeScript enums in files with moduleSideEffects:
|
|
3297
3292
|
// false because we cannot properly track whether a "var" has been
|
|
3298
3293
|
// initialized. This should be reverted once we can properly track this.
|
|
3299
|
-
// ALSO needs to be updated once this is resolved:
|
|
3300
|
-
// - literals-from-return-expressions-branches/main.js
|
|
3301
3294
|
// return UnknownTruthyValue;
|
|
3302
3295
|
return UnknownValue;
|
|
3303
3296
|
}
|
|
@@ -6010,156 +6003,6 @@ class ThisVariable extends ParameterVariable {
|
|
|
6010
6003
|
}
|
|
6011
6004
|
}
|
|
6012
6005
|
|
|
6013
|
-
const UNASSIGNED = Symbol('unassigned');
|
|
6014
|
-
|
|
6015
|
-
class ReturnStatement extends NodeBase {
|
|
6016
|
-
constructor() {
|
|
6017
|
-
super(...arguments);
|
|
6018
|
-
this.expressionsToBeDeoptimized = [];
|
|
6019
|
-
}
|
|
6020
|
-
checkReached(origin) {
|
|
6021
|
-
if (this.deoptimized)
|
|
6022
|
-
return true;
|
|
6023
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
6024
|
-
return false;
|
|
6025
|
-
}
|
|
6026
|
-
applyDeoptimizations() {
|
|
6027
|
-
this.deoptimized = true;
|
|
6028
|
-
const { expressionsToBeDeoptimized } = this;
|
|
6029
|
-
if (expressionsToBeDeoptimized.length) {
|
|
6030
|
-
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
6031
|
-
for (const expression of expressionsToBeDeoptimized) {
|
|
6032
|
-
expression.deoptimizeCache();
|
|
6033
|
-
}
|
|
6034
|
-
this.scope.context.requestTreeshakingPass();
|
|
6035
|
-
}
|
|
6036
|
-
}
|
|
6037
|
-
hasEffects(context) {
|
|
6038
|
-
if (!this.deoptimized)
|
|
6039
|
-
this.applyDeoptimizations();
|
|
6040
|
-
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
6041
|
-
return true;
|
|
6042
|
-
context.brokenFlow = true;
|
|
6043
|
-
return false;
|
|
6044
|
-
}
|
|
6045
|
-
include(context, includeChildrenRecursively) {
|
|
6046
|
-
if (!this.included)
|
|
6047
|
-
this.includeNode(context);
|
|
6048
|
-
this.argument?.include(context, includeChildrenRecursively);
|
|
6049
|
-
context.brokenFlow = true;
|
|
6050
|
-
}
|
|
6051
|
-
includeNode(context) {
|
|
6052
|
-
this.included = true;
|
|
6053
|
-
if (!this.deoptimized)
|
|
6054
|
-
this.applyDeoptimizations();
|
|
6055
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
6056
|
-
}
|
|
6057
|
-
initialise() {
|
|
6058
|
-
super.initialise();
|
|
6059
|
-
this.scope.addReturnExpression(this.argument || new LiteralExpression(undefined, this));
|
|
6060
|
-
}
|
|
6061
|
-
render(code, options) {
|
|
6062
|
-
if (this.argument) {
|
|
6063
|
-
this.argument.render(code, options, { preventASI: true });
|
|
6064
|
-
if (this.argument.start === this.start + 6 /* 'return'.length */) {
|
|
6065
|
-
code.prependLeft(this.start + 6, ' ');
|
|
6066
|
-
}
|
|
6067
|
-
}
|
|
6068
|
-
}
|
|
6069
|
-
}
|
|
6070
|
-
|
|
6071
|
-
function mergeValues(a, b) {
|
|
6072
|
-
if (a === b)
|
|
6073
|
-
return a;
|
|
6074
|
-
if (a === UnknownTruthyValue) {
|
|
6075
|
-
if (b && b !== UnknownFalsyValue)
|
|
6076
|
-
return UnknownTruthyValue;
|
|
6077
|
-
return UnknownValue;
|
|
6078
|
-
}
|
|
6079
|
-
if (a === UnknownFalsyValue) {
|
|
6080
|
-
if (!b || b === UnknownFalsyValue)
|
|
6081
|
-
return UnknownFalsyValue;
|
|
6082
|
-
return UnknownValue;
|
|
6083
|
-
}
|
|
6084
|
-
if (a && b)
|
|
6085
|
-
return UnknownTruthyValue;
|
|
6086
|
-
if (!a && !b)
|
|
6087
|
-
return UnknownFalsyValue;
|
|
6088
|
-
return UnknownValue;
|
|
6089
|
-
}
|
|
6090
|
-
class MultiExpression extends ExpressionEntity {
|
|
6091
|
-
constructor(expressions) {
|
|
6092
|
-
super();
|
|
6093
|
-
this.expressions = expressions;
|
|
6094
|
-
this.literalValue = UNASSIGNED;
|
|
6095
|
-
this.dependantEntities = new Set();
|
|
6096
|
-
}
|
|
6097
|
-
deoptimizeCache() {
|
|
6098
|
-
if (this.literalValue !== UNASSIGNED) {
|
|
6099
|
-
const { dependantEntities } = this;
|
|
6100
|
-
this.literalValue = UNASSIGNED;
|
|
6101
|
-
this.dependantEntities = new Set();
|
|
6102
|
-
for (const entity of dependantEntities) {
|
|
6103
|
-
entity.deoptimizeCache();
|
|
6104
|
-
}
|
|
6105
|
-
}
|
|
6106
|
-
}
|
|
6107
|
-
deoptimizePath(path) {
|
|
6108
|
-
for (const expression of this.expressions) {
|
|
6109
|
-
expression.deoptimizePath(path);
|
|
6110
|
-
}
|
|
6111
|
-
}
|
|
6112
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6113
|
-
if (path.length === 0) {
|
|
6114
|
-
if (this.literalValue === UNASSIGNED)
|
|
6115
|
-
this.literalValue = this.doGetLiteralValueAtPath(path, recursionTracker, this);
|
|
6116
|
-
this.dependantEntities.add(origin);
|
|
6117
|
-
return this.literalValue;
|
|
6118
|
-
}
|
|
6119
|
-
return this.doGetLiteralValueAtPath(path, recursionTracker, origin);
|
|
6120
|
-
}
|
|
6121
|
-
doGetLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6122
|
-
let value = UnknownValue;
|
|
6123
|
-
for (const expression of this.expressions) {
|
|
6124
|
-
if (this.isTreeshaken(expression))
|
|
6125
|
-
continue;
|
|
6126
|
-
const expressionValue = expression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6127
|
-
if (expressionValue === UnknownValue)
|
|
6128
|
-
return UnknownValue;
|
|
6129
|
-
if (value === UnknownValue) {
|
|
6130
|
-
value = expressionValue;
|
|
6131
|
-
continue;
|
|
6132
|
-
}
|
|
6133
|
-
value = mergeValues(value, expressionValue);
|
|
6134
|
-
if (value === UnknownValue)
|
|
6135
|
-
return UnknownValue;
|
|
6136
|
-
}
|
|
6137
|
-
return value;
|
|
6138
|
-
}
|
|
6139
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6140
|
-
const returnExpressions = this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin));
|
|
6141
|
-
let pure = true;
|
|
6142
|
-
return [
|
|
6143
|
-
new MultiExpression(returnExpressions.map(expression => ((pure &&= expression[1]), expression[0]))),
|
|
6144
|
-
pure
|
|
6145
|
-
];
|
|
6146
|
-
}
|
|
6147
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6148
|
-
for (const expression of this.expressions) {
|
|
6149
|
-
if (!this.isTreeshaken(expression) &&
|
|
6150
|
-
expression.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
6151
|
-
return true;
|
|
6152
|
-
}
|
|
6153
|
-
return false;
|
|
6154
|
-
}
|
|
6155
|
-
isTreeshaken(expression) {
|
|
6156
|
-
if ('parent' in expression && expression.parent instanceof ReturnStatement) {
|
|
6157
|
-
return !expression.parent.checkReached(this);
|
|
6158
|
-
}
|
|
6159
|
-
return false;
|
|
6160
|
-
}
|
|
6161
|
-
}
|
|
6162
|
-
|
|
6163
6006
|
class CatchBodyScope extends ChildScope {
|
|
6164
6007
|
constructor(parent) {
|
|
6165
6008
|
super(parent, parent.context);
|
|
@@ -6369,12 +6212,8 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6369
6212
|
}
|
|
6370
6213
|
}
|
|
6371
6214
|
getReturnExpression() {
|
|
6372
|
-
if (
|
|
6373
|
-
this.
|
|
6374
|
-
this.returnExpressions.length === 1
|
|
6375
|
-
? this.returnExpressions[0]
|
|
6376
|
-
: new MultiExpression(this.returnExpressions);
|
|
6377
|
-
}
|
|
6215
|
+
if (this.returnExpression === null)
|
|
6216
|
+
this.updateReturnExpression();
|
|
6378
6217
|
return this.returnExpression;
|
|
6379
6218
|
}
|
|
6380
6219
|
deoptimizeAllParameters() {
|
|
@@ -6393,6 +6232,17 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6393
6232
|
}
|
|
6394
6233
|
}
|
|
6395
6234
|
addArgumentToBeDeoptimized(_argument) { }
|
|
6235
|
+
updateReturnExpression() {
|
|
6236
|
+
if (this.returnExpressions.length === 1) {
|
|
6237
|
+
this.returnExpression = this.returnExpressions[0];
|
|
6238
|
+
}
|
|
6239
|
+
else {
|
|
6240
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
6241
|
+
for (const expression of this.returnExpressions) {
|
|
6242
|
+
expression.deoptimizePath(UNKNOWN_PATH);
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6396
6246
|
}
|
|
6397
6247
|
|
|
6398
6248
|
class FunctionScope extends ReturnValueScope {
|
|
@@ -6454,10 +6304,6 @@ ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
|
6454
6304
|
ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6455
6305
|
|
|
6456
6306
|
class BlockStatement extends NodeBase {
|
|
6457
|
-
constructor() {
|
|
6458
|
-
super(...arguments);
|
|
6459
|
-
this.virtualReturnStatement = null;
|
|
6460
|
-
}
|
|
6461
6307
|
get deoptimizeBody() {
|
|
6462
6308
|
return isFlagSet(this.flags, 32768 /* Flag.deoptimizeBody */);
|
|
6463
6309
|
}
|
|
@@ -6473,13 +6319,7 @@ class BlockStatement extends NodeBase {
|
|
|
6473
6319
|
addImplicitReturnExpressionToScope() {
|
|
6474
6320
|
const lastStatement = this.body[this.body.length - 1];
|
|
6475
6321
|
if (!lastStatement || lastStatement.type !== ReturnStatement$1) {
|
|
6476
|
-
|
|
6477
|
-
virtualReturnStatement.type = ReturnStatement$1;
|
|
6478
|
-
virtualReturnStatement.argument = null;
|
|
6479
|
-
virtualReturnStatement.initialise();
|
|
6480
|
-
if (this.deoptimizeBody)
|
|
6481
|
-
virtualReturnStatement.includeNode(createInclusionContext());
|
|
6482
|
-
this.virtualReturnStatement = virtualReturnStatement;
|
|
6322
|
+
this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
|
|
6483
6323
|
}
|
|
6484
6324
|
}
|
|
6485
6325
|
createScope(parentScope) {
|
|
@@ -6490,15 +6330,13 @@ class BlockStatement extends NodeBase {
|
|
|
6490
6330
|
hasEffects(context) {
|
|
6491
6331
|
if (this.deoptimizeBody)
|
|
6492
6332
|
return true;
|
|
6493
|
-
let hasEffect = false;
|
|
6494
6333
|
for (const node of this.body) {
|
|
6495
|
-
if (context.brokenFlow
|
|
6334
|
+
if (context.brokenFlow)
|
|
6496
6335
|
break;
|
|
6336
|
+
if (node.hasEffects(context))
|
|
6337
|
+
return true;
|
|
6497
6338
|
}
|
|
6498
|
-
|
|
6499
|
-
hasEffect ||= !!this.virtualReturnStatement?.hasEffects(context);
|
|
6500
|
-
}
|
|
6501
|
-
return hasEffect;
|
|
6339
|
+
return false;
|
|
6502
6340
|
}
|
|
6503
6341
|
include(context, includeChildrenRecursively) {
|
|
6504
6342
|
if (!(this.deoptimizeBody && this.directlyIncluded)) {
|
|
@@ -6510,8 +6348,6 @@ class BlockStatement extends NodeBase {
|
|
|
6510
6348
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
6511
6349
|
node.include(context, includeChildrenRecursively);
|
|
6512
6350
|
}
|
|
6513
|
-
if (includeChildrenRecursively || !context.brokenFlow)
|
|
6514
|
-
this.virtualReturnStatement?.include(context, includeChildrenRecursively);
|
|
6515
6351
|
}
|
|
6516
6352
|
}
|
|
6517
6353
|
initialise() {
|
|
@@ -7524,7 +7360,7 @@ class MemberExpression extends NodeBase {
|
|
|
7524
7360
|
if (!this.included)
|
|
7525
7361
|
this.includeNode(context);
|
|
7526
7362
|
if (this.variable) {
|
|
7527
|
-
this.variable
|
|
7363
|
+
this.variable?.includePath(path, context);
|
|
7528
7364
|
}
|
|
7529
7365
|
else if (!this.isUndefined) {
|
|
7530
7366
|
this.object.includePath([
|
|
@@ -9472,7 +9308,7 @@ function requireScan () {
|
|
|
9472
9308
|
const opts = options || {};
|
|
9473
9309
|
|
|
9474
9310
|
const length = input.length - 1;
|
|
9475
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
9311
|
+
const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
|
|
9476
9312
|
const slashes = [];
|
|
9477
9313
|
const tokens = [];
|
|
9478
9314
|
const parts = [];
|
|
@@ -9606,15 +9442,21 @@ function requireScan () {
|
|
|
9606
9442
|
}
|
|
9607
9443
|
|
|
9608
9444
|
if (scanToEnd === true) {
|
|
9445
|
+
let parens = 0;
|
|
9446
|
+
|
|
9609
9447
|
while (eos() !== true && (code = advance())) {
|
|
9610
9448
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
9611
9449
|
backslashes = token.backslashes = true;
|
|
9612
|
-
|
|
9450
|
+
advance();
|
|
9451
|
+
continue;
|
|
9452
|
+
}
|
|
9453
|
+
|
|
9454
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
9455
|
+
parens++;
|
|
9613
9456
|
continue;
|
|
9614
9457
|
}
|
|
9615
9458
|
|
|
9616
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
9617
|
-
isGlob = token.isGlob = true;
|
|
9459
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
9618
9460
|
finished = true;
|
|
9619
9461
|
break;
|
|
9620
9462
|
}
|
|
@@ -9679,14 +9521,21 @@ function requireScan () {
|
|
|
9679
9521
|
isGlob = token.isGlob = true;
|
|
9680
9522
|
|
|
9681
9523
|
if (scanToEnd === true) {
|
|
9524
|
+
let parens = 1;
|
|
9525
|
+
|
|
9682
9526
|
while (eos() !== true && (code = advance())) {
|
|
9683
|
-
if (code ===
|
|
9527
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
9684
9528
|
backslashes = token.backslashes = true;
|
|
9685
|
-
|
|
9529
|
+
advance();
|
|
9686
9530
|
continue;
|
|
9687
9531
|
}
|
|
9688
9532
|
|
|
9689
|
-
if (code ===
|
|
9533
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
9534
|
+
parens++;
|
|
9535
|
+
continue;
|
|
9536
|
+
}
|
|
9537
|
+
|
|
9538
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
9690
9539
|
finished = true;
|
|
9691
9540
|
break;
|
|
9692
9541
|
}
|
|
@@ -9773,7 +9622,7 @@ function requireScan () {
|
|
|
9773
9622
|
let prevIndex;
|
|
9774
9623
|
|
|
9775
9624
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
9776
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
9625
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
9777
9626
|
const i = slashes[idx];
|
|
9778
9627
|
const value = input.slice(n, i);
|
|
9779
9628
|
if (opts.tokens) {
|
|
@@ -9786,21 +9635,20 @@ function requireScan () {
|
|
|
9786
9635
|
depth(tokens[idx]);
|
|
9787
9636
|
state.maxDepth += tokens[idx].depth;
|
|
9788
9637
|
}
|
|
9789
|
-
if (
|
|
9638
|
+
if (i >= start) {
|
|
9790
9639
|
parts.push(value);
|
|
9640
|
+
prevIndex = i;
|
|
9791
9641
|
}
|
|
9792
|
-
prevIndex = i;
|
|
9793
9642
|
}
|
|
9794
9643
|
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9644
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
9645
|
+
const value = input.slice(n);
|
|
9646
|
+
parts.push(value);
|
|
9798
9647
|
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
}
|
|
9648
|
+
if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
|
|
9649
|
+
tokens[tokens.length - 1].value = value;
|
|
9650
|
+
depth(tokens[tokens.length - 1]);
|
|
9651
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
9804
9652
|
}
|
|
9805
9653
|
|
|
9806
9654
|
state.slashes = slashes;
|
|
@@ -10351,9 +10199,33 @@ function requireParse () {
|
|
|
10351
10199
|
};
|
|
10352
10200
|
|
|
10353
10201
|
const extglobClose = token => {
|
|
10354
|
-
input.slice(token.startIndex, state.index + 1);
|
|
10202
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
10355
10203
|
const body = input.slice(token.startIndex + 2, state.index);
|
|
10356
|
-
analyzeRepeatedExtglob(body, opts);
|
|
10204
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
10205
|
+
|
|
10206
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
10207
|
+
const safeOutput = analysis.safeOutput
|
|
10208
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
10209
|
+
: undefined;
|
|
10210
|
+
const open = tokens[token.tokensIndex];
|
|
10211
|
+
|
|
10212
|
+
open.type = 'text';
|
|
10213
|
+
open.value = literal;
|
|
10214
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
10215
|
+
|
|
10216
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
10217
|
+
tokens[i].value = '';
|
|
10218
|
+
tokens[i].output = '';
|
|
10219
|
+
delete tokens[i].suffix;
|
|
10220
|
+
}
|
|
10221
|
+
|
|
10222
|
+
state.output = token.output + open.output;
|
|
10223
|
+
state.backtrack = true;
|
|
10224
|
+
|
|
10225
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
10226
|
+
decrement('parens');
|
|
10227
|
+
return;
|
|
10228
|
+
}
|
|
10357
10229
|
|
|
10358
10230
|
let output = token.close + (opts.capture ? ')' : '');
|
|
10359
10231
|
let rest;
|
|
@@ -10965,6 +10837,15 @@ function requireParse () {
|
|
|
10965
10837
|
consume('/**', 3);
|
|
10966
10838
|
}
|
|
10967
10839
|
|
|
10840
|
+
// A globstar followed only by balanced closing parens is at the logical end of patterns like
|
|
10841
|
+
// `test(/utils/**)` and `test?(/utils/**)`. Treat it as EOS so the trailing `/**` can match its
|
|
10842
|
+
// parent path, except in negated extglobs where that would change the exclusion semantics.
|
|
10843
|
+
const isEnd = eos() || (
|
|
10844
|
+
state.parens > 0
|
|
10845
|
+
&& rest === ')'.repeat(state.parens)
|
|
10846
|
+
&& !extglobs.some(extglob => extglob.type === 'negate')
|
|
10847
|
+
);
|
|
10848
|
+
|
|
10968
10849
|
if (prior.type === 'bos' && eos()) {
|
|
10969
10850
|
prev.type = 'globstar';
|
|
10970
10851
|
prev.value += value;
|
|
@@ -10975,7 +10856,7 @@ function requireParse () {
|
|
|
10975
10856
|
continue;
|
|
10976
10857
|
}
|
|
10977
10858
|
|
|
10978
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar &&
|
|
10859
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && isEnd) {
|
|
10979
10860
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
10980
10861
|
prior.output = `(?:${prior.output}`;
|
|
10981
10862
|
|
|
@@ -12230,10 +12111,11 @@ const binaryOperators = {
|
|
|
12230
12111
|
// in: () => UnknownValue,
|
|
12231
12112
|
// instanceof: () => UnknownValue,
|
|
12232
12113
|
};
|
|
12114
|
+
const UNASSIGNED$1 = Symbol('Unassigned');
|
|
12233
12115
|
class BinaryExpression extends NodeBase {
|
|
12234
12116
|
constructor() {
|
|
12235
12117
|
super(...arguments);
|
|
12236
|
-
this.renderedLiteralValue = UNASSIGNED;
|
|
12118
|
+
this.renderedLiteralValue = UNASSIGNED$1;
|
|
12237
12119
|
}
|
|
12238
12120
|
deoptimizeCache() {
|
|
12239
12121
|
this.renderedLiteralValue = UnknownValue;
|
|
@@ -12266,7 +12148,7 @@ class BinaryExpression extends NodeBase {
|
|
|
12266
12148
|
if (this.operator !== 'in' || !(this.right.variable instanceof NamespaceVariable)) {
|
|
12267
12149
|
return UnknownValue;
|
|
12268
12150
|
}
|
|
12269
|
-
if (this.renderedLiteralValue !== UNASSIGNED)
|
|
12151
|
+
if (this.renderedLiteralValue !== UNASSIGNED$1)
|
|
12270
12152
|
return this.renderedLiteralValue;
|
|
12271
12153
|
return (this.renderedLiteralValue = getRenderedLiteralValue(this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
12272
12154
|
}
|
|
@@ -12401,10 +12283,10 @@ class CallExpressionBase extends NodeBase {
|
|
|
12401
12283
|
}
|
|
12402
12284
|
deoptimizeCache() {
|
|
12403
12285
|
if (this.returnExpression?.[0] !== UNKNOWN_EXPRESSION) {
|
|
12404
|
-
this.returnExpression =
|
|
12286
|
+
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
12405
12287
|
const { deoptimizableDependentExpressions, expressionsToBeDeoptimized } = this;
|
|
12406
|
-
this.expressionsToBeDeoptimized =
|
|
12407
|
-
this.deoptimizableDependentExpressions =
|
|
12288
|
+
this.expressionsToBeDeoptimized = EMPTY_SET;
|
|
12289
|
+
this.deoptimizableDependentExpressions = EMPTY_ARRAY;
|
|
12408
12290
|
for (const expression of deoptimizableDependentExpressions) {
|
|
12409
12291
|
expression.deoptimizeCache();
|
|
12410
12292
|
}
|
|
@@ -12430,7 +12312,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
12430
12312
|
}
|
|
12431
12313
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
12432
12314
|
this.deoptimizableDependentExpressions.push(origin);
|
|
12433
|
-
return returnExpression.getLiteralValueAtPath(path, recursionTracker,
|
|
12315
|
+
return returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
12434
12316
|
}, UnknownValue);
|
|
12435
12317
|
}
|
|
12436
12318
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -12542,6 +12424,11 @@ class CallExpression extends CallExpressionBase {
|
|
|
12542
12424
|
this.callee.includeCallArguments(this.interaction, context);
|
|
12543
12425
|
}
|
|
12544
12426
|
}
|
|
12427
|
+
includeNode(_context) {
|
|
12428
|
+
this.included = true;
|
|
12429
|
+
if (!this.deoptimized)
|
|
12430
|
+
this.applyDeoptimizations();
|
|
12431
|
+
}
|
|
12545
12432
|
initialise() {
|
|
12546
12433
|
super.initialise();
|
|
12547
12434
|
if (this.annotations &&
|
|
@@ -12573,13 +12460,12 @@ class CallExpression extends CallExpressionBase {
|
|
|
12573
12460
|
}
|
|
12574
12461
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
12575
12462
|
if (this.returnExpression === null) {
|
|
12576
|
-
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
12577
|
-
this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this);
|
|
12463
|
+
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
12464
|
+
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
12578
12465
|
}
|
|
12579
12466
|
return this.returnExpression;
|
|
12580
12467
|
}
|
|
12581
12468
|
}
|
|
12582
|
-
CallExpression.prototype.includeNode = onlyIncludeSelf;
|
|
12583
12469
|
|
|
12584
12470
|
class CatchClause extends NodeBase {
|
|
12585
12471
|
createScope(parentScope) {
|
|
@@ -12679,6 +12565,31 @@ function tryCastLiteralValueToBoolean(literalValue) {
|
|
|
12679
12565
|
return !!literalValue;
|
|
12680
12566
|
}
|
|
12681
12567
|
|
|
12568
|
+
class MultiExpression extends ExpressionEntity {
|
|
12569
|
+
constructor(expressions) {
|
|
12570
|
+
super();
|
|
12571
|
+
this.expressions = expressions;
|
|
12572
|
+
}
|
|
12573
|
+
deoptimizePath(path) {
|
|
12574
|
+
for (const expression of this.expressions) {
|
|
12575
|
+
expression.deoptimizePath(path);
|
|
12576
|
+
}
|
|
12577
|
+
}
|
|
12578
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
12579
|
+
return [
|
|
12580
|
+
new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0])),
|
|
12581
|
+
false
|
|
12582
|
+
];
|
|
12583
|
+
}
|
|
12584
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
12585
|
+
for (const expression of this.expressions) {
|
|
12586
|
+
if (expression.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
12587
|
+
return true;
|
|
12588
|
+
}
|
|
12589
|
+
return false;
|
|
12590
|
+
}
|
|
12591
|
+
}
|
|
12592
|
+
|
|
12682
12593
|
class ConditionalExpression extends NodeBase {
|
|
12683
12594
|
constructor() {
|
|
12684
12595
|
super(...arguments);
|
|
@@ -13182,13 +13093,14 @@ class TrackingScope extends BlockScope {
|
|
|
13182
13093
|
}
|
|
13183
13094
|
}
|
|
13184
13095
|
|
|
13096
|
+
const unset = Symbol('unset');
|
|
13185
13097
|
class IfStatement extends NodeBase {
|
|
13186
13098
|
constructor() {
|
|
13187
13099
|
super(...arguments);
|
|
13188
|
-
this.testValue =
|
|
13100
|
+
this.testValue = unset;
|
|
13189
13101
|
}
|
|
13190
13102
|
deoptimizeCache() {
|
|
13191
|
-
this.testValue =
|
|
13103
|
+
this.testValue = UnknownValue;
|
|
13192
13104
|
}
|
|
13193
13105
|
hasEffects(context) {
|
|
13194
13106
|
if (this.test.hasEffects(context)) {
|
|
@@ -13277,8 +13189,8 @@ class IfStatement extends NodeBase {
|
|
|
13277
13189
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
13278
13190
|
}
|
|
13279
13191
|
getTestValue() {
|
|
13280
|
-
if (this.testValue ===
|
|
13281
|
-
this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
13192
|
+
if (this.testValue === unset) {
|
|
13193
|
+
return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
13282
13194
|
}
|
|
13283
13195
|
return this.testValue;
|
|
13284
13196
|
}
|
|
@@ -14932,6 +14844,38 @@ class PropertyDefinition extends NodeBase {
|
|
|
14932
14844
|
}
|
|
14933
14845
|
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14934
14846
|
|
|
14847
|
+
class ReturnStatement extends NodeBase {
|
|
14848
|
+
hasEffects(context) {
|
|
14849
|
+
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
14850
|
+
return true;
|
|
14851
|
+
context.brokenFlow = true;
|
|
14852
|
+
return false;
|
|
14853
|
+
}
|
|
14854
|
+
include(context, includeChildrenRecursively) {
|
|
14855
|
+
if (!this.included)
|
|
14856
|
+
this.includeNode(context);
|
|
14857
|
+
this.argument?.include(context, includeChildrenRecursively);
|
|
14858
|
+
context.brokenFlow = true;
|
|
14859
|
+
}
|
|
14860
|
+
includeNode(context) {
|
|
14861
|
+
this.included = true;
|
|
14862
|
+
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
14863
|
+
}
|
|
14864
|
+
initialise() {
|
|
14865
|
+
super.initialise();
|
|
14866
|
+
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
14867
|
+
}
|
|
14868
|
+
render(code, options) {
|
|
14869
|
+
if (this.argument) {
|
|
14870
|
+
this.argument.render(code, options, { preventASI: true });
|
|
14871
|
+
if (this.argument.start === this.start + 6 /* 'return'.length */) {
|
|
14872
|
+
code.prependLeft(this.start + 6, ' ');
|
|
14873
|
+
}
|
|
14874
|
+
}
|
|
14875
|
+
}
|
|
14876
|
+
}
|
|
14877
|
+
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14878
|
+
|
|
14935
14879
|
class SequenceExpression extends NodeBase {
|
|
14936
14880
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
14937
14881
|
this.expressions[this.expressions.length - 1].deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -15455,6 +15399,7 @@ const unaryOperators = {
|
|
|
15455
15399
|
void: () => undefined,
|
|
15456
15400
|
'~': value => ~value
|
|
15457
15401
|
};
|
|
15402
|
+
const UNASSIGNED = Symbol('Unassigned');
|
|
15458
15403
|
class UnaryExpression extends NodeBase {
|
|
15459
15404
|
constructor() {
|
|
15460
15405
|
super(...arguments);
|