rollup 3.4.0-1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +57 -115
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +0 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +61 -119
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/bin/rollup
CHANGED
package/dist/es/rollup.js
CHANGED
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.4.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.4.0
|
|
4
|
+
Tue, 22 Nov 2022 05:15:54 GMT - commit 780e3421e8a498f3248fd7d8506e97fcee8dd1e6
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { promises } from 'node:fs';
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.4.0
|
|
19
|
+
var version$1 = "3.4.0";
|
|
20
20
|
|
|
21
21
|
var charToInteger = {};
|
|
22
22
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -1776,7 +1776,7 @@ class ExpressionEntity {
|
|
|
1776
1776
|
return UnknownValue;
|
|
1777
1777
|
}
|
|
1778
1778
|
getReturnExpressionWhenCalledAtPath(_path, _interaction, _recursionTracker, _origin) {
|
|
1779
|
-
return
|
|
1779
|
+
return UNKNOWN_EXPRESSION;
|
|
1780
1780
|
}
|
|
1781
1781
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
1782
1782
|
return true;
|
|
@@ -1795,10 +1795,6 @@ class ExpressionEntity {
|
|
|
1795
1795
|
}
|
|
1796
1796
|
const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
|
|
1797
1797
|
})();
|
|
1798
|
-
const UNKNOWN_RETURN_EXPRESSION = [
|
|
1799
|
-
UNKNOWN_EXPRESSION,
|
|
1800
|
-
false
|
|
1801
|
-
];
|
|
1802
1798
|
|
|
1803
1799
|
const INTERACTION_ACCESSED = 0;
|
|
1804
1800
|
const INTERACTION_ASSIGNED = 1;
|
|
@@ -4934,7 +4930,7 @@ const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEnti
|
|
|
4934
4930
|
if (path.length === 1) {
|
|
4935
4931
|
return getMemberReturnExpressionWhenCalled(literalBooleanMembers, path[0]);
|
|
4936
4932
|
}
|
|
4937
|
-
return
|
|
4933
|
+
return UNKNOWN_EXPRESSION;
|
|
4938
4934
|
}
|
|
4939
4935
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4940
4936
|
if (interaction.type === INTERACTION_ACCESSED) {
|
|
@@ -4957,7 +4953,7 @@ const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity
|
|
|
4957
4953
|
if (path.length === 1) {
|
|
4958
4954
|
return getMemberReturnExpressionWhenCalled(literalNumberMembers, path[0]);
|
|
4959
4955
|
}
|
|
4960
|
-
return
|
|
4956
|
+
return UNKNOWN_EXPRESSION;
|
|
4961
4957
|
}
|
|
4962
4958
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4963
4959
|
if (interaction.type === INTERACTION_ACCESSED) {
|
|
@@ -4980,7 +4976,7 @@ const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity
|
|
|
4980
4976
|
if (path.length === 1) {
|
|
4981
4977
|
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
4982
4978
|
}
|
|
4983
|
-
return
|
|
4979
|
+
return UNKNOWN_EXPRESSION;
|
|
4984
4980
|
}
|
|
4985
4981
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4986
4982
|
if (interaction.type === INTERACTION_ACCESSED) {
|
|
@@ -5101,8 +5097,8 @@ function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
|
5101
5097
|
}
|
|
5102
5098
|
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
5103
5099
|
if (typeof memberName !== 'string' || !members[memberName])
|
|
5104
|
-
return
|
|
5105
|
-
return
|
|
5100
|
+
return UNKNOWN_EXPRESSION;
|
|
5101
|
+
return members[memberName].returns;
|
|
5106
5102
|
}
|
|
5107
5103
|
|
|
5108
5104
|
// AST walker module for Mozilla Parser API compatible trees
|
|
@@ -5752,15 +5748,12 @@ class Method extends ExpressionEntity {
|
|
|
5752
5748
|
}
|
|
5753
5749
|
getReturnExpressionWhenCalledAtPath(path, { thisArg }) {
|
|
5754
5750
|
if (path.length > 0) {
|
|
5755
|
-
return
|
|
5751
|
+
return UNKNOWN_EXPRESSION;
|
|
5756
5752
|
}
|
|
5757
|
-
return
|
|
5758
|
-
this.description.
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
: this.description.returns()),
|
|
5762
|
-
false
|
|
5763
|
-
];
|
|
5753
|
+
return (this.description.returnsPrimitive ||
|
|
5754
|
+
(this.description.returns === 'self'
|
|
5755
|
+
? thisArg || UNKNOWN_EXPRESSION
|
|
5756
|
+
: this.description.returns()));
|
|
5764
5757
|
}
|
|
5765
5758
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5766
5759
|
const { type } = interaction;
|
|
@@ -6003,7 +5996,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6003
5996
|
}
|
|
6004
5997
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6005
5998
|
if (path.length === 0) {
|
|
6006
|
-
return
|
|
5999
|
+
return UNKNOWN_EXPRESSION;
|
|
6007
6000
|
}
|
|
6008
6001
|
const [key, ...subPath] = path;
|
|
6009
6002
|
const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
|
|
@@ -6013,7 +6006,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6013
6006
|
if (this.prototypeExpression) {
|
|
6014
6007
|
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6015
6008
|
}
|
|
6016
|
-
return
|
|
6009
|
+
return UNKNOWN_EXPRESSION;
|
|
6017
6010
|
}
|
|
6018
6011
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6019
6012
|
const [key, ...subPath] = path;
|
|
@@ -6485,12 +6478,12 @@ class LocalVariable extends Variable {
|
|
|
6485
6478
|
}
|
|
6486
6479
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6487
6480
|
if (this.isReassigned || !this.init) {
|
|
6488
|
-
return
|
|
6481
|
+
return UNKNOWN_EXPRESSION;
|
|
6489
6482
|
}
|
|
6490
6483
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6491
6484
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6492
6485
|
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6493
|
-
},
|
|
6486
|
+
}, UNKNOWN_EXPRESSION);
|
|
6494
6487
|
}
|
|
6495
6488
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6496
6489
|
switch (interaction.type) {
|
|
@@ -6847,19 +6840,6 @@ function is_reference (node, parent) {
|
|
|
6847
6840
|
return false;
|
|
6848
6841
|
}
|
|
6849
6842
|
|
|
6850
|
-
const PureFunctionKey = Symbol('PureFunction');
|
|
6851
|
-
const getPureFunctions = ({ treeshake }) => {
|
|
6852
|
-
const pureFunctions = Object.create(null);
|
|
6853
|
-
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
6854
|
-
let currentFunctions = pureFunctions;
|
|
6855
|
-
for (const pathSegment of functionName.split('.')) {
|
|
6856
|
-
currentFunctions = currentFunctions[pathSegment] || (currentFunctions[pathSegment] = Object.create(null));
|
|
6857
|
-
}
|
|
6858
|
-
currentFunctions[PureFunctionKey] = true;
|
|
6859
|
-
}
|
|
6860
|
-
return pureFunctions;
|
|
6861
|
-
};
|
|
6862
|
-
|
|
6863
6843
|
/* eslint sort-keys: "off" */
|
|
6864
6844
|
const ValueProperties = Symbol('Value Properties');
|
|
6865
6845
|
const getTruthyLiteralValue = () => UnknownTruthyValue;
|
|
@@ -7038,6 +7018,7 @@ const knownGlobals = {
|
|
|
7038
7018
|
// deoptimizes everything anyway
|
|
7039
7019
|
defineProperty: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
7040
7020
|
defineProperties: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
7021
|
+
freeze: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
7041
7022
|
getOwnPropertyDescriptor: PF,
|
|
7042
7023
|
getOwnPropertyNames: PF,
|
|
7043
7024
|
getOwnPropertySymbols: PF,
|
|
@@ -7837,8 +7818,7 @@ class Identifier extends NodeBase {
|
|
|
7837
7818
|
return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7838
7819
|
}
|
|
7839
7820
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
7840
|
-
|
|
7841
|
-
return [expression, isPure || this.isPureFunction(path)];
|
|
7821
|
+
return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
7842
7822
|
}
|
|
7843
7823
|
hasEffects(context) {
|
|
7844
7824
|
if (!this.deoptimized)
|
|
@@ -7848,22 +7828,19 @@ class Identifier extends NodeBase {
|
|
|
7848
7828
|
}
|
|
7849
7829
|
return (this.context.options.treeshake.unknownGlobalSideEffects &&
|
|
7850
7830
|
this.variable instanceof GlobalVariable &&
|
|
7851
|
-
!this.isPureFunction(EMPTY_PATH) &&
|
|
7852
7831
|
this.variable.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7853
7832
|
}
|
|
7854
7833
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7855
7834
|
switch (interaction.type) {
|
|
7856
7835
|
case INTERACTION_ACCESSED: {
|
|
7857
7836
|
return (this.variable !== null &&
|
|
7858
|
-
!this.isPureFunction(path) &&
|
|
7859
7837
|
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
7860
7838
|
}
|
|
7861
7839
|
case INTERACTION_ASSIGNED: {
|
|
7862
7840
|
return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7863
7841
|
}
|
|
7864
7842
|
case INTERACTION_CALLED: {
|
|
7865
|
-
return
|
|
7866
|
-
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
7843
|
+
return this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7867
7844
|
}
|
|
7868
7845
|
}
|
|
7869
7846
|
}
|
|
@@ -7945,21 +7922,6 @@ class Identifier extends NodeBase {
|
|
|
7945
7922
|
}
|
|
7946
7923
|
return this.variable;
|
|
7947
7924
|
}
|
|
7948
|
-
isPureFunction(path) {
|
|
7949
|
-
let currentPureFunction = this.context.manualPureFunctions[this.name];
|
|
7950
|
-
for (const segment of path) {
|
|
7951
|
-
if (currentPureFunction) {
|
|
7952
|
-
if (currentPureFunction[PureFunctionKey]) {
|
|
7953
|
-
return true;
|
|
7954
|
-
}
|
|
7955
|
-
currentPureFunction = currentPureFunction[segment];
|
|
7956
|
-
}
|
|
7957
|
-
else {
|
|
7958
|
-
return false;
|
|
7959
|
-
}
|
|
7960
|
-
}
|
|
7961
|
-
return currentPureFunction?.[PureFunctionKey];
|
|
7962
|
-
}
|
|
7963
7925
|
}
|
|
7964
7926
|
function closestParentFunctionOrProgram(node) {
|
|
7965
7927
|
while (node && !/^Program|Function/.test(node.type)) {
|
|
@@ -8281,9 +8243,9 @@ class FunctionBase extends NodeBase {
|
|
|
8281
8243
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
8282
8244
|
this.context.requestTreeshakingPass();
|
|
8283
8245
|
}
|
|
8284
|
-
return
|
|
8246
|
+
return UNKNOWN_EXPRESSION;
|
|
8285
8247
|
}
|
|
8286
|
-
return
|
|
8248
|
+
return this.scope.getReturnExpression();
|
|
8287
8249
|
}
|
|
8288
8250
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8289
8251
|
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
@@ -8882,7 +8844,7 @@ class Literal extends NodeBase {
|
|
|
8882
8844
|
}
|
|
8883
8845
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
8884
8846
|
if (path.length !== 1)
|
|
8885
|
-
return
|
|
8847
|
+
return UNKNOWN_EXPRESSION;
|
|
8886
8848
|
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
|
|
8887
8849
|
}
|
|
8888
8850
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
@@ -9035,13 +8997,13 @@ class MemberExpression extends NodeBase {
|
|
|
9035
8997
|
return this.variable.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9036
8998
|
}
|
|
9037
8999
|
if (this.isUndefined) {
|
|
9038
|
-
return
|
|
9000
|
+
return UNDEFINED_EXPRESSION;
|
|
9039
9001
|
}
|
|
9040
9002
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9041
9003
|
if (path.length < MAX_PATH_DEPTH) {
|
|
9042
9004
|
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
9043
9005
|
}
|
|
9044
|
-
return
|
|
9006
|
+
return UNKNOWN_EXPRESSION;
|
|
9045
9007
|
}
|
|
9046
9008
|
hasEffects(context) {
|
|
9047
9009
|
if (!this.deoptimized)
|
|
@@ -9218,8 +9180,8 @@ class CallExpressionBase extends NodeBase {
|
|
|
9218
9180
|
this.expressionsToBeDeoptimized = new Set();
|
|
9219
9181
|
}
|
|
9220
9182
|
deoptimizeCache() {
|
|
9221
|
-
if (this.returnExpression
|
|
9222
|
-
this.returnExpression =
|
|
9183
|
+
if (this.returnExpression !== UNKNOWN_EXPRESSION) {
|
|
9184
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
9223
9185
|
for (const expression of this.deoptimizableDependentExpressions) {
|
|
9224
9186
|
expression.deoptimizeCache();
|
|
9225
9187
|
}
|
|
@@ -9233,15 +9195,13 @@ class CallExpressionBase extends NodeBase {
|
|
|
9233
9195
|
this.context.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
9234
9196
|
return;
|
|
9235
9197
|
}
|
|
9236
|
-
const
|
|
9198
|
+
const returnExpression = this.getReturnExpression();
|
|
9237
9199
|
if (returnExpression !== UNKNOWN_EXPRESSION) {
|
|
9238
9200
|
returnExpression.deoptimizePath(path);
|
|
9239
9201
|
}
|
|
9240
9202
|
}
|
|
9241
9203
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9242
|
-
const
|
|
9243
|
-
if (isPure)
|
|
9244
|
-
return;
|
|
9204
|
+
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9245
9205
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
9246
9206
|
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
9247
9207
|
}
|
|
@@ -9253,7 +9213,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
9253
9213
|
}
|
|
9254
9214
|
}
|
|
9255
9215
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9256
|
-
const
|
|
9216
|
+
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9257
9217
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
9258
9218
|
return UnknownValue;
|
|
9259
9219
|
}
|
|
@@ -9264,14 +9224,13 @@ class CallExpressionBase extends NodeBase {
|
|
|
9264
9224
|
}
|
|
9265
9225
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9266
9226
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9267
|
-
if (returnExpression
|
|
9268
|
-
return
|
|
9227
|
+
if (this.returnExpression === UNKNOWN_EXPRESSION) {
|
|
9228
|
+
return UNKNOWN_EXPRESSION;
|
|
9269
9229
|
}
|
|
9270
9230
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
9271
9231
|
this.deoptimizableDependentExpressions.push(origin);
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
}, UNKNOWN_RETURN_EXPRESSION);
|
|
9232
|
+
return returnExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9233
|
+
}, UNKNOWN_EXPRESSION);
|
|
9275
9234
|
}
|
|
9276
9235
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9277
9236
|
const { type } = interaction;
|
|
@@ -9286,9 +9245,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
9286
9245
|
: context.accessed).trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
9287
9246
|
return false;
|
|
9288
9247
|
}
|
|
9289
|
-
|
|
9290
|
-
return ((type === INTERACTION_ASSIGNED || !isPure) &&
|
|
9291
|
-
returnExpression.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
9248
|
+
return this.getReturnExpression().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9292
9249
|
}
|
|
9293
9250
|
}
|
|
9294
9251
|
|
|
@@ -9367,7 +9324,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9367
9324
|
}
|
|
9368
9325
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
9369
9326
|
if (this.returnExpression === null) {
|
|
9370
|
-
this.returnExpression =
|
|
9327
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
9371
9328
|
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
9372
9329
|
}
|
|
9373
9330
|
return this.returnExpression;
|
|
@@ -9451,7 +9408,7 @@ class MethodBase extends NodeBase {
|
|
|
9451
9408
|
// expressions, there is no known situation where a getter is deoptimized.
|
|
9452
9409
|
deoptimizeCache() { }
|
|
9453
9410
|
deoptimizePath(path) {
|
|
9454
|
-
this.getAccessedValue()
|
|
9411
|
+
this.getAccessedValue().deoptimizePath(path);
|
|
9455
9412
|
}
|
|
9456
9413
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9457
9414
|
if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
|
|
@@ -9470,13 +9427,13 @@ class MethodBase extends NodeBase {
|
|
|
9470
9427
|
withNew: false
|
|
9471
9428
|
}, EMPTY_PATH, recursionTracker);
|
|
9472
9429
|
}
|
|
9473
|
-
this.getAccessedValue()
|
|
9430
|
+
this.getAccessedValue().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9474
9431
|
}
|
|
9475
9432
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9476
|
-
return this.getAccessedValue()
|
|
9433
|
+
return this.getAccessedValue().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9477
9434
|
}
|
|
9478
9435
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9479
|
-
return this.getAccessedValue()
|
|
9436
|
+
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9480
9437
|
}
|
|
9481
9438
|
hasEffects(context) {
|
|
9482
9439
|
return this.key.hasEffects(context);
|
|
@@ -9499,17 +9456,17 @@ class MethodBase extends NodeBase {
|
|
|
9499
9456
|
withNew: false
|
|
9500
9457
|
}, context);
|
|
9501
9458
|
}
|
|
9502
|
-
return this.getAccessedValue()
|
|
9459
|
+
return this.getAccessedValue().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9503
9460
|
}
|
|
9504
9461
|
applyDeoptimizations() { }
|
|
9505
9462
|
getAccessedValue() {
|
|
9506
9463
|
if (this.accessedValue === null) {
|
|
9507
9464
|
if (this.kind === 'get') {
|
|
9508
|
-
this.accessedValue =
|
|
9465
|
+
this.accessedValue = UNKNOWN_EXPRESSION;
|
|
9509
9466
|
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, SHARED_RECURSION_TRACKER, this));
|
|
9510
9467
|
}
|
|
9511
9468
|
else {
|
|
9512
|
-
return (this.accessedValue =
|
|
9469
|
+
return (this.accessedValue = this.value);
|
|
9513
9470
|
}
|
|
9514
9471
|
}
|
|
9515
9472
|
return this.accessedValue;
|
|
@@ -9722,10 +9679,7 @@ class MultiExpression extends ExpressionEntity {
|
|
|
9722
9679
|
}
|
|
9723
9680
|
}
|
|
9724
9681
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9725
|
-
return
|
|
9726
|
-
new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0])),
|
|
9727
|
-
false
|
|
9728
|
-
];
|
|
9682
|
+
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)));
|
|
9729
9683
|
}
|
|
9730
9684
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9731
9685
|
for (const expression of this.expressions) {
|
|
@@ -9777,13 +9731,10 @@ class ConditionalExpression extends NodeBase {
|
|
|
9777
9731
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9778
9732
|
const usedBranch = this.getUsedBranch();
|
|
9779
9733
|
if (!usedBranch)
|
|
9780
|
-
return [
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
]),
|
|
9785
|
-
false
|
|
9786
|
-
];
|
|
9734
|
+
return new MultiExpression([
|
|
9735
|
+
this.consequent.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
9736
|
+
this.alternate.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
9737
|
+
]);
|
|
9787
9738
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9788
9739
|
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9789
9740
|
}
|
|
@@ -10908,13 +10859,10 @@ class LogicalExpression extends NodeBase {
|
|
|
10908
10859
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10909
10860
|
const usedBranch = this.getUsedBranch();
|
|
10910
10861
|
if (!usedBranch)
|
|
10911
|
-
return [
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
]),
|
|
10916
|
-
false
|
|
10917
|
-
];
|
|
10862
|
+
return new MultiExpression([
|
|
10863
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
10864
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
10865
|
+
]);
|
|
10918
10866
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10919
10867
|
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
10920
10868
|
}
|
|
@@ -11340,7 +11288,7 @@ class PropertyDefinition extends NodeBase {
|
|
|
11340
11288
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
11341
11289
|
return this.value
|
|
11342
11290
|
? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
11343
|
-
:
|
|
11291
|
+
: UNKNOWN_EXPRESSION;
|
|
11344
11292
|
}
|
|
11345
11293
|
hasEffects(context) {
|
|
11346
11294
|
return this.key.hasEffects(context) || (this.static && !!this.value?.hasEffects(context));
|
|
@@ -11631,7 +11579,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11631
11579
|
this.quasi.include(context, includeChildrenRecursively);
|
|
11632
11580
|
}
|
|
11633
11581
|
this.tag.includeCallArguments(context, this.interaction.args);
|
|
11634
|
-
const
|
|
11582
|
+
const returnExpression = this.getReturnExpression();
|
|
11635
11583
|
if (!returnExpression.included) {
|
|
11636
11584
|
returnExpression.include(context, false);
|
|
11637
11585
|
}
|
|
@@ -11661,7 +11609,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11661
11609
|
}
|
|
11662
11610
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
11663
11611
|
if (this.returnExpression === null) {
|
|
11664
|
-
this.returnExpression =
|
|
11612
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
11665
11613
|
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
11666
11614
|
}
|
|
11667
11615
|
return this.returnExpression;
|
|
@@ -11694,7 +11642,7 @@ class TemplateLiteral extends NodeBase {
|
|
|
11694
11642
|
}
|
|
11695
11643
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
11696
11644
|
if (path.length !== 1) {
|
|
11697
|
-
return
|
|
11645
|
+
return UNKNOWN_EXPRESSION;
|
|
11698
11646
|
}
|
|
11699
11647
|
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
11700
11648
|
}
|
|
@@ -13208,7 +13156,6 @@ class Module {
|
|
|
13208
13156
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
13209
13157
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
13210
13158
|
magicString: this.magicString,
|
|
13211
|
-
manualPureFunctions: this.graph.pureFunctions,
|
|
13212
13159
|
module: this,
|
|
13213
13160
|
moduleContext: this.context,
|
|
13214
13161
|
options: this.options,
|
|
@@ -23530,7 +23477,6 @@ class Graph {
|
|
|
23530
23477
|
this.acornParser = Parser.extend(...options.acornInjectPlugins);
|
|
23531
23478
|
this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver);
|
|
23532
23479
|
this.fileOperationQueue = new Queue(options.maxParallelFileOps);
|
|
23533
|
-
this.pureFunctions = getPureFunctions(options);
|
|
23534
23480
|
}
|
|
23535
23481
|
async build() {
|
|
23536
23482
|
timeStart('generate module graph', 2);
|
|
@@ -24030,7 +23976,6 @@ const treeshakePresets = {
|
|
|
24030
23976
|
recommended: {
|
|
24031
23977
|
annotations: true,
|
|
24032
23978
|
correctVarValueBeforeDeclaration: false,
|
|
24033
|
-
manualPureFunctions: EMPTY_ARRAY,
|
|
24034
23979
|
moduleSideEffects: () => true,
|
|
24035
23980
|
propertyReadSideEffects: true,
|
|
24036
23981
|
tryCatchDeoptimization: true,
|
|
@@ -24039,7 +23984,6 @@ const treeshakePresets = {
|
|
|
24039
23984
|
safest: {
|
|
24040
23985
|
annotations: true,
|
|
24041
23986
|
correctVarValueBeforeDeclaration: true,
|
|
24042
|
-
manualPureFunctions: EMPTY_ARRAY,
|
|
24043
23987
|
moduleSideEffects: () => true,
|
|
24044
23988
|
propertyReadSideEffects: true,
|
|
24045
23989
|
tryCatchDeoptimization: true,
|
|
@@ -24048,7 +23992,6 @@ const treeshakePresets = {
|
|
|
24048
23992
|
smallest: {
|
|
24049
23993
|
annotations: true,
|
|
24050
23994
|
correctVarValueBeforeDeclaration: false,
|
|
24051
|
-
manualPureFunctions: EMPTY_ARRAY,
|
|
24052
23995
|
moduleSideEffects: () => false,
|
|
24053
23996
|
propertyReadSideEffects: false,
|
|
24054
23997
|
tryCatchDeoptimization: false,
|
|
@@ -24245,7 +24188,6 @@ const getTreeshake = (config) => {
|
|
|
24245
24188
|
return {
|
|
24246
24189
|
annotations: configWithPreset.annotations !== false,
|
|
24247
24190
|
correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true,
|
|
24248
|
-
manualPureFunctions: configWithPreset.manualPureFunctions ?? EMPTY_ARRAY,
|
|
24249
24191
|
moduleSideEffects: getHasModuleSideEffects(configWithPreset.moduleSideEffects),
|
|
24250
24192
|
propertyReadSideEffects: configWithPreset.propertyReadSideEffects === 'always'
|
|
24251
24193
|
? 'always'
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.d.ts
CHANGED
|
@@ -466,7 +466,6 @@ type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
|
|
|
466
466
|
export interface NormalizedTreeshakingOptions {
|
|
467
467
|
annotations: boolean;
|
|
468
468
|
correctVarValueBeforeDeclaration: boolean;
|
|
469
|
-
manualPureFunctions: readonly string[];
|
|
470
469
|
moduleSideEffects: HasModuleSideEffects;
|
|
471
470
|
propertyReadSideEffects: boolean | 'always';
|
|
472
471
|
tryCatchDeoptimization: boolean;
|
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.4.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.4.0
|
|
4
|
+
Tue, 22 Nov 2022 05:15:54 GMT - commit 780e3421e8a498f3248fd7d8506e97fcee8dd1e6
|
|
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$1 = "3.4.0
|
|
34
|
+
var version$1 = "3.4.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -50,10 +50,6 @@ async function asyncFlatten(array) {
|
|
|
50
50
|
return array;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const BLANK = Object.freeze(Object.create(null));
|
|
54
|
-
const EMPTY_OBJECT = Object.freeze({});
|
|
55
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
56
|
-
|
|
57
53
|
function getLocator$1(source, options) {
|
|
58
54
|
if (options === void 0) { options = {}; }
|
|
59
55
|
var offsetLine = options.offsetLine || 0;
|
|
@@ -818,7 +814,6 @@ const treeshakePresets = {
|
|
|
818
814
|
recommended: {
|
|
819
815
|
annotations: true,
|
|
820
816
|
correctVarValueBeforeDeclaration: false,
|
|
821
|
-
manualPureFunctions: EMPTY_ARRAY,
|
|
822
817
|
moduleSideEffects: () => true,
|
|
823
818
|
propertyReadSideEffects: true,
|
|
824
819
|
tryCatchDeoptimization: true,
|
|
@@ -827,7 +822,6 @@ const treeshakePresets = {
|
|
|
827
822
|
safest: {
|
|
828
823
|
annotations: true,
|
|
829
824
|
correctVarValueBeforeDeclaration: true,
|
|
830
|
-
manualPureFunctions: EMPTY_ARRAY,
|
|
831
825
|
moduleSideEffects: () => true,
|
|
832
826
|
propertyReadSideEffects: true,
|
|
833
827
|
tryCatchDeoptimization: true,
|
|
@@ -836,7 +830,6 @@ const treeshakePresets = {
|
|
|
836
830
|
smallest: {
|
|
837
831
|
annotations: true,
|
|
838
832
|
correctVarValueBeforeDeclaration: false,
|
|
839
|
-
manualPureFunctions: EMPTY_ARRAY,
|
|
840
833
|
moduleSideEffects: () => false,
|
|
841
834
|
propertyReadSideEffects: false,
|
|
842
835
|
tryCatchDeoptimization: false,
|
|
@@ -2923,7 +2916,7 @@ class ExpressionEntity {
|
|
|
2923
2916
|
return UnknownValue;
|
|
2924
2917
|
}
|
|
2925
2918
|
getReturnExpressionWhenCalledAtPath(_path, _interaction, _recursionTracker, _origin) {
|
|
2926
|
-
return
|
|
2919
|
+
return UNKNOWN_EXPRESSION;
|
|
2927
2920
|
}
|
|
2928
2921
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2929
2922
|
return true;
|
|
@@ -2942,10 +2935,6 @@ class ExpressionEntity {
|
|
|
2942
2935
|
}
|
|
2943
2936
|
const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
|
|
2944
2937
|
})();
|
|
2945
|
-
const UNKNOWN_RETURN_EXPRESSION = [
|
|
2946
|
-
UNKNOWN_EXPRESSION,
|
|
2947
|
-
false
|
|
2948
|
-
];
|
|
2949
2938
|
|
|
2950
2939
|
const INTERACTION_ACCESSED = 0;
|
|
2951
2940
|
const INTERACTION_ASSIGNED = 1;
|
|
@@ -3046,6 +3035,10 @@ class ExternalVariable extends Variable {
|
|
|
3046
3035
|
}
|
|
3047
3036
|
}
|
|
3048
3037
|
|
|
3038
|
+
const BLANK = Object.freeze(Object.create(null));
|
|
3039
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
3040
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
3041
|
+
|
|
3049
3042
|
const RESERVED_NAMES = new Set([
|
|
3050
3043
|
'await',
|
|
3051
3044
|
'break',
|
|
@@ -5449,7 +5442,7 @@ const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEnti
|
|
|
5449
5442
|
if (path.length === 1) {
|
|
5450
5443
|
return getMemberReturnExpressionWhenCalled(literalBooleanMembers, path[0]);
|
|
5451
5444
|
}
|
|
5452
|
-
return
|
|
5445
|
+
return UNKNOWN_EXPRESSION;
|
|
5453
5446
|
}
|
|
5454
5447
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5455
5448
|
if (interaction.type === INTERACTION_ACCESSED) {
|
|
@@ -5472,7 +5465,7 @@ const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity
|
|
|
5472
5465
|
if (path.length === 1) {
|
|
5473
5466
|
return getMemberReturnExpressionWhenCalled(literalNumberMembers, path[0]);
|
|
5474
5467
|
}
|
|
5475
|
-
return
|
|
5468
|
+
return UNKNOWN_EXPRESSION;
|
|
5476
5469
|
}
|
|
5477
5470
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5478
5471
|
if (interaction.type === INTERACTION_ACCESSED) {
|
|
@@ -5495,7 +5488,7 @@ const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity
|
|
|
5495
5488
|
if (path.length === 1) {
|
|
5496
5489
|
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
5497
5490
|
}
|
|
5498
|
-
return
|
|
5491
|
+
return UNKNOWN_EXPRESSION;
|
|
5499
5492
|
}
|
|
5500
5493
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5501
5494
|
if (interaction.type === INTERACTION_ACCESSED) {
|
|
@@ -5616,8 +5609,8 @@ function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
|
5616
5609
|
}
|
|
5617
5610
|
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
5618
5611
|
if (typeof memberName !== 'string' || !members[memberName])
|
|
5619
|
-
return
|
|
5620
|
-
return
|
|
5612
|
+
return UNKNOWN_EXPRESSION;
|
|
5613
|
+
return members[memberName].returns;
|
|
5621
5614
|
}
|
|
5622
5615
|
|
|
5623
5616
|
// AST walker module for Mozilla Parser API compatible trees
|
|
@@ -6267,15 +6260,12 @@ class Method extends ExpressionEntity {
|
|
|
6267
6260
|
}
|
|
6268
6261
|
getReturnExpressionWhenCalledAtPath(path, { thisArg }) {
|
|
6269
6262
|
if (path.length > 0) {
|
|
6270
|
-
return
|
|
6263
|
+
return UNKNOWN_EXPRESSION;
|
|
6271
6264
|
}
|
|
6272
|
-
return
|
|
6273
|
-
this.description.
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
: this.description.returns()),
|
|
6277
|
-
false
|
|
6278
|
-
];
|
|
6265
|
+
return (this.description.returnsPrimitive ||
|
|
6266
|
+
(this.description.returns === 'self'
|
|
6267
|
+
? thisArg || UNKNOWN_EXPRESSION
|
|
6268
|
+
: this.description.returns()));
|
|
6279
6269
|
}
|
|
6280
6270
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6281
6271
|
const { type } = interaction;
|
|
@@ -6518,7 +6508,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6518
6508
|
}
|
|
6519
6509
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6520
6510
|
if (path.length === 0) {
|
|
6521
|
-
return
|
|
6511
|
+
return UNKNOWN_EXPRESSION;
|
|
6522
6512
|
}
|
|
6523
6513
|
const [key, ...subPath] = path;
|
|
6524
6514
|
const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
|
|
@@ -6528,7 +6518,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6528
6518
|
if (this.prototypeExpression) {
|
|
6529
6519
|
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6530
6520
|
}
|
|
6531
|
-
return
|
|
6521
|
+
return UNKNOWN_EXPRESSION;
|
|
6532
6522
|
}
|
|
6533
6523
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6534
6524
|
const [key, ...subPath] = path;
|
|
@@ -7000,12 +6990,12 @@ class LocalVariable extends Variable {
|
|
|
7000
6990
|
}
|
|
7001
6991
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
7002
6992
|
if (this.isReassigned || !this.init) {
|
|
7003
|
-
return
|
|
6993
|
+
return UNKNOWN_EXPRESSION;
|
|
7004
6994
|
}
|
|
7005
6995
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
7006
6996
|
this.expressionsToBeDeoptimized.push(origin);
|
|
7007
6997
|
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
7008
|
-
},
|
|
6998
|
+
}, UNKNOWN_EXPRESSION);
|
|
7009
6999
|
}
|
|
7010
7000
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7011
7001
|
switch (interaction.type) {
|
|
@@ -7362,19 +7352,6 @@ function is_reference (node, parent) {
|
|
|
7362
7352
|
return false;
|
|
7363
7353
|
}
|
|
7364
7354
|
|
|
7365
|
-
const PureFunctionKey = Symbol('PureFunction');
|
|
7366
|
-
const getPureFunctions = ({ treeshake }) => {
|
|
7367
|
-
const pureFunctions = Object.create(null);
|
|
7368
|
-
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
7369
|
-
let currentFunctions = pureFunctions;
|
|
7370
|
-
for (const pathSegment of functionName.split('.')) {
|
|
7371
|
-
currentFunctions = currentFunctions[pathSegment] || (currentFunctions[pathSegment] = Object.create(null));
|
|
7372
|
-
}
|
|
7373
|
-
currentFunctions[PureFunctionKey] = true;
|
|
7374
|
-
}
|
|
7375
|
-
return pureFunctions;
|
|
7376
|
-
};
|
|
7377
|
-
|
|
7378
7355
|
/* eslint sort-keys: "off" */
|
|
7379
7356
|
const ValueProperties = Symbol('Value Properties');
|
|
7380
7357
|
const getTruthyLiteralValue = () => UnknownTruthyValue;
|
|
@@ -7553,6 +7530,7 @@ const knownGlobals = {
|
|
|
7553
7530
|
// deoptimizes everything anyway
|
|
7554
7531
|
defineProperty: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
7555
7532
|
defineProperties: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
7533
|
+
freeze: MUTATES_ARG_WITHOUT_ACCESSOR,
|
|
7556
7534
|
getOwnPropertyDescriptor: PF,
|
|
7557
7535
|
getOwnPropertyNames: PF,
|
|
7558
7536
|
getOwnPropertySymbols: PF,
|
|
@@ -8352,8 +8330,7 @@ class Identifier extends NodeBase {
|
|
|
8352
8330
|
return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8353
8331
|
}
|
|
8354
8332
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
8355
|
-
|
|
8356
|
-
return [expression, isPure || this.isPureFunction(path)];
|
|
8333
|
+
return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
8357
8334
|
}
|
|
8358
8335
|
hasEffects(context) {
|
|
8359
8336
|
if (!this.deoptimized)
|
|
@@ -8363,22 +8340,19 @@ class Identifier extends NodeBase {
|
|
|
8363
8340
|
}
|
|
8364
8341
|
return (this.context.options.treeshake.unknownGlobalSideEffects &&
|
|
8365
8342
|
this.variable instanceof GlobalVariable &&
|
|
8366
|
-
!this.isPureFunction(EMPTY_PATH) &&
|
|
8367
8343
|
this.variable.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
8368
8344
|
}
|
|
8369
8345
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8370
8346
|
switch (interaction.type) {
|
|
8371
8347
|
case INTERACTION_ACCESSED: {
|
|
8372
8348
|
return (this.variable !== null &&
|
|
8373
|
-
!this.isPureFunction(path) &&
|
|
8374
8349
|
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
8375
8350
|
}
|
|
8376
8351
|
case INTERACTION_ASSIGNED: {
|
|
8377
8352
|
return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8378
8353
|
}
|
|
8379
8354
|
case INTERACTION_CALLED: {
|
|
8380
|
-
return
|
|
8381
|
-
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
8355
|
+
return this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8382
8356
|
}
|
|
8383
8357
|
}
|
|
8384
8358
|
}
|
|
@@ -8460,21 +8434,6 @@ class Identifier extends NodeBase {
|
|
|
8460
8434
|
}
|
|
8461
8435
|
return this.variable;
|
|
8462
8436
|
}
|
|
8463
|
-
isPureFunction(path) {
|
|
8464
|
-
let currentPureFunction = this.context.manualPureFunctions[this.name];
|
|
8465
|
-
for (const segment of path) {
|
|
8466
|
-
if (currentPureFunction) {
|
|
8467
|
-
if (currentPureFunction[PureFunctionKey]) {
|
|
8468
|
-
return true;
|
|
8469
|
-
}
|
|
8470
|
-
currentPureFunction = currentPureFunction[segment];
|
|
8471
|
-
}
|
|
8472
|
-
else {
|
|
8473
|
-
return false;
|
|
8474
|
-
}
|
|
8475
|
-
}
|
|
8476
|
-
return currentPureFunction?.[PureFunctionKey];
|
|
8477
|
-
}
|
|
8478
8437
|
}
|
|
8479
8438
|
function closestParentFunctionOrProgram(node) {
|
|
8480
8439
|
while (node && !/^Program|Function/.test(node.type)) {
|
|
@@ -8796,9 +8755,9 @@ class FunctionBase extends NodeBase {
|
|
|
8796
8755
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
8797
8756
|
this.context.requestTreeshakingPass();
|
|
8798
8757
|
}
|
|
8799
|
-
return
|
|
8758
|
+
return UNKNOWN_EXPRESSION;
|
|
8800
8759
|
}
|
|
8801
|
-
return
|
|
8760
|
+
return this.scope.getReturnExpression();
|
|
8802
8761
|
}
|
|
8803
8762
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8804
8763
|
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
@@ -9397,7 +9356,7 @@ class Literal extends NodeBase {
|
|
|
9397
9356
|
}
|
|
9398
9357
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
9399
9358
|
if (path.length !== 1)
|
|
9400
|
-
return
|
|
9359
|
+
return UNKNOWN_EXPRESSION;
|
|
9401
9360
|
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
|
|
9402
9361
|
}
|
|
9403
9362
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
@@ -9550,13 +9509,13 @@ class MemberExpression extends NodeBase {
|
|
|
9550
9509
|
return this.variable.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9551
9510
|
}
|
|
9552
9511
|
if (this.isUndefined) {
|
|
9553
|
-
return
|
|
9512
|
+
return UNDEFINED_EXPRESSION;
|
|
9554
9513
|
}
|
|
9555
9514
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9556
9515
|
if (path.length < MAX_PATH_DEPTH) {
|
|
9557
9516
|
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
9558
9517
|
}
|
|
9559
|
-
return
|
|
9518
|
+
return UNKNOWN_EXPRESSION;
|
|
9560
9519
|
}
|
|
9561
9520
|
hasEffects(context) {
|
|
9562
9521
|
if (!this.deoptimized)
|
|
@@ -9733,8 +9692,8 @@ class CallExpressionBase extends NodeBase {
|
|
|
9733
9692
|
this.expressionsToBeDeoptimized = new Set();
|
|
9734
9693
|
}
|
|
9735
9694
|
deoptimizeCache() {
|
|
9736
|
-
if (this.returnExpression
|
|
9737
|
-
this.returnExpression =
|
|
9695
|
+
if (this.returnExpression !== UNKNOWN_EXPRESSION) {
|
|
9696
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
9738
9697
|
for (const expression of this.deoptimizableDependentExpressions) {
|
|
9739
9698
|
expression.deoptimizeCache();
|
|
9740
9699
|
}
|
|
@@ -9748,15 +9707,13 @@ class CallExpressionBase extends NodeBase {
|
|
|
9748
9707
|
this.context.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
9749
9708
|
return;
|
|
9750
9709
|
}
|
|
9751
|
-
const
|
|
9710
|
+
const returnExpression = this.getReturnExpression();
|
|
9752
9711
|
if (returnExpression !== UNKNOWN_EXPRESSION) {
|
|
9753
9712
|
returnExpression.deoptimizePath(path);
|
|
9754
9713
|
}
|
|
9755
9714
|
}
|
|
9756
9715
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9757
|
-
const
|
|
9758
|
-
if (isPure)
|
|
9759
|
-
return;
|
|
9716
|
+
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9760
9717
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
9761
9718
|
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
9762
9719
|
}
|
|
@@ -9768,7 +9725,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
9768
9725
|
}
|
|
9769
9726
|
}
|
|
9770
9727
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9771
|
-
const
|
|
9728
|
+
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9772
9729
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
9773
9730
|
return UnknownValue;
|
|
9774
9731
|
}
|
|
@@ -9779,14 +9736,13 @@ class CallExpressionBase extends NodeBase {
|
|
|
9779
9736
|
}
|
|
9780
9737
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9781
9738
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9782
|
-
if (returnExpression
|
|
9783
|
-
return
|
|
9739
|
+
if (this.returnExpression === UNKNOWN_EXPRESSION) {
|
|
9740
|
+
return UNKNOWN_EXPRESSION;
|
|
9784
9741
|
}
|
|
9785
9742
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
9786
9743
|
this.deoptimizableDependentExpressions.push(origin);
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
}, UNKNOWN_RETURN_EXPRESSION);
|
|
9744
|
+
return returnExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9745
|
+
}, UNKNOWN_EXPRESSION);
|
|
9790
9746
|
}
|
|
9791
9747
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9792
9748
|
const { type } = interaction;
|
|
@@ -9801,9 +9757,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
9801
9757
|
: context.accessed).trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
9802
9758
|
return false;
|
|
9803
9759
|
}
|
|
9804
|
-
|
|
9805
|
-
return ((type === INTERACTION_ASSIGNED || !isPure) &&
|
|
9806
|
-
returnExpression.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
9760
|
+
return this.getReturnExpression().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9807
9761
|
}
|
|
9808
9762
|
}
|
|
9809
9763
|
|
|
@@ -9882,7 +9836,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9882
9836
|
}
|
|
9883
9837
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
9884
9838
|
if (this.returnExpression === null) {
|
|
9885
|
-
this.returnExpression =
|
|
9839
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
9886
9840
|
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
9887
9841
|
}
|
|
9888
9842
|
return this.returnExpression;
|
|
@@ -9966,7 +9920,7 @@ class MethodBase extends NodeBase {
|
|
|
9966
9920
|
// expressions, there is no known situation where a getter is deoptimized.
|
|
9967
9921
|
deoptimizeCache() { }
|
|
9968
9922
|
deoptimizePath(path) {
|
|
9969
|
-
this.getAccessedValue()
|
|
9923
|
+
this.getAccessedValue().deoptimizePath(path);
|
|
9970
9924
|
}
|
|
9971
9925
|
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9972
9926
|
if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
|
|
@@ -9985,13 +9939,13 @@ class MethodBase extends NodeBase {
|
|
|
9985
9939
|
withNew: false
|
|
9986
9940
|
}, EMPTY_PATH, recursionTracker);
|
|
9987
9941
|
}
|
|
9988
|
-
this.getAccessedValue()
|
|
9942
|
+
this.getAccessedValue().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9989
9943
|
}
|
|
9990
9944
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9991
|
-
return this.getAccessedValue()
|
|
9945
|
+
return this.getAccessedValue().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9992
9946
|
}
|
|
9993
9947
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9994
|
-
return this.getAccessedValue()
|
|
9948
|
+
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9995
9949
|
}
|
|
9996
9950
|
hasEffects(context) {
|
|
9997
9951
|
return this.key.hasEffects(context);
|
|
@@ -10014,17 +9968,17 @@ class MethodBase extends NodeBase {
|
|
|
10014
9968
|
withNew: false
|
|
10015
9969
|
}, context);
|
|
10016
9970
|
}
|
|
10017
|
-
return this.getAccessedValue()
|
|
9971
|
+
return this.getAccessedValue().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
10018
9972
|
}
|
|
10019
9973
|
applyDeoptimizations() { }
|
|
10020
9974
|
getAccessedValue() {
|
|
10021
9975
|
if (this.accessedValue === null) {
|
|
10022
9976
|
if (this.kind === 'get') {
|
|
10023
|
-
this.accessedValue =
|
|
9977
|
+
this.accessedValue = UNKNOWN_EXPRESSION;
|
|
10024
9978
|
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, SHARED_RECURSION_TRACKER, this));
|
|
10025
9979
|
}
|
|
10026
9980
|
else {
|
|
10027
|
-
return (this.accessedValue =
|
|
9981
|
+
return (this.accessedValue = this.value);
|
|
10028
9982
|
}
|
|
10029
9983
|
}
|
|
10030
9984
|
return this.accessedValue;
|
|
@@ -10237,10 +10191,7 @@ class MultiExpression extends ExpressionEntity {
|
|
|
10237
10191
|
}
|
|
10238
10192
|
}
|
|
10239
10193
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10240
|
-
return
|
|
10241
|
-
new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0])),
|
|
10242
|
-
false
|
|
10243
|
-
];
|
|
10194
|
+
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)));
|
|
10244
10195
|
}
|
|
10245
10196
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10246
10197
|
for (const expression of this.expressions) {
|
|
@@ -10292,13 +10243,10 @@ class ConditionalExpression extends NodeBase {
|
|
|
10292
10243
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10293
10244
|
const usedBranch = this.getUsedBranch();
|
|
10294
10245
|
if (!usedBranch)
|
|
10295
|
-
return [
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
]),
|
|
10300
|
-
false
|
|
10301
|
-
];
|
|
10246
|
+
return new MultiExpression([
|
|
10247
|
+
this.consequent.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
10248
|
+
this.alternate.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
10249
|
+
]);
|
|
10302
10250
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10303
10251
|
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
10304
10252
|
}
|
|
@@ -11423,13 +11371,10 @@ class LogicalExpression extends NodeBase {
|
|
|
11423
11371
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
11424
11372
|
const usedBranch = this.getUsedBranch();
|
|
11425
11373
|
if (!usedBranch)
|
|
11426
|
-
return [
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
]),
|
|
11431
|
-
false
|
|
11432
|
-
];
|
|
11374
|
+
return new MultiExpression([
|
|
11375
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
11376
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
11377
|
+
]);
|
|
11433
11378
|
this.expressionsToBeDeoptimized.push(origin);
|
|
11434
11379
|
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
11435
11380
|
}
|
|
@@ -11855,7 +11800,7 @@ class PropertyDefinition extends NodeBase {
|
|
|
11855
11800
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
11856
11801
|
return this.value
|
|
11857
11802
|
? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
11858
|
-
:
|
|
11803
|
+
: UNKNOWN_EXPRESSION;
|
|
11859
11804
|
}
|
|
11860
11805
|
hasEffects(context) {
|
|
11861
11806
|
return this.key.hasEffects(context) || (this.static && !!this.value?.hasEffects(context));
|
|
@@ -12146,7 +12091,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
12146
12091
|
this.quasi.include(context, includeChildrenRecursively);
|
|
12147
12092
|
}
|
|
12148
12093
|
this.tag.includeCallArguments(context, this.interaction.args);
|
|
12149
|
-
const
|
|
12094
|
+
const returnExpression = this.getReturnExpression();
|
|
12150
12095
|
if (!returnExpression.included) {
|
|
12151
12096
|
returnExpression.include(context, false);
|
|
12152
12097
|
}
|
|
@@ -12176,7 +12121,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
12176
12121
|
}
|
|
12177
12122
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
12178
12123
|
if (this.returnExpression === null) {
|
|
12179
|
-
this.returnExpression =
|
|
12124
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
12180
12125
|
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
12181
12126
|
}
|
|
12182
12127
|
return this.returnExpression;
|
|
@@ -12209,7 +12154,7 @@ class TemplateLiteral extends NodeBase {
|
|
|
12209
12154
|
}
|
|
12210
12155
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
12211
12156
|
if (path.length !== 1) {
|
|
12212
|
-
return
|
|
12157
|
+
return UNKNOWN_EXPRESSION;
|
|
12213
12158
|
}
|
|
12214
12159
|
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
12215
12160
|
}
|
|
@@ -13723,7 +13668,6 @@ class Module {
|
|
|
13723
13668
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
13724
13669
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
13725
13670
|
magicString: this.magicString,
|
|
13726
|
-
manualPureFunctions: this.graph.pureFunctions,
|
|
13727
13671
|
module: this,
|
|
13728
13672
|
moduleContext: this.context,
|
|
13729
13673
|
options: this.options,
|
|
@@ -24045,7 +23989,6 @@ class Graph {
|
|
|
24045
23989
|
this.acornParser = Parser.extend(...options.acornInjectPlugins);
|
|
24046
23990
|
this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver);
|
|
24047
23991
|
this.fileOperationQueue = new Queue(options.maxParallelFileOps);
|
|
24048
|
-
this.pureFunctions = getPureFunctions(options);
|
|
24049
23992
|
}
|
|
24050
23993
|
async build() {
|
|
24051
23994
|
timeStart('generate module graph', 2);
|
|
@@ -24663,7 +24606,6 @@ const getTreeshake = (config) => {
|
|
|
24663
24606
|
return {
|
|
24664
24607
|
annotations: configWithPreset.annotations !== false,
|
|
24665
24608
|
correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true,
|
|
24666
|
-
manualPureFunctions: configWithPreset.manualPureFunctions ?? EMPTY_ARRAY,
|
|
24667
24609
|
moduleSideEffects: getHasModuleSideEffects(configWithPreset.moduleSideEffects),
|
|
24668
24610
|
propertyReadSideEffects: configWithPreset.propertyReadSideEffects === 'always'
|
|
24669
24611
|
? 'always'
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED