rollup 4.16.3 → 4.16.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 +4 -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 +30 -258
- package/dist/es/shared/parseAst.js +7 -9
- 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/parseAst.js +6 -10
- package/dist/shared/rollup.js +29 -257
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +17 -17
package/dist/es/shared/watch.js
CHANGED
package/dist/getLogFilter.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/parseAst.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/parseAst.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.16.
|
|
4
|
-
Tue, 23 Apr 2024
|
|
3
|
+
Rollup.js v4.16.4
|
|
4
|
+
Tue, 23 Apr 2024 13:14:37 GMT - commit 1c404fa352b70007066e94ff4c1981f8046f8cef
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -438,7 +438,7 @@ function logDeprecation(deprecation, urlSnippet, plugin) {
|
|
|
438
438
|
code: DEPRECATED_FEATURE,
|
|
439
439
|
message: deprecation,
|
|
440
440
|
url: getRollupUrl(urlSnippet),
|
|
441
|
-
...({})
|
|
441
|
+
...(plugin ? { plugin } : {})
|
|
442
442
|
};
|
|
443
443
|
}
|
|
444
444
|
function logConstVariableReassignError() {
|
|
@@ -980,11 +980,11 @@ function logFailedValidation(message) {
|
|
|
980
980
|
};
|
|
981
981
|
}
|
|
982
982
|
function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
|
|
983
|
-
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations);
|
|
983
|
+
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations, plugin);
|
|
984
984
|
}
|
|
985
985
|
function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
|
|
986
|
-
{
|
|
987
|
-
const warning = logDeprecation(deprecation, urlSnippet);
|
|
986
|
+
if (activeDeprecation || strictDeprecations) {
|
|
987
|
+
const warning = logDeprecation(deprecation, urlSnippet, plugin);
|
|
988
988
|
if (strictDeprecations) {
|
|
989
989
|
return error(warning);
|
|
990
990
|
}
|
|
@@ -1005,7 +1005,6 @@ const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
|
1005
1005
|
const BlockStatement = 'BlockStatement';
|
|
1006
1006
|
const CallExpression = 'CallExpression';
|
|
1007
1007
|
const CatchClause = 'CatchClause';
|
|
1008
|
-
const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
|
|
1009
1008
|
const ExpressionStatement = 'ExpressionStatement';
|
|
1010
1009
|
const Identifier = 'Identifier';
|
|
1011
1010
|
const Literal = 'Literal';
|
|
@@ -1015,7 +1014,6 @@ const Program = 'Program';
|
|
|
1015
1014
|
const Property = 'Property';
|
|
1016
1015
|
const ReturnStatement = 'ReturnStatement';
|
|
1017
1016
|
const TemplateLiteral = 'TemplateLiteral';
|
|
1018
|
-
const VariableDeclarator = 'VariableDeclarator';
|
|
1019
1017
|
|
|
1020
1018
|
// This file is generated by scripts/generate-string-constants.js.
|
|
1021
1019
|
// Do not edit this file directly.
|
|
@@ -2278,7 +2276,6 @@ exports.CatchClause = CatchClause;
|
|
|
2278
2276
|
exports.EMPTY_ARRAY = EMPTY_ARRAY;
|
|
2279
2277
|
exports.EMPTY_OBJECT = EMPTY_OBJECT;
|
|
2280
2278
|
exports.EMPTY_SET = EMPTY_SET;
|
|
2281
|
-
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
|
|
2282
2279
|
exports.ExpressionStatement = ExpressionStatement;
|
|
2283
2280
|
exports.FIXED_STRINGS = FIXED_STRINGS;
|
|
2284
2281
|
exports.INVALID_ANNOTATION_KEY = INVALID_ANNOTATION_KEY;
|
|
@@ -2314,7 +2311,6 @@ exports.URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = URL_TREATING_MODULE_AS_EXTE
|
|
|
2314
2311
|
exports.URL_TREESHAKE = URL_TREESHAKE;
|
|
2315
2312
|
exports.URL_TREESHAKE_MODULESIDEEFFECTS = URL_TREESHAKE_MODULESIDEEFFECTS;
|
|
2316
2313
|
exports.URL_WATCH = URL_WATCH;
|
|
2317
|
-
exports.VariableDeclarator = VariableDeclarator;
|
|
2318
2314
|
exports.addTrailingSlashIfMissed = addTrailingSlashIfMissed;
|
|
2319
2315
|
exports.augmentCodeLocation = augmentCodeLocation;
|
|
2320
2316
|
exports.augmentLogMessage = augmentLogMessage;
|
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.16.
|
|
4
|
-
Tue, 23 Apr 2024
|
|
3
|
+
Rollup.js v4.16.4
|
|
4
|
+
Tue, 23 Apr 2024 13:14:37 GMT - commit 1c404fa352b70007066e94ff4c1981f8046f8cef
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version = "4.16.
|
|
34
|
+
var version = "4.16.4";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -3393,9 +3393,6 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
3393
3393
|
};
|
|
3394
3394
|
|
|
3395
3395
|
class Variable extends ExpressionEntity {
|
|
3396
|
-
markReassigned() {
|
|
3397
|
-
this.isReassigned = true;
|
|
3398
|
-
}
|
|
3399
3396
|
constructor(name) {
|
|
3400
3397
|
super();
|
|
3401
3398
|
this.name = name;
|
|
@@ -3403,36 +3400,16 @@ class Variable extends ExpressionEntity {
|
|
|
3403
3400
|
this.forbiddenNames = null;
|
|
3404
3401
|
this.initReached = false;
|
|
3405
3402
|
this.isId = false;
|
|
3403
|
+
this.isReassigned = false;
|
|
3406
3404
|
this.kind = null;
|
|
3407
3405
|
this.renderBaseName = null;
|
|
3408
3406
|
this.renderName = null;
|
|
3409
|
-
this.isReassigned = false;
|
|
3410
|
-
this.onlyFunctionCallUsed = true;
|
|
3411
3407
|
}
|
|
3412
3408
|
/**
|
|
3413
3409
|
* Binds identifiers that reference this variable to this variable.
|
|
3414
3410
|
* Necessary to be able to change variable names.
|
|
3415
3411
|
*/
|
|
3416
3412
|
addReference(_identifier) { }
|
|
3417
|
-
/**
|
|
3418
|
-
* Check if the identifier variable is only used as function call
|
|
3419
|
-
* Forward the check to the export default variable if it is only used once
|
|
3420
|
-
* @returns true if the variable is only used as function call
|
|
3421
|
-
*/
|
|
3422
|
-
getOnlyFunctionCallUsed() {
|
|
3423
|
-
return this.onlyFunctionCallUsed;
|
|
3424
|
-
}
|
|
3425
|
-
/**
|
|
3426
|
-
* Collect the places where the identifier variable is used
|
|
3427
|
-
* @param usedPlace Where the variable is used
|
|
3428
|
-
*/
|
|
3429
|
-
addUsedPlace(usedPlace) {
|
|
3430
|
-
const isFunctionCall = usedPlace.parent.type === parseAst_js.CallExpression &&
|
|
3431
|
-
usedPlace.parent.callee === usedPlace;
|
|
3432
|
-
if (!isFunctionCall && usedPlace.parent.type !== parseAst_js.ExportDefaultDeclaration) {
|
|
3433
|
-
this.onlyFunctionCallUsed = false;
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
3413
|
/**
|
|
3437
3414
|
* Prevent this variable from being renamed to this name to avoid name
|
|
3438
3415
|
* collisions
|
|
@@ -7170,7 +7147,7 @@ class LocalVariable extends Variable {
|
|
|
7170
7147
|
return;
|
|
7171
7148
|
}
|
|
7172
7149
|
if (path.length === 0) {
|
|
7173
|
-
this.
|
|
7150
|
+
this.isReassigned = true;
|
|
7174
7151
|
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized;
|
|
7175
7152
|
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
7176
7153
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -7264,7 +7241,7 @@ class LocalVariable extends Variable {
|
|
|
7264
7241
|
if (this.additionalInitializers === null) {
|
|
7265
7242
|
this.additionalInitializers = [this.init];
|
|
7266
7243
|
this.init = UNKNOWN_EXPRESSION;
|
|
7267
|
-
this.
|
|
7244
|
+
this.isReassigned = true;
|
|
7268
7245
|
}
|
|
7269
7246
|
return this.additionalInitializers;
|
|
7270
7247
|
}
|
|
@@ -7282,8 +7259,6 @@ class ParameterVariable extends LocalVariable {
|
|
|
7282
7259
|
this.deoptimizations = new PathTracker();
|
|
7283
7260
|
this.deoptimizedFields = new Set();
|
|
7284
7261
|
this.entitiesToBeDeoptimized = new Set();
|
|
7285
|
-
this.knownExpressionsToBeDeoptimized = [];
|
|
7286
|
-
this.knownValue = UNKNOWN_EXPRESSION;
|
|
7287
7262
|
}
|
|
7288
7263
|
addEntityToBeDeoptimized(entity) {
|
|
7289
7264
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
@@ -7313,47 +7288,6 @@ class ParameterVariable extends LocalVariable {
|
|
|
7313
7288
|
}
|
|
7314
7289
|
}
|
|
7315
7290
|
}
|
|
7316
|
-
markReassigned() {
|
|
7317
|
-
if (this.isReassigned) {
|
|
7318
|
-
return;
|
|
7319
|
-
}
|
|
7320
|
-
super.markReassigned();
|
|
7321
|
-
for (const expression of this.knownExpressionsToBeDeoptimized) {
|
|
7322
|
-
expression.deoptimizeCache();
|
|
7323
|
-
}
|
|
7324
|
-
this.knownExpressionsToBeDeoptimized = [];
|
|
7325
|
-
}
|
|
7326
|
-
/**
|
|
7327
|
-
* If we are sure about the value of this parameter, we can set it here.
|
|
7328
|
-
* It can be a literal or the only possible value of the parameter.
|
|
7329
|
-
* an undefined value means that the parameter is not known.
|
|
7330
|
-
* @param value The known value of the parameter to be set.
|
|
7331
|
-
*/
|
|
7332
|
-
setKnownValue(value) {
|
|
7333
|
-
if (this.isReassigned) {
|
|
7334
|
-
return;
|
|
7335
|
-
}
|
|
7336
|
-
if (this.knownValue !== value) {
|
|
7337
|
-
for (const expression of this.knownExpressionsToBeDeoptimized) {
|
|
7338
|
-
expression.deoptimizeCache();
|
|
7339
|
-
}
|
|
7340
|
-
this.knownExpressionsToBeDeoptimized = [];
|
|
7341
|
-
}
|
|
7342
|
-
this.knownValue = value;
|
|
7343
|
-
}
|
|
7344
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7345
|
-
if (this.isReassigned) {
|
|
7346
|
-
return UnknownValue;
|
|
7347
|
-
}
|
|
7348
|
-
this.knownExpressionsToBeDeoptimized.push(origin);
|
|
7349
|
-
return recursionTracker.withTrackedEntityAtPath(path, this.knownValue, () => this.knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
7350
|
-
}
|
|
7351
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7352
|
-
// assigned is a bit different, since the value has a new name (the parameter)
|
|
7353
|
-
return interaction.type === INTERACTION_ASSIGNED
|
|
7354
|
-
? super.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
7355
|
-
: this.knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7356
|
-
}
|
|
7357
7291
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
7358
7292
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
7359
7293
|
if (path.length >= 2 ||
|
|
@@ -7378,11 +7312,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
7378
7312
|
}
|
|
7379
7313
|
}
|
|
7380
7314
|
deoptimizePath(path) {
|
|
7381
|
-
if (path.length === 0) {
|
|
7382
|
-
this.markReassigned();
|
|
7383
|
-
return;
|
|
7384
|
-
}
|
|
7385
|
-
if (this.deoptimizedFields.has(UnknownKey)) {
|
|
7315
|
+
if (path.length === 0 || this.deoptimizedFields.has(UnknownKey)) {
|
|
7386
7316
|
return;
|
|
7387
7317
|
}
|
|
7388
7318
|
const key = path[0];
|
|
@@ -8744,11 +8674,11 @@ function getGlobalAtPath(path) {
|
|
|
8744
8674
|
}
|
|
8745
8675
|
|
|
8746
8676
|
class GlobalVariable extends Variable {
|
|
8747
|
-
constructor(
|
|
8748
|
-
super(
|
|
8677
|
+
constructor() {
|
|
8678
|
+
super(...arguments);
|
|
8749
8679
|
// Ensure we use live-bindings for globals as we do not know if they have
|
|
8750
8680
|
// been reassigned
|
|
8751
|
-
this.
|
|
8681
|
+
this.isReassigned = true;
|
|
8752
8682
|
}
|
|
8753
8683
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8754
8684
|
switch (interaction.type) {
|
|
@@ -8802,7 +8732,6 @@ class Identifier extends NodeBase {
|
|
|
8802
8732
|
constructor() {
|
|
8803
8733
|
super(...arguments);
|
|
8804
8734
|
this.variable = null;
|
|
8805
|
-
this.isReferenceVariable = false;
|
|
8806
8735
|
}
|
|
8807
8736
|
get isTDZAccess() {
|
|
8808
8737
|
if (!isFlagSet(this.flags, 4 /* Flag.tdzAccessDefined */)) {
|
|
@@ -8823,7 +8752,6 @@ class Identifier extends NodeBase {
|
|
|
8823
8752
|
if (!this.variable && is_reference(this, this.parent)) {
|
|
8824
8753
|
this.variable = this.scope.findVariable(this.name);
|
|
8825
8754
|
this.variable.addReference(this);
|
|
8826
|
-
this.isReferenceVariable = true;
|
|
8827
8755
|
}
|
|
8828
8756
|
}
|
|
8829
8757
|
declare(kind, init) {
|
|
@@ -8986,9 +8914,6 @@ class Identifier extends NodeBase {
|
|
|
8986
8914
|
this.variable.consolidateInitializers();
|
|
8987
8915
|
this.scope.context.requestTreeshakingPass();
|
|
8988
8916
|
}
|
|
8989
|
-
if (this.isReferenceVariable) {
|
|
8990
|
-
this.variable.addUsedPlace(this);
|
|
8991
|
-
}
|
|
8992
8917
|
}
|
|
8993
8918
|
getVariableRespectingTDZ() {
|
|
8994
8919
|
if (this.isPossibleTDZ()) {
|
|
@@ -9308,17 +9233,10 @@ class RestElement extends NodeBase {
|
|
|
9308
9233
|
}
|
|
9309
9234
|
}
|
|
9310
9235
|
|
|
9311
|
-
// This handler does nothing.
|
|
9312
|
-
// Since we always re-evaluate argument values in a new tree-shaking pass,
|
|
9313
|
-
// we don't need to get notified if it is deoptimized.
|
|
9314
|
-
const EMPTY_DEOPTIMIZABLE_HANDLER = { deoptimizeCache() { } };
|
|
9315
9236
|
class FunctionBase extends NodeBase {
|
|
9316
9237
|
constructor() {
|
|
9317
9238
|
super(...arguments);
|
|
9318
|
-
this.knownParameterValues = [];
|
|
9319
|
-
this.allArguments = [];
|
|
9320
9239
|
this.objectEntity = null;
|
|
9321
|
-
this.functionParametersOptimized = false;
|
|
9322
9240
|
}
|
|
9323
9241
|
get async() {
|
|
9324
9242
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -9338,87 +9256,6 @@ class FunctionBase extends NodeBase {
|
|
|
9338
9256
|
set generator(value) {
|
|
9339
9257
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
9340
9258
|
}
|
|
9341
|
-
/**
|
|
9342
|
-
* update knownParameterValues when a call is made to this function
|
|
9343
|
-
* @param newArguments arguments of the call
|
|
9344
|
-
*/
|
|
9345
|
-
updateKnownParameterValues(newArguments) {
|
|
9346
|
-
for (let position = 0; position < this.params.length; position++) {
|
|
9347
|
-
// only the "this" argument newArguments[0] can be null
|
|
9348
|
-
// it's possible that some arguments are empty, so the value is undefined
|
|
9349
|
-
const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
9350
|
-
const parameter = this.params[position];
|
|
9351
|
-
// RestElement can be, and can only be, the last parameter
|
|
9352
|
-
if (parameter instanceof RestElement) {
|
|
9353
|
-
return;
|
|
9354
|
-
}
|
|
9355
|
-
const knownParameterValue = this.knownParameterValues[position];
|
|
9356
|
-
if (knownParameterValue === undefined) {
|
|
9357
|
-
this.knownParameterValues[position] = argument;
|
|
9358
|
-
continue;
|
|
9359
|
-
}
|
|
9360
|
-
if (knownParameterValue === UNKNOWN_EXPRESSION ||
|
|
9361
|
-
knownParameterValue === argument ||
|
|
9362
|
-
(knownParameterValue instanceof Identifier &&
|
|
9363
|
-
argument instanceof Identifier &&
|
|
9364
|
-
knownParameterValue.variable === argument.variable)) {
|
|
9365
|
-
continue;
|
|
9366
|
-
}
|
|
9367
|
-
const oldValue = knownParameterValue.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
|
|
9368
|
-
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
|
|
9369
|
-
if (oldValue !== newValue || typeof oldValue === 'symbol') {
|
|
9370
|
-
this.knownParameterValues[position] = UNKNOWN_EXPRESSION;
|
|
9371
|
-
} // else both are the same literal, no need to update
|
|
9372
|
-
}
|
|
9373
|
-
}
|
|
9374
|
-
forwardArgumentsForFunctionCalledOnce(newArguments) {
|
|
9375
|
-
for (let position = 0; position < this.params.length; position++) {
|
|
9376
|
-
const parameter = this.params[position];
|
|
9377
|
-
if (parameter instanceof Identifier) {
|
|
9378
|
-
const ParameterVariable = parameter.variable;
|
|
9379
|
-
const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
9380
|
-
ParameterVariable?.setKnownValue(argument);
|
|
9381
|
-
}
|
|
9382
|
-
}
|
|
9383
|
-
}
|
|
9384
|
-
/**
|
|
9385
|
-
* each time tree-shake starts, this method should be called to reoptimize the parameters
|
|
9386
|
-
* a parameter's state will change at most twice:
|
|
9387
|
-
* `undefined` (no call is made) -> an expression -> `UnknownArgument`
|
|
9388
|
-
* we are sure it will converge, and can use state from last iteration
|
|
9389
|
-
*/
|
|
9390
|
-
applyFunctionParameterOptimization() {
|
|
9391
|
-
if (this.allArguments.length === 0) {
|
|
9392
|
-
return;
|
|
9393
|
-
}
|
|
9394
|
-
if (this.allArguments.length === 1) {
|
|
9395
|
-
// we are sure what knownParameterValues will be, so skip it and do setKnownValue
|
|
9396
|
-
this.forwardArgumentsForFunctionCalledOnce(this.allArguments[0]);
|
|
9397
|
-
return;
|
|
9398
|
-
}
|
|
9399
|
-
// reoptimize all arguments, that's why we save them
|
|
9400
|
-
for (const argumentsList of this.allArguments) {
|
|
9401
|
-
this.updateKnownParameterValues(argumentsList);
|
|
9402
|
-
}
|
|
9403
|
-
for (let position = 0; position < this.params.length; position++) {
|
|
9404
|
-
const parameter = this.params[position];
|
|
9405
|
-
// Parameters without default values
|
|
9406
|
-
if (parameter instanceof Identifier) {
|
|
9407
|
-
const parameterVariable = parameter.variable;
|
|
9408
|
-
// Only the RestElement may be undefined
|
|
9409
|
-
const knownParameterValue = this.knownParameterValues[position];
|
|
9410
|
-
parameterVariable?.setKnownValue(knownParameterValue);
|
|
9411
|
-
}
|
|
9412
|
-
}
|
|
9413
|
-
}
|
|
9414
|
-
deoptimizeFunctionParameters() {
|
|
9415
|
-
for (const parameter of this.params) {
|
|
9416
|
-
if (parameter instanceof Identifier) {
|
|
9417
|
-
const parameterVariable = parameter.variable;
|
|
9418
|
-
parameterVariable?.markReassigned();
|
|
9419
|
-
}
|
|
9420
|
-
}
|
|
9421
|
-
}
|
|
9422
9259
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9423
9260
|
if (interaction.type === INTERACTION_CALLED) {
|
|
9424
9261
|
const { parameters } = this.scope;
|
|
@@ -9443,7 +9280,6 @@ class FunctionBase extends NodeBase {
|
|
|
9443
9280
|
this.addArgumentToBeDeoptimized(argument);
|
|
9444
9281
|
}
|
|
9445
9282
|
}
|
|
9446
|
-
this.allArguments.push(args);
|
|
9447
9283
|
}
|
|
9448
9284
|
else {
|
|
9449
9285
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -9458,7 +9294,6 @@ class FunctionBase extends NodeBase {
|
|
|
9458
9294
|
for (const parameterList of this.scope.parameters) {
|
|
9459
9295
|
for (const parameter of parameterList) {
|
|
9460
9296
|
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
9461
|
-
parameter.markReassigned();
|
|
9462
9297
|
}
|
|
9463
9298
|
}
|
|
9464
9299
|
}
|
|
@@ -9504,28 +9339,7 @@ class FunctionBase extends NodeBase {
|
|
|
9504
9339
|
}
|
|
9505
9340
|
return false;
|
|
9506
9341
|
}
|
|
9507
|
-
/**
|
|
9508
|
-
* If the function (expression or declaration) is only used as function calls
|
|
9509
|
-
*/
|
|
9510
|
-
onlyFunctionCallUsed() {
|
|
9511
|
-
let variable = null;
|
|
9512
|
-
if (this.parent.type === parseAst_js.VariableDeclarator) {
|
|
9513
|
-
variable = this.parent.id.variable ?? null;
|
|
9514
|
-
}
|
|
9515
|
-
if (this.parent.type === parseAst_js.ExportDefaultDeclaration) {
|
|
9516
|
-
variable = this.parent.variable;
|
|
9517
|
-
}
|
|
9518
|
-
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
9519
|
-
}
|
|
9520
9342
|
include(context, includeChildrenRecursively) {
|
|
9521
|
-
const shouldOptimizeFunctionParameters = this.onlyFunctionCallUsed();
|
|
9522
|
-
if (shouldOptimizeFunctionParameters) {
|
|
9523
|
-
this.applyFunctionParameterOptimization();
|
|
9524
|
-
}
|
|
9525
|
-
else if (this.functionParametersOptimized) {
|
|
9526
|
-
this.deoptimizeFunctionParameters();
|
|
9527
|
-
}
|
|
9528
|
-
this.functionParametersOptimized = shouldOptimizeFunctionParameters;
|
|
9529
9343
|
if (!this.deoptimized)
|
|
9530
9344
|
this.applyDeoptimizations();
|
|
9531
9345
|
this.included = true;
|
|
@@ -9609,11 +9423,6 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
9609
9423
|
}
|
|
9610
9424
|
return false;
|
|
9611
9425
|
}
|
|
9612
|
-
onlyFunctionCallUsed() {
|
|
9613
|
-
const isIIFE = this.parent.type === parseAst_js.CallExpression &&
|
|
9614
|
-
this.parent.callee === this;
|
|
9615
|
-
return isIIFE || super.onlyFunctionCallUsed();
|
|
9616
|
-
}
|
|
9617
9426
|
include(context, includeChildrenRecursively) {
|
|
9618
9427
|
super.include(context, includeChildrenRecursively);
|
|
9619
9428
|
for (const parameter of this.params) {
|
|
@@ -10280,7 +10089,7 @@ class MemberExpression extends NodeBase {
|
|
|
10280
10089
|
}
|
|
10281
10090
|
deoptimizeCache() {
|
|
10282
10091
|
const { expressionsToBeDeoptimized, object } = this;
|
|
10283
|
-
this.expressionsToBeDeoptimized =
|
|
10092
|
+
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
10284
10093
|
this.propertyKey = UnknownKey;
|
|
10285
10094
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
10286
10095
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -10429,9 +10238,6 @@ class MemberExpression extends NodeBase {
|
|
|
10429
10238
|
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
10430
10239
|
this.scope.context.requestTreeshakingPass();
|
|
10431
10240
|
}
|
|
10432
|
-
if (this.variable) {
|
|
10433
|
-
this.variable.addUsedPlace(this);
|
|
10434
|
-
}
|
|
10435
10241
|
}
|
|
10436
10242
|
applyAssignmentDeoptimization() {
|
|
10437
10243
|
this.assignmentDeoptimized = true;
|
|
@@ -11081,24 +10887,15 @@ class ConditionalExpression extends NodeBase {
|
|
|
11081
10887
|
this.alternate.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11082
10888
|
}
|
|
11083
10889
|
deoptimizeCache() {
|
|
11084
|
-
if (this.usedBranch ||
|
|
11085
|
-
this.isBranchResolutionAnalysed ||
|
|
11086
|
-
this.expressionsToBeDeoptimized.length > 0) {
|
|
11087
|
-
// Request another pass because we need to ensure "include" runs again if it is rendered
|
|
11088
|
-
this.scope.context.requestTreeshakingPass();
|
|
11089
|
-
}
|
|
11090
|
-
const { expressionsToBeDeoptimized } = this;
|
|
11091
|
-
if (expressionsToBeDeoptimized.length > 0) {
|
|
11092
|
-
this.expressionsToBeDeoptimized = [];
|
|
11093
|
-
for (const expression of expressionsToBeDeoptimized) {
|
|
11094
|
-
expression.deoptimizeCache();
|
|
11095
|
-
}
|
|
11096
|
-
}
|
|
11097
|
-
this.isBranchResolutionAnalysed = false;
|
|
11098
10890
|
if (this.usedBranch !== null) {
|
|
11099
10891
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
11100
10892
|
this.usedBranch = null;
|
|
11101
10893
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
10894
|
+
const { expressionsToBeDeoptimized } = this;
|
|
10895
|
+
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
10896
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
10897
|
+
expression.deoptimizeCache();
|
|
10898
|
+
}
|
|
11102
10899
|
}
|
|
11103
10900
|
}
|
|
11104
10901
|
deoptimizePath(path) {
|
|
@@ -11112,10 +10909,10 @@ class ConditionalExpression extends NodeBase {
|
|
|
11112
10909
|
}
|
|
11113
10910
|
}
|
|
11114
10911
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11115
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
11116
10912
|
const usedBranch = this.getUsedBranch();
|
|
11117
10913
|
if (!usedBranch)
|
|
11118
10914
|
return UnknownValue;
|
|
10915
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
11119
10916
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
11120
10917
|
}
|
|
11121
10918
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -11314,10 +11111,6 @@ class FunctionDeclaration extends FunctionNode {
|
|
|
11314
11111
|
this.id.variable.isId = true;
|
|
11315
11112
|
}
|
|
11316
11113
|
}
|
|
11317
|
-
onlyFunctionCallUsed() {
|
|
11318
|
-
// call super.onlyFunctionCallUsed for export default anonymous function
|
|
11319
|
-
return this.id?.variable.getOnlyFunctionCallUsed() ?? super.onlyFunctionCallUsed();
|
|
11320
|
-
}
|
|
11321
11114
|
parseNode(esTreeNode) {
|
|
11322
11115
|
if (esTreeNode.id !== null) {
|
|
11323
11116
|
this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
|
|
@@ -11579,12 +11372,6 @@ class FunctionExpression extends FunctionNode {
|
|
|
11579
11372
|
}
|
|
11580
11373
|
return super.parseNode(esTreeNode);
|
|
11581
11374
|
}
|
|
11582
|
-
onlyFunctionCallUsed() {
|
|
11583
|
-
const isIIFE = this.parent.type === parseAst_js.CallExpression &&
|
|
11584
|
-
this.parent.callee === this &&
|
|
11585
|
-
(this.id === null || this.id.variable.getOnlyFunctionCallUsed());
|
|
11586
|
-
return isIIFE || super.onlyFunctionCallUsed();
|
|
11587
|
-
}
|
|
11588
11375
|
render(code, options, { renderedSurroundingElement } = parseAst_js.BLANK) {
|
|
11589
11376
|
super.render(code, options);
|
|
11590
11377
|
if (renderedSurroundingElement === parseAst_js.ExpressionStatement) {
|
|
@@ -11612,7 +11399,7 @@ class IfStatement extends NodeBase {
|
|
|
11612
11399
|
this.testValue = unset;
|
|
11613
11400
|
}
|
|
11614
11401
|
deoptimizeCache() {
|
|
11615
|
-
this.testValue =
|
|
11402
|
+
this.testValue = UnknownValue;
|
|
11616
11403
|
}
|
|
11617
11404
|
hasEffects(context) {
|
|
11618
11405
|
if (this.test.hasEffects(context)) {
|
|
@@ -12420,24 +12207,18 @@ class LogicalExpression extends NodeBase {
|
|
|
12420
12207
|
this.right.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
12421
12208
|
}
|
|
12422
12209
|
deoptimizeCache() {
|
|
12423
|
-
if (this.usedBranch ||
|
|
12424
|
-
this.isBranchResolutionAnalysed ||
|
|
12425
|
-
this.expressionsToBeDeoptimized.length > 0) {
|
|
12426
|
-
// Request another pass because we need to ensure "include" runs again if it is rendered
|
|
12427
|
-
this.scope.context.requestTreeshakingPass();
|
|
12428
|
-
}
|
|
12429
|
-
const { expressionsToBeDeoptimized } = this;
|
|
12430
|
-
if (expressionsToBeDeoptimized.length > 0) {
|
|
12431
|
-
this.expressionsToBeDeoptimized = [];
|
|
12432
|
-
for (const expression of expressionsToBeDeoptimized) {
|
|
12433
|
-
expression.deoptimizeCache();
|
|
12434
|
-
}
|
|
12435
|
-
}
|
|
12436
|
-
this.isBranchResolutionAnalysed = false;
|
|
12437
12210
|
if (this.usedBranch) {
|
|
12438
12211
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
12439
12212
|
this.usedBranch = null;
|
|
12440
12213
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
12214
|
+
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
12215
|
+
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
12216
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
12217
|
+
expression.deoptimizeCache();
|
|
12218
|
+
}
|
|
12219
|
+
// Request another pass because we need to ensure "include" runs again if
|
|
12220
|
+
// it is rendered
|
|
12221
|
+
context.requestTreeshakingPass();
|
|
12441
12222
|
}
|
|
12442
12223
|
}
|
|
12443
12224
|
deoptimizePath(path) {
|
|
@@ -12451,10 +12232,10 @@ class LogicalExpression extends NodeBase {
|
|
|
12451
12232
|
}
|
|
12452
12233
|
}
|
|
12453
12234
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
12454
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
12455
12235
|
const usedBranch = this.getUsedBranch();
|
|
12456
12236
|
if (!usedBranch)
|
|
12457
12237
|
return UnknownValue;
|
|
12238
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
12458
12239
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
12459
12240
|
}
|
|
12460
12241
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -13396,15 +13177,6 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
13396
13177
|
this.name = identifier.name;
|
|
13397
13178
|
}
|
|
13398
13179
|
}
|
|
13399
|
-
addUsedPlace(usedPlace) {
|
|
13400
|
-
const original = this.getOriginalVariable();
|
|
13401
|
-
if (original === this) {
|
|
13402
|
-
super.addUsedPlace(usedPlace);
|
|
13403
|
-
}
|
|
13404
|
-
else {
|
|
13405
|
-
original.addUsedPlace(usedPlace);
|
|
13406
|
-
}
|
|
13407
|
-
}
|
|
13408
13180
|
forbidName(name) {
|
|
13409
13181
|
const original = this.getOriginalVariable();
|
|
13410
13182
|
if (original === this) {
|
|
@@ -13678,7 +13450,7 @@ class UpdateExpression extends NodeBase {
|
|
|
13678
13450
|
this.argument.deoptimizePath(EMPTY_PATH);
|
|
13679
13451
|
if (this.argument instanceof Identifier) {
|
|
13680
13452
|
const variable = this.scope.findVariable(this.argument.name);
|
|
13681
|
-
variable.
|
|
13453
|
+
variable.isReassigned = true;
|
|
13682
13454
|
}
|
|
13683
13455
|
this.scope.context.requestTreeshakingPass();
|
|
13684
13456
|
}
|
|
@@ -19663,7 +19435,7 @@ function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
|
|
|
19663
19435
|
|
|
19664
19436
|
function flru (max) {
|
|
19665
19437
|
var num, curr, prev;
|
|
19666
|
-
var limit = max ;
|
|
19438
|
+
var limit = max || 1;
|
|
19667
19439
|
|
|
19668
19440
|
function keep(key, value) {
|
|
19669
19441
|
if (++num > limit) {
|
package/dist/shared/watch-cli.js
CHANGED