rollup 3.20.1 → 3.20.3-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/node-entry.js +143 -115
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +1 -1
- 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/rollup.js +143 -115
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch-proxy.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.20.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.20.3-0
|
|
4
|
+
Fri, 14 Apr 2023 05:11:57 GMT - commit 80c2fcb882e8a5ec2be167784d8ab14654f69379
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.20.
|
|
19
|
+
var version$1 = "3.20.3-0";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -1860,11 +1860,8 @@ const UNKNOWN_RETURN_EXPRESSION = [
|
|
|
1860
1860
|
false
|
|
1861
1861
|
];
|
|
1862
1862
|
const deoptimizeInteraction = (interaction) => {
|
|
1863
|
-
interaction.
|
|
1864
|
-
|
|
1865
|
-
for (const argument of interaction.args) {
|
|
1866
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
1867
|
-
}
|
|
1863
|
+
for (const argument of interaction.args) {
|
|
1864
|
+
argument?.deoptimizePath(UNKNOWN_PATH);
|
|
1868
1865
|
}
|
|
1869
1866
|
};
|
|
1870
1867
|
|
|
@@ -1872,23 +1869,18 @@ const INTERACTION_ACCESSED = 0;
|
|
|
1872
1869
|
const INTERACTION_ASSIGNED = 1;
|
|
1873
1870
|
const INTERACTION_CALLED = 2;
|
|
1874
1871
|
const NODE_INTERACTION_UNKNOWN_ACCESS = {
|
|
1875
|
-
args: null,
|
|
1876
|
-
thisArg: null,
|
|
1872
|
+
args: [null],
|
|
1877
1873
|
type: INTERACTION_ACCESSED
|
|
1878
1874
|
};
|
|
1879
|
-
const UNKNOWN_ARG = [UNKNOWN_EXPRESSION];
|
|
1880
1875
|
const NODE_INTERACTION_UNKNOWN_ASSIGNMENT = {
|
|
1881
|
-
args:
|
|
1882
|
-
thisArg: null,
|
|
1876
|
+
args: [null, UNKNOWN_EXPRESSION],
|
|
1883
1877
|
type: INTERACTION_ASSIGNED
|
|
1884
1878
|
};
|
|
1885
|
-
const NO_ARGS = [];
|
|
1886
1879
|
// While this is technically a call without arguments, we can compare against
|
|
1887
|
-
// this reference in places where precise values or
|
|
1880
|
+
// this reference in places where precise values or this argument would make a
|
|
1888
1881
|
// difference
|
|
1889
1882
|
const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
1890
|
-
args:
|
|
1891
|
-
thisArg: null,
|
|
1883
|
+
args: [null],
|
|
1892
1884
|
type: INTERACTION_CALLED,
|
|
1893
1885
|
withNew: false
|
|
1894
1886
|
};
|
|
@@ -1974,6 +1966,11 @@ class ExternalVariable extends Variable {
|
|
|
1974
1966
|
const BLANK = Object.freeze(Object.create(null));
|
|
1975
1967
|
const EMPTY_OBJECT = Object.freeze({});
|
|
1976
1968
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
1969
|
+
const EMPTY_SET = Object.freeze(new (class extends Set {
|
|
1970
|
+
add() {
|
|
1971
|
+
throw new Error('Cannot add to empty set');
|
|
1972
|
+
}
|
|
1973
|
+
})());
|
|
1977
1974
|
|
|
1978
1975
|
function getLocator(source, options) {
|
|
1979
1976
|
if (options === void 0) { options = {}; }
|
|
@@ -2030,6 +2027,9 @@ const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
|
2030
2027
|
const ELLIPSIS = '...';
|
|
2031
2028
|
function getCodeFrame(source, line, column) {
|
|
2032
2029
|
let lines = source.split('\n');
|
|
2030
|
+
// Needed if a plugin did not generate correct sourcemaps
|
|
2031
|
+
if (line > lines.length)
|
|
2032
|
+
return '';
|
|
2033
2033
|
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length +
|
|
2034
2034
|
MIN_CHARACTERS_SHOWN_AFTER_LOCATION +
|
|
2035
2035
|
ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
|
|
@@ -5154,8 +5154,8 @@ const returnsString = {
|
|
|
5154
5154
|
const stringReplace = {
|
|
5155
5155
|
value: {
|
|
5156
5156
|
hasEffectsWhenCalled({ args }, context) {
|
|
5157
|
-
const argument1 = args[
|
|
5158
|
-
return (args.length <
|
|
5157
|
+
const argument1 = args[2];
|
|
5158
|
+
return (args.length < 3 ||
|
|
5159
5159
|
(typeof argument1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
5160
5160
|
deoptimizeCache() { }
|
|
5161
5161
|
}) === 'symbol' &&
|
|
@@ -5853,7 +5853,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
5853
5853
|
}
|
|
5854
5854
|
}
|
|
5855
5855
|
setAssignedValue(value) {
|
|
5856
|
-
this.assignmentInteraction = { args: [value],
|
|
5856
|
+
this.assignmentInteraction = { args: [null, value], type: INTERACTION_ASSIGNED };
|
|
5857
5857
|
}
|
|
5858
5858
|
shouldBeIncluded(context) {
|
|
5859
5859
|
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
@@ -5912,19 +5912,19 @@ class Method extends ExpressionEntity {
|
|
|
5912
5912
|
super();
|
|
5913
5913
|
this.description = description;
|
|
5914
5914
|
}
|
|
5915
|
-
deoptimizeArgumentsOnInteractionAtPath({
|
|
5915
|
+
deoptimizeArgumentsOnInteractionAtPath({ args, type }, path) {
|
|
5916
5916
|
if (type === INTERACTION_CALLED && path.length === 0 && this.description.mutatesSelfAsArray) {
|
|
5917
|
-
|
|
5917
|
+
args[0]?.deoptimizePath(UNKNOWN_INTEGER_PATH);
|
|
5918
5918
|
}
|
|
5919
5919
|
}
|
|
5920
|
-
getReturnExpressionWhenCalledAtPath(path, {
|
|
5920
|
+
getReturnExpressionWhenCalledAtPath(path, { args }) {
|
|
5921
5921
|
if (path.length > 0) {
|
|
5922
5922
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
5923
5923
|
}
|
|
5924
5924
|
return [
|
|
5925
5925
|
this.description.returnsPrimitive ||
|
|
5926
5926
|
(this.description.returns === 'self'
|
|
5927
|
-
?
|
|
5927
|
+
? args[0] || UNKNOWN_EXPRESSION
|
|
5928
5928
|
: this.description.returns()),
|
|
5929
5929
|
false
|
|
5930
5930
|
];
|
|
@@ -5935,14 +5935,14 @@ class Method extends ExpressionEntity {
|
|
|
5935
5935
|
return true;
|
|
5936
5936
|
}
|
|
5937
5937
|
if (type === INTERACTION_CALLED) {
|
|
5938
|
-
const { args
|
|
5938
|
+
const { args } = interaction;
|
|
5939
5939
|
if (this.description.mutatesSelfAsArray === true &&
|
|
5940
|
-
|
|
5940
|
+
args[0]?.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)) {
|
|
5941
5941
|
return true;
|
|
5942
5942
|
}
|
|
5943
5943
|
if (this.description.callsArgs) {
|
|
5944
5944
|
for (const argumentIndex of this.description.callsArgs) {
|
|
5945
|
-
if (args[argumentIndex]?.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
|
|
5945
|
+
if (args[argumentIndex + 1]?.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
|
|
5946
5946
|
return true;
|
|
5947
5947
|
}
|
|
5948
5948
|
}
|
|
@@ -6042,18 +6042,13 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6042
6042
|
}
|
|
6043
6043
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6044
6044
|
const [key, ...subPath] = path;
|
|
6045
|
-
const { args,
|
|
6045
|
+
const { args, type } = interaction;
|
|
6046
6046
|
if (this.hasLostTrack ||
|
|
6047
6047
|
// single paths that are deoptimized will not become getters or setters
|
|
6048
6048
|
((type === INTERACTION_CALLED || path.length > 1) &&
|
|
6049
6049
|
(this.hasUnknownDeoptimizedProperty ||
|
|
6050
6050
|
(typeof key === 'string' && this.deoptimizedPaths[key])))) {
|
|
6051
|
-
|
|
6052
|
-
if (args) {
|
|
6053
|
-
for (const argument of args) {
|
|
6054
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6055
|
-
}
|
|
6056
|
-
}
|
|
6051
|
+
deoptimizeInteraction(interaction);
|
|
6057
6052
|
return;
|
|
6058
6053
|
}
|
|
6059
6054
|
const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] = type === INTERACTION_CALLED || path.length > 1
|
|
@@ -6074,11 +6069,8 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6074
6069
|
}
|
|
6075
6070
|
}
|
|
6076
6071
|
if (!this.immutable) {
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
}
|
|
6080
|
-
if (args) {
|
|
6081
|
-
for (const argument of args) {
|
|
6072
|
+
for (const argument of args) {
|
|
6073
|
+
if (argument) {
|
|
6082
6074
|
this.additionalExpressionsToBeDeoptimized.add(argument);
|
|
6083
6075
|
}
|
|
6084
6076
|
}
|
|
@@ -6108,11 +6100,8 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6108
6100
|
}
|
|
6109
6101
|
}
|
|
6110
6102
|
if (!this.immutable) {
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
}
|
|
6114
|
-
if (args) {
|
|
6115
|
-
for (const argument of args) {
|
|
6103
|
+
for (const argument of args) {
|
|
6104
|
+
if (argument) {
|
|
6116
6105
|
this.additionalExpressionsToBeDeoptimized.add(argument);
|
|
6117
6106
|
}
|
|
6118
6107
|
}
|
|
@@ -6646,7 +6635,7 @@ class LocalVariable extends Variable {
|
|
|
6646
6635
|
if (!this.isReassigned) {
|
|
6647
6636
|
this.isReassigned = true;
|
|
6648
6637
|
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized;
|
|
6649
|
-
this.expressionsToBeDeoptimized =
|
|
6638
|
+
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
6650
6639
|
for (const expression of expressionsToBeDeoptimized) {
|
|
6651
6640
|
expression.deoptimizeCache();
|
|
6652
6641
|
}
|
|
@@ -6758,43 +6747,68 @@ class LocalVariable extends Variable {
|
|
|
6758
6747
|
}
|
|
6759
6748
|
}
|
|
6760
6749
|
|
|
6750
|
+
const MAX_TRACKED_INTERACTIONS = 20;
|
|
6751
|
+
const NO_INTERACTIONS = EMPTY_ARRAY;
|
|
6752
|
+
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
6753
|
+
const EMPTY_PATH_TRACKER = new PathTracker();
|
|
6754
|
+
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
6761
6755
|
class ParameterVariable extends LocalVariable {
|
|
6762
6756
|
constructor(name, declarator, context) {
|
|
6763
6757
|
super(name, declarator, UNKNOWN_EXPRESSION, context);
|
|
6764
6758
|
this.deoptimizationInteractions = [];
|
|
6765
|
-
this.deoptimizations = new
|
|
6759
|
+
this.deoptimizations = new PathTracker();
|
|
6766
6760
|
this.deoptimizedFields = new Set();
|
|
6767
6761
|
this.entitiesToBeDeoptimized = new Set();
|
|
6768
6762
|
}
|
|
6769
6763
|
addEntityToBeDeoptimized(entity) {
|
|
6770
|
-
if (
|
|
6764
|
+
if (entity === UNKNOWN_EXPRESSION) {
|
|
6765
|
+
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
6766
|
+
// the interaction cache at this point provided we keep this optimization
|
|
6767
|
+
// in mind when adding new interactions
|
|
6768
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
6769
|
+
this.entitiesToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
6770
|
+
for (const { interaction } of this.deoptimizationInteractions) {
|
|
6771
|
+
deoptimizeInteraction(interaction);
|
|
6772
|
+
}
|
|
6773
|
+
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
6774
|
+
}
|
|
6775
|
+
}
|
|
6776
|
+
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
6777
|
+
// This means that we already deoptimized all interactions and no longer
|
|
6778
|
+
// track them
|
|
6771
6779
|
entity.deoptimizePath(UNKNOWN_PATH);
|
|
6772
6780
|
}
|
|
6773
|
-
else {
|
|
6781
|
+
else if (!this.entitiesToBeDeoptimized.has(entity)) {
|
|
6782
|
+
this.entitiesToBeDeoptimized.add(entity);
|
|
6774
6783
|
for (const field of this.deoptimizedFields) {
|
|
6775
6784
|
entity.deoptimizePath([field]);
|
|
6776
6785
|
}
|
|
6786
|
+
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
6787
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
6788
|
+
}
|
|
6777
6789
|
}
|
|
6778
|
-
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
6779
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
6780
|
-
}
|
|
6781
|
-
this.entitiesToBeDeoptimized.add(entity);
|
|
6782
6790
|
}
|
|
6783
6791
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
6784
6792
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
6785
|
-
if (path.length >= 2
|
|
6793
|
+
if (path.length >= 2 ||
|
|
6794
|
+
this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
6795
|
+
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
6796
|
+
(path.length === 1 &&
|
|
6797
|
+
(this.deoptimizedFields.has(UnknownKey) ||
|
|
6798
|
+
(interaction.type === INTERACTION_CALLED && this.deoptimizedFields.has(path[0]))))) {
|
|
6786
6799
|
deoptimizeInteraction(interaction);
|
|
6787
6800
|
return;
|
|
6788
6801
|
}
|
|
6789
|
-
if (interaction.
|
|
6790
|
-
!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args, interaction.thisArg)) {
|
|
6802
|
+
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
6791
6803
|
for (const entity of this.entitiesToBeDeoptimized) {
|
|
6792
6804
|
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
6793
6805
|
}
|
|
6794
|
-
this.
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6806
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
6807
|
+
this.deoptimizationInteractions.push({
|
|
6808
|
+
interaction,
|
|
6809
|
+
path
|
|
6810
|
+
});
|
|
6811
|
+
}
|
|
6798
6812
|
}
|
|
6799
6813
|
}
|
|
6800
6814
|
deoptimizePath(path) {
|
|
@@ -6807,8 +6821,17 @@ class ParameterVariable extends LocalVariable {
|
|
|
6807
6821
|
}
|
|
6808
6822
|
this.deoptimizedFields.add(key);
|
|
6809
6823
|
for (const entity of this.entitiesToBeDeoptimized) {
|
|
6824
|
+
// We do not need a recursion tracker here as we already track whether
|
|
6825
|
+
// this field is deoptimized
|
|
6810
6826
|
entity.deoptimizePath(path);
|
|
6811
6827
|
}
|
|
6828
|
+
if (key === UnknownKey) {
|
|
6829
|
+
// save some memory
|
|
6830
|
+
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
6831
|
+
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
6832
|
+
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
6833
|
+
this.entitiesToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
6834
|
+
}
|
|
6812
6835
|
}
|
|
6813
6836
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
6814
6837
|
// We deoptimize everything that is called as that will trivially deoptimize
|
|
@@ -6818,7 +6841,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
6818
6841
|
this.deoptimizePath(UNKNOWN_PATH);
|
|
6819
6842
|
}
|
|
6820
6843
|
else if (!this.deoptimizedFields.has(path[0])) {
|
|
6821
|
-
this.deoptimizePath(path
|
|
6844
|
+
this.deoptimizePath([path[0]]);
|
|
6822
6845
|
}
|
|
6823
6846
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
6824
6847
|
}
|
|
@@ -7149,13 +7172,13 @@ const PF = {
|
|
|
7149
7172
|
const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
7150
7173
|
__proto__: null,
|
|
7151
7174
|
[ValueProperties]: {
|
|
7152
|
-
deoptimizeArgumentsOnCall({ args: [firstArgument] }) {
|
|
7175
|
+
deoptimizeArgumentsOnCall({ args: [, firstArgument] }) {
|
|
7153
7176
|
firstArgument?.deoptimizePath(UNKNOWN_PATH);
|
|
7154
7177
|
},
|
|
7155
7178
|
getLiteralValue: getTruthyLiteralValue,
|
|
7156
7179
|
hasEffectsWhenCalled({ args }, context) {
|
|
7157
|
-
return (args.length
|
|
7158
|
-
args[
|
|
7180
|
+
return (args.length <= 1 ||
|
|
7181
|
+
args[1].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
|
|
7159
7182
|
}
|
|
7160
7183
|
}
|
|
7161
7184
|
};
|
|
@@ -8578,18 +8601,19 @@ class FunctionBase extends NodeBase {
|
|
|
8578
8601
|
const { parameters } = this.scope;
|
|
8579
8602
|
const { args } = interaction;
|
|
8580
8603
|
let hasRest = false;
|
|
8581
|
-
for (let position = 0; position < args.length; position++) {
|
|
8604
|
+
for (let position = 0; position < args.length - 1; position++) {
|
|
8582
8605
|
const parameter = this.params[position];
|
|
8606
|
+
// Only the "this" argument arg[0] can be null
|
|
8607
|
+
const argument = args[position + 1];
|
|
8583
8608
|
if (hasRest || parameter instanceof RestElement) {
|
|
8584
8609
|
hasRest = true;
|
|
8585
|
-
|
|
8610
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
8586
8611
|
}
|
|
8587
8612
|
else if (parameter instanceof Identifier) {
|
|
8588
|
-
|
|
8589
|
-
parameters[position][0].addEntityToBeDeoptimized(args[position]);
|
|
8613
|
+
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
8590
8614
|
}
|
|
8591
8615
|
else if (parameter) {
|
|
8592
|
-
|
|
8616
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
8593
8617
|
}
|
|
8594
8618
|
}
|
|
8595
8619
|
}
|
|
@@ -8971,8 +8995,9 @@ class FunctionNode extends FunctionBase {
|
|
|
8971
8995
|
}
|
|
8972
8996
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8973
8997
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8974
|
-
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.
|
|
8975
|
-
this
|
|
8998
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
8999
|
+
// args[0] is the "this" argument
|
|
9000
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.args[0]);
|
|
8976
9001
|
}
|
|
8977
9002
|
}
|
|
8978
9003
|
hasEffects(context) {
|
|
@@ -9302,10 +9327,10 @@ class MemberExpression extends NodeBase {
|
|
|
9302
9327
|
}
|
|
9303
9328
|
}
|
|
9304
9329
|
deoptimizeCache() {
|
|
9305
|
-
const expressionsToBeDeoptimized = this
|
|
9306
|
-
this.expressionsToBeDeoptimized =
|
|
9330
|
+
const { expressionsToBeDeoptimized, object } = this;
|
|
9331
|
+
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
9307
9332
|
this.propertyKey = UnknownKey;
|
|
9308
|
-
|
|
9333
|
+
object.deoptimizePath(UNKNOWN_PATH);
|
|
9309
9334
|
for (const expression of expressionsToBeDeoptimized) {
|
|
9310
9335
|
expression.deoptimizeCache();
|
|
9311
9336
|
}
|
|
@@ -9331,8 +9356,8 @@ class MemberExpression extends NodeBase {
|
|
|
9331
9356
|
if (this.isUndefined) {
|
|
9332
9357
|
return undefined;
|
|
9333
9358
|
}
|
|
9334
|
-
this.
|
|
9335
|
-
|
|
9359
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
9360
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
9336
9361
|
return this.object.getLiteralValueAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
9337
9362
|
}
|
|
9338
9363
|
return UnknownValue;
|
|
@@ -9344,8 +9369,8 @@ class MemberExpression extends NodeBase {
|
|
|
9344
9369
|
if (this.isUndefined) {
|
|
9345
9370
|
return [UNDEFINED_EXPRESSION, false];
|
|
9346
9371
|
}
|
|
9347
|
-
this.
|
|
9348
|
-
|
|
9372
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
9373
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
9349
9374
|
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
9350
9375
|
}
|
|
9351
9376
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
@@ -9404,7 +9429,7 @@ class MemberExpression extends NodeBase {
|
|
|
9404
9429
|
}
|
|
9405
9430
|
initialise() {
|
|
9406
9431
|
this.propertyKey = getResolvablePropertyKey(this);
|
|
9407
|
-
this.accessInteraction = { args:
|
|
9432
|
+
this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
|
|
9408
9433
|
}
|
|
9409
9434
|
isSkippedAsOptional(origin) {
|
|
9410
9435
|
return (!this.variable &&
|
|
@@ -9434,8 +9459,7 @@ class MemberExpression extends NodeBase {
|
|
|
9434
9459
|
}
|
|
9435
9460
|
setAssignedValue(value) {
|
|
9436
9461
|
this.assignmentInteraction = {
|
|
9437
|
-
args: [value],
|
|
9438
|
-
thisArg: this.object,
|
|
9462
|
+
args: [this.object, value],
|
|
9439
9463
|
type: INTERACTION_ASSIGNED
|
|
9440
9464
|
};
|
|
9441
9465
|
}
|
|
@@ -9535,27 +9559,22 @@ class CallExpressionBase extends NodeBase {
|
|
|
9535
9559
|
this.expressionsToBeDeoptimized = new Set();
|
|
9536
9560
|
}
|
|
9537
9561
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9538
|
-
const { args
|
|
9562
|
+
const { args } = interaction;
|
|
9539
9563
|
const [returnExpression, isPure] = this.getReturnExpression(recursionTracker);
|
|
9540
9564
|
if (isPure)
|
|
9541
9565
|
return;
|
|
9566
|
+
const deoptimizedExpressions = args.filter(expression => !!expression && expression !== UNKNOWN_EXPRESSION);
|
|
9567
|
+
if (deoptimizedExpressions.length === 0)
|
|
9568
|
+
return;
|
|
9542
9569
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
for (const argument of args) {
|
|
9546
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
9547
|
-
}
|
|
9570
|
+
for (const expression of deoptimizedExpressions) {
|
|
9571
|
+
expression.deoptimizePath(UNKNOWN_PATH);
|
|
9548
9572
|
}
|
|
9549
9573
|
}
|
|
9550
9574
|
else {
|
|
9551
9575
|
recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
9552
|
-
|
|
9553
|
-
this.expressionsToBeDeoptimized.add(
|
|
9554
|
-
}
|
|
9555
|
-
if (args) {
|
|
9556
|
-
for (const argument of args) {
|
|
9557
|
-
this.expressionsToBeDeoptimized.add(argument);
|
|
9558
|
-
}
|
|
9576
|
+
for (const expression of deoptimizedExpressions) {
|
|
9577
|
+
this.expressionsToBeDeoptimized.add(expression);
|
|
9559
9578
|
}
|
|
9560
9579
|
returnExpression.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9561
9580
|
}, null);
|
|
@@ -9564,10 +9583,13 @@ class CallExpressionBase extends NodeBase {
|
|
|
9564
9583
|
deoptimizeCache() {
|
|
9565
9584
|
if (this.returnExpression?.[0] !== UNKNOWN_EXPRESSION) {
|
|
9566
9585
|
this.returnExpression = UNKNOWN_RETURN_EXPRESSION;
|
|
9567
|
-
|
|
9586
|
+
const { deoptimizableDependentExpressions, expressionsToBeDeoptimized } = this;
|
|
9587
|
+
this.expressionsToBeDeoptimized = EMPTY_SET;
|
|
9588
|
+
this.deoptimizableDependentExpressions = EMPTY_ARRAY;
|
|
9589
|
+
for (const expression of deoptimizableDependentExpressions) {
|
|
9568
9590
|
expression.deoptimizeCache();
|
|
9569
9591
|
}
|
|
9570
|
-
for (const expression of
|
|
9592
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
9571
9593
|
expression.deoptimizePath(UNKNOWN_PATH);
|
|
9572
9594
|
}
|
|
9573
9595
|
}
|
|
@@ -9635,10 +9657,12 @@ class CallExpression extends CallExpressionBase {
|
|
|
9635
9657
|
}
|
|
9636
9658
|
}
|
|
9637
9659
|
this.interaction = {
|
|
9638
|
-
args:
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9660
|
+
args: [
|
|
9661
|
+
this.callee instanceof MemberExpression && !this.callee.variable
|
|
9662
|
+
? this.callee.object
|
|
9663
|
+
: null,
|
|
9664
|
+
...this.arguments
|
|
9665
|
+
],
|
|
9642
9666
|
type: INTERACTION_CALLED,
|
|
9643
9667
|
withNew: false
|
|
9644
9668
|
};
|
|
@@ -9791,8 +9815,7 @@ class MethodBase extends NodeBase {
|
|
|
9791
9815
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9792
9816
|
if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
|
|
9793
9817
|
return this.value.deoptimizeArgumentsOnInteractionAtPath({
|
|
9794
|
-
args:
|
|
9795
|
-
thisArg: interaction.thisArg,
|
|
9818
|
+
args: interaction.args,
|
|
9796
9819
|
type: INTERACTION_CALLED,
|
|
9797
9820
|
withNew: false
|
|
9798
9821
|
}, EMPTY_PATH, recursionTracker);
|
|
@@ -9800,7 +9823,6 @@ class MethodBase extends NodeBase {
|
|
|
9800
9823
|
if (interaction.type === INTERACTION_ASSIGNED && this.kind === 'set' && path.length === 0) {
|
|
9801
9824
|
return this.value.deoptimizeArgumentsOnInteractionAtPath({
|
|
9802
9825
|
args: interaction.args,
|
|
9803
|
-
thisArg: interaction.thisArg,
|
|
9804
9826
|
type: INTERACTION_CALLED,
|
|
9805
9827
|
withNew: false
|
|
9806
9828
|
}, EMPTY_PATH, recursionTracker);
|
|
@@ -9825,8 +9847,7 @@ class MethodBase extends NodeBase {
|
|
|
9825
9847
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9826
9848
|
if (this.kind === 'get' && interaction.type === INTERACTION_ACCESSED && path.length === 0) {
|
|
9827
9849
|
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9828
|
-
args:
|
|
9829
|
-
thisArg: interaction.thisArg,
|
|
9850
|
+
args: interaction.args,
|
|
9830
9851
|
type: INTERACTION_CALLED,
|
|
9831
9852
|
withNew: false
|
|
9832
9853
|
}, context);
|
|
@@ -9835,7 +9856,6 @@ class MethodBase extends NodeBase {
|
|
|
9835
9856
|
if (this.kind === 'set' && interaction.type === INTERACTION_ASSIGNED) {
|
|
9836
9857
|
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9837
9858
|
args: interaction.args,
|
|
9838
|
-
thisArg: interaction.thisArg,
|
|
9839
9859
|
type: INTERACTION_CALLED,
|
|
9840
9860
|
withNew: false
|
|
9841
9861
|
}, context);
|
|
@@ -10096,7 +10116,9 @@ class ConditionalExpression extends NodeBase {
|
|
|
10096
10116
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
10097
10117
|
this.usedBranch = null;
|
|
10098
10118
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
10099
|
-
|
|
10119
|
+
const { expressionsToBeDeoptimized } = this;
|
|
10120
|
+
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
10121
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
10100
10122
|
expression.deoptimizeCache();
|
|
10101
10123
|
}
|
|
10102
10124
|
}
|
|
@@ -11228,12 +11250,14 @@ class LogicalExpression extends NodeBase {
|
|
|
11228
11250
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
11229
11251
|
this.usedBranch = null;
|
|
11230
11252
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
11231
|
-
|
|
11253
|
+
const { context, expressionsToBeDeoptimized } = this;
|
|
11254
|
+
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
11255
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
11232
11256
|
expression.deoptimizeCache();
|
|
11233
11257
|
}
|
|
11234
11258
|
// Request another pass because we need to ensure "include" runs again if
|
|
11235
11259
|
// it is rendered
|
|
11236
|
-
|
|
11260
|
+
context.requestTreeshakingPass();
|
|
11237
11261
|
}
|
|
11238
11262
|
}
|
|
11239
11263
|
deoptimizePath(path) {
|
|
@@ -11503,8 +11527,7 @@ class NewExpression extends NodeBase {
|
|
|
11503
11527
|
}
|
|
11504
11528
|
initialise() {
|
|
11505
11529
|
this.interaction = {
|
|
11506
|
-
args: this.arguments,
|
|
11507
|
-
thisArg: null,
|
|
11530
|
+
args: [null, ...this.arguments],
|
|
11508
11531
|
type: INTERACTION_CALLED,
|
|
11509
11532
|
withNew: true
|
|
11510
11533
|
};
|
|
@@ -11626,6 +11649,9 @@ class Program extends NodeBase {
|
|
|
11626
11649
|
this.hasLoggedEffect = false;
|
|
11627
11650
|
}
|
|
11628
11651
|
hasCachedEffects() {
|
|
11652
|
+
if (!this.included) {
|
|
11653
|
+
return false;
|
|
11654
|
+
}
|
|
11629
11655
|
return this.hasCachedEffect === null
|
|
11630
11656
|
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11631
11657
|
: this.hasCachedEffect;
|
|
@@ -12020,16 +12046,19 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
12020
12046
|
this.tag.include(context, includeChildrenRecursively);
|
|
12021
12047
|
this.quasi.include(context, includeChildrenRecursively);
|
|
12022
12048
|
}
|
|
12023
|
-
this.tag.includeCallArguments(context, this.
|
|
12049
|
+
this.tag.includeCallArguments(context, this.args);
|
|
12024
12050
|
const [returnExpression] = this.getReturnExpression();
|
|
12025
12051
|
if (!returnExpression.included) {
|
|
12026
12052
|
returnExpression.include(context, false);
|
|
12027
12053
|
}
|
|
12028
12054
|
}
|
|
12029
12055
|
initialise() {
|
|
12056
|
+
this.args = [UNKNOWN_EXPRESSION, ...this.quasi.expressions];
|
|
12030
12057
|
this.interaction = {
|
|
12031
|
-
args: [
|
|
12032
|
-
|
|
12058
|
+
args: [
|
|
12059
|
+
this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null,
|
|
12060
|
+
...this.args
|
|
12061
|
+
],
|
|
12033
12062
|
type: INTERACTION_CALLED,
|
|
12034
12063
|
withNew: false
|
|
12035
12064
|
};
|
|
@@ -12214,8 +12243,7 @@ class ThisExpression extends NodeBase {
|
|
|
12214
12243
|
this.variable = this.scope.findVariable('this');
|
|
12215
12244
|
}
|
|
12216
12245
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
12217
|
-
|
|
12218
|
-
this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction.thisArg === this ? { ...interaction, thisArg: this.variable } : interaction, path, recursionTracker);
|
|
12246
|
+
this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
12219
12247
|
}
|
|
12220
12248
|
deoptimizePath(path) {
|
|
12221
12249
|
this.variable.deoptimizePath(path);
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.d.ts
CHANGED
package/dist/rollup.js
CHANGED