rollup 4.0.2 → 4.1.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/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 +300 -145
- package/dist/es/shared/parseAst.js +2 -2
- 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.d.ts +3 -3
- 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 +2 -2
- package/dist/shared/rollup.js +300 -145
- 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 +31 -31
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.1.0
|
|
4
|
+
Sat, 14 Oct 2023 05:51:28 GMT - commit cb144b2be4262b3743b31983b26f7fa985be3ceb
|
|
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.0
|
|
34
|
+
var version = "4.1.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -3267,11 +3267,24 @@ class DiscriminatedPathTracker {
|
|
|
3267
3267
|
}
|
|
3268
3268
|
}
|
|
3269
3269
|
|
|
3270
|
+
function isFlagSet(flags, flag) {
|
|
3271
|
+
return (flags & flag) !== 0;
|
|
3272
|
+
}
|
|
3273
|
+
function setFlag(flags, flag, value) {
|
|
3274
|
+
return (flags & ~flag) | (-value & flag);
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3270
3277
|
const UnknownValue = Symbol('Unknown Value');
|
|
3271
3278
|
const UnknownTruthyValue = Symbol('Unknown Truthy Value');
|
|
3272
3279
|
class ExpressionEntity {
|
|
3273
3280
|
constructor() {
|
|
3274
|
-
this.
|
|
3281
|
+
this.flags = 0;
|
|
3282
|
+
}
|
|
3283
|
+
get included() {
|
|
3284
|
+
return isFlagSet(this.flags, 1 /* Flag.included */);
|
|
3285
|
+
}
|
|
3286
|
+
set included(value) {
|
|
3287
|
+
this.flags = setFlag(this.flags, 1 /* Flag.included */, value);
|
|
3275
3288
|
}
|
|
3276
3289
|
deoptimizeArgumentsOnInteractionAtPath(interaction, _path, _recursionTracker) {
|
|
3277
3290
|
deoptimizeInteraction(interaction);
|
|
@@ -5996,33 +6009,40 @@ const keys = {
|
|
|
5996
6009
|
Literal: [],
|
|
5997
6010
|
Program: ['body']
|
|
5998
6011
|
};
|
|
5999
|
-
function
|
|
6000
|
-
|
|
6001
|
-
return keys[esTreeNode.type];
|
|
6012
|
+
function createKeysForNode(esTreeNode) {
|
|
6013
|
+
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
6002
6014
|
}
|
|
6003
6015
|
|
|
6004
6016
|
const INCLUDE_PARAMETERS = 'variables';
|
|
6005
6017
|
class NodeBase extends ExpressionEntity {
|
|
6018
|
+
/**
|
|
6019
|
+
* Nodes can apply custom deoptimizations once they become part of the
|
|
6020
|
+
* executed code. To do this, they must initialize this as false, implement
|
|
6021
|
+
* applyDeoptimizations and call this from include and hasEffects if they have
|
|
6022
|
+
* custom handlers
|
|
6023
|
+
*/
|
|
6024
|
+
get deoptimized() {
|
|
6025
|
+
return isFlagSet(this.flags, 2 /* Flag.deoptimized */);
|
|
6026
|
+
}
|
|
6027
|
+
set deoptimized(value) {
|
|
6028
|
+
this.flags = setFlag(this.flags, 2 /* Flag.deoptimized */, value);
|
|
6029
|
+
}
|
|
6006
6030
|
constructor(esTreeNode, parent, parentScope, keepEsTreeNode = false) {
|
|
6007
6031
|
super();
|
|
6008
|
-
/**
|
|
6009
|
-
* Nodes can apply custom deoptimizations once they become part of the
|
|
6010
|
-
* executed code. To do this, they must initialize this as false, implement
|
|
6011
|
-
* applyDeoptimizations and call this from include and hasEffects if they have
|
|
6012
|
-
* custom handlers
|
|
6013
|
-
*/
|
|
6014
|
-
this.deoptimized = false;
|
|
6015
6032
|
// Nodes can opt-in to keep the AST if needed during the build pipeline.
|
|
6016
6033
|
// Avoid true when possible as large AST takes up memory.
|
|
6017
|
-
|
|
6018
|
-
|
|
6034
|
+
if (keepEsTreeNode) {
|
|
6035
|
+
this.esTreeNode = esTreeNode;
|
|
6036
|
+
}
|
|
6037
|
+
const { type } = esTreeNode;
|
|
6038
|
+
keys[type] ||= createKeysForNode(esTreeNode);
|
|
6019
6039
|
this.parent = parent;
|
|
6020
|
-
this.
|
|
6040
|
+
this.scope = parentScope;
|
|
6021
6041
|
this.createScope(parentScope);
|
|
6022
6042
|
this.parseNode(esTreeNode);
|
|
6023
6043
|
this.initialise();
|
|
6024
|
-
this.context.magicString.addSourcemapLocation(this.start);
|
|
6025
|
-
this.context.magicString.addSourcemapLocation(this.end);
|
|
6044
|
+
this.scope.context.magicString.addSourcemapLocation(this.start);
|
|
6045
|
+
this.scope.context.magicString.addSourcemapLocation(this.end);
|
|
6026
6046
|
}
|
|
6027
6047
|
addExportedVariables(_variables, _exportNamesByVariable) { }
|
|
6028
6048
|
/**
|
|
@@ -6030,7 +6050,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6030
6050
|
* that require the scopes to be populated with variables.
|
|
6031
6051
|
*/
|
|
6032
6052
|
bind() {
|
|
6033
|
-
for (const key of this.
|
|
6053
|
+
for (const key of keys[this.type]) {
|
|
6034
6054
|
const value = this[key];
|
|
6035
6055
|
if (Array.isArray(value)) {
|
|
6036
6056
|
for (const child of value) {
|
|
@@ -6052,7 +6072,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6052
6072
|
hasEffects(context) {
|
|
6053
6073
|
if (!this.deoptimized)
|
|
6054
6074
|
this.applyDeoptimizations();
|
|
6055
|
-
for (const key of this.
|
|
6075
|
+
for (const key of keys[this.type]) {
|
|
6056
6076
|
const value = this[key];
|
|
6057
6077
|
if (value === null)
|
|
6058
6078
|
continue;
|
|
@@ -6075,7 +6095,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6075
6095
|
if (!this.deoptimized)
|
|
6076
6096
|
this.applyDeoptimizations();
|
|
6077
6097
|
this.included = true;
|
|
6078
|
-
for (const key of this.
|
|
6098
|
+
for (const key of keys[this.type]) {
|
|
6079
6099
|
const value = this[key];
|
|
6080
6100
|
if (value === null)
|
|
6081
6101
|
continue;
|
|
@@ -6099,23 +6119,26 @@ class NodeBase extends ExpressionEntity {
|
|
|
6099
6119
|
initialise() { }
|
|
6100
6120
|
parseNode(esTreeNode, keepEsTreeNodeKeys) {
|
|
6101
6121
|
for (const [key, value] of Object.entries(esTreeNode)) {
|
|
6102
|
-
//
|
|
6122
|
+
// Skip properties defined on the class already.
|
|
6123
|
+
// This way, we can override this function to add custom initialisation and then call super.parseNode
|
|
6124
|
+
// Note: this doesn't skip properties with defined getters/setters which we use to pack wrap booleans
|
|
6125
|
+
// in bitfields. Those are still assigned from the value in the esTreeNode.
|
|
6103
6126
|
if (this.hasOwnProperty(key))
|
|
6104
6127
|
continue;
|
|
6105
6128
|
if (key.charCodeAt(0) === 95 /* _ */) {
|
|
6106
6129
|
if (key === parseAst_js.ANNOTATION_KEY) {
|
|
6107
6130
|
const annotations = value;
|
|
6108
6131
|
this.annotations = annotations;
|
|
6109
|
-
if (this.context.options.treeshake.annotations) {
|
|
6132
|
+
if (this.scope.context.options.treeshake.annotations) {
|
|
6110
6133
|
this.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
6111
6134
|
this.annotationPure = annotations.some(comment => comment.type === 'pure');
|
|
6112
6135
|
}
|
|
6113
6136
|
}
|
|
6114
6137
|
else if (key === parseAst_js.INVALID_ANNOTATION_KEY) {
|
|
6115
6138
|
for (const { start, end, type } of value) {
|
|
6116
|
-
this.context.magicString.remove(start, end);
|
|
6139
|
+
this.scope.context.magicString.remove(start, end);
|
|
6117
6140
|
if (type === 'pure' || type === 'noSideEffects') {
|
|
6118
|
-
this.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logInvalidAnnotation(this.context.code.slice(start, end), this.context.module.id, type), start);
|
|
6141
|
+
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logInvalidAnnotation(this.scope.context.code.slice(start, end), this.scope.context.module.id, type), start);
|
|
6119
6142
|
}
|
|
6120
6143
|
}
|
|
6121
6144
|
}
|
|
@@ -6128,11 +6151,11 @@ class NodeBase extends ExpressionEntity {
|
|
|
6128
6151
|
for (const child of value) {
|
|
6129
6152
|
this[key].push(child === null
|
|
6130
6153
|
? null
|
|
6131
|
-
: new (this.context.getNodeConstructor(child.type))(child, this, this.scope, keepEsTreeNodeKeys?.includes(key)));
|
|
6154
|
+
: new (this.scope.context.getNodeConstructor(child.type))(child, this, this.scope, keepEsTreeNodeKeys?.includes(key)));
|
|
6132
6155
|
}
|
|
6133
6156
|
}
|
|
6134
6157
|
else {
|
|
6135
|
-
this[key] = new (this.context.getNodeConstructor(value.type))(value, this, this.scope, keepEsTreeNodeKeys?.includes(key));
|
|
6158
|
+
this[key] = new (this.scope.context.getNodeConstructor(value.type))(value, this, this.scope, keepEsTreeNodeKeys?.includes(key));
|
|
6136
6159
|
}
|
|
6137
6160
|
}
|
|
6138
6161
|
}
|
|
@@ -6144,7 +6167,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6144
6167
|
}
|
|
6145
6168
|
}
|
|
6146
6169
|
render(code, options) {
|
|
6147
|
-
for (const key of this.
|
|
6170
|
+
for (const key of keys[this.type]) {
|
|
6148
6171
|
const value = this[key];
|
|
6149
6172
|
if (value === null)
|
|
6150
6173
|
continue;
|
|
@@ -6171,7 +6194,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6171
6194
|
*/
|
|
6172
6195
|
applyDeoptimizations() {
|
|
6173
6196
|
this.deoptimized = true;
|
|
6174
|
-
for (const key of this.
|
|
6197
|
+
for (const key of keys[this.type]) {
|
|
6175
6198
|
const value = this[key];
|
|
6176
6199
|
if (value === null)
|
|
6177
6200
|
continue;
|
|
@@ -6184,7 +6207,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6184
6207
|
value.deoptimizePath(UNKNOWN_PATH);
|
|
6185
6208
|
}
|
|
6186
6209
|
}
|
|
6187
|
-
this.context.requestTreeshakingPass();
|
|
6210
|
+
this.scope.context.requestTreeshakingPass();
|
|
6188
6211
|
}
|
|
6189
6212
|
}
|
|
6190
6213
|
|
|
@@ -6197,7 +6220,7 @@ class SpreadElement extends NodeBase {
|
|
|
6197
6220
|
hasEffects(context) {
|
|
6198
6221
|
if (!this.deoptimized)
|
|
6199
6222
|
this.applyDeoptimizations();
|
|
6200
|
-
const { propertyReadSideEffects } = this.context.options
|
|
6223
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
6201
6224
|
.treeshake;
|
|
6202
6225
|
return (this.argument.hasEffects(context) ||
|
|
6203
6226
|
(propertyReadSideEffects &&
|
|
@@ -6209,7 +6232,7 @@ class SpreadElement extends NodeBase {
|
|
|
6209
6232
|
// Only properties of properties of the argument could become subject to reassignment
|
|
6210
6233
|
// This will also reassign the return values of iterators
|
|
6211
6234
|
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
6212
|
-
this.context.requestTreeshakingPass();
|
|
6235
|
+
this.scope.context.requestTreeshakingPass();
|
|
6213
6236
|
}
|
|
6214
6237
|
}
|
|
6215
6238
|
|
|
@@ -6292,6 +6315,24 @@ const METHOD_RETURNS_UNKNOWN = [
|
|
|
6292
6315
|
|
|
6293
6316
|
const INTEGER_REG_EXP = /^\d+$/;
|
|
6294
6317
|
class ObjectEntity extends ExpressionEntity {
|
|
6318
|
+
get hasLostTrack() {
|
|
6319
|
+
return isFlagSet(this.flags, 2048 /* Flag.hasLostTrack */);
|
|
6320
|
+
}
|
|
6321
|
+
set hasLostTrack(value) {
|
|
6322
|
+
this.flags = setFlag(this.flags, 2048 /* Flag.hasLostTrack */, value);
|
|
6323
|
+
}
|
|
6324
|
+
get hasUnknownDeoptimizedInteger() {
|
|
6325
|
+
return isFlagSet(this.flags, 4096 /* Flag.hasUnknownDeoptimizedInteger */);
|
|
6326
|
+
}
|
|
6327
|
+
set hasUnknownDeoptimizedInteger(value) {
|
|
6328
|
+
this.flags = setFlag(this.flags, 4096 /* Flag.hasUnknownDeoptimizedInteger */, value);
|
|
6329
|
+
}
|
|
6330
|
+
get hasUnknownDeoptimizedProperty() {
|
|
6331
|
+
return isFlagSet(this.flags, 8192 /* Flag.hasUnknownDeoptimizedProperty */);
|
|
6332
|
+
}
|
|
6333
|
+
set hasUnknownDeoptimizedProperty(value) {
|
|
6334
|
+
this.flags = setFlag(this.flags, 8192 /* Flag.hasUnknownDeoptimizedProperty */, value);
|
|
6335
|
+
}
|
|
6295
6336
|
// If a PropertyMap is used, this will be taken as propertiesAndGettersByKey
|
|
6296
6337
|
// and we assume there are no setters or getters
|
|
6297
6338
|
constructor(properties, prototypeExpression, immutable = false) {
|
|
@@ -6303,9 +6344,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
6303
6344
|
this.deoptimizedPaths = Object.create(null);
|
|
6304
6345
|
this.expressionsToBeDeoptimizedByKey = Object.create(null);
|
|
6305
6346
|
this.gettersByKey = Object.create(null);
|
|
6306
|
-
this.hasLostTrack = false;
|
|
6307
|
-
this.hasUnknownDeoptimizedInteger = false;
|
|
6308
|
-
this.hasUnknownDeoptimizedProperty = false;
|
|
6309
6347
|
this.propertiesAndGettersByKey = Object.create(null);
|
|
6310
6348
|
this.propertiesAndSettersByKey = Object.create(null);
|
|
6311
6349
|
this.settersByKey = Object.create(null);
|
|
@@ -6837,7 +6875,7 @@ class ArrayExpression extends NodeBase {
|
|
|
6837
6875
|
element.deoptimizePath(UNKNOWN_PATH);
|
|
6838
6876
|
}
|
|
6839
6877
|
}
|
|
6840
|
-
this.context.requestTreeshakingPass();
|
|
6878
|
+
this.scope.context.requestTreeshakingPass();
|
|
6841
6879
|
}
|
|
6842
6880
|
getObjectEntity() {
|
|
6843
6881
|
if (this.objectEntity !== null) {
|
|
@@ -7198,10 +7236,11 @@ class Scope {
|
|
|
7198
7236
|
}
|
|
7199
7237
|
|
|
7200
7238
|
class ChildScope extends Scope {
|
|
7201
|
-
constructor(parent) {
|
|
7239
|
+
constructor(parent, context) {
|
|
7202
7240
|
super();
|
|
7203
7241
|
this.accessedOutsideVariables = new Map();
|
|
7204
7242
|
this.parent = parent;
|
|
7243
|
+
this.context = context;
|
|
7205
7244
|
parent.children.push(this);
|
|
7206
7245
|
}
|
|
7207
7246
|
addAccessedDynamicImport(importExpression) {
|
|
@@ -7281,11 +7320,10 @@ class ChildScope extends Scope {
|
|
|
7281
7320
|
|
|
7282
7321
|
class ParameterScope extends ChildScope {
|
|
7283
7322
|
constructor(parent, context) {
|
|
7284
|
-
super(parent);
|
|
7323
|
+
super(parent, context);
|
|
7285
7324
|
this.parameters = [];
|
|
7286
7325
|
this.hasRest = false;
|
|
7287
|
-
this.
|
|
7288
|
-
this.hoistedBodyVarScope = new ChildScope(this);
|
|
7326
|
+
this.hoistedBodyVarScope = new ChildScope(this, context);
|
|
7289
7327
|
}
|
|
7290
7328
|
/**
|
|
7291
7329
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
@@ -8457,7 +8495,16 @@ class Identifier extends NodeBase {
|
|
|
8457
8495
|
constructor() {
|
|
8458
8496
|
super(...arguments);
|
|
8459
8497
|
this.variable = null;
|
|
8460
|
-
|
|
8498
|
+
}
|
|
8499
|
+
get isTDZAccess() {
|
|
8500
|
+
if (!isFlagSet(this.flags, 4 /* Flag.tdzAccessDefined */)) {
|
|
8501
|
+
return null;
|
|
8502
|
+
}
|
|
8503
|
+
return isFlagSet(this.flags, 8 /* Flag.tdzAccess */);
|
|
8504
|
+
}
|
|
8505
|
+
set isTDZAccess(value) {
|
|
8506
|
+
this.flags = setFlag(this.flags, 4 /* Flag.tdzAccessDefined */, true);
|
|
8507
|
+
this.flags = setFlag(this.flags, 8 /* Flag.tdzAccess */, value);
|
|
8461
8508
|
}
|
|
8462
8509
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
8463
8510
|
if (exportNamesByVariable.has(this.variable)) {
|
|
@@ -8472,10 +8519,10 @@ class Identifier extends NodeBase {
|
|
|
8472
8519
|
}
|
|
8473
8520
|
declare(kind, init) {
|
|
8474
8521
|
let variable;
|
|
8475
|
-
const { treeshake } = this.context.options;
|
|
8522
|
+
const { treeshake } = this.scope.context.options;
|
|
8476
8523
|
switch (kind) {
|
|
8477
8524
|
case 'var': {
|
|
8478
|
-
variable = this.scope.addDeclaration(this, this.context, init, true);
|
|
8525
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, true);
|
|
8479
8526
|
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
8480
8527
|
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
8481
8528
|
variable.markInitializersForDeoptimization();
|
|
@@ -8484,13 +8531,13 @@ class Identifier extends NodeBase {
|
|
|
8484
8531
|
}
|
|
8485
8532
|
case 'function': {
|
|
8486
8533
|
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
8487
|
-
variable = this.scope.addDeclaration(this, this.context, init, false);
|
|
8534
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, false);
|
|
8488
8535
|
break;
|
|
8489
8536
|
}
|
|
8490
8537
|
case 'let':
|
|
8491
8538
|
case 'const':
|
|
8492
8539
|
case 'class': {
|
|
8493
|
-
variable = this.scope.addDeclaration(this, this.context, init, false);
|
|
8540
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, false);
|
|
8494
8541
|
break;
|
|
8495
8542
|
}
|
|
8496
8543
|
case 'parameter': {
|
|
@@ -8527,7 +8574,8 @@ class Identifier extends NodeBase {
|
|
|
8527
8574
|
if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
|
|
8528
8575
|
return true;
|
|
8529
8576
|
}
|
|
8530
|
-
return (this.context.options.treeshake
|
|
8577
|
+
return (this.scope.context.options.treeshake
|
|
8578
|
+
.unknownGlobalSideEffects &&
|
|
8531
8579
|
this.variable instanceof GlobalVariable &&
|
|
8532
8580
|
!this.isPureFunction(EMPTY_PATH) &&
|
|
8533
8581
|
this.variable.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
@@ -8554,7 +8602,7 @@ class Identifier extends NodeBase {
|
|
|
8554
8602
|
if (!this.included) {
|
|
8555
8603
|
this.included = true;
|
|
8556
8604
|
if (this.variable !== null) {
|
|
8557
|
-
this.context.includeVariableInModule(this.variable);
|
|
8605
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
8558
8606
|
}
|
|
8559
8607
|
}
|
|
8560
8608
|
}
|
|
@@ -8563,14 +8611,15 @@ class Identifier extends NodeBase {
|
|
|
8563
8611
|
}
|
|
8564
8612
|
isPossibleTDZ() {
|
|
8565
8613
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
8566
|
-
|
|
8567
|
-
|
|
8614
|
+
const cachedTdzAccess = this.isTDZAccess;
|
|
8615
|
+
if (cachedTdzAccess !== null)
|
|
8616
|
+
return cachedTdzAccess;
|
|
8568
8617
|
if (!(this.variable instanceof LocalVariable &&
|
|
8569
8618
|
this.variable.kind &&
|
|
8570
8619
|
this.variable.kind in tdzVariableKinds &&
|
|
8571
8620
|
// we ignore possible TDZs due to circular module dependencies as
|
|
8572
8621
|
// otherwise we get many false positives
|
|
8573
|
-
this.variable.module === this.context.module)) {
|
|
8622
|
+
this.variable.module === this.scope.context.module)) {
|
|
8574
8623
|
return (this.isTDZAccess = false);
|
|
8575
8624
|
}
|
|
8576
8625
|
let decl_id;
|
|
@@ -8617,7 +8666,7 @@ class Identifier extends NodeBase {
|
|
|
8617
8666
|
this.deoptimized = true;
|
|
8618
8667
|
if (this.variable instanceof LocalVariable) {
|
|
8619
8668
|
this.variable.consolidateInitializers();
|
|
8620
|
-
this.context.requestTreeshakingPass();
|
|
8669
|
+
this.scope.context.requestTreeshakingPass();
|
|
8621
8670
|
}
|
|
8622
8671
|
}
|
|
8623
8672
|
getVariableRespectingTDZ() {
|
|
@@ -8627,7 +8676,7 @@ class Identifier extends NodeBase {
|
|
|
8627
8676
|
return this.variable;
|
|
8628
8677
|
}
|
|
8629
8678
|
isPureFunction(path) {
|
|
8630
|
-
let currentPureFunction = this.context.manualPureFunctions[this.name];
|
|
8679
|
+
let currentPureFunction = this.scope.context.manualPureFunctions[this.name];
|
|
8631
8680
|
for (const segment of path) {
|
|
8632
8681
|
if (currentPureFunction) {
|
|
8633
8682
|
if (currentPureFunction[PureFunctionKey]) {
|
|
@@ -8807,9 +8856,9 @@ class ExpressionStatement extends NodeBase {
|
|
|
8807
8856
|
if (this.directive &&
|
|
8808
8857
|
this.directive !== 'use strict' &&
|
|
8809
8858
|
this.parent.type === Program$1) {
|
|
8810
|
-
this.context.log(parseAst_js.LOGLEVEL_WARN,
|
|
8859
|
+
this.scope.context.log(parseAst_js.LOGLEVEL_WARN,
|
|
8811
8860
|
// This is necessary, because either way (deleting or not) can lead to errors.
|
|
8812
|
-
parseAst_js.logModuleLevelDirective(this.directive, this.context.module.id), this.start);
|
|
8861
|
+
parseAst_js.logModuleLevelDirective(this.directive, this.scope.context.module.id), this.start);
|
|
8813
8862
|
}
|
|
8814
8863
|
}
|
|
8815
8864
|
removeAnnotations(code) {
|
|
@@ -8830,9 +8879,17 @@ class ExpressionStatement extends NodeBase {
|
|
|
8830
8879
|
}
|
|
8831
8880
|
|
|
8832
8881
|
class BlockStatement extends NodeBase {
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8882
|
+
get deoptimizeBody() {
|
|
8883
|
+
return isFlagSet(this.flags, 32768 /* Flag.deoptimizeBody */);
|
|
8884
|
+
}
|
|
8885
|
+
set deoptimizeBody(value) {
|
|
8886
|
+
this.flags = setFlag(this.flags, 32768 /* Flag.deoptimizeBody */, value);
|
|
8887
|
+
}
|
|
8888
|
+
get directlyIncluded() {
|
|
8889
|
+
return isFlagSet(this.flags, 16384 /* Flag.directlyIncluded */);
|
|
8890
|
+
}
|
|
8891
|
+
set directlyIncluded(value) {
|
|
8892
|
+
this.flags = setFlag(this.flags, 16384 /* Flag.directlyIncluded */, value);
|
|
8836
8893
|
}
|
|
8837
8894
|
addImplicitReturnExpressionToScope() {
|
|
8838
8895
|
const lastStatement = this.body[this.body.length - 1];
|
|
@@ -8843,7 +8900,7 @@ class BlockStatement extends NodeBase {
|
|
|
8843
8900
|
createScope(parentScope) {
|
|
8844
8901
|
this.scope = this.parent.preventChildBlockScope
|
|
8845
8902
|
? parentScope
|
|
8846
|
-
: new BlockScope(parentScope);
|
|
8903
|
+
: new BlockScope(parentScope, this.scope.context);
|
|
8847
8904
|
}
|
|
8848
8905
|
hasEffects(context) {
|
|
8849
8906
|
if (this.deoptimizeBody)
|
|
@@ -8910,7 +8967,7 @@ class RestElement extends NodeBase {
|
|
|
8910
8967
|
this.deoptimized = true;
|
|
8911
8968
|
if (this.declarationInit !== null) {
|
|
8912
8969
|
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
8913
|
-
this.context.requestTreeshakingPass();
|
|
8970
|
+
this.scope.context.requestTreeshakingPass();
|
|
8914
8971
|
}
|
|
8915
8972
|
}
|
|
8916
8973
|
}
|
|
@@ -8919,7 +8976,18 @@ class FunctionBase extends NodeBase {
|
|
|
8919
8976
|
constructor() {
|
|
8920
8977
|
super(...arguments);
|
|
8921
8978
|
this.objectEntity = null;
|
|
8922
|
-
|
|
8979
|
+
}
|
|
8980
|
+
get async() {
|
|
8981
|
+
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
8982
|
+
}
|
|
8983
|
+
set async(value) {
|
|
8984
|
+
this.flags = setFlag(this.flags, 256 /* Flag.async */, value);
|
|
8985
|
+
}
|
|
8986
|
+
get deoptimizedReturn() {
|
|
8987
|
+
return isFlagSet(this.flags, 512 /* Flag.deoptimizedReturn */);
|
|
8988
|
+
}
|
|
8989
|
+
set deoptimizedReturn(value) {
|
|
8990
|
+
this.flags = setFlag(this.flags, 512 /* Flag.deoptimizedReturn */, value);
|
|
8923
8991
|
}
|
|
8924
8992
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8925
8993
|
if (interaction.type === INTERACTION_CALLED) {
|
|
@@ -8974,7 +9042,7 @@ class FunctionBase extends NodeBase {
|
|
|
8974
9042
|
if (!this.deoptimizedReturn) {
|
|
8975
9043
|
this.deoptimizedReturn = true;
|
|
8976
9044
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
8977
|
-
this.context.requestTreeshakingPass();
|
|
9045
|
+
this.scope.context.requestTreeshakingPass();
|
|
8978
9046
|
}
|
|
8979
9047
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
8980
9048
|
}
|
|
@@ -8988,7 +9056,7 @@ class FunctionBase extends NodeBase {
|
|
|
8988
9056
|
return false;
|
|
8989
9057
|
}
|
|
8990
9058
|
if (this.async) {
|
|
8991
|
-
const { propertyReadSideEffects } = this.context.options
|
|
9059
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
8992
9060
|
.treeshake;
|
|
8993
9061
|
const returnExpression = this.scope.getReturnExpression();
|
|
8994
9062
|
if (returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_CALL, context) ||
|
|
@@ -9042,7 +9110,7 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
9042
9110
|
this.objectEntity = null;
|
|
9043
9111
|
}
|
|
9044
9112
|
createScope(parentScope) {
|
|
9045
|
-
this.scope = new ReturnValueScope(parentScope, this.context);
|
|
9113
|
+
this.scope = new ReturnValueScope(parentScope, this.scope.context);
|
|
9046
9114
|
}
|
|
9047
9115
|
hasEffects() {
|
|
9048
9116
|
if (!this.deoptimized)
|
|
@@ -9252,7 +9320,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
9252
9320
|
this.deoptimized = true;
|
|
9253
9321
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
9254
9322
|
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
9255
|
-
this.context.requestTreeshakingPass();
|
|
9323
|
+
this.scope.context.requestTreeshakingPass();
|
|
9256
9324
|
}
|
|
9257
9325
|
}
|
|
9258
9326
|
|
|
@@ -9280,7 +9348,7 @@ class AssignmentPattern extends NodeBase {
|
|
|
9280
9348
|
this.deoptimized = true;
|
|
9281
9349
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
9282
9350
|
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
9283
|
-
this.context.requestTreeshakingPass();
|
|
9351
|
+
this.scope.context.requestTreeshakingPass();
|
|
9284
9352
|
}
|
|
9285
9353
|
}
|
|
9286
9354
|
|
|
@@ -9345,7 +9413,7 @@ class FunctionNode extends FunctionBase {
|
|
|
9345
9413
|
this.objectEntity = null;
|
|
9346
9414
|
}
|
|
9347
9415
|
createScope(parentScope) {
|
|
9348
|
-
this.scope = new FunctionScope(parentScope, this.context);
|
|
9416
|
+
this.scope = new FunctionScope(parentScope, this.scope.context);
|
|
9349
9417
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
9350
9418
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
9351
9419
|
// constructed entity.
|
|
@@ -9438,13 +9506,13 @@ class AwaitExpression extends NodeBase {
|
|
|
9438
9506
|
this.applyDeoptimizations();
|
|
9439
9507
|
if (!this.included) {
|
|
9440
9508
|
this.included = true;
|
|
9441
|
-
checkTopLevelAwait: if (!this.context.usesTopLevelAwait) {
|
|
9509
|
+
checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
|
|
9442
9510
|
let parent = this.parent;
|
|
9443
9511
|
do {
|
|
9444
9512
|
if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
|
|
9445
9513
|
break checkTopLevelAwait;
|
|
9446
9514
|
} while ((parent = parent.parent));
|
|
9447
|
-
this.context.usesTopLevelAwait = true;
|
|
9515
|
+
this.scope.context.usesTopLevelAwait = true;
|
|
9448
9516
|
}
|
|
9449
9517
|
}
|
|
9450
9518
|
this.argument.include(context, includeChildrenRecursively);
|
|
@@ -9572,10 +9640,10 @@ class Literal extends NodeBase {
|
|
|
9572
9640
|
getLiteralValueAtPath(path) {
|
|
9573
9641
|
if (path.length > 0 ||
|
|
9574
9642
|
// unknown literals can also be null but do not start with an "n"
|
|
9575
|
-
(this.value === null && this.context.code.charCodeAt(this.start) !== 110) ||
|
|
9643
|
+
(this.value === null && this.scope.context.code.charCodeAt(this.start) !== 110) ||
|
|
9576
9644
|
typeof this.value === 'bigint' ||
|
|
9577
9645
|
// to support shims for regular expressions
|
|
9578
|
-
this.context.code.charCodeAt(this.start) === 47) {
|
|
9646
|
+
this.scope.context.code.charCodeAt(this.start) === 47) {
|
|
9579
9647
|
return UnknownValue;
|
|
9580
9648
|
}
|
|
9581
9649
|
return this.value;
|
|
@@ -9660,17 +9728,44 @@ class MemberExpression extends NodeBase {
|
|
|
9660
9728
|
constructor() {
|
|
9661
9729
|
super(...arguments);
|
|
9662
9730
|
this.variable = null;
|
|
9663
|
-
this.assignmentDeoptimized = false;
|
|
9664
|
-
this.bound = false;
|
|
9665
9731
|
this.expressionsToBeDeoptimized = [];
|
|
9666
|
-
|
|
9732
|
+
}
|
|
9733
|
+
get computed() {
|
|
9734
|
+
return isFlagSet(this.flags, 1024 /* Flag.computed */);
|
|
9735
|
+
}
|
|
9736
|
+
set computed(value) {
|
|
9737
|
+
this.flags = setFlag(this.flags, 1024 /* Flag.computed */, value);
|
|
9738
|
+
}
|
|
9739
|
+
get optional() {
|
|
9740
|
+
return isFlagSet(this.flags, 128 /* Flag.optional */);
|
|
9741
|
+
}
|
|
9742
|
+
set optional(value) {
|
|
9743
|
+
this.flags = setFlag(this.flags, 128 /* Flag.optional */, value);
|
|
9744
|
+
}
|
|
9745
|
+
get assignmentDeoptimized() {
|
|
9746
|
+
return isFlagSet(this.flags, 16 /* Flag.assignmentDeoptimized */);
|
|
9747
|
+
}
|
|
9748
|
+
set assignmentDeoptimized(value) {
|
|
9749
|
+
this.flags = setFlag(this.flags, 16 /* Flag.assignmentDeoptimized */, value);
|
|
9750
|
+
}
|
|
9751
|
+
get bound() {
|
|
9752
|
+
return isFlagSet(this.flags, 32 /* Flag.bound */);
|
|
9753
|
+
}
|
|
9754
|
+
set bound(value) {
|
|
9755
|
+
this.flags = setFlag(this.flags, 32 /* Flag.bound */, value);
|
|
9756
|
+
}
|
|
9757
|
+
get isUndefined() {
|
|
9758
|
+
return isFlagSet(this.flags, 64 /* Flag.isUndefined */);
|
|
9759
|
+
}
|
|
9760
|
+
set isUndefined(value) {
|
|
9761
|
+
this.flags = setFlag(this.flags, 64 /* Flag.isUndefined */, value);
|
|
9667
9762
|
}
|
|
9668
9763
|
bind() {
|
|
9669
9764
|
this.bound = true;
|
|
9670
9765
|
const path = getPathIfNotComputed(this);
|
|
9671
9766
|
const baseVariable = path && this.scope.findVariable(path[0].key);
|
|
9672
9767
|
if (baseVariable?.isNamespace) {
|
|
9673
|
-
const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.context);
|
|
9768
|
+
const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.scope.context);
|
|
9674
9769
|
if (!resolvedVariable) {
|
|
9675
9770
|
super.bind();
|
|
9676
9771
|
}
|
|
@@ -9838,7 +9933,7 @@ class MemberExpression extends NodeBase {
|
|
|
9838
9933
|
}
|
|
9839
9934
|
applyDeoptimizations() {
|
|
9840
9935
|
this.deoptimized = true;
|
|
9841
|
-
const { propertyReadSideEffects } = this.context.options
|
|
9936
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
9842
9937
|
.treeshake;
|
|
9843
9938
|
if (
|
|
9844
9939
|
// Namespaces are not bound and should not be deoptimized
|
|
@@ -9847,12 +9942,12 @@ class MemberExpression extends NodeBase {
|
|
|
9847
9942
|
!(this.variable || this.isUndefined)) {
|
|
9848
9943
|
const propertyKey = this.getPropertyKey();
|
|
9849
9944
|
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
9850
|
-
this.context.requestTreeshakingPass();
|
|
9945
|
+
this.scope.context.requestTreeshakingPass();
|
|
9851
9946
|
}
|
|
9852
9947
|
}
|
|
9853
9948
|
applyAssignmentDeoptimization() {
|
|
9854
9949
|
this.assignmentDeoptimized = true;
|
|
9855
|
-
const { propertyReadSideEffects } = this.context.options
|
|
9950
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
9856
9951
|
.treeshake;
|
|
9857
9952
|
if (
|
|
9858
9953
|
// Namespaces are not bound and should not be deoptimized
|
|
@@ -9860,7 +9955,7 @@ class MemberExpression extends NodeBase {
|
|
|
9860
9955
|
propertyReadSideEffects &&
|
|
9861
9956
|
!(this.variable || this.isUndefined)) {
|
|
9862
9957
|
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
9863
|
-
this.context.requestTreeshakingPass();
|
|
9958
|
+
this.scope.context.requestTreeshakingPass();
|
|
9864
9959
|
}
|
|
9865
9960
|
}
|
|
9866
9961
|
disallowNamespaceReassignment() {
|
|
@@ -9868,9 +9963,9 @@ class MemberExpression extends NodeBase {
|
|
|
9868
9963
|
const variable = this.scope.findVariable(this.object.name);
|
|
9869
9964
|
if (variable.isNamespace) {
|
|
9870
9965
|
if (this.variable) {
|
|
9871
|
-
this.context.includeVariableInModule(this.variable);
|
|
9966
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
9872
9967
|
}
|
|
9873
|
-
this.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
|
|
9968
|
+
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
9874
9969
|
}
|
|
9875
9970
|
}
|
|
9876
9971
|
}
|
|
@@ -9888,7 +9983,7 @@ class MemberExpression extends NodeBase {
|
|
|
9888
9983
|
return this.propertyKey;
|
|
9889
9984
|
}
|
|
9890
9985
|
hasAccessEffect(context) {
|
|
9891
|
-
const { propertyReadSideEffects } = this.context.options
|
|
9986
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
9892
9987
|
.treeshake;
|
|
9893
9988
|
return (!(this.variable || this.isUndefined) &&
|
|
9894
9989
|
propertyReadSideEffects &&
|
|
@@ -9899,7 +9994,7 @@ class MemberExpression extends NodeBase {
|
|
|
9899
9994
|
if (!this.included) {
|
|
9900
9995
|
this.included = true;
|
|
9901
9996
|
if (this.variable) {
|
|
9902
|
-
this.context.includeVariableInModule(this.variable);
|
|
9997
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
9903
9998
|
}
|
|
9904
9999
|
}
|
|
9905
10000
|
this.object.include(context, includeChildrenRecursively);
|
|
@@ -9969,7 +10064,7 @@ class CallExpressionBase extends NodeBase {
|
|
|
9969
10064
|
}
|
|
9970
10065
|
deoptimizePath(path) {
|
|
9971
10066
|
if (path.length === 0 ||
|
|
9972
|
-
this.context.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
10067
|
+
this.scope.context.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
9973
10068
|
return;
|
|
9974
10069
|
}
|
|
9975
10070
|
const [returnExpression] = this.getReturnExpression();
|
|
@@ -10018,15 +10113,21 @@ class CallExpressionBase extends NodeBase {
|
|
|
10018
10113
|
}
|
|
10019
10114
|
|
|
10020
10115
|
class CallExpression extends CallExpressionBase {
|
|
10116
|
+
get optional() {
|
|
10117
|
+
return isFlagSet(this.flags, 128 /* Flag.optional */);
|
|
10118
|
+
}
|
|
10119
|
+
set optional(value) {
|
|
10120
|
+
this.flags = setFlag(this.flags, 128 /* Flag.optional */, value);
|
|
10121
|
+
}
|
|
10021
10122
|
bind() {
|
|
10022
10123
|
super.bind();
|
|
10023
10124
|
if (this.callee instanceof Identifier) {
|
|
10024
10125
|
const variable = this.scope.findVariable(this.callee.name);
|
|
10025
10126
|
if (variable.isNamespace) {
|
|
10026
|
-
this.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logCannotCallNamespace(this.callee.name), this.start);
|
|
10127
|
+
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logCannotCallNamespace(this.callee.name), this.start);
|
|
10027
10128
|
}
|
|
10028
10129
|
if (this.callee.name === 'eval') {
|
|
10029
|
-
this.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logEval(this.context.module.id), this.start);
|
|
10130
|
+
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logEval(this.scope.context.module.id), this.start);
|
|
10030
10131
|
}
|
|
10031
10132
|
}
|
|
10032
10133
|
this.interaction = {
|
|
@@ -10089,7 +10190,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
10089
10190
|
applyDeoptimizations() {
|
|
10090
10191
|
this.deoptimized = true;
|
|
10091
10192
|
this.callee.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
10092
|
-
this.context.requestTreeshakingPass();
|
|
10193
|
+
this.scope.context.requestTreeshakingPass();
|
|
10093
10194
|
}
|
|
10094
10195
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
10095
10196
|
if (this.returnExpression === null) {
|
|
@@ -10117,7 +10218,7 @@ class CatchScope extends ParameterScope {
|
|
|
10117
10218
|
|
|
10118
10219
|
class CatchClause extends NodeBase {
|
|
10119
10220
|
createScope(parentScope) {
|
|
10120
|
-
this.scope = new CatchScope(parentScope, this.context);
|
|
10221
|
+
this.scope = new CatchScope(parentScope, this.scope.context);
|
|
10121
10222
|
}
|
|
10122
10223
|
parseNode(esTreeNode) {
|
|
10123
10224
|
// Parameters need to be declared first as the logic is that initializers
|
|
@@ -10125,7 +10226,7 @@ class CatchClause extends NodeBase {
|
|
|
10125
10226
|
// name instead of the variable
|
|
10126
10227
|
const { param } = esTreeNode;
|
|
10127
10228
|
if (param) {
|
|
10128
|
-
this.param = new (this.context.getNodeConstructor(param.type))(param, this, this.scope);
|
|
10229
|
+
this.param = new (this.scope.context.getNodeConstructor(param.type))(param, this, this.scope);
|
|
10129
10230
|
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
10130
10231
|
}
|
|
10131
10232
|
super.parseNode(esTreeNode);
|
|
@@ -10152,9 +10253,9 @@ class ChainExpression extends NodeBase {
|
|
|
10152
10253
|
|
|
10153
10254
|
class ClassBodyScope extends ChildScope {
|
|
10154
10255
|
constructor(parent, classNode, context) {
|
|
10155
|
-
super(parent);
|
|
10256
|
+
super(parent, context);
|
|
10156
10257
|
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context)));
|
|
10157
|
-
this.instanceScope = new ChildScope(this);
|
|
10258
|
+
this.instanceScope = new ChildScope(this, context);
|
|
10158
10259
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
10159
10260
|
}
|
|
10160
10261
|
findLexicalBoundary() {
|
|
@@ -10164,11 +10265,11 @@ class ClassBodyScope extends ChildScope {
|
|
|
10164
10265
|
|
|
10165
10266
|
class ClassBody extends NodeBase {
|
|
10166
10267
|
createScope(parentScope) {
|
|
10167
|
-
this.scope = new ClassBodyScope(parentScope, this.parent, this.context);
|
|
10268
|
+
this.scope = new ClassBodyScope(parentScope, this.parent, this.scope.context);
|
|
10168
10269
|
}
|
|
10169
10270
|
include(context, includeChildrenRecursively) {
|
|
10170
10271
|
this.included = true;
|
|
10171
|
-
this.context.includeVariableInModule(this.scope.thisVariable);
|
|
10272
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
10172
10273
|
for (const definition of this.body) {
|
|
10173
10274
|
definition.include(context, includeChildrenRecursively);
|
|
10174
10275
|
}
|
|
@@ -10176,7 +10277,7 @@ class ClassBody extends NodeBase {
|
|
|
10176
10277
|
parseNode(esTreeNode) {
|
|
10177
10278
|
const body = (this.body = []);
|
|
10178
10279
|
for (const definition of esTreeNode.body) {
|
|
10179
|
-
body.push(new (this.context.getNodeConstructor(definition.type))(definition, this, definition.static ? this.scope : this.scope.instanceScope));
|
|
10280
|
+
body.push(new (this.scope.context.getNodeConstructor(definition.type))(definition, this, definition.static ? this.scope : this.scope.instanceScope));
|
|
10180
10281
|
}
|
|
10181
10282
|
super.parseNode(esTreeNode);
|
|
10182
10283
|
}
|
|
@@ -10188,6 +10289,12 @@ class MethodBase extends NodeBase {
|
|
|
10188
10289
|
super(...arguments);
|
|
10189
10290
|
this.accessedValue = null;
|
|
10190
10291
|
}
|
|
10292
|
+
get computed() {
|
|
10293
|
+
return isFlagSet(this.flags, 1024 /* Flag.computed */);
|
|
10294
|
+
}
|
|
10295
|
+
set computed(value) {
|
|
10296
|
+
this.flags = setFlag(this.flags, 1024 /* Flag.computed */, value);
|
|
10297
|
+
}
|
|
10191
10298
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10192
10299
|
if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
|
|
10193
10300
|
return this.value.deoptimizeArgumentsOnInteractionAtPath({
|
|
@@ -10286,7 +10393,7 @@ class ClassNode extends NodeBase {
|
|
|
10286
10393
|
this.objectEntity = null;
|
|
10287
10394
|
}
|
|
10288
10395
|
createScope(parentScope) {
|
|
10289
|
-
this.scope = new ChildScope(parentScope);
|
|
10396
|
+
this.scope = new ChildScope(parentScope, this.scope.context);
|
|
10290
10397
|
}
|
|
10291
10398
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10292
10399
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -10349,7 +10456,7 @@ class ClassNode extends NodeBase {
|
|
|
10349
10456
|
definition.deoptimizePath(UNKNOWN_PATH);
|
|
10350
10457
|
}
|
|
10351
10458
|
}
|
|
10352
|
-
this.context.requestTreeshakingPass();
|
|
10459
|
+
this.scope.context.requestTreeshakingPass();
|
|
10353
10460
|
}
|
|
10354
10461
|
getObjectEntity() {
|
|
10355
10462
|
if (this.objectEntity !== null) {
|
|
@@ -10454,7 +10561,6 @@ class MultiExpression extends ExpressionEntity {
|
|
|
10454
10561
|
constructor(expressions) {
|
|
10455
10562
|
super();
|
|
10456
10563
|
this.expressions = expressions;
|
|
10457
|
-
this.included = false;
|
|
10458
10564
|
}
|
|
10459
10565
|
deoptimizePath(path) {
|
|
10460
10566
|
for (const expression of this.expressions) {
|
|
@@ -10480,9 +10586,14 @@ class ConditionalExpression extends NodeBase {
|
|
|
10480
10586
|
constructor() {
|
|
10481
10587
|
super(...arguments);
|
|
10482
10588
|
this.expressionsToBeDeoptimized = [];
|
|
10483
|
-
this.isBranchResolutionAnalysed = false;
|
|
10484
10589
|
this.usedBranch = null;
|
|
10485
10590
|
}
|
|
10591
|
+
get isBranchResolutionAnalysed() {
|
|
10592
|
+
return isFlagSet(this.flags, 65536 /* Flag.isBranchResolutionAnalysed */);
|
|
10593
|
+
}
|
|
10594
|
+
set isBranchResolutionAnalysed(value) {
|
|
10595
|
+
this.flags = setFlag(this.flags, 65536 /* Flag.isBranchResolutionAnalysed */, value);
|
|
10596
|
+
}
|
|
10486
10597
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10487
10598
|
this.consequent.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10488
10599
|
this.alternate.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -10689,7 +10800,7 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
10689
10800
|
return false;
|
|
10690
10801
|
}
|
|
10691
10802
|
initialise() {
|
|
10692
|
-
this.context.addExport(this);
|
|
10803
|
+
this.scope.context.addExport(this);
|
|
10693
10804
|
}
|
|
10694
10805
|
render(code, _options, nodeRenderOptions) {
|
|
10695
10806
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
@@ -10730,15 +10841,15 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
10730
10841
|
include(context, includeChildrenRecursively) {
|
|
10731
10842
|
super.include(context, includeChildrenRecursively);
|
|
10732
10843
|
if (includeChildrenRecursively) {
|
|
10733
|
-
this.context.includeVariableInModule(this.variable);
|
|
10844
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
10734
10845
|
}
|
|
10735
10846
|
}
|
|
10736
10847
|
initialise() {
|
|
10737
10848
|
const declaration = this.declaration;
|
|
10738
10849
|
this.declarationName =
|
|
10739
10850
|
(declaration.id && declaration.id.name) || this.declaration.name;
|
|
10740
|
-
this.variable = this.scope.addExportDefaultDeclaration(this.declarationName || this.context.getModuleName(), this, this.context);
|
|
10741
|
-
this.context.addExport(this);
|
|
10851
|
+
this.variable = this.scope.addExportDefaultDeclaration(this.declarationName || this.scope.context.getModuleName(), this, this.scope.context);
|
|
10852
|
+
this.scope.context.addExport(this);
|
|
10742
10853
|
}
|
|
10743
10854
|
removeAnnotations(code) {
|
|
10744
10855
|
this.declaration.removeAnnotations(code);
|
|
@@ -10817,7 +10928,7 @@ class ExportNamedDeclaration extends NodeBase {
|
|
|
10817
10928
|
return !!this.declaration?.hasEffects(context);
|
|
10818
10929
|
}
|
|
10819
10930
|
initialise() {
|
|
10820
|
-
this.context.addExport(this);
|
|
10931
|
+
this.scope.context.addExport(this);
|
|
10821
10932
|
}
|
|
10822
10933
|
removeAnnotations(code) {
|
|
10823
10934
|
this.declaration?.removeAnnotations(code);
|
|
@@ -10842,7 +10953,7 @@ class ExportSpecifier extends NodeBase {
|
|
|
10842
10953
|
|
|
10843
10954
|
class ForInStatement extends NodeBase {
|
|
10844
10955
|
createScope(parentScope) {
|
|
10845
|
-
this.scope = new BlockScope(parentScope);
|
|
10956
|
+
this.scope = new BlockScope(parentScope, this.scope.context);
|
|
10846
10957
|
}
|
|
10847
10958
|
hasEffects(context) {
|
|
10848
10959
|
const { body, deoptimized, left, right } = this;
|
|
@@ -10876,13 +10987,19 @@ class ForInStatement extends NodeBase {
|
|
|
10876
10987
|
applyDeoptimizations() {
|
|
10877
10988
|
this.deoptimized = true;
|
|
10878
10989
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
10879
|
-
this.context.requestTreeshakingPass();
|
|
10990
|
+
this.scope.context.requestTreeshakingPass();
|
|
10880
10991
|
}
|
|
10881
10992
|
}
|
|
10882
10993
|
|
|
10883
10994
|
class ForOfStatement extends NodeBase {
|
|
10995
|
+
get await() {
|
|
10996
|
+
return isFlagSet(this.flags, 131072 /* Flag.await */);
|
|
10997
|
+
}
|
|
10998
|
+
set await(value) {
|
|
10999
|
+
this.flags = setFlag(this.flags, 131072 /* Flag.await */, value);
|
|
11000
|
+
}
|
|
10884
11001
|
createScope(parentScope) {
|
|
10885
|
-
this.scope = new BlockScope(parentScope);
|
|
11002
|
+
this.scope = new BlockScope(parentScope, this.scope.context);
|
|
10886
11003
|
}
|
|
10887
11004
|
hasEffects() {
|
|
10888
11005
|
if (!this.deoptimized)
|
|
@@ -10915,13 +11032,13 @@ class ForOfStatement extends NodeBase {
|
|
|
10915
11032
|
this.deoptimized = true;
|
|
10916
11033
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
10917
11034
|
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
10918
|
-
this.context.requestTreeshakingPass();
|
|
11035
|
+
this.scope.context.requestTreeshakingPass();
|
|
10919
11036
|
}
|
|
10920
11037
|
}
|
|
10921
11038
|
|
|
10922
11039
|
class ForStatement extends NodeBase {
|
|
10923
11040
|
createScope(parentScope) {
|
|
10924
|
-
this.scope = new BlockScope(parentScope);
|
|
11041
|
+
this.scope = new BlockScope(parentScope, this.scope.context);
|
|
10925
11042
|
}
|
|
10926
11043
|
hasEffects(context) {
|
|
10927
11044
|
if (this.init?.hasEffects(context) ||
|
|
@@ -11014,11 +11131,11 @@ class IfStatement extends NodeBase {
|
|
|
11014
11131
|
}
|
|
11015
11132
|
}
|
|
11016
11133
|
parseNode(esTreeNode) {
|
|
11017
|
-
this.consequentScope = new TrackingScope(this.scope);
|
|
11018
|
-
this.consequent = new (this.context.getNodeConstructor(esTreeNode.consequent.type))(esTreeNode.consequent, this, this.consequentScope);
|
|
11134
|
+
this.consequentScope = new TrackingScope(this.scope, this.scope.context);
|
|
11135
|
+
this.consequent = new (this.scope.context.getNodeConstructor(esTreeNode.consequent.type))(esTreeNode.consequent, this, this.consequentScope);
|
|
11019
11136
|
if (esTreeNode.alternate) {
|
|
11020
|
-
this.alternateScope = new TrackingScope(this.scope);
|
|
11021
|
-
this.alternate = new (this.context.getNodeConstructor(esTreeNode.alternate.type))(esTreeNode.alternate, this, this.alternateScope);
|
|
11137
|
+
this.alternateScope = new TrackingScope(this.scope, this.scope.context);
|
|
11138
|
+
this.alternate = new (this.scope.context.getNodeConstructor(esTreeNode.alternate.type))(esTreeNode.alternate, this, this.alternateScope);
|
|
11022
11139
|
}
|
|
11023
11140
|
super.parseNode(esTreeNode);
|
|
11024
11141
|
}
|
|
@@ -11028,7 +11145,7 @@ class IfStatement extends NodeBase {
|
|
|
11028
11145
|
const testValue = this.getTestValue();
|
|
11029
11146
|
const hoistedDeclarations = [];
|
|
11030
11147
|
const includesIfElse = this.test.included;
|
|
11031
|
-
const noTreeshake = !this.context.options.treeshake;
|
|
11148
|
+
const noTreeshake = !this.scope.context.options.treeshake;
|
|
11032
11149
|
if (includesIfElse) {
|
|
11033
11150
|
this.test.render(code, options);
|
|
11034
11151
|
}
|
|
@@ -11148,7 +11265,7 @@ class ImportDeclaration extends NodeBase {
|
|
|
11148
11265
|
return false;
|
|
11149
11266
|
}
|
|
11150
11267
|
initialise() {
|
|
11151
|
-
this.context.addImport(this);
|
|
11268
|
+
this.scope.context.addImport(this);
|
|
11152
11269
|
}
|
|
11153
11270
|
render(code, _options, nodeRenderOptions) {
|
|
11154
11271
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
@@ -11532,13 +11649,13 @@ class ImportExpression extends NodeBase {
|
|
|
11532
11649
|
include(context, includeChildrenRecursively) {
|
|
11533
11650
|
if (!this.included) {
|
|
11534
11651
|
this.included = true;
|
|
11535
|
-
this.context.includeDynamicImport(this);
|
|
11652
|
+
this.scope.context.includeDynamicImport(this);
|
|
11536
11653
|
this.scope.addAccessedDynamicImport(this);
|
|
11537
11654
|
}
|
|
11538
11655
|
this.source.include(context, includeChildrenRecursively);
|
|
11539
11656
|
}
|
|
11540
11657
|
initialise() {
|
|
11541
|
-
this.context.addDynamicImport(this);
|
|
11658
|
+
this.scope.context.addDynamicImport(this);
|
|
11542
11659
|
}
|
|
11543
11660
|
parseNode(esTreeNode) {
|
|
11544
11661
|
// Keep the source AST to be used by renderDynamicImport
|
|
@@ -11610,7 +11727,7 @@ class ImportExpression extends NodeBase {
|
|
|
11610
11727
|
{
|
|
11611
11728
|
customResolution: typeof this.resolution === 'string' ? this.resolution : null,
|
|
11612
11729
|
format,
|
|
11613
|
-
moduleId: this.context.module.id,
|
|
11730
|
+
moduleId: this.scope.context.module.id,
|
|
11614
11731
|
targetModuleId: this.resolution && typeof this.resolution !== 'string' ? this.resolution.id : null
|
|
11615
11732
|
}
|
|
11616
11733
|
]);
|
|
@@ -11763,9 +11880,15 @@ class LogicalExpression extends NodeBase {
|
|
|
11763
11880
|
super(...arguments);
|
|
11764
11881
|
// We collect deoptimization information if usedBranch !== null
|
|
11765
11882
|
this.expressionsToBeDeoptimized = [];
|
|
11766
|
-
this.isBranchResolutionAnalysed = false;
|
|
11767
11883
|
this.usedBranch = null;
|
|
11768
11884
|
}
|
|
11885
|
+
//private isBranchResolutionAnalysed = false;
|
|
11886
|
+
get isBranchResolutionAnalysed() {
|
|
11887
|
+
return isFlagSet(this.flags, 65536 /* Flag.isBranchResolutionAnalysed */);
|
|
11888
|
+
}
|
|
11889
|
+
set isBranchResolutionAnalysed(value) {
|
|
11890
|
+
this.flags = setFlag(this.flags, 65536 /* Flag.isBranchResolutionAnalysed */, value);
|
|
11891
|
+
}
|
|
11769
11892
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11770
11893
|
this.left.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11771
11894
|
this.right.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -11775,7 +11898,7 @@ class LogicalExpression extends NodeBase {
|
|
|
11775
11898
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
11776
11899
|
this.usedBranch = null;
|
|
11777
11900
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
11778
|
-
const { context, expressionsToBeDeoptimized } = this;
|
|
11901
|
+
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
11779
11902
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
11780
11903
|
for (const expression of expressionsToBeDeoptimized) {
|
|
11781
11904
|
expression.deoptimizeCache();
|
|
@@ -11923,7 +12046,7 @@ class MetaProperty extends NodeBase {
|
|
|
11923
12046
|
if (!this.included) {
|
|
11924
12047
|
this.included = true;
|
|
11925
12048
|
if (this.meta.name === IMPORT) {
|
|
11926
|
-
this.context.addImportMeta(this);
|
|
12049
|
+
this.scope.context.addImportMeta(this);
|
|
11927
12050
|
const parent = this.parent;
|
|
11928
12051
|
const metaProperty = (this.metaProperty =
|
|
11929
12052
|
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
@@ -11937,7 +12060,7 @@ class MetaProperty extends NodeBase {
|
|
|
11937
12060
|
}
|
|
11938
12061
|
render(code, renderOptions) {
|
|
11939
12062
|
const { format, pluginDriver, snippets } = renderOptions;
|
|
11940
|
-
const { context: { module }, meta: { name }, metaProperty, parent, preliminaryChunkId, referenceId, start, end } = this;
|
|
12063
|
+
const { scope: { context: { module } }, meta: { name }, metaProperty, parent, preliminaryChunkId, referenceId, start, end } = this;
|
|
11941
12064
|
const { id: moduleId } = module;
|
|
11942
12065
|
if (name !== IMPORT)
|
|
11943
12066
|
return;
|
|
@@ -12074,7 +12197,7 @@ class NewExpression extends NodeBase {
|
|
|
12074
12197
|
applyDeoptimizations() {
|
|
12075
12198
|
this.deoptimized = true;
|
|
12076
12199
|
this.callee.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
12077
|
-
this.context.requestTreeshakingPass();
|
|
12200
|
+
this.scope.context.requestTreeshakingPass();
|
|
12078
12201
|
}
|
|
12079
12202
|
}
|
|
12080
12203
|
|
|
@@ -12171,9 +12294,9 @@ class Program extends NodeBase {
|
|
|
12171
12294
|
hasEffects(context) {
|
|
12172
12295
|
for (const node of this.body) {
|
|
12173
12296
|
if (node.hasEffects(context)) {
|
|
12174
|
-
if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
|
|
12297
|
+
if (this.scope.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
|
|
12175
12298
|
this.hasLoggedEffect = true;
|
|
12176
|
-
const { code, log, module } = this.context;
|
|
12299
|
+
const { code, log, module } = this.scope.context;
|
|
12177
12300
|
log(parseAst_js.LOGLEVEL_INFO, parseAst_js.logFirstSideEffect(code, module.id, parseAst_js.locate(code, node.start, { offsetLine: 1 })), node.start);
|
|
12178
12301
|
}
|
|
12179
12302
|
return (this.hasCachedEffect = true);
|
|
@@ -12218,6 +12341,20 @@ class Property extends MethodBase {
|
|
|
12218
12341
|
super(...arguments);
|
|
12219
12342
|
this.declarationInit = null;
|
|
12220
12343
|
}
|
|
12344
|
+
//declare method: boolean;
|
|
12345
|
+
get method() {
|
|
12346
|
+
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
12347
|
+
}
|
|
12348
|
+
set method(value) {
|
|
12349
|
+
this.flags = setFlag(this.flags, 262144 /* Flag.method */, value);
|
|
12350
|
+
}
|
|
12351
|
+
//declare shorthand: boolean;
|
|
12352
|
+
get shorthand() {
|
|
12353
|
+
return isFlagSet(this.flags, 524288 /* Flag.shorthand */);
|
|
12354
|
+
}
|
|
12355
|
+
set shorthand(value) {
|
|
12356
|
+
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
12357
|
+
}
|
|
12221
12358
|
declare(kind, init) {
|
|
12222
12359
|
this.declarationInit = init;
|
|
12223
12360
|
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
@@ -12225,8 +12362,7 @@ class Property extends MethodBase {
|
|
|
12225
12362
|
hasEffects(context) {
|
|
12226
12363
|
if (!this.deoptimized)
|
|
12227
12364
|
this.applyDeoptimizations();
|
|
12228
|
-
const propertyReadSideEffects = this.context.options.treeshake
|
|
12229
|
-
.propertyReadSideEffects;
|
|
12365
|
+
const propertyReadSideEffects = this.scope.context.options.treeshake.propertyReadSideEffects;
|
|
12230
12366
|
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
12231
12367
|
this.key.hasEffects(context) ||
|
|
12232
12368
|
this.value.hasEffects(context));
|
|
@@ -12244,12 +12380,18 @@ class Property extends MethodBase {
|
|
|
12244
12380
|
this.deoptimized = true;
|
|
12245
12381
|
if (this.declarationInit !== null) {
|
|
12246
12382
|
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
12247
|
-
this.context.requestTreeshakingPass();
|
|
12383
|
+
this.scope.context.requestTreeshakingPass();
|
|
12248
12384
|
}
|
|
12249
12385
|
}
|
|
12250
12386
|
}
|
|
12251
12387
|
|
|
12252
12388
|
class PropertyDefinition extends NodeBase {
|
|
12389
|
+
get computed() {
|
|
12390
|
+
return isFlagSet(this.flags, 1024 /* Flag.computed */);
|
|
12391
|
+
}
|
|
12392
|
+
set computed(value) {
|
|
12393
|
+
this.flags = setFlag(this.flags, 1024 /* Flag.computed */, value);
|
|
12394
|
+
}
|
|
12253
12395
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
12254
12396
|
this.value?.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
12255
12397
|
}
|
|
@@ -12367,7 +12509,7 @@ class SequenceExpression extends NodeBase {
|
|
|
12367
12509
|
|
|
12368
12510
|
class StaticBlock extends NodeBase {
|
|
12369
12511
|
createScope(parentScope) {
|
|
12370
|
-
this.scope = new BlockScope(parentScope);
|
|
12512
|
+
this.scope = new BlockScope(parentScope, this.scope.context);
|
|
12371
12513
|
}
|
|
12372
12514
|
hasEffects(context) {
|
|
12373
12515
|
for (const node of this.body) {
|
|
@@ -12407,7 +12549,7 @@ class Super extends NodeBase {
|
|
|
12407
12549
|
include() {
|
|
12408
12550
|
if (!this.included) {
|
|
12409
12551
|
this.included = true;
|
|
12410
|
-
this.context.includeVariableInModule(this.variable);
|
|
12552
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
12411
12553
|
}
|
|
12412
12554
|
}
|
|
12413
12555
|
}
|
|
@@ -12451,7 +12593,7 @@ SwitchCase.prototype.needsBoundaries = true;
|
|
|
12451
12593
|
class SwitchStatement extends NodeBase {
|
|
12452
12594
|
createScope(parentScope) {
|
|
12453
12595
|
this.parentScope = parentScope;
|
|
12454
|
-
this.scope = new BlockScope(parentScope);
|
|
12596
|
+
this.scope = new BlockScope(parentScope, this.scope.context);
|
|
12455
12597
|
}
|
|
12456
12598
|
hasEffects(context) {
|
|
12457
12599
|
if (this.discriminant.hasEffects(context))
|
|
@@ -12520,7 +12662,7 @@ class SwitchStatement extends NodeBase {
|
|
|
12520
12662
|
this.defaultCase = null;
|
|
12521
12663
|
}
|
|
12522
12664
|
parseNode(esTreeNode) {
|
|
12523
|
-
this.discriminant = new (this.context.getNodeConstructor(esTreeNode.discriminant.type))(esTreeNode.discriminant, this, this.parentScope);
|
|
12665
|
+
this.discriminant = new (this.scope.context.getNodeConstructor(esTreeNode.discriminant.type))(esTreeNode.discriminant, this, this.parentScope);
|
|
12524
12666
|
super.parseNode(esTreeNode);
|
|
12525
12667
|
}
|
|
12526
12668
|
render(code, options) {
|
|
@@ -12538,7 +12680,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
12538
12680
|
const name = this.tag.name;
|
|
12539
12681
|
const variable = this.scope.findVariable(name);
|
|
12540
12682
|
if (variable.isNamespace) {
|
|
12541
|
-
this.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logCannotCallNamespace(name), this.start);
|
|
12683
|
+
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logCannotCallNamespace(name), this.start);
|
|
12542
12684
|
}
|
|
12543
12685
|
}
|
|
12544
12686
|
}
|
|
@@ -12591,7 +12733,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
12591
12733
|
applyDeoptimizations() {
|
|
12592
12734
|
this.deoptimized = true;
|
|
12593
12735
|
this.tag.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
12594
|
-
this.context.requestTreeshakingPass();
|
|
12736
|
+
this.scope.context.requestTreeshakingPass();
|
|
12595
12737
|
}
|
|
12596
12738
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
12597
12739
|
if (this.returnExpression === null) {
|
|
@@ -12603,6 +12745,12 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
12603
12745
|
}
|
|
12604
12746
|
|
|
12605
12747
|
class TemplateElement extends NodeBase {
|
|
12748
|
+
get tail() {
|
|
12749
|
+
return isFlagSet(this.flags, 1048576 /* Flag.tail */);
|
|
12750
|
+
}
|
|
12751
|
+
set tail(value) {
|
|
12752
|
+
this.flags = setFlag(this.flags, 1048576 /* Flag.tail */, value);
|
|
12753
|
+
}
|
|
12606
12754
|
// Do not try to bind value
|
|
12607
12755
|
bind() { }
|
|
12608
12756
|
hasEffects() {
|
|
@@ -12728,8 +12876,7 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
12728
12876
|
|
|
12729
12877
|
class ModuleScope extends ChildScope {
|
|
12730
12878
|
constructor(parent, context) {
|
|
12731
|
-
super(parent);
|
|
12732
|
-
this.context = context;
|
|
12879
|
+
super(parent, context);
|
|
12733
12880
|
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context));
|
|
12734
12881
|
}
|
|
12735
12882
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
@@ -12778,14 +12925,16 @@ class ThisExpression extends NodeBase {
|
|
|
12778
12925
|
include() {
|
|
12779
12926
|
if (!this.included) {
|
|
12780
12927
|
this.included = true;
|
|
12781
|
-
this.context.includeVariableInModule(this.variable);
|
|
12928
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
12782
12929
|
}
|
|
12783
12930
|
}
|
|
12784
12931
|
initialise() {
|
|
12785
12932
|
this.alias =
|
|
12786
|
-
this.scope.findLexicalBoundary() instanceof ModuleScope
|
|
12933
|
+
this.scope.findLexicalBoundary() instanceof ModuleScope
|
|
12934
|
+
? this.scope.context.moduleContext
|
|
12935
|
+
: null;
|
|
12787
12936
|
if (this.alias === 'undefined') {
|
|
12788
|
-
this.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logThisIsUndefined(), this.start);
|
|
12937
|
+
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logThisIsUndefined(), this.start);
|
|
12789
12938
|
}
|
|
12790
12939
|
}
|
|
12791
12940
|
render(code) {
|
|
@@ -12822,13 +12971,12 @@ class TryStatement extends NodeBase {
|
|
|
12822
12971
|
this.includedLabelsAfterBlock = null;
|
|
12823
12972
|
}
|
|
12824
12973
|
hasEffects(context) {
|
|
12825
|
-
return ((this.context.options.treeshake.tryCatchDeoptimization
|
|
12974
|
+
return ((this.scope.context.options.treeshake.tryCatchDeoptimization
|
|
12826
12975
|
? this.block.body.length > 0
|
|
12827
12976
|
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
12828
12977
|
}
|
|
12829
12978
|
include(context, includeChildrenRecursively) {
|
|
12830
|
-
const tryCatchDeoptimization = this.context.options.treeshake
|
|
12831
|
-
?.tryCatchDeoptimization;
|
|
12979
|
+
const tryCatchDeoptimization = this.scope.context.options.treeshake?.tryCatchDeoptimization;
|
|
12832
12980
|
const { brokenFlow, includedLabels } = context;
|
|
12833
12981
|
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
12834
12982
|
this.included = true;
|
|
@@ -12862,6 +13010,12 @@ const unaryOperators = {
|
|
|
12862
13010
|
'~': value => ~value
|
|
12863
13011
|
};
|
|
12864
13012
|
class UnaryExpression extends NodeBase {
|
|
13013
|
+
get prefix() {
|
|
13014
|
+
return isFlagSet(this.flags, 2097152 /* Flag.prefix */);
|
|
13015
|
+
}
|
|
13016
|
+
set prefix(value) {
|
|
13017
|
+
this.flags = setFlag(this.flags, 2097152 /* Flag.prefix */, value);
|
|
13018
|
+
}
|
|
12865
13019
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
12866
13020
|
if (path.length > 0)
|
|
12867
13021
|
return UnknownValue;
|
|
@@ -12886,7 +13040,7 @@ class UnaryExpression extends NodeBase {
|
|
|
12886
13040
|
this.deoptimized = true;
|
|
12887
13041
|
if (this.operator === 'delete') {
|
|
12888
13042
|
this.argument.deoptimizePath(EMPTY_PATH);
|
|
12889
|
-
this.context.requestTreeshakingPass();
|
|
13043
|
+
this.scope.context.requestTreeshakingPass();
|
|
12890
13044
|
}
|
|
12891
13045
|
}
|
|
12892
13046
|
}
|
|
@@ -12947,7 +13101,7 @@ class UpdateExpression extends NodeBase {
|
|
|
12947
13101
|
const variable = this.scope.findVariable(this.argument.name);
|
|
12948
13102
|
variable.isReassigned = true;
|
|
12949
13103
|
}
|
|
12950
|
-
this.context.requestTreeshakingPass();
|
|
13104
|
+
this.scope.context.requestTreeshakingPass();
|
|
12951
13105
|
}
|
|
12952
13106
|
}
|
|
12953
13107
|
|
|
@@ -13371,7 +13525,8 @@ class NamespaceVariable extends Variable {
|
|
|
13371
13525
|
this.mergedNamespaces = mergedNamespaces;
|
|
13372
13526
|
const moduleExecIndex = this.context.getModuleExecIndex();
|
|
13373
13527
|
for (const identifier of this.references) {
|
|
13374
|
-
|
|
13528
|
+
const { context } = identifier.scope;
|
|
13529
|
+
if (context.getModuleExecIndex() <= moduleExecIndex) {
|
|
13375
13530
|
this.referencedEarly = true;
|
|
13376
13531
|
break;
|
|
13377
13532
|
}
|
|
@@ -13520,7 +13675,7 @@ function getOriginalLocation(sourcemapChain, location) {
|
|
|
13520
13675
|
|
|
13521
13676
|
const ATTRIBUTE_KEYWORDS = new Set(['assert', 'with']);
|
|
13522
13677
|
function getAttributesFromImportExpression(node) {
|
|
13523
|
-
const { context, options, start } = node;
|
|
13678
|
+
const { scope: { context }, options, start } = node;
|
|
13524
13679
|
if (!(options instanceof ObjectExpression)) {
|
|
13525
13680
|
if (options) {
|
|
13526
13681
|
context.module.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logImportAttributeIsInvalid(context.module.id), start);
|