@rollup/wasm-node 4.10.0 → 4.12.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 +10 -4
- 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 +1003 -153
- package/dist/es/shared/parseAst.js +90 -44
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +3 -3
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +15 -4
- package/dist/rollup.js +3 -3
- 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 +108 -43
- package/dist/shared/rollup.js +1024 -174
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +15 -14
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.12.0
|
|
4
|
+
Fri, 16 Feb 2024 13:31:42 GMT - commit 0146b84be33a8416b4df4b9382549a7ca19dd64a
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -14,8 +14,8 @@ const process$1 = require('node:process');
|
|
|
14
14
|
const tty = require('tty');
|
|
15
15
|
const node_path = require('node:path');
|
|
16
16
|
const require$$0$1 = require('path');
|
|
17
|
-
const node_perf_hooks = require('node:perf_hooks');
|
|
18
17
|
const native_js = require('../native.js');
|
|
18
|
+
const node_perf_hooks = require('node:perf_hooks');
|
|
19
19
|
const promises = require('node:fs/promises');
|
|
20
20
|
|
|
21
21
|
function _interopNamespaceDefault(e) {
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version = "4.
|
|
34
|
+
var version = "4.12.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -1294,6 +1294,7 @@ async function mergeOutputOptions(config, overrides, log) {
|
|
|
1294
1294
|
plugins: await normalizePluginOption(config.plugins),
|
|
1295
1295
|
preserveModules: getOption('preserveModules'),
|
|
1296
1296
|
preserveModulesRoot: getOption('preserveModulesRoot'),
|
|
1297
|
+
reexportProtoFromExternal: getOption('reexportProtoFromExternal'),
|
|
1297
1298
|
sanitizeFileName: getOption('sanitizeFileName'),
|
|
1298
1299
|
sourcemap: getOption('sourcemap'),
|
|
1299
1300
|
sourcemapBaseUrl: getOption('sourcemapBaseUrl'),
|
|
@@ -6068,13 +6069,83 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
6068
6069
|
return [members[memberName].returns, false];
|
|
6069
6070
|
}
|
|
6070
6071
|
|
|
6071
|
-
|
|
6072
|
+
// This file is generated by scripts/generate-ast-converters.js.
|
|
6073
|
+
// Do not edit this file directly.
|
|
6074
|
+
const childNodeKeys = {
|
|
6075
|
+
ArrayExpression: ['elements'],
|
|
6076
|
+
ArrayPattern: ['elements'],
|
|
6077
|
+
ArrowFunctionExpression: ['params', 'body'],
|
|
6078
|
+
AssignmentExpression: ['left', 'right'],
|
|
6079
|
+
AssignmentPattern: ['left', 'right'],
|
|
6080
|
+
AwaitExpression: ['argument'],
|
|
6081
|
+
BinaryExpression: ['left', 'right'],
|
|
6082
|
+
BlockStatement: ['body'],
|
|
6083
|
+
BreakStatement: ['label'],
|
|
6084
|
+
CallExpression: ['callee', 'arguments'],
|
|
6085
|
+
CatchClause: ['param', 'body'],
|
|
6086
|
+
ChainExpression: ['expression'],
|
|
6087
|
+
ClassBody: ['body'],
|
|
6088
|
+
ClassDeclaration: ['id', 'superClass', 'body'],
|
|
6089
|
+
ClassExpression: ['id', 'superClass', 'body'],
|
|
6090
|
+
ConditionalExpression: ['test', 'consequent', 'alternate'],
|
|
6091
|
+
ContinueStatement: ['label'],
|
|
6092
|
+
DebuggerStatement: [],
|
|
6093
|
+
DoWhileStatement: ['body', 'test'],
|
|
6094
|
+
EmptyStatement: [],
|
|
6095
|
+
ExportAllDeclaration: ['exported', 'source', 'attributes'],
|
|
6096
|
+
ExportDefaultDeclaration: ['declaration'],
|
|
6097
|
+
ExportNamedDeclaration: ['specifiers', 'source', 'attributes', 'declaration'],
|
|
6098
|
+
ExportSpecifier: ['local', 'exported'],
|
|
6099
|
+
ExpressionStatement: ['expression'],
|
|
6100
|
+
ForInStatement: ['left', 'right', 'body'],
|
|
6101
|
+
ForOfStatement: ['left', 'right', 'body'],
|
|
6102
|
+
ForStatement: ['init', 'test', 'update', 'body'],
|
|
6103
|
+
FunctionDeclaration: ['id', 'params', 'body'],
|
|
6104
|
+
FunctionExpression: ['id', 'params', 'body'],
|
|
6105
|
+
Identifier: [],
|
|
6106
|
+
IfStatement: ['test', 'consequent', 'alternate'],
|
|
6107
|
+
ImportAttribute: ['key', 'value'],
|
|
6108
|
+
ImportDeclaration: ['specifiers', 'source', 'attributes'],
|
|
6109
|
+
ImportDefaultSpecifier: ['local'],
|
|
6110
|
+
ImportExpression: ['source', 'options'],
|
|
6111
|
+
ImportNamespaceSpecifier: ['local'],
|
|
6112
|
+
ImportSpecifier: ['imported', 'local'],
|
|
6113
|
+
LabeledStatement: ['label', 'body'],
|
|
6072
6114
|
Literal: [],
|
|
6073
|
-
|
|
6115
|
+
LogicalExpression: ['left', 'right'],
|
|
6116
|
+
MemberExpression: ['object', 'property'],
|
|
6117
|
+
MetaProperty: ['meta', 'property'],
|
|
6118
|
+
MethodDefinition: ['key', 'value'],
|
|
6119
|
+
NewExpression: ['callee', 'arguments'],
|
|
6120
|
+
ObjectExpression: ['properties'],
|
|
6121
|
+
ObjectPattern: ['properties'],
|
|
6122
|
+
PanicError: [],
|
|
6123
|
+
ParseError: [],
|
|
6124
|
+
PrivateIdentifier: [],
|
|
6125
|
+
Program: ['body'],
|
|
6126
|
+
Property: ['key', 'value'],
|
|
6127
|
+
PropertyDefinition: ['key', 'value'],
|
|
6128
|
+
RestElement: ['argument'],
|
|
6129
|
+
ReturnStatement: ['argument'],
|
|
6130
|
+
SequenceExpression: ['expressions'],
|
|
6131
|
+
SpreadElement: ['argument'],
|
|
6132
|
+
StaticBlock: ['body'],
|
|
6133
|
+
Super: [],
|
|
6134
|
+
SwitchCase: ['test', 'consequent'],
|
|
6135
|
+
SwitchStatement: ['discriminant', 'cases'],
|
|
6136
|
+
TaggedTemplateExpression: ['tag', 'quasi'],
|
|
6137
|
+
TemplateElement: [],
|
|
6138
|
+
TemplateLiteral: ['quasis', 'expressions'],
|
|
6139
|
+
ThisExpression: [],
|
|
6140
|
+
ThrowStatement: ['argument'],
|
|
6141
|
+
TryStatement: ['block', 'handler', 'finalizer'],
|
|
6142
|
+
UnaryExpression: ['argument'],
|
|
6143
|
+
UpdateExpression: ['argument'],
|
|
6144
|
+
VariableDeclaration: ['declarations'],
|
|
6145
|
+
VariableDeclarator: ['id', 'init'],
|
|
6146
|
+
WhileStatement: ['test', 'body'],
|
|
6147
|
+
YieldExpression: ['argument']
|
|
6074
6148
|
};
|
|
6075
|
-
function createKeysForNode(esTreeNode) {
|
|
6076
|
-
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
6077
|
-
}
|
|
6078
6149
|
|
|
6079
6150
|
const INCLUDE_PARAMETERS = 'variables';
|
|
6080
6151
|
class NodeBase extends ExpressionEntity {
|
|
@@ -6090,22 +6161,11 @@ class NodeBase extends ExpressionEntity {
|
|
|
6090
6161
|
set deoptimized(value) {
|
|
6091
6162
|
this.flags = setFlag(this.flags, 2 /* Flag.deoptimized */, value);
|
|
6092
6163
|
}
|
|
6093
|
-
constructor(
|
|
6164
|
+
constructor(parent, parentScope) {
|
|
6094
6165
|
super();
|
|
6095
|
-
// Nodes can opt-in to keep the AST if needed during the build pipeline.
|
|
6096
|
-
// Avoid true when possible as large AST takes up memory.
|
|
6097
|
-
if (keepEsTreeNode) {
|
|
6098
|
-
this.esTreeNode = esTreeNode;
|
|
6099
|
-
}
|
|
6100
|
-
const { type } = esTreeNode;
|
|
6101
|
-
keys[type] ||= createKeysForNode(esTreeNode);
|
|
6102
6166
|
this.parent = parent;
|
|
6103
6167
|
this.scope = parentScope;
|
|
6104
6168
|
this.createScope(parentScope);
|
|
6105
|
-
this.parseNode(esTreeNode);
|
|
6106
|
-
this.initialise();
|
|
6107
|
-
this.scope.context.magicString.addSourcemapLocation(this.start);
|
|
6108
|
-
this.scope.context.magicString.addSourcemapLocation(this.end);
|
|
6109
6169
|
}
|
|
6110
6170
|
addExportedVariables(_variables, _exportNamesByVariable) { }
|
|
6111
6171
|
/**
|
|
@@ -6113,7 +6173,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6113
6173
|
* that require the scopes to be populated with variables.
|
|
6114
6174
|
*/
|
|
6115
6175
|
bind() {
|
|
6116
|
-
for (const key of
|
|
6176
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6117
6177
|
const value = this[key];
|
|
6118
6178
|
if (Array.isArray(value)) {
|
|
6119
6179
|
for (const child of value) {
|
|
@@ -6135,7 +6195,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6135
6195
|
hasEffects(context) {
|
|
6136
6196
|
if (!this.deoptimized)
|
|
6137
6197
|
this.applyDeoptimizations();
|
|
6138
|
-
for (const key of
|
|
6198
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6139
6199
|
const value = this[key];
|
|
6140
6200
|
if (value === null)
|
|
6141
6201
|
continue;
|
|
@@ -6158,7 +6218,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6158
6218
|
if (!this.deoptimized)
|
|
6159
6219
|
this.applyDeoptimizations();
|
|
6160
6220
|
this.included = true;
|
|
6161
|
-
for (const key of
|
|
6221
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6162
6222
|
const value = this[key];
|
|
6163
6223
|
if (value === null)
|
|
6164
6224
|
continue;
|
|
@@ -6179,8 +6239,11 @@ class NodeBase extends ExpressionEntity {
|
|
|
6179
6239
|
* Override to perform special initialisation steps after the scope is
|
|
6180
6240
|
* initialised
|
|
6181
6241
|
*/
|
|
6182
|
-
initialise() {
|
|
6183
|
-
|
|
6242
|
+
initialise() {
|
|
6243
|
+
this.scope.context.magicString.addSourcemapLocation(this.start);
|
|
6244
|
+
this.scope.context.magicString.addSourcemapLocation(this.end);
|
|
6245
|
+
}
|
|
6246
|
+
parseNode(esTreeNode) {
|
|
6184
6247
|
for (const [key, value] of Object.entries(esTreeNode)) {
|
|
6185
6248
|
// Skip properties defined on the class already.
|
|
6186
6249
|
// This way, we can override this function to add custom initialisation and then call super.parseNode
|
|
@@ -6190,20 +6253,10 @@ class NodeBase extends ExpressionEntity {
|
|
|
6190
6253
|
continue;
|
|
6191
6254
|
if (key.charCodeAt(0) === 95 /* _ */) {
|
|
6192
6255
|
if (key === parseAst_js.ANNOTATION_KEY) {
|
|
6193
|
-
|
|
6194
|
-
this.annotations = annotations;
|
|
6195
|
-
if (this.scope.context.options.treeshake.annotations) {
|
|
6196
|
-
this.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
6197
|
-
this.annotationPure = annotations.some(comment => comment.type === 'pure');
|
|
6198
|
-
}
|
|
6256
|
+
this.annotations = value;
|
|
6199
6257
|
}
|
|
6200
6258
|
else if (key === parseAst_js.INVALID_ANNOTATION_KEY) {
|
|
6201
|
-
|
|
6202
|
-
this.scope.context.magicString.remove(start, end);
|
|
6203
|
-
if (type === 'pure' || type === 'noSideEffects') {
|
|
6204
|
-
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);
|
|
6205
|
-
}
|
|
6206
|
-
}
|
|
6259
|
+
this.invalidAnnotations = value;
|
|
6207
6260
|
}
|
|
6208
6261
|
}
|
|
6209
6262
|
else if (typeof value !== 'object' || value === null) {
|
|
@@ -6214,13 +6267,17 @@ class NodeBase extends ExpressionEntity {
|
|
|
6214
6267
|
for (const child of value) {
|
|
6215
6268
|
this[key].push(child === null
|
|
6216
6269
|
? null
|
|
6217
|
-
: new (this.scope.context.getNodeConstructor(child.type))(
|
|
6270
|
+
: new (this.scope.context.getNodeConstructor(child.type))(this, this.scope).parseNode(child));
|
|
6218
6271
|
}
|
|
6219
6272
|
}
|
|
6220
6273
|
else {
|
|
6221
|
-
this[key] = new (this.scope.context.getNodeConstructor(value.type))(
|
|
6274
|
+
this[key] = new (this.scope.context.getNodeConstructor(value.type))(this, this.scope).parseNode(value);
|
|
6222
6275
|
}
|
|
6223
6276
|
}
|
|
6277
|
+
// extend child keys for unknown node types
|
|
6278
|
+
childNodeKeys[esTreeNode.type] ||= createChildNodeKeysForNode(esTreeNode);
|
|
6279
|
+
this.initialise();
|
|
6280
|
+
return this;
|
|
6224
6281
|
}
|
|
6225
6282
|
removeAnnotations(code) {
|
|
6226
6283
|
if (this.annotations) {
|
|
@@ -6230,7 +6287,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6230
6287
|
}
|
|
6231
6288
|
}
|
|
6232
6289
|
render(code, options) {
|
|
6233
|
-
for (const key of
|
|
6290
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6234
6291
|
const value = this[key];
|
|
6235
6292
|
if (value === null)
|
|
6236
6293
|
continue;
|
|
@@ -6257,7 +6314,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
6257
6314
|
*/
|
|
6258
6315
|
applyDeoptimizations() {
|
|
6259
6316
|
this.deoptimized = true;
|
|
6260
|
-
for (const key of
|
|
6317
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6261
6318
|
const value = this[key];
|
|
6262
6319
|
if (value === null)
|
|
6263
6320
|
continue;
|
|
@@ -6273,6 +6330,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
6273
6330
|
this.scope.context.requestTreeshakingPass();
|
|
6274
6331
|
}
|
|
6275
6332
|
}
|
|
6333
|
+
function createChildNodeKeysForNode(esTreeNode) {
|
|
6334
|
+
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
6335
|
+
}
|
|
6276
6336
|
|
|
6277
6337
|
class SpreadElement extends NodeBase {
|
|
6278
6338
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -7025,16 +7085,6 @@ class ArrayPattern extends NodeBase {
|
|
|
7025
7085
|
}
|
|
7026
7086
|
}
|
|
7027
7087
|
|
|
7028
|
-
const ArrowFunctionExpression$1 = 'ArrowFunctionExpression';
|
|
7029
|
-
const BlockStatement$1 = 'BlockStatement';
|
|
7030
|
-
const CallExpression$1 = 'CallExpression';
|
|
7031
|
-
const CatchClause$1 = 'CatchClause';
|
|
7032
|
-
const ExpressionStatement$1 = 'ExpressionStatement';
|
|
7033
|
-
const Identifier$1 = 'Identifier';
|
|
7034
|
-
const Program$1 = 'Program';
|
|
7035
|
-
const Property$1 = 'Property';
|
|
7036
|
-
const ReturnStatement$1 = 'ReturnStatement';
|
|
7037
|
-
|
|
7038
7088
|
class LocalVariable extends Variable {
|
|
7039
7089
|
constructor(name, declarator, init, context, kind) {
|
|
7040
7090
|
super(name);
|
|
@@ -7140,7 +7190,7 @@ class LocalVariable extends Variable {
|
|
|
7140
7190
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
7141
7191
|
// in which case .include() might pull in more dead code
|
|
7142
7192
|
node.included = true;
|
|
7143
|
-
if (node.type === Program
|
|
7193
|
+
if (node.type === parseAst_js.Program)
|
|
7144
7194
|
break;
|
|
7145
7195
|
node = node.parent;
|
|
7146
7196
|
}
|
|
@@ -7179,7 +7229,7 @@ const EMPTY_PATH_TRACKER = new PathTracker();
|
|
|
7179
7229
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
7180
7230
|
class ParameterVariable extends LocalVariable {
|
|
7181
7231
|
constructor(name, declarator, context) {
|
|
7182
|
-
super(name, declarator, UNKNOWN_EXPRESSION, context,
|
|
7232
|
+
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
7183
7233
|
this.deoptimizationInteractions = [];
|
|
7184
7234
|
this.deoptimizations = new PathTracker();
|
|
7185
7235
|
this.deoptimizedFields = new Set();
|
|
@@ -7304,7 +7354,7 @@ class Scope {
|
|
|
7304
7354
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
7305
7355
|
if (existingVariable) {
|
|
7306
7356
|
const existingKind = existingVariable.kind;
|
|
7307
|
-
if (kind ===
|
|
7357
|
+
if (kind === 'var' && existingKind === 'var') {
|
|
7308
7358
|
existingVariable.addDeclaration(identifier, init);
|
|
7309
7359
|
return existingVariable;
|
|
7310
7360
|
}
|
|
@@ -7415,14 +7465,14 @@ class CatchBodyScope extends ChildScope {
|
|
|
7415
7465
|
this.parent = parent;
|
|
7416
7466
|
}
|
|
7417
7467
|
addDeclaration(identifier, context, init, kind) {
|
|
7418
|
-
if (kind ===
|
|
7468
|
+
if (kind === 'var') {
|
|
7419
7469
|
const name = identifier.name;
|
|
7420
7470
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
7421
7471
|
if (existingVariable) {
|
|
7422
7472
|
const existingKind = existingVariable.kind;
|
|
7423
|
-
if (existingKind ===
|
|
7473
|
+
if (existingKind === 'parameter' &&
|
|
7424
7474
|
// If this is a destructured parameter, it is forbidden to redeclare
|
|
7425
|
-
existingVariable.declarations[0].parent.type === CatchClause
|
|
7475
|
+
existingVariable.declarations[0].parent.type === parseAst_js.CatchClause) {
|
|
7426
7476
|
// If this is a var with the same name as the catch scope parameter,
|
|
7427
7477
|
// the assignment actually goes to the parameter and the var is
|
|
7428
7478
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
@@ -7439,7 +7489,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7439
7489
|
this.addHoistedVariable(name, declaredVariable);
|
|
7440
7490
|
return declaredVariable;
|
|
7441
7491
|
}
|
|
7442
|
-
if (existingKind ===
|
|
7492
|
+
if (existingKind === 'var') {
|
|
7443
7493
|
existingVariable.addDeclaration(identifier, init);
|
|
7444
7494
|
return existingVariable;
|
|
7445
7495
|
}
|
|
@@ -7469,10 +7519,8 @@ class FunctionBodyScope extends ChildScope {
|
|
|
7469
7519
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
7470
7520
|
if (existingVariable) {
|
|
7471
7521
|
const existingKind = existingVariable.kind;
|
|
7472
|
-
if ((kind ===
|
|
7473
|
-
(existingKind ===
|
|
7474
|
-
existingKind === "function" /* VariableKind.function */ ||
|
|
7475
|
-
existingKind === "parameter" /* VariableKind.parameter */)) {
|
|
7522
|
+
if ((kind === 'var' || kind === 'function') &&
|
|
7523
|
+
(existingKind === 'var' || existingKind === 'function' || existingKind === 'parameter')) {
|
|
7476
7524
|
existingVariable.addDeclaration(identifier, init);
|
|
7477
7525
|
return existingVariable;
|
|
7478
7526
|
}
|
|
@@ -8691,7 +8739,7 @@ class Identifier extends NodeBase {
|
|
|
8691
8739
|
let variable;
|
|
8692
8740
|
const { treeshake } = this.scope.context.options;
|
|
8693
8741
|
switch (kind) {
|
|
8694
|
-
case
|
|
8742
|
+
case 'var': {
|
|
8695
8743
|
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
8696
8744
|
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
8697
8745
|
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
@@ -8699,18 +8747,18 @@ class Identifier extends NodeBase {
|
|
|
8699
8747
|
}
|
|
8700
8748
|
break;
|
|
8701
8749
|
}
|
|
8702
|
-
case
|
|
8750
|
+
case 'function': {
|
|
8703
8751
|
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
8704
8752
|
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
8705
8753
|
break;
|
|
8706
8754
|
}
|
|
8707
|
-
case
|
|
8708
|
-
case
|
|
8709
|
-
case
|
|
8755
|
+
case 'let':
|
|
8756
|
+
case 'const':
|
|
8757
|
+
case 'class': {
|
|
8710
8758
|
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
8711
8759
|
break;
|
|
8712
8760
|
}
|
|
8713
|
-
case
|
|
8761
|
+
case 'parameter': {
|
|
8714
8762
|
variable = this.scope.addParameterDeclaration(this);
|
|
8715
8763
|
break;
|
|
8716
8764
|
}
|
|
@@ -8743,7 +8791,7 @@ class Identifier extends NodeBase {
|
|
|
8743
8791
|
hasEffects(context) {
|
|
8744
8792
|
if (!this.deoptimized)
|
|
8745
8793
|
this.applyDeoptimizations();
|
|
8746
|
-
if (this.isPossibleTDZ() && this.variable.kind !==
|
|
8794
|
+
if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
|
|
8747
8795
|
return true;
|
|
8748
8796
|
}
|
|
8749
8797
|
return (this.scope.context.options.treeshake
|
|
@@ -8830,7 +8878,7 @@ class Identifier extends NodeBase {
|
|
|
8830
8878
|
}
|
|
8831
8879
|
// In strict mode, any variable named "eval" must be the actual "eval" function
|
|
8832
8880
|
if (name === 'eval' &&
|
|
8833
|
-
renderedParentType === CallExpression
|
|
8881
|
+
renderedParentType === parseAst_js.CallExpression &&
|
|
8834
8882
|
isCalleeOfRenderedParent) {
|
|
8835
8883
|
code.appendRight(this.start, '0, ');
|
|
8836
8884
|
}
|
|
@@ -9018,12 +9066,12 @@ class BlockScope extends ChildScope {
|
|
|
9018
9066
|
super(parent, parent.context);
|
|
9019
9067
|
}
|
|
9020
9068
|
addDeclaration(identifier, context, init, kind) {
|
|
9021
|
-
if (kind ===
|
|
9069
|
+
if (kind === 'var') {
|
|
9022
9070
|
const name = identifier.name;
|
|
9023
9071
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
9024
9072
|
if (existingVariable) {
|
|
9025
|
-
if (existingVariable.kind ===
|
|
9026
|
-
(kind ===
|
|
9073
|
+
if (existingVariable.kind === 'var' ||
|
|
9074
|
+
(kind === 'var' && existingVariable.kind === 'parameter')) {
|
|
9027
9075
|
existingVariable.addDeclaration(identifier, init);
|
|
9028
9076
|
return existingVariable;
|
|
9029
9077
|
}
|
|
@@ -9043,9 +9091,10 @@ class BlockScope extends ChildScope {
|
|
|
9043
9091
|
|
|
9044
9092
|
class ExpressionStatement extends NodeBase {
|
|
9045
9093
|
initialise() {
|
|
9094
|
+
super.initialise();
|
|
9046
9095
|
if (this.directive &&
|
|
9047
9096
|
this.directive !== 'use strict' &&
|
|
9048
|
-
this.parent.type === Program
|
|
9097
|
+
this.parent.type === parseAst_js.Program) {
|
|
9049
9098
|
this.scope.context.log(parseAst_js.LOGLEVEL_WARN,
|
|
9050
9099
|
// This is necessary, because either way (deleting or not) can lead to errors.
|
|
9051
9100
|
parseAst_js.logModuleLevelDirective(this.directive, this.scope.context.module.id), this.start);
|
|
@@ -9062,7 +9111,7 @@ class ExpressionStatement extends NodeBase {
|
|
|
9062
9111
|
}
|
|
9063
9112
|
shouldBeIncluded(context) {
|
|
9064
9113
|
if (this.directive && this.directive !== 'use strict')
|
|
9065
|
-
return this.parent.type !== Program
|
|
9114
|
+
return this.parent.type !== parseAst_js.Program;
|
|
9066
9115
|
return super.shouldBeIncluded(context);
|
|
9067
9116
|
}
|
|
9068
9117
|
applyDeoptimizations() { }
|
|
@@ -9083,7 +9132,7 @@ class BlockStatement extends NodeBase {
|
|
|
9083
9132
|
}
|
|
9084
9133
|
addImplicitReturnExpressionToScope() {
|
|
9085
9134
|
const lastStatement = this.body[this.body.length - 1];
|
|
9086
|
-
if (!lastStatement || lastStatement.type !== ReturnStatement
|
|
9135
|
+
if (!lastStatement || lastStatement.type !== parseAst_js.ReturnStatement) {
|
|
9087
9136
|
this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
|
|
9088
9137
|
}
|
|
9089
9138
|
}
|
|
@@ -9116,6 +9165,7 @@ class BlockStatement extends NodeBase {
|
|
|
9116
9165
|
}
|
|
9117
9166
|
}
|
|
9118
9167
|
initialise() {
|
|
9168
|
+
super.initialise();
|
|
9119
9169
|
const firstBodyStatement = this.body[0];
|
|
9120
9170
|
this.deoptimizeBody =
|
|
9121
9171
|
firstBodyStatement instanceof ExpressionStatement &&
|
|
@@ -9179,6 +9229,12 @@ class FunctionBase extends NodeBase {
|
|
|
9179
9229
|
set deoptimizedReturn(value) {
|
|
9180
9230
|
this.flags = setFlag(this.flags, 512 /* Flag.deoptimizedReturn */, value);
|
|
9181
9231
|
}
|
|
9232
|
+
get generator() {
|
|
9233
|
+
return isFlagSet(this.flags, 4194304 /* Flag.generator */);
|
|
9234
|
+
}
|
|
9235
|
+
set generator(value) {
|
|
9236
|
+
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
9237
|
+
}
|
|
9182
9238
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9183
9239
|
if (interaction.type === INTERACTION_CALLED) {
|
|
9184
9240
|
const { parameters } = this.scope;
|
|
@@ -9275,12 +9331,17 @@ class FunctionBase extends NodeBase {
|
|
|
9275
9331
|
this.scope.includeCallArguments(context, parameters);
|
|
9276
9332
|
}
|
|
9277
9333
|
initialise() {
|
|
9334
|
+
super.initialise();
|
|
9278
9335
|
if (this.body instanceof BlockStatement) {
|
|
9279
9336
|
this.body.addImplicitReturnExpressionToScope();
|
|
9280
9337
|
}
|
|
9281
9338
|
else {
|
|
9282
9339
|
this.scope.addReturnExpression(this.body);
|
|
9283
9340
|
}
|
|
9341
|
+
if (this.annotations &&
|
|
9342
|
+
this.scope.context.options.treeshake.annotations) {
|
|
9343
|
+
this.annotationNoSideEffects = this.annotations.some(comment => comment.type === 'noSideEffects');
|
|
9344
|
+
}
|
|
9284
9345
|
}
|
|
9285
9346
|
parseNode(esTreeNode) {
|
|
9286
9347
|
const { body, params } = esTreeNode;
|
|
@@ -9291,11 +9352,11 @@ class FunctionBase extends NodeBase {
|
|
|
9291
9352
|
// so that the scope already knows all parameters and can detect conflicts
|
|
9292
9353
|
// when parsing the body.
|
|
9293
9354
|
for (const parameter of params) {
|
|
9294
|
-
parameters.push(new (context.getNodeConstructor(parameter.type))(
|
|
9355
|
+
parameters.push(new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter));
|
|
9295
9356
|
}
|
|
9296
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare(
|
|
9297
|
-
this.body = new (context.getNodeConstructor(body.type))(
|
|
9298
|
-
super.parseNode(esTreeNode);
|
|
9357
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
9358
|
+
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
9359
|
+
return super.parseNode(esTreeNode);
|
|
9299
9360
|
}
|
|
9300
9361
|
addArgumentToBeDeoptimized(_argument) { }
|
|
9301
9362
|
applyDeoptimizations() { }
|
|
@@ -9307,6 +9368,12 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
9307
9368
|
super(...arguments);
|
|
9308
9369
|
this.objectEntity = null;
|
|
9309
9370
|
}
|
|
9371
|
+
get expression() {
|
|
9372
|
+
return isFlagSet(this.flags, 8388608 /* Flag.expression */);
|
|
9373
|
+
}
|
|
9374
|
+
set expression(value) {
|
|
9375
|
+
this.flags = setFlag(this.flags, 8388608 /* Flag.expression */, value);
|
|
9376
|
+
}
|
|
9310
9377
|
createScope(parentScope) {
|
|
9311
9378
|
this.scope = new ReturnValueScope(parentScope, false);
|
|
9312
9379
|
}
|
|
@@ -9400,7 +9467,7 @@ function renderSystemExportSequenceBeforeExpression(exportedVariable, expression
|
|
|
9400
9467
|
class ObjectPattern extends NodeBase {
|
|
9401
9468
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
9402
9469
|
for (const property of this.properties) {
|
|
9403
|
-
if (property.type === Property
|
|
9470
|
+
if (property.type === parseAst_js.Property) {
|
|
9404
9471
|
property.value.addExportedVariables(variables, exportNamesByVariable);
|
|
9405
9472
|
}
|
|
9406
9473
|
else {
|
|
@@ -9465,6 +9532,13 @@ class AssignmentExpression extends NodeBase {
|
|
|
9465
9532
|
right.include(context, includeChildrenRecursively);
|
|
9466
9533
|
}
|
|
9467
9534
|
initialise() {
|
|
9535
|
+
super.initialise();
|
|
9536
|
+
if (this.left instanceof Identifier) {
|
|
9537
|
+
const variable = this.scope.variables.get(this.left.name);
|
|
9538
|
+
if (variable?.kind === 'const') {
|
|
9539
|
+
this.scope.context.error(parseAst_js.logConstVariableReassignError(), this.left.start);
|
|
9540
|
+
}
|
|
9541
|
+
}
|
|
9468
9542
|
this.left.setAssignedValue(this.right);
|
|
9469
9543
|
}
|
|
9470
9544
|
render(code, options, { preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
@@ -9493,7 +9567,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
9493
9567
|
renderSystemExportExpression(variable, start, end, code, options);
|
|
9494
9568
|
}
|
|
9495
9569
|
else {
|
|
9496
|
-
renderSystemExportSequenceAfterExpression(variable, start, end, parent.type !== ExpressionStatement
|
|
9570
|
+
renderSystemExportSequenceAfterExpression(variable, start, end, parent.type !== parseAst_js.ExpressionStatement, code, options);
|
|
9497
9571
|
}
|
|
9498
9572
|
return;
|
|
9499
9573
|
}
|
|
@@ -9502,15 +9576,15 @@ class AssignmentExpression extends NodeBase {
|
|
|
9502
9576
|
const systemPatternExports = [];
|
|
9503
9577
|
left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
|
|
9504
9578
|
if (systemPatternExports.length > 0) {
|
|
9505
|
-
renderSystemExportFunction(systemPatternExports, start, end, renderedSurroundingElement === ExpressionStatement
|
|
9579
|
+
renderSystemExportFunction(systemPatternExports, start, end, renderedSurroundingElement === parseAst_js.ExpressionStatement, code, options);
|
|
9506
9580
|
return;
|
|
9507
9581
|
}
|
|
9508
9582
|
}
|
|
9509
9583
|
}
|
|
9510
9584
|
if (left.included &&
|
|
9511
9585
|
left instanceof ObjectPattern &&
|
|
9512
|
-
(renderedSurroundingElement === ExpressionStatement
|
|
9513
|
-
renderedSurroundingElement === ArrowFunctionExpression
|
|
9586
|
+
(renderedSurroundingElement === parseAst_js.ExpressionStatement ||
|
|
9587
|
+
renderedSurroundingElement === parseAst_js.ArrowFunctionExpression)) {
|
|
9514
9588
|
code.appendRight(start, '(');
|
|
9515
9589
|
code.prependLeft(end, ')');
|
|
9516
9590
|
}
|
|
@@ -9553,7 +9627,7 @@ class AssignmentPattern extends NodeBase {
|
|
|
9553
9627
|
|
|
9554
9628
|
class ArgumentsVariable extends LocalVariable {
|
|
9555
9629
|
constructor(context) {
|
|
9556
|
-
super('arguments', null, UNKNOWN_EXPRESSION, context,
|
|
9630
|
+
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
9557
9631
|
this.deoptimizedArguments = [];
|
|
9558
9632
|
}
|
|
9559
9633
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -9676,7 +9750,7 @@ class FunctionNode extends FunctionBase {
|
|
|
9676
9750
|
}
|
|
9677
9751
|
initialise() {
|
|
9678
9752
|
super.initialise();
|
|
9679
|
-
this.id?.declare(
|
|
9753
|
+
this.id?.declare('function', this);
|
|
9680
9754
|
}
|
|
9681
9755
|
addArgumentToBeDeoptimized(argument) {
|
|
9682
9756
|
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
@@ -9873,12 +9947,13 @@ class Literal extends NodeBase {
|
|
|
9873
9947
|
}
|
|
9874
9948
|
}
|
|
9875
9949
|
initialise() {
|
|
9950
|
+
super.initialise();
|
|
9876
9951
|
this.members = getLiteralMembersForValue(this.value);
|
|
9877
9952
|
}
|
|
9878
9953
|
parseNode(esTreeNode) {
|
|
9879
9954
|
this.value = esTreeNode.value;
|
|
9880
9955
|
this.regex = esTreeNode.regex;
|
|
9881
|
-
super.parseNode(esTreeNode);
|
|
9956
|
+
return super.parseNode(esTreeNode);
|
|
9882
9957
|
}
|
|
9883
9958
|
render(code) {
|
|
9884
9959
|
if (typeof this.value === 'string') {
|
|
@@ -10096,6 +10171,7 @@ class MemberExpression extends NodeBase {
|
|
|
10096
10171
|
}
|
|
10097
10172
|
}
|
|
10098
10173
|
initialise() {
|
|
10174
|
+
super.initialise();
|
|
10099
10175
|
this.propertyKey = getResolvablePropertyKey(this);
|
|
10100
10176
|
this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
|
|
10101
10177
|
}
|
|
@@ -10375,6 +10451,13 @@ class CallExpression extends CallExpressionBase {
|
|
|
10375
10451
|
}
|
|
10376
10452
|
this.callee.includeCallArguments(context, this.arguments);
|
|
10377
10453
|
}
|
|
10454
|
+
initialise() {
|
|
10455
|
+
super.initialise();
|
|
10456
|
+
if (this.annotations &&
|
|
10457
|
+
this.scope.context.options.treeshake.annotations) {
|
|
10458
|
+
this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
|
|
10459
|
+
}
|
|
10460
|
+
}
|
|
10378
10461
|
isSkippedAsOptional(origin) {
|
|
10379
10462
|
return (this.callee.isSkippedAsOptional?.(origin) ||
|
|
10380
10463
|
(this.optional &&
|
|
@@ -10409,11 +10492,11 @@ class CatchClause extends NodeBase {
|
|
|
10409
10492
|
const { body, param, type } = esTreeNode;
|
|
10410
10493
|
this.type = type;
|
|
10411
10494
|
if (param) {
|
|
10412
|
-
this.param = new (this.scope.context.getNodeConstructor(param.type))(
|
|
10413
|
-
this.param.declare(
|
|
10495
|
+
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
10496
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
10414
10497
|
}
|
|
10415
|
-
this.body = new BlockStatement(
|
|
10416
|
-
super.parseNode(esTreeNode);
|
|
10498
|
+
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
10499
|
+
return super.parseNode(esTreeNode);
|
|
10417
10500
|
}
|
|
10418
10501
|
}
|
|
10419
10502
|
CatchClause.prototype.preventChildBlockScope = true;
|
|
@@ -10440,7 +10523,7 @@ class ClassBodyScope extends ChildScope {
|
|
|
10440
10523
|
constructor(parent, classNode) {
|
|
10441
10524
|
const { context } = parent;
|
|
10442
10525
|
super(parent, context);
|
|
10443
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context,
|
|
10526
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
10444
10527
|
this.instanceScope = new ChildScope(this, context);
|
|
10445
10528
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
10446
10529
|
}
|
|
@@ -10463,9 +10546,9 @@ class ClassBody extends NodeBase {
|
|
|
10463
10546
|
parseNode(esTreeNode) {
|
|
10464
10547
|
const body = (this.body = []);
|
|
10465
10548
|
for (const definition of esTreeNode.body) {
|
|
10466
|
-
body.push(new (this.scope.context.getNodeConstructor(definition.type))(
|
|
10549
|
+
body.push(new (this.scope.context.getNodeConstructor(definition.type))(this, definition.static ? this.scope : this.scope.instanceScope).parseNode(definition));
|
|
10467
10550
|
}
|
|
10468
|
-
super.parseNode(esTreeNode);
|
|
10551
|
+
return super.parseNode(esTreeNode);
|
|
10469
10552
|
}
|
|
10470
10553
|
applyDeoptimizations() { }
|
|
10471
10554
|
}
|
|
@@ -10624,7 +10707,8 @@ class ClassNode extends NodeBase {
|
|
|
10624
10707
|
}
|
|
10625
10708
|
}
|
|
10626
10709
|
initialise() {
|
|
10627
|
-
|
|
10710
|
+
super.initialise();
|
|
10711
|
+
this.id?.declare('class', this);
|
|
10628
10712
|
for (const method of this.body.body) {
|
|
10629
10713
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
10630
10714
|
this.classConstructor = method;
|
|
@@ -10694,9 +10778,9 @@ class ClassDeclaration extends ClassNode {
|
|
|
10694
10778
|
}
|
|
10695
10779
|
parseNode(esTreeNode) {
|
|
10696
10780
|
if (esTreeNode.id !== null) {
|
|
10697
|
-
this.id = new Identifier(
|
|
10781
|
+
this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
|
|
10698
10782
|
}
|
|
10699
|
-
super.parseNode(esTreeNode);
|
|
10783
|
+
return super.parseNode(esTreeNode);
|
|
10700
10784
|
}
|
|
10701
10785
|
render(code, options) {
|
|
10702
10786
|
const { exportNamesByVariable, format, snippets: { _, getPropertyAccess } } = options;
|
|
@@ -10736,7 +10820,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
10736
10820
|
class ClassExpression extends ClassNode {
|
|
10737
10821
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
10738
10822
|
super.render(code, options);
|
|
10739
|
-
if (renderedSurroundingElement === ExpressionStatement
|
|
10823
|
+
if (renderedSurroundingElement === parseAst_js.ExpressionStatement) {
|
|
10740
10824
|
code.appendRight(this.start, '(');
|
|
10741
10825
|
code.prependLeft(this.end, ')');
|
|
10742
10826
|
}
|
|
@@ -10936,6 +11020,12 @@ class ContinueStatement extends NodeBase {
|
|
|
10936
11020
|
}
|
|
10937
11021
|
}
|
|
10938
11022
|
|
|
11023
|
+
class DebuggerStatement extends NodeBase {
|
|
11024
|
+
hasEffects() {
|
|
11025
|
+
return true;
|
|
11026
|
+
}
|
|
11027
|
+
}
|
|
11028
|
+
|
|
10939
11029
|
function hasLoopBodyEffects(context, body) {
|
|
10940
11030
|
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
10941
11031
|
const { breaks, continues } = ignore;
|
|
@@ -10986,6 +11076,7 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
10986
11076
|
return false;
|
|
10987
11077
|
}
|
|
10988
11078
|
initialise() {
|
|
11079
|
+
super.initialise();
|
|
10989
11080
|
this.scope.context.addExport(this);
|
|
10990
11081
|
}
|
|
10991
11082
|
render(code, _options, nodeRenderOptions) {
|
|
@@ -11004,9 +11095,9 @@ class FunctionDeclaration extends FunctionNode {
|
|
|
11004
11095
|
}
|
|
11005
11096
|
parseNode(esTreeNode) {
|
|
11006
11097
|
if (esTreeNode.id !== null) {
|
|
11007
|
-
this.id = new Identifier(
|
|
11098
|
+
this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
|
|
11008
11099
|
}
|
|
11009
|
-
super.parseNode(esTreeNode);
|
|
11100
|
+
return super.parseNode(esTreeNode);
|
|
11010
11101
|
}
|
|
11011
11102
|
}
|
|
11012
11103
|
|
|
@@ -11031,6 +11122,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
11031
11122
|
}
|
|
11032
11123
|
}
|
|
11033
11124
|
initialise() {
|
|
11125
|
+
super.initialise();
|
|
11034
11126
|
const declaration = this.declaration;
|
|
11035
11127
|
this.declarationName =
|
|
11036
11128
|
(declaration.id && declaration.id.name) || this.declaration.name;
|
|
@@ -11064,7 +11156,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
11064
11156
|
else {
|
|
11065
11157
|
code.remove(this.start, declarationStart);
|
|
11066
11158
|
this.declaration.render(code, options, {
|
|
11067
|
-
renderedSurroundingElement: ExpressionStatement
|
|
11159
|
+
renderedSurroundingElement: parseAst_js.ExpressionStatement
|
|
11068
11160
|
});
|
|
11069
11161
|
if (code.original[this.end - 1] !== ';') {
|
|
11070
11162
|
code.appendLeft(this.end, ';');
|
|
@@ -11114,6 +11206,7 @@ class ExportNamedDeclaration extends NodeBase {
|
|
|
11114
11206
|
return !!this.declaration?.hasEffects(context);
|
|
11115
11207
|
}
|
|
11116
11208
|
initialise() {
|
|
11209
|
+
super.initialise();
|
|
11117
11210
|
this.scope.context.addExport(this);
|
|
11118
11211
|
}
|
|
11119
11212
|
removeAnnotations(code) {
|
|
@@ -11159,6 +11252,7 @@ class ForInStatement extends NodeBase {
|
|
|
11159
11252
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
11160
11253
|
}
|
|
11161
11254
|
initialise() {
|
|
11255
|
+
super.initialise();
|
|
11162
11256
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
11163
11257
|
}
|
|
11164
11258
|
render(code, options) {
|
|
@@ -11203,6 +11297,7 @@ class ForOfStatement extends NodeBase {
|
|
|
11203
11297
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
11204
11298
|
}
|
|
11205
11299
|
initialise() {
|
|
11300
|
+
super.initialise();
|
|
11206
11301
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
11207
11302
|
}
|
|
11208
11303
|
render(code, options) {
|
|
@@ -11255,13 +11350,13 @@ class FunctionExpression extends FunctionNode {
|
|
|
11255
11350
|
}
|
|
11256
11351
|
parseNode(esTreeNode) {
|
|
11257
11352
|
if (esTreeNode.id !== null) {
|
|
11258
|
-
this.id = new Identifier(
|
|
11353
|
+
this.id = new Identifier(this, this.idScope).parseNode(esTreeNode.id);
|
|
11259
11354
|
}
|
|
11260
|
-
super.parseNode(esTreeNode);
|
|
11355
|
+
return super.parseNode(esTreeNode);
|
|
11261
11356
|
}
|
|
11262
11357
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
11263
11358
|
super.render(code, options);
|
|
11264
|
-
if (renderedSurroundingElement === ExpressionStatement
|
|
11359
|
+
if (renderedSurroundingElement === parseAst_js.ExpressionStatement) {
|
|
11265
11360
|
code.appendRight(this.start, '(');
|
|
11266
11361
|
code.prependLeft(this.end, ')');
|
|
11267
11362
|
}
|
|
@@ -11324,13 +11419,11 @@ class IfStatement extends NodeBase {
|
|
|
11324
11419
|
}
|
|
11325
11420
|
}
|
|
11326
11421
|
parseNode(esTreeNode) {
|
|
11327
|
-
this.consequentScope = new TrackingScope(this.scope);
|
|
11328
|
-
this.consequent = new (this.scope.context.getNodeConstructor(esTreeNode.consequent.type))(esTreeNode.consequent, this, this.consequentScope);
|
|
11422
|
+
this.consequent = new (this.scope.context.getNodeConstructor(esTreeNode.consequent.type))(this, (this.consequentScope = new TrackingScope(this.scope))).parseNode(esTreeNode.consequent);
|
|
11329
11423
|
if (esTreeNode.alternate) {
|
|
11330
|
-
this.alternateScope = new TrackingScope(this.scope);
|
|
11331
|
-
this.alternate = new (this.scope.context.getNodeConstructor(esTreeNode.alternate.type))(esTreeNode.alternate, this, this.alternateScope);
|
|
11424
|
+
this.alternate = new (this.scope.context.getNodeConstructor(esTreeNode.alternate.type))(this, (this.alternateScope = new TrackingScope(this.scope))).parseNode(esTreeNode.alternate);
|
|
11332
11425
|
}
|
|
11333
|
-
super.parseNode(esTreeNode);
|
|
11426
|
+
return super.parseNode(esTreeNode);
|
|
11334
11427
|
}
|
|
11335
11428
|
render(code, options) {
|
|
11336
11429
|
const { snippets: { getPropertyAccess } } = options;
|
|
@@ -11424,7 +11517,7 @@ class IfStatement extends NodeBase {
|
|
|
11424
11517
|
.join(', ');
|
|
11425
11518
|
if (hoistedVariables) {
|
|
11426
11519
|
const parentType = this.parent.type;
|
|
11427
|
-
const needsBraces = parentType !== Program
|
|
11520
|
+
const needsBraces = parentType !== parseAst_js.Program && parentType !== parseAst_js.BlockStatement;
|
|
11428
11521
|
code.prependRight(this.start, `${needsBraces ? '{ ' : ''}var ${hoistedVariables}; `);
|
|
11429
11522
|
if (needsBraces) {
|
|
11430
11523
|
code.appendLeft(this.end, ` }`);
|
|
@@ -11456,6 +11549,7 @@ class ImportDeclaration extends NodeBase {
|
|
|
11456
11549
|
return false;
|
|
11457
11550
|
}
|
|
11458
11551
|
initialise() {
|
|
11552
|
+
super.initialise();
|
|
11459
11553
|
this.scope.context.addImport(this);
|
|
11460
11554
|
}
|
|
11461
11555
|
render(code, _options, nodeRenderOptions) {
|
|
@@ -11726,7 +11820,7 @@ class VariableDeclarator extends NodeBase {
|
|
|
11726
11820
|
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
11727
11821
|
}
|
|
11728
11822
|
}
|
|
11729
|
-
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement
|
|
11823
|
+
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: parseAst_js.ExpressionStatement });
|
|
11730
11824
|
}
|
|
11731
11825
|
else if (id instanceof Identifier &&
|
|
11732
11826
|
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
@@ -11846,11 +11940,12 @@ class ImportExpression extends NodeBase {
|
|
|
11846
11940
|
this.source.include(context, includeChildrenRecursively);
|
|
11847
11941
|
}
|
|
11848
11942
|
initialise() {
|
|
11943
|
+
super.initialise();
|
|
11849
11944
|
this.scope.context.addDynamicImport(this);
|
|
11850
11945
|
}
|
|
11851
11946
|
parseNode(esTreeNode) {
|
|
11852
|
-
|
|
11853
|
-
super.parseNode(esTreeNode
|
|
11947
|
+
this.sourceAstNode = esTreeNode.source;
|
|
11948
|
+
return super.parseNode(esTreeNode);
|
|
11854
11949
|
}
|
|
11855
11950
|
render(code, options) {
|
|
11856
11951
|
const { snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess } } = options;
|
|
@@ -12383,11 +12478,16 @@ class NewExpression extends NodeBase {
|
|
|
12383
12478
|
this.callee.includeCallArguments(context, this.arguments);
|
|
12384
12479
|
}
|
|
12385
12480
|
initialise() {
|
|
12481
|
+
super.initialise();
|
|
12386
12482
|
this.interaction = {
|
|
12387
12483
|
args: [null, ...this.arguments],
|
|
12388
12484
|
type: INTERACTION_CALLED,
|
|
12389
12485
|
withNew: true
|
|
12390
12486
|
};
|
|
12487
|
+
if (this.annotations &&
|
|
12488
|
+
this.scope.context.options.treeshake.annotations) {
|
|
12489
|
+
this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
|
|
12490
|
+
}
|
|
12391
12491
|
}
|
|
12392
12492
|
render(code, options) {
|
|
12393
12493
|
this.callee.render(code, options);
|
|
@@ -12425,8 +12525,8 @@ class ObjectExpression extends NodeBase {
|
|
|
12425
12525
|
}
|
|
12426
12526
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
12427
12527
|
super.render(code, options);
|
|
12428
|
-
if (renderedSurroundingElement === ExpressionStatement
|
|
12429
|
-
renderedSurroundingElement === ArrowFunctionExpression
|
|
12528
|
+
if (renderedSurroundingElement === parseAst_js.ExpressionStatement ||
|
|
12529
|
+
renderedSurroundingElement === parseAst_js.ArrowFunctionExpression) {
|
|
12430
12530
|
code.appendRight(this.start, '(');
|
|
12431
12531
|
code.prependLeft(this.end, ')');
|
|
12432
12532
|
}
|
|
@@ -12473,6 +12573,29 @@ class ObjectExpression extends NodeBase {
|
|
|
12473
12573
|
}
|
|
12474
12574
|
}
|
|
12475
12575
|
|
|
12576
|
+
class PanicError extends NodeBase {
|
|
12577
|
+
initialise() {
|
|
12578
|
+
const id = this.scope.context.module.id;
|
|
12579
|
+
// This simulates the current nested error structure. We could also just
|
|
12580
|
+
// replace it with a flat error.
|
|
12581
|
+
const parseError = parseAst_js.getRollupEror(parseAst_js.logParseError(this.message));
|
|
12582
|
+
const moduleParseError = parseAst_js.logModuleParseError(parseError, id);
|
|
12583
|
+
return parseAst_js.error(moduleParseError);
|
|
12584
|
+
}
|
|
12585
|
+
}
|
|
12586
|
+
|
|
12587
|
+
class ParseError extends NodeBase {
|
|
12588
|
+
initialise() {
|
|
12589
|
+
const pos = this.start;
|
|
12590
|
+
const id = this.scope.context.module.id;
|
|
12591
|
+
// This simulates the current nested error structure. We could also just
|
|
12592
|
+
// replace it with a flat error.
|
|
12593
|
+
const parseError = parseAst_js.getRollupEror(parseAst_js.logParseError(this.message, pos));
|
|
12594
|
+
const moduleParseError = parseAst_js.logModuleParseError(parseError, id);
|
|
12595
|
+
this.scope.context.error(moduleParseError, pos);
|
|
12596
|
+
}
|
|
12597
|
+
}
|
|
12598
|
+
|
|
12476
12599
|
class PrivateIdentifier extends NodeBase {
|
|
12477
12600
|
}
|
|
12478
12601
|
|
|
@@ -12511,6 +12634,16 @@ class Program extends NodeBase {
|
|
|
12511
12634
|
}
|
|
12512
12635
|
}
|
|
12513
12636
|
}
|
|
12637
|
+
initialise() {
|
|
12638
|
+
super.initialise();
|
|
12639
|
+
if (this.invalidAnnotations)
|
|
12640
|
+
for (const { start, end, type } of this.invalidAnnotations) {
|
|
12641
|
+
this.scope.context.magicString.remove(start, end);
|
|
12642
|
+
if (type === 'pure' || type === 'noSideEffects') {
|
|
12643
|
+
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);
|
|
12644
|
+
}
|
|
12645
|
+
}
|
|
12646
|
+
}
|
|
12514
12647
|
render(code, options) {
|
|
12515
12648
|
let start = this.start;
|
|
12516
12649
|
if (code.original.startsWith('#!')) {
|
|
@@ -12629,6 +12762,7 @@ class ReturnStatement extends NodeBase {
|
|
|
12629
12762
|
context.brokenFlow = true;
|
|
12630
12763
|
}
|
|
12631
12764
|
initialise() {
|
|
12765
|
+
super.initialise();
|
|
12632
12766
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
12633
12767
|
}
|
|
12634
12768
|
render(code, options) {
|
|
@@ -12850,6 +12984,7 @@ class SwitchStatement extends NodeBase {
|
|
|
12850
12984
|
context.hasBreak = hasBreak;
|
|
12851
12985
|
}
|
|
12852
12986
|
initialise() {
|
|
12987
|
+
super.initialise();
|
|
12853
12988
|
for (let caseIndex = 0; caseIndex < this.cases.length; caseIndex++) {
|
|
12854
12989
|
if (this.cases[caseIndex].test === null) {
|
|
12855
12990
|
this.defaultCase = caseIndex;
|
|
@@ -12859,8 +12994,8 @@ class SwitchStatement extends NodeBase {
|
|
|
12859
12994
|
this.defaultCase = null;
|
|
12860
12995
|
}
|
|
12861
12996
|
parseNode(esTreeNode) {
|
|
12862
|
-
this.discriminant = new (this.scope.context.getNodeConstructor(esTreeNode.discriminant.type))(
|
|
12863
|
-
super.parseNode(esTreeNode);
|
|
12997
|
+
this.discriminant = new (this.scope.context.getNodeConstructor(esTreeNode.discriminant.type))(this, this.parentScope).parseNode(esTreeNode.discriminant);
|
|
12998
|
+
return super.parseNode(esTreeNode);
|
|
12864
12999
|
}
|
|
12865
13000
|
render(code, options) {
|
|
12866
13001
|
this.discriminant.render(code, options);
|
|
@@ -12873,7 +13008,7 @@ class SwitchStatement extends NodeBase {
|
|
|
12873
13008
|
class TaggedTemplateExpression extends CallExpressionBase {
|
|
12874
13009
|
bind() {
|
|
12875
13010
|
super.bind();
|
|
12876
|
-
if (this.tag.type === Identifier
|
|
13011
|
+
if (this.tag.type === parseAst_js.Identifier) {
|
|
12877
13012
|
const name = this.tag.name;
|
|
12878
13013
|
const variable = this.scope.findVariable(name);
|
|
12879
13014
|
if (variable.isNamespace) {
|
|
@@ -12913,6 +13048,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
12913
13048
|
}
|
|
12914
13049
|
}
|
|
12915
13050
|
initialise() {
|
|
13051
|
+
super.initialise();
|
|
12916
13052
|
this.args = [UNKNOWN_EXPRESSION, ...this.quasi.expressions];
|
|
12917
13053
|
this.interaction = {
|
|
12918
13054
|
args: [
|
|
@@ -12958,7 +13094,7 @@ class TemplateElement extends NodeBase {
|
|
|
12958
13094
|
}
|
|
12959
13095
|
parseNode(esTreeNode) {
|
|
12960
13096
|
this.value = esTreeNode.value;
|
|
12961
|
-
super.parseNode(esTreeNode);
|
|
13097
|
+
return super.parseNode(esTreeNode);
|
|
12962
13098
|
}
|
|
12963
13099
|
render() { }
|
|
12964
13100
|
}
|
|
@@ -13003,7 +13139,7 @@ class UndefinedVariable extends Variable {
|
|
|
13003
13139
|
|
|
13004
13140
|
class ExportDefaultVariable extends LocalVariable {
|
|
13005
13141
|
constructor(name, exportDefaultDeclaration, context) {
|
|
13006
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context,
|
|
13142
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
13007
13143
|
this.hasId = false;
|
|
13008
13144
|
this.originalId = null;
|
|
13009
13145
|
this.originalVariable = null;
|
|
@@ -13074,7 +13210,7 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
13074
13210
|
class ModuleScope extends ChildScope {
|
|
13075
13211
|
constructor(parent, context) {
|
|
13076
13212
|
super(parent, context);
|
|
13077
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context,
|
|
13213
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
13078
13214
|
}
|
|
13079
13215
|
addDeclaration(identifier, context, init, kind) {
|
|
13080
13216
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
@@ -13132,6 +13268,7 @@ class ThisExpression extends NodeBase {
|
|
|
13132
13268
|
}
|
|
13133
13269
|
}
|
|
13134
13270
|
initialise() {
|
|
13271
|
+
super.initialise();
|
|
13135
13272
|
this.alias =
|
|
13136
13273
|
this.scope.findLexicalBoundary() instanceof ModuleScope
|
|
13137
13274
|
? this.scope.context.moduleContext
|
|
@@ -13248,15 +13385,6 @@ class UnaryExpression extends NodeBase {
|
|
|
13248
13385
|
}
|
|
13249
13386
|
}
|
|
13250
13387
|
|
|
13251
|
-
class UnknownNode extends NodeBase {
|
|
13252
|
-
hasEffects() {
|
|
13253
|
-
return true;
|
|
13254
|
-
}
|
|
13255
|
-
include(context) {
|
|
13256
|
-
super.include(context, true);
|
|
13257
|
-
}
|
|
13258
|
-
}
|
|
13259
|
-
|
|
13260
13388
|
class UpdateExpression extends NodeBase {
|
|
13261
13389
|
hasEffects(context) {
|
|
13262
13390
|
if (!this.deoptimized)
|
|
@@ -13273,6 +13401,7 @@ class UpdateExpression extends NodeBase {
|
|
|
13273
13401
|
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
13274
13402
|
}
|
|
13275
13403
|
initialise() {
|
|
13404
|
+
super.initialise();
|
|
13276
13405
|
this.argument.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
13277
13406
|
}
|
|
13278
13407
|
render(code, options) {
|
|
@@ -13287,12 +13416,12 @@ class UpdateExpression extends NodeBase {
|
|
|
13287
13416
|
renderSystemExportExpression(variable, this.start, this.end, code, options);
|
|
13288
13417
|
}
|
|
13289
13418
|
else {
|
|
13290
|
-
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement
|
|
13419
|
+
renderSystemExportSequenceAfterExpression(variable, this.start, this.end, this.parent.type !== parseAst_js.ExpressionStatement, code, options);
|
|
13291
13420
|
}
|
|
13292
13421
|
}
|
|
13293
13422
|
else {
|
|
13294
13423
|
const operator = this.operator[0];
|
|
13295
|
-
renderSystemExportSequenceBeforeExpression(variable, this.start, this.end, this.parent.type !== ExpressionStatement
|
|
13424
|
+
renderSystemExportSequenceBeforeExpression(variable, this.start, this.end, this.parent.type !== parseAst_js.ExpressionStatement, code, options, `${_}${operator}${_}1`);
|
|
13296
13425
|
}
|
|
13297
13426
|
}
|
|
13298
13427
|
}
|
|
@@ -13312,7 +13441,7 @@ function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVar
|
|
|
13312
13441
|
for (const declarator of declarations) {
|
|
13313
13442
|
if (!declarator.id.included)
|
|
13314
13443
|
return false;
|
|
13315
|
-
if (declarator.id.type === Identifier
|
|
13444
|
+
if (declarator.id.type === parseAst_js.Identifier) {
|
|
13316
13445
|
if (exportNamesByVariable.has(declarator.id.variable))
|
|
13317
13446
|
return false;
|
|
13318
13447
|
}
|
|
@@ -13352,6 +13481,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
13352
13481
|
}
|
|
13353
13482
|
}
|
|
13354
13483
|
initialise() {
|
|
13484
|
+
super.initialise();
|
|
13355
13485
|
for (const declarator of this.declarations) {
|
|
13356
13486
|
declarator.declareDeclarator(this.kind);
|
|
13357
13487
|
}
|
|
@@ -13517,6 +13647,711 @@ class YieldExpression extends NodeBase {
|
|
|
13517
13647
|
}
|
|
13518
13648
|
}
|
|
13519
13649
|
|
|
13650
|
+
// This file is generated by scripts/generate-ast-converters.js.
|
|
13651
|
+
// Do not edit this file directly.
|
|
13652
|
+
function convertProgram(buffer, parent, parentScope) {
|
|
13653
|
+
return convertNode(parent, parentScope, 0, new Uint32Array(buffer.buffer), parseAst_js.getReadStringFunction(buffer));
|
|
13654
|
+
}
|
|
13655
|
+
const nodeTypeStrings = [
|
|
13656
|
+
'PanicError',
|
|
13657
|
+
'ParseError',
|
|
13658
|
+
'ArrayExpression',
|
|
13659
|
+
'ArrayPattern',
|
|
13660
|
+
'ArrowFunctionExpression',
|
|
13661
|
+
'AssignmentExpression',
|
|
13662
|
+
'AssignmentPattern',
|
|
13663
|
+
'AwaitExpression',
|
|
13664
|
+
'BinaryExpression',
|
|
13665
|
+
'BlockStatement',
|
|
13666
|
+
'BreakStatement',
|
|
13667
|
+
'CallExpression',
|
|
13668
|
+
'CatchClause',
|
|
13669
|
+
'ChainExpression',
|
|
13670
|
+
'ClassBody',
|
|
13671
|
+
'ClassDeclaration',
|
|
13672
|
+
'ClassExpression',
|
|
13673
|
+
'ConditionalExpression',
|
|
13674
|
+
'ContinueStatement',
|
|
13675
|
+
'DebuggerStatement',
|
|
13676
|
+
'ExpressionStatement',
|
|
13677
|
+
'DoWhileStatement',
|
|
13678
|
+
'EmptyStatement',
|
|
13679
|
+
'ExportAllDeclaration',
|
|
13680
|
+
'ExportDefaultDeclaration',
|
|
13681
|
+
'ExportNamedDeclaration',
|
|
13682
|
+
'ExportSpecifier',
|
|
13683
|
+
'ExpressionStatement',
|
|
13684
|
+
'ForInStatement',
|
|
13685
|
+
'ForOfStatement',
|
|
13686
|
+
'ForStatement',
|
|
13687
|
+
'FunctionDeclaration',
|
|
13688
|
+
'FunctionExpression',
|
|
13689
|
+
'Identifier',
|
|
13690
|
+
'IfStatement',
|
|
13691
|
+
'ImportAttribute',
|
|
13692
|
+
'ImportDeclaration',
|
|
13693
|
+
'ImportDefaultSpecifier',
|
|
13694
|
+
'ImportExpression',
|
|
13695
|
+
'ImportNamespaceSpecifier',
|
|
13696
|
+
'ImportSpecifier',
|
|
13697
|
+
'LabeledStatement',
|
|
13698
|
+
'Literal',
|
|
13699
|
+
'Literal',
|
|
13700
|
+
'Literal',
|
|
13701
|
+
'Literal',
|
|
13702
|
+
'Literal',
|
|
13703
|
+
'Literal',
|
|
13704
|
+
'LogicalExpression',
|
|
13705
|
+
'MemberExpression',
|
|
13706
|
+
'MetaProperty',
|
|
13707
|
+
'MethodDefinition',
|
|
13708
|
+
'NewExpression',
|
|
13709
|
+
'ObjectExpression',
|
|
13710
|
+
'ObjectPattern',
|
|
13711
|
+
'PrivateIdentifier',
|
|
13712
|
+
'Program',
|
|
13713
|
+
'Property',
|
|
13714
|
+
'PropertyDefinition',
|
|
13715
|
+
'RestElement',
|
|
13716
|
+
'ReturnStatement',
|
|
13717
|
+
'SequenceExpression',
|
|
13718
|
+
'SpreadElement',
|
|
13719
|
+
'StaticBlock',
|
|
13720
|
+
'Super',
|
|
13721
|
+
'SwitchCase',
|
|
13722
|
+
'SwitchStatement',
|
|
13723
|
+
'TaggedTemplateExpression',
|
|
13724
|
+
'TemplateElement',
|
|
13725
|
+
'TemplateLiteral',
|
|
13726
|
+
'ThisExpression',
|
|
13727
|
+
'ThrowStatement',
|
|
13728
|
+
'TryStatement',
|
|
13729
|
+
'UnaryExpression',
|
|
13730
|
+
'UpdateExpression',
|
|
13731
|
+
'VariableDeclaration',
|
|
13732
|
+
'VariableDeclarator',
|
|
13733
|
+
'WhileStatement',
|
|
13734
|
+
'YieldExpression'
|
|
13735
|
+
];
|
|
13736
|
+
const nodeConstructors$1 = [
|
|
13737
|
+
PanicError,
|
|
13738
|
+
ParseError,
|
|
13739
|
+
ArrayExpression,
|
|
13740
|
+
ArrayPattern,
|
|
13741
|
+
ArrowFunctionExpression,
|
|
13742
|
+
AssignmentExpression,
|
|
13743
|
+
AssignmentPattern,
|
|
13744
|
+
AwaitExpression,
|
|
13745
|
+
BinaryExpression,
|
|
13746
|
+
BlockStatement,
|
|
13747
|
+
BreakStatement,
|
|
13748
|
+
CallExpression,
|
|
13749
|
+
CatchClause,
|
|
13750
|
+
ChainExpression,
|
|
13751
|
+
ClassBody,
|
|
13752
|
+
ClassDeclaration,
|
|
13753
|
+
ClassExpression,
|
|
13754
|
+
ConditionalExpression,
|
|
13755
|
+
ContinueStatement,
|
|
13756
|
+
DebuggerStatement,
|
|
13757
|
+
ExpressionStatement,
|
|
13758
|
+
DoWhileStatement,
|
|
13759
|
+
EmptyStatement,
|
|
13760
|
+
ExportAllDeclaration,
|
|
13761
|
+
ExportDefaultDeclaration,
|
|
13762
|
+
ExportNamedDeclaration,
|
|
13763
|
+
ExportSpecifier,
|
|
13764
|
+
ExpressionStatement,
|
|
13765
|
+
ForInStatement,
|
|
13766
|
+
ForOfStatement,
|
|
13767
|
+
ForStatement,
|
|
13768
|
+
FunctionDeclaration,
|
|
13769
|
+
FunctionExpression,
|
|
13770
|
+
Identifier,
|
|
13771
|
+
IfStatement,
|
|
13772
|
+
ImportAttribute,
|
|
13773
|
+
ImportDeclaration,
|
|
13774
|
+
ImportDefaultSpecifier,
|
|
13775
|
+
ImportExpression,
|
|
13776
|
+
ImportNamespaceSpecifier,
|
|
13777
|
+
ImportSpecifier,
|
|
13778
|
+
LabeledStatement,
|
|
13779
|
+
Literal,
|
|
13780
|
+
Literal,
|
|
13781
|
+
Literal,
|
|
13782
|
+
Literal,
|
|
13783
|
+
Literal,
|
|
13784
|
+
Literal,
|
|
13785
|
+
LogicalExpression,
|
|
13786
|
+
MemberExpression,
|
|
13787
|
+
MetaProperty,
|
|
13788
|
+
MethodDefinition,
|
|
13789
|
+
NewExpression,
|
|
13790
|
+
ObjectExpression,
|
|
13791
|
+
ObjectPattern,
|
|
13792
|
+
PrivateIdentifier,
|
|
13793
|
+
Program,
|
|
13794
|
+
Property,
|
|
13795
|
+
PropertyDefinition,
|
|
13796
|
+
RestElement,
|
|
13797
|
+
ReturnStatement,
|
|
13798
|
+
SequenceExpression,
|
|
13799
|
+
SpreadElement,
|
|
13800
|
+
StaticBlock,
|
|
13801
|
+
Super,
|
|
13802
|
+
SwitchCase,
|
|
13803
|
+
SwitchStatement,
|
|
13804
|
+
TaggedTemplateExpression,
|
|
13805
|
+
TemplateElement,
|
|
13806
|
+
TemplateLiteral,
|
|
13807
|
+
ThisExpression,
|
|
13808
|
+
ThrowStatement,
|
|
13809
|
+
TryStatement,
|
|
13810
|
+
UnaryExpression,
|
|
13811
|
+
UpdateExpression,
|
|
13812
|
+
VariableDeclaration,
|
|
13813
|
+
VariableDeclarator,
|
|
13814
|
+
WhileStatement,
|
|
13815
|
+
YieldExpression
|
|
13816
|
+
];
|
|
13817
|
+
const bufferParsers = [
|
|
13818
|
+
function panicError(node, position, buffer, readString) {
|
|
13819
|
+
node.message = parseAst_js.convertString(position, buffer, readString);
|
|
13820
|
+
},
|
|
13821
|
+
function parseError(node, position, buffer, readString) {
|
|
13822
|
+
node.message = parseAst_js.convertString(position, buffer, readString);
|
|
13823
|
+
},
|
|
13824
|
+
function arrayExpression(node, position, buffer, readString) {
|
|
13825
|
+
const { scope } = node;
|
|
13826
|
+
node.elements = convertNodeList(node, scope, position, buffer, readString);
|
|
13827
|
+
},
|
|
13828
|
+
function arrayPattern(node, position, buffer, readString) {
|
|
13829
|
+
const { scope } = node;
|
|
13830
|
+
node.elements = convertNodeList(node, scope, position, buffer, readString);
|
|
13831
|
+
},
|
|
13832
|
+
function arrowFunctionExpression(node, position, buffer, readString) {
|
|
13833
|
+
const { scope } = node;
|
|
13834
|
+
const flags = buffer[position];
|
|
13835
|
+
node.async = (flags & 1) === 1;
|
|
13836
|
+
node.expression = (flags & 2) === 2;
|
|
13837
|
+
node.generator = (flags & 4) === 4;
|
|
13838
|
+
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 1], buffer, readString));
|
|
13839
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
13840
|
+
node.body = convertNode(node, scope.bodyScope, buffer[position + 2], buffer, readString);
|
|
13841
|
+
const annotations = (node.annotations = parseAst_js.convertAnnotations(position + 3, buffer));
|
|
13842
|
+
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
13843
|
+
},
|
|
13844
|
+
function assignmentExpression(node, position, buffer, readString) {
|
|
13845
|
+
const { scope } = node;
|
|
13846
|
+
node.operator = parseAst_js.FIXED_STRINGS[buffer[position]];
|
|
13847
|
+
node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
13848
|
+
node.left = convertNode(node, scope, position + 2, buffer, readString);
|
|
13849
|
+
},
|
|
13850
|
+
function assignmentPattern(node, position, buffer, readString) {
|
|
13851
|
+
const { scope } = node;
|
|
13852
|
+
node.right = convertNode(node, scope, buffer[position], buffer, readString);
|
|
13853
|
+
node.left = convertNode(node, scope, position + 1, buffer, readString);
|
|
13854
|
+
},
|
|
13855
|
+
function awaitExpression(node, position, buffer, readString) {
|
|
13856
|
+
const { scope } = node;
|
|
13857
|
+
node.argument = convertNode(node, scope, position, buffer, readString);
|
|
13858
|
+
},
|
|
13859
|
+
function binaryExpression(node, position, buffer, readString) {
|
|
13860
|
+
const { scope } = node;
|
|
13861
|
+
node.operator = parseAst_js.FIXED_STRINGS[buffer[position]];
|
|
13862
|
+
node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
13863
|
+
node.left = convertNode(node, scope, position + 2, buffer, readString);
|
|
13864
|
+
},
|
|
13865
|
+
function blockStatement(node, position, buffer, readString) {
|
|
13866
|
+
const { scope } = node;
|
|
13867
|
+
node.body = convertNodeList(node, scope, position, buffer, readString);
|
|
13868
|
+
},
|
|
13869
|
+
function breakStatement(node, position, buffer, readString) {
|
|
13870
|
+
const { scope } = node;
|
|
13871
|
+
const labelPosition = buffer[position];
|
|
13872
|
+
node.label =
|
|
13873
|
+
labelPosition === 0 ? null : convertNode(node, scope, labelPosition, buffer, readString);
|
|
13874
|
+
},
|
|
13875
|
+
function callExpression(node, position, buffer, readString) {
|
|
13876
|
+
const { scope } = node;
|
|
13877
|
+
const flags = buffer[position];
|
|
13878
|
+
node.optional = (flags & 1) === 1;
|
|
13879
|
+
node.callee = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
13880
|
+
node.arguments = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
|
|
13881
|
+
node.annotations = parseAst_js.convertAnnotations(position + 3, buffer);
|
|
13882
|
+
},
|
|
13883
|
+
function catchClause(node, position, buffer, readString) {
|
|
13884
|
+
const { scope } = node;
|
|
13885
|
+
const parameterPosition = buffer[position];
|
|
13886
|
+
const parameter = (node.param =
|
|
13887
|
+
parameterPosition === 0
|
|
13888
|
+
? null
|
|
13889
|
+
: convertNode(node, scope, parameterPosition, buffer, readString));
|
|
13890
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
13891
|
+
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer, readString);
|
|
13892
|
+
},
|
|
13893
|
+
function chainExpression(node, position, buffer, readString) {
|
|
13894
|
+
const { scope } = node;
|
|
13895
|
+
node.expression = convertNode(node, scope, position, buffer, readString);
|
|
13896
|
+
},
|
|
13897
|
+
function classBody(node, position, buffer, readString) {
|
|
13898
|
+
const { scope } = node;
|
|
13899
|
+
const length = buffer[position];
|
|
13900
|
+
const body = (node.body = []);
|
|
13901
|
+
for (let index = 0; index < length; index++) {
|
|
13902
|
+
const nodePosition = buffer[position + 1 + index];
|
|
13903
|
+
body.push(convertNode(node, (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, nodePosition, buffer, readString));
|
|
13904
|
+
}
|
|
13905
|
+
},
|
|
13906
|
+
function classDeclaration(node, position, buffer, readString) {
|
|
13907
|
+
const { scope } = node;
|
|
13908
|
+
const idPosition = buffer[position];
|
|
13909
|
+
node.id =
|
|
13910
|
+
idPosition === 0
|
|
13911
|
+
? null
|
|
13912
|
+
: convertNode(node, scope.parent, idPosition, buffer, readString);
|
|
13913
|
+
const superClassPosition = buffer[position + 1];
|
|
13914
|
+
node.superClass =
|
|
13915
|
+
superClassPosition === 0
|
|
13916
|
+
? null
|
|
13917
|
+
: convertNode(node, scope, superClassPosition, buffer, readString);
|
|
13918
|
+
node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
|
|
13919
|
+
},
|
|
13920
|
+
function classExpression(node, position, buffer, readString) {
|
|
13921
|
+
const { scope } = node;
|
|
13922
|
+
const idPosition = buffer[position];
|
|
13923
|
+
node.id = idPosition === 0 ? null : convertNode(node, scope, idPosition, buffer, readString);
|
|
13924
|
+
const superClassPosition = buffer[position + 1];
|
|
13925
|
+
node.superClass =
|
|
13926
|
+
superClassPosition === 0
|
|
13927
|
+
? null
|
|
13928
|
+
: convertNode(node, scope, superClassPosition, buffer, readString);
|
|
13929
|
+
node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
|
|
13930
|
+
},
|
|
13931
|
+
function conditionalExpression(node, position, buffer, readString) {
|
|
13932
|
+
const { scope } = node;
|
|
13933
|
+
node.consequent = convertNode(node, scope, buffer[position], buffer, readString);
|
|
13934
|
+
node.alternate = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
13935
|
+
node.test = convertNode(node, scope, position + 2, buffer, readString);
|
|
13936
|
+
},
|
|
13937
|
+
function continueStatement(node, position, buffer, readString) {
|
|
13938
|
+
const { scope } = node;
|
|
13939
|
+
const labelPosition = buffer[position];
|
|
13940
|
+
node.label =
|
|
13941
|
+
labelPosition === 0 ? null : convertNode(node, scope, labelPosition, buffer, readString);
|
|
13942
|
+
},
|
|
13943
|
+
function debuggerStatement() { },
|
|
13944
|
+
function directive(node, position, buffer, readString) {
|
|
13945
|
+
const { scope } = node;
|
|
13946
|
+
node.expression = convertNode(node, scope, buffer[position], buffer, readString);
|
|
13947
|
+
node.directive = parseAst_js.convertString(position + 1, buffer, readString);
|
|
13948
|
+
},
|
|
13949
|
+
function doWhileStatement(node, position, buffer, readString) {
|
|
13950
|
+
const { scope } = node;
|
|
13951
|
+
node.test = convertNode(node, scope, buffer[position], buffer, readString);
|
|
13952
|
+
node.body = convertNode(node, scope, position + 1, buffer, readString);
|
|
13953
|
+
},
|
|
13954
|
+
function emptyStatement() { },
|
|
13955
|
+
function exportAllDeclaration(node, position, buffer, readString) {
|
|
13956
|
+
const { scope } = node;
|
|
13957
|
+
const exportedPosition = buffer[position];
|
|
13958
|
+
node.exported =
|
|
13959
|
+
exportedPosition === 0
|
|
13960
|
+
? null
|
|
13961
|
+
: convertNode(node, scope, exportedPosition, buffer, readString);
|
|
13962
|
+
node.source = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
13963
|
+
node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
|
|
13964
|
+
},
|
|
13965
|
+
function exportDefaultDeclaration(node, position, buffer, readString) {
|
|
13966
|
+
const { scope } = node;
|
|
13967
|
+
node.declaration = convertNode(node, scope, position, buffer, readString);
|
|
13968
|
+
},
|
|
13969
|
+
function exportNamedDeclaration(node, position, buffer, readString) {
|
|
13970
|
+
const { scope } = node;
|
|
13971
|
+
const sourcePosition = buffer[position];
|
|
13972
|
+
node.source =
|
|
13973
|
+
sourcePosition === 0 ? null : convertNode(node, scope, sourcePosition, buffer, readString);
|
|
13974
|
+
node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
|
|
13975
|
+
const declarationPosition = buffer[position + 2];
|
|
13976
|
+
node.declaration =
|
|
13977
|
+
declarationPosition === 0
|
|
13978
|
+
? null
|
|
13979
|
+
: convertNode(node, scope, declarationPosition, buffer, readString);
|
|
13980
|
+
node.specifiers = convertNodeList(node, scope, position + 3, buffer, readString);
|
|
13981
|
+
},
|
|
13982
|
+
function exportSpecifier(node, position, buffer, readString) {
|
|
13983
|
+
const { scope } = node;
|
|
13984
|
+
const exportedPosition = buffer[position];
|
|
13985
|
+
node.local = convertNode(node, scope, position + 1, buffer, readString);
|
|
13986
|
+
node.exported =
|
|
13987
|
+
exportedPosition === 0
|
|
13988
|
+
? node.local
|
|
13989
|
+
: convertNode(node, scope, exportedPosition, buffer, readString);
|
|
13990
|
+
},
|
|
13991
|
+
function expressionStatement(node, position, buffer, readString) {
|
|
13992
|
+
const { scope } = node;
|
|
13993
|
+
node.expression = convertNode(node, scope, position, buffer, readString);
|
|
13994
|
+
},
|
|
13995
|
+
function forInStatement(node, position, buffer, readString) {
|
|
13996
|
+
const { scope } = node;
|
|
13997
|
+
node.right = convertNode(node, scope, buffer[position], buffer, readString);
|
|
13998
|
+
node.body = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
13999
|
+
node.left = convertNode(node, scope, position + 2, buffer, readString);
|
|
14000
|
+
},
|
|
14001
|
+
function forOfStatement(node, position, buffer, readString) {
|
|
14002
|
+
const { scope } = node;
|
|
14003
|
+
const flags = buffer[position];
|
|
14004
|
+
node.await = (flags & 1) === 1;
|
|
14005
|
+
node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
14006
|
+
node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
|
|
14007
|
+
node.left = convertNode(node, scope, position + 3, buffer, readString);
|
|
14008
|
+
},
|
|
14009
|
+
function forStatement(node, position, buffer, readString) {
|
|
14010
|
+
const { scope } = node;
|
|
14011
|
+
const initPosition = buffer[position];
|
|
14012
|
+
node.init =
|
|
14013
|
+
initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer, readString);
|
|
14014
|
+
const testPosition = buffer[position + 1];
|
|
14015
|
+
node.test =
|
|
14016
|
+
testPosition === 0 ? null : convertNode(node, scope, testPosition, buffer, readString);
|
|
14017
|
+
const updatePosition = buffer[position + 2];
|
|
14018
|
+
node.update =
|
|
14019
|
+
updatePosition === 0 ? null : convertNode(node, scope, updatePosition, buffer, readString);
|
|
14020
|
+
node.body = convertNode(node, scope, buffer[position + 3], buffer, readString);
|
|
14021
|
+
},
|
|
14022
|
+
function functionDeclaration(node, position, buffer, readString) {
|
|
14023
|
+
const { scope } = node;
|
|
14024
|
+
const flags = buffer[position];
|
|
14025
|
+
node.async = (flags & 1) === 1;
|
|
14026
|
+
node.generator = (flags & 2) === 2;
|
|
14027
|
+
const idPosition = buffer[position + 1];
|
|
14028
|
+
node.id =
|
|
14029
|
+
idPosition === 0
|
|
14030
|
+
? null
|
|
14031
|
+
: convertNode(node, scope.parent, idPosition, buffer, readString);
|
|
14032
|
+
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer, readString));
|
|
14033
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14034
|
+
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString);
|
|
14035
|
+
const annotations = (node.annotations = parseAst_js.convertAnnotations(position + 4, buffer));
|
|
14036
|
+
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
14037
|
+
},
|
|
14038
|
+
function functionExpression(node, position, buffer, readString) {
|
|
14039
|
+
const { scope } = node;
|
|
14040
|
+
const flags = buffer[position];
|
|
14041
|
+
node.async = (flags & 1) === 1;
|
|
14042
|
+
node.generator = (flags & 2) === 2;
|
|
14043
|
+
const idPosition = buffer[position + 1];
|
|
14044
|
+
node.id =
|
|
14045
|
+
idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer, readString);
|
|
14046
|
+
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer, readString));
|
|
14047
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14048
|
+
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString);
|
|
14049
|
+
const annotations = (node.annotations = parseAst_js.convertAnnotations(position + 4, buffer));
|
|
14050
|
+
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
14051
|
+
},
|
|
14052
|
+
function identifier(node, position, buffer, readString) {
|
|
14053
|
+
node.name = parseAst_js.convertString(position, buffer, readString);
|
|
14054
|
+
},
|
|
14055
|
+
function ifStatement(node, position, buffer, readString) {
|
|
14056
|
+
const { scope } = node;
|
|
14057
|
+
node.consequent = convertNode(node, (node.consequentScope = new TrackingScope(scope)), buffer[position], buffer, readString);
|
|
14058
|
+
const alternatePosition = buffer[position + 1];
|
|
14059
|
+
node.alternate =
|
|
14060
|
+
alternatePosition === 0
|
|
14061
|
+
? null
|
|
14062
|
+
: convertNode(node, (node.alternateScope = new TrackingScope(scope)), alternatePosition, buffer, readString);
|
|
14063
|
+
node.test = convertNode(node, scope, position + 2, buffer, readString);
|
|
14064
|
+
},
|
|
14065
|
+
function importAttribute(node, position, buffer, readString) {
|
|
14066
|
+
const { scope } = node;
|
|
14067
|
+
node.value = convertNode(node, scope, buffer[position], buffer, readString);
|
|
14068
|
+
node.key = convertNode(node, scope, position + 1, buffer, readString);
|
|
14069
|
+
},
|
|
14070
|
+
function importDeclaration(node, position, buffer, readString) {
|
|
14071
|
+
const { scope } = node;
|
|
14072
|
+
node.source = convertNode(node, scope, buffer[position], buffer, readString);
|
|
14073
|
+
node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
|
|
14074
|
+
node.specifiers = convertNodeList(node, scope, position + 2, buffer, readString);
|
|
14075
|
+
},
|
|
14076
|
+
function importDefaultSpecifier(node, position, buffer, readString) {
|
|
14077
|
+
const { scope } = node;
|
|
14078
|
+
node.local = convertNode(node, scope, position, buffer, readString);
|
|
14079
|
+
},
|
|
14080
|
+
function importExpression(node, position, buffer, readString) {
|
|
14081
|
+
const { scope } = node;
|
|
14082
|
+
const optionsPosition = buffer[position];
|
|
14083
|
+
node.options =
|
|
14084
|
+
optionsPosition === 0 ? null : convertNode(node, scope, optionsPosition, buffer, readString);
|
|
14085
|
+
node.source = convertNode(node, scope, position + 1, buffer, readString);
|
|
14086
|
+
node.sourceAstNode = parseAst_js.convertNode(position + 1, buffer, readString);
|
|
14087
|
+
},
|
|
14088
|
+
function importNamespaceSpecifier(node, position, buffer, readString) {
|
|
14089
|
+
const { scope } = node;
|
|
14090
|
+
node.local = convertNode(node, scope, position, buffer, readString);
|
|
14091
|
+
},
|
|
14092
|
+
function importSpecifier(node, position, buffer, readString) {
|
|
14093
|
+
const { scope } = node;
|
|
14094
|
+
const importedPosition = buffer[position];
|
|
14095
|
+
node.local = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
14096
|
+
node.imported =
|
|
14097
|
+
importedPosition === 0
|
|
14098
|
+
? node.local
|
|
14099
|
+
: convertNode(node, scope, importedPosition, buffer, readString);
|
|
14100
|
+
},
|
|
14101
|
+
function labeledStatement(node, position, buffer, readString) {
|
|
14102
|
+
const { scope } = node;
|
|
14103
|
+
node.body = convertNode(node, scope, buffer[position], buffer, readString);
|
|
14104
|
+
node.label = convertNode(node, scope, position + 1, buffer, readString);
|
|
14105
|
+
},
|
|
14106
|
+
function literalBigInt(node, position, buffer, readString) {
|
|
14107
|
+
node.raw = parseAst_js.convertString(buffer[position], buffer, readString);
|
|
14108
|
+
const bigint = (node.bigint = parseAst_js.convertString(position + 1, buffer, readString));
|
|
14109
|
+
node.value = BigInt(bigint);
|
|
14110
|
+
},
|
|
14111
|
+
function literalBoolean(node, position, buffer) {
|
|
14112
|
+
const flags = buffer[position];
|
|
14113
|
+
const value = (node.value = (flags & 1) === 1);
|
|
14114
|
+
node.raw = value ? 'true' : 'false';
|
|
14115
|
+
},
|
|
14116
|
+
function literalNull(node) {
|
|
14117
|
+
node.value = null;
|
|
14118
|
+
},
|
|
14119
|
+
function literalNumber(node, position, buffer, readString) {
|
|
14120
|
+
const rawPosition = buffer[position];
|
|
14121
|
+
node.raw = rawPosition === 0 ? undefined : parseAst_js.convertString(rawPosition, buffer, readString);
|
|
14122
|
+
node.value = new DataView(buffer.buffer).getFloat64((position + 1) << 2, true);
|
|
14123
|
+
},
|
|
14124
|
+
function literalRegExp(node, position, buffer, readString) {
|
|
14125
|
+
const pattern = parseAst_js.convertString(buffer[position], buffer, readString);
|
|
14126
|
+
const flags = parseAst_js.convertString(position + 1, buffer, readString);
|
|
14127
|
+
node.raw = `/${pattern}/${flags}`;
|
|
14128
|
+
node.regex = { flags, pattern };
|
|
14129
|
+
node.value = new RegExp(pattern, flags);
|
|
14130
|
+
},
|
|
14131
|
+
function literalString(node, position, buffer, readString) {
|
|
14132
|
+
const rawPosition = buffer[position];
|
|
14133
|
+
node.raw = rawPosition === 0 ? undefined : parseAst_js.convertString(rawPosition, buffer, readString);
|
|
14134
|
+
node.value = parseAst_js.convertString(position + 1, buffer, readString);
|
|
14135
|
+
},
|
|
14136
|
+
function logicalExpression(node, position, buffer, readString) {
|
|
14137
|
+
const { scope } = node;
|
|
14138
|
+
node.operator = parseAst_js.FIXED_STRINGS[buffer[position]];
|
|
14139
|
+
node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
14140
|
+
node.left = convertNode(node, scope, position + 2, buffer, readString);
|
|
14141
|
+
},
|
|
14142
|
+
function memberExpression(node, position, buffer, readString) {
|
|
14143
|
+
const { scope } = node;
|
|
14144
|
+
const flags = buffer[position];
|
|
14145
|
+
node.computed = (flags & 1) === 1;
|
|
14146
|
+
node.optional = (flags & 2) === 2;
|
|
14147
|
+
node.property = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
14148
|
+
node.object = convertNode(node, scope, position + 2, buffer, readString);
|
|
14149
|
+
},
|
|
14150
|
+
function metaProperty(node, position, buffer, readString) {
|
|
14151
|
+
const { scope } = node;
|
|
14152
|
+
node.property = convertNode(node, scope, buffer[position], buffer, readString);
|
|
14153
|
+
node.meta = convertNode(node, scope, position + 1, buffer, readString);
|
|
14154
|
+
},
|
|
14155
|
+
function methodDefinition(node, position, buffer, readString) {
|
|
14156
|
+
const { scope } = node;
|
|
14157
|
+
const flags = buffer[position];
|
|
14158
|
+
node.static = (flags & 1) === 1;
|
|
14159
|
+
node.computed = (flags & 2) === 2;
|
|
14160
|
+
node.value = convertNode(node, scope, buffer[position + 1], buffer, readString);
|
|
14161
|
+
node.kind = parseAst_js.FIXED_STRINGS[buffer[position + 2]];
|
|
14162
|
+
node.key = convertNode(node, scope, position + 3, buffer, readString);
|
|
14163
|
+
},
|
|
14164
|
+
function newExpression(node, position, buffer, readString) {
|
|
14165
|
+
const { scope } = node;
|
|
14166
|
+
node.callee = convertNode(node, scope, buffer[position], buffer, readString);
|
|
14167
|
+
node.arguments = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
|
|
14168
|
+
node.annotations = parseAst_js.convertAnnotations(position + 2, buffer);
|
|
14169
|
+
},
|
|
14170
|
+
function objectExpression(node, position, buffer, readString) {
|
|
14171
|
+
const { scope } = node;
|
|
14172
|
+
node.properties = convertNodeList(node, scope, position, buffer, readString);
|
|
14173
|
+
},
|
|
14174
|
+
function objectPattern(node, position, buffer, readString) {
|
|
14175
|
+
const { scope } = node;
|
|
14176
|
+
node.properties = convertNodeList(node, scope, position, buffer, readString);
|
|
14177
|
+
},
|
|
14178
|
+
function privateIdentifier(node, position, buffer, readString) {
|
|
14179
|
+
node.name = parseAst_js.convertString(position, buffer, readString);
|
|
14180
|
+
},
|
|
14181
|
+
function program(node, position, buffer, readString) {
|
|
14182
|
+
const { scope } = node;
|
|
14183
|
+
node.invalidAnnotations = parseAst_js.convertAnnotations(buffer[position], buffer);
|
|
14184
|
+
node.body = convertNodeList(node, scope, position + 1, buffer, readString);
|
|
14185
|
+
},
|
|
14186
|
+
function property(node, position, buffer, readString) {
|
|
14187
|
+
const { scope } = node;
|
|
14188
|
+
const flags = buffer[position];
|
|
14189
|
+
node.method = (flags & 1) === 1;
|
|
14190
|
+
node.shorthand = (flags & 2) === 2;
|
|
14191
|
+
node.computed = (flags & 4) === 4;
|
|
14192
|
+
const keyPosition = buffer[position + 1];
|
|
14193
|
+
node.value = convertNode(node, scope, buffer[position + 2], buffer, readString);
|
|
14194
|
+
node.kind = parseAst_js.FIXED_STRINGS[buffer[position + 3]];
|
|
14195
|
+
node.key =
|
|
14196
|
+
keyPosition === 0 ? node.value : convertNode(node, scope, keyPosition, buffer, readString);
|
|
14197
|
+
},
|
|
14198
|
+
function propertyDefinition(node, position, buffer, readString) {
|
|
14199
|
+
const { scope } = node;
|
|
14200
|
+
const flags = buffer[position];
|
|
14201
|
+
node.static = (flags & 1) === 1;
|
|
14202
|
+
node.computed = (flags & 2) === 2;
|
|
14203
|
+
const valuePosition = buffer[position + 1];
|
|
14204
|
+
node.value =
|
|
14205
|
+
valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer, readString);
|
|
14206
|
+
node.key = convertNode(node, scope, position + 2, buffer, readString);
|
|
14207
|
+
},
|
|
14208
|
+
function restElement(node, position, buffer, readString) {
|
|
14209
|
+
const { scope } = node;
|
|
14210
|
+
node.argument = convertNode(node, scope, position, buffer, readString);
|
|
14211
|
+
},
|
|
14212
|
+
function returnStatement(node, position, buffer, readString) {
|
|
14213
|
+
const { scope } = node;
|
|
14214
|
+
const argumentPosition = buffer[position];
|
|
14215
|
+
node.argument =
|
|
14216
|
+
argumentPosition === 0
|
|
14217
|
+
? null
|
|
14218
|
+
: convertNode(node, scope, argumentPosition, buffer, readString);
|
|
14219
|
+
},
|
|
14220
|
+
function sequenceExpression(node, position, buffer, readString) {
|
|
14221
|
+
const { scope } = node;
|
|
14222
|
+
node.expressions = convertNodeList(node, scope, position, buffer, readString);
|
|
14223
|
+
},
|
|
14224
|
+
function spreadElement(node, position, buffer, readString) {
|
|
14225
|
+
const { scope } = node;
|
|
14226
|
+
node.argument = convertNode(node, scope, position, buffer, readString);
|
|
14227
|
+
},
|
|
14228
|
+
function staticBlock(node, position, buffer, readString) {
|
|
14229
|
+
const { scope } = node;
|
|
14230
|
+
node.body = convertNodeList(node, scope, position, buffer, readString);
|
|
14231
|
+
},
|
|
14232
|
+
function superElement() { },
|
|
14233
|
+
function switchCase(node, position, buffer, readString) {
|
|
14234
|
+
const { scope } = node;
|
|
14235
|
+
const testPosition = buffer[position];
|
|
14236
|
+
node.test =
|
|
14237
|
+
testPosition === 0 ? null : convertNode(node, scope, testPosition, buffer, readString);
|
|
14238
|
+
node.consequent = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
|
|
14239
|
+
},
|
|
14240
|
+
function switchStatement(node, position, buffer, readString) {
|
|
14241
|
+
const { scope } = node;
|
|
14242
|
+
node.cases = convertNodeList(node, scope, buffer[position], buffer, readString);
|
|
14243
|
+
node.discriminant = convertNode(node, node.parentScope, position + 1, buffer, readString);
|
|
14244
|
+
},
|
|
14245
|
+
function taggedTemplateExpression(node, position, buffer, readString) {
|
|
14246
|
+
const { scope } = node;
|
|
14247
|
+
node.quasi = convertNode(node, scope, buffer[position], buffer, readString);
|
|
14248
|
+
node.tag = convertNode(node, scope, position + 1, buffer, readString);
|
|
14249
|
+
},
|
|
14250
|
+
function templateElement(node, position, buffer, readString) {
|
|
14251
|
+
const flags = buffer[position];
|
|
14252
|
+
node.tail = (flags & 1) === 1;
|
|
14253
|
+
const cookedPosition = buffer[position + 1];
|
|
14254
|
+
const cooked = cookedPosition === 0 ? undefined : parseAst_js.convertString(cookedPosition, buffer, readString);
|
|
14255
|
+
const raw = parseAst_js.convertString(position + 2, buffer, readString);
|
|
14256
|
+
node.value = { cooked, raw };
|
|
14257
|
+
},
|
|
14258
|
+
function templateLiteral(node, position, buffer, readString) {
|
|
14259
|
+
const { scope } = node;
|
|
14260
|
+
node.expressions = convertNodeList(node, scope, buffer[position], buffer, readString);
|
|
14261
|
+
node.quasis = convertNodeList(node, scope, position + 1, buffer, readString);
|
|
14262
|
+
},
|
|
14263
|
+
function thisExpression() { },
|
|
14264
|
+
function throwStatement(node, position, buffer, readString) {
|
|
14265
|
+
const { scope } = node;
|
|
14266
|
+
node.argument = convertNode(node, scope, position, buffer, readString);
|
|
14267
|
+
},
|
|
14268
|
+
function tryStatement(node, position, buffer, readString) {
|
|
14269
|
+
const { scope } = node;
|
|
14270
|
+
const handlerPosition = buffer[position];
|
|
14271
|
+
node.handler =
|
|
14272
|
+
handlerPosition === 0 ? null : convertNode(node, scope, handlerPosition, buffer, readString);
|
|
14273
|
+
const finalizerPosition = buffer[position + 1];
|
|
14274
|
+
node.finalizer =
|
|
14275
|
+
finalizerPosition === 0
|
|
14276
|
+
? null
|
|
14277
|
+
: convertNode(node, scope, finalizerPosition, buffer, readString);
|
|
14278
|
+
node.block = convertNode(node, scope, position + 2, buffer, readString);
|
|
14279
|
+
},
|
|
14280
|
+
function unaryExpression(node, position, buffer, readString) {
|
|
14281
|
+
const { scope } = node;
|
|
14282
|
+
node.operator = parseAst_js.FIXED_STRINGS[buffer[position]];
|
|
14283
|
+
node.argument = convertNode(node, scope, position + 1, buffer, readString);
|
|
14284
|
+
},
|
|
14285
|
+
function updateExpression(node, position, buffer, readString) {
|
|
14286
|
+
const { scope } = node;
|
|
14287
|
+
const flags = buffer[position];
|
|
14288
|
+
node.prefix = (flags & 1) === 1;
|
|
14289
|
+
node.operator = parseAst_js.FIXED_STRINGS[buffer[position + 1]];
|
|
14290
|
+
node.argument = convertNode(node, scope, position + 2, buffer, readString);
|
|
14291
|
+
},
|
|
14292
|
+
function variableDeclaration(node, position, buffer, readString) {
|
|
14293
|
+
const { scope } = node;
|
|
14294
|
+
node.kind = parseAst_js.FIXED_STRINGS[buffer[position]];
|
|
14295
|
+
node.declarations = convertNodeList(node, scope, position + 1, buffer, readString);
|
|
14296
|
+
},
|
|
14297
|
+
function variableDeclarator(node, position, buffer, readString) {
|
|
14298
|
+
const { scope } = node;
|
|
14299
|
+
const initPosition = buffer[position];
|
|
14300
|
+
node.init =
|
|
14301
|
+
initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer, readString);
|
|
14302
|
+
node.id = convertNode(node, scope, position + 1, buffer, readString);
|
|
14303
|
+
},
|
|
14304
|
+
function whileStatement(node, position, buffer, readString) {
|
|
14305
|
+
const { scope } = node;
|
|
14306
|
+
node.body = convertNode(node, scope, buffer[position], buffer, readString);
|
|
14307
|
+
node.test = convertNode(node, scope, position + 1, buffer, readString);
|
|
14308
|
+
},
|
|
14309
|
+
function yieldExpression(node, position, buffer, readString) {
|
|
14310
|
+
const { scope } = node;
|
|
14311
|
+
const flags = buffer[position];
|
|
14312
|
+
node.delegate = (flags & 1) === 1;
|
|
14313
|
+
const argumentPosition = buffer[position + 1];
|
|
14314
|
+
node.argument =
|
|
14315
|
+
argumentPosition === 0
|
|
14316
|
+
? null
|
|
14317
|
+
: convertNode(node, scope, argumentPosition, buffer, readString);
|
|
14318
|
+
}
|
|
14319
|
+
];
|
|
14320
|
+
function convertNode(parent, parentScope, position, buffer, readString) {
|
|
14321
|
+
const nodeType = buffer[position];
|
|
14322
|
+
const NodeConstructor = nodeConstructors$1[nodeType];
|
|
14323
|
+
/* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
|
|
14324
|
+
if (!NodeConstructor) {
|
|
14325
|
+
console.trace();
|
|
14326
|
+
throw new Error(`Unknown node type: ${nodeType}`);
|
|
14327
|
+
}
|
|
14328
|
+
const node = new NodeConstructor(parent, parentScope);
|
|
14329
|
+
node.type = nodeTypeStrings[nodeType];
|
|
14330
|
+
node.start = buffer[position + 1];
|
|
14331
|
+
node.end = buffer[position + 2];
|
|
14332
|
+
bufferParsers[nodeType](node, position + 3, buffer, readString);
|
|
14333
|
+
node.initialise();
|
|
14334
|
+
return node;
|
|
14335
|
+
}
|
|
14336
|
+
function convertNodeList(parent, parentScope, position, buffer, readString) {
|
|
14337
|
+
const length = buffer[position++];
|
|
14338
|
+
const list = [];
|
|
14339
|
+
for (let index = 0; index < length; index++) {
|
|
14340
|
+
const nodePosition = buffer[position++];
|
|
14341
|
+
list.push(nodePosition ? convertNode(parent, parentScope, nodePosition, buffer, readString) : null);
|
|
14342
|
+
}
|
|
14343
|
+
return list;
|
|
14344
|
+
}
|
|
14345
|
+
|
|
14346
|
+
class UnknownNode extends NodeBase {
|
|
14347
|
+
hasEffects() {
|
|
14348
|
+
return true;
|
|
14349
|
+
}
|
|
14350
|
+
include(context) {
|
|
14351
|
+
super.include(context, true);
|
|
14352
|
+
}
|
|
14353
|
+
}
|
|
14354
|
+
|
|
13520
14355
|
const nodeConstructors = {
|
|
13521
14356
|
ArrayExpression,
|
|
13522
14357
|
ArrayPattern,
|
|
@@ -13564,6 +14399,8 @@ const nodeConstructors = {
|
|
|
13564
14399
|
NewExpression,
|
|
13565
14400
|
ObjectExpression,
|
|
13566
14401
|
ObjectPattern,
|
|
14402
|
+
PanicError,
|
|
14403
|
+
ParseError,
|
|
13567
14404
|
PrivateIdentifier,
|
|
13568
14405
|
Program,
|
|
13569
14406
|
Property,
|
|
@@ -13911,7 +14748,9 @@ function getAttributesFromImportExpression(node) {
|
|
|
13911
14748
|
}
|
|
13912
14749
|
const getPropertyKey = (property) => {
|
|
13913
14750
|
const key = property.key;
|
|
13914
|
-
return (key &&
|
|
14751
|
+
return (key &&
|
|
14752
|
+
!property.computed &&
|
|
14753
|
+
(key.name || key.value));
|
|
13915
14754
|
};
|
|
13916
14755
|
function getAttributesFromImportExportDeclaration(attributes) {
|
|
13917
14756
|
return attributes?.length
|
|
@@ -14559,11 +15398,11 @@ class Module {
|
|
|
14559
15398
|
return { source, usesTopLevelAwait };
|
|
14560
15399
|
}
|
|
14561
15400
|
async setSource({ ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
|
|
15401
|
+
timeStart('generate ast', 3);
|
|
14562
15402
|
if (code.startsWith('#!')) {
|
|
14563
15403
|
const shebangEndPosition = code.indexOf('\n');
|
|
14564
15404
|
this.shebang = code.slice(2, shebangEndPosition);
|
|
14565
15405
|
}
|
|
14566
|
-
timeStart('generate ast', 3);
|
|
14567
15406
|
this.info.code = code;
|
|
14568
15407
|
this.originalCode = originalCode;
|
|
14569
15408
|
// We need to call decodedSourcemap on the input in case they were hydrated from json in the cache and don't
|
|
@@ -14579,9 +15418,6 @@ class Module {
|
|
|
14579
15418
|
this.transformDependencies = transformDependencies;
|
|
14580
15419
|
this.customTransformCache = customTransformCache;
|
|
14581
15420
|
this.updateOptions(moduleOptions);
|
|
14582
|
-
const moduleAst = ast ?? (await this.tryParseAsync());
|
|
14583
|
-
timeEnd('generate ast', 3);
|
|
14584
|
-
timeStart('analyze ast', 3);
|
|
14585
15421
|
this.resolvedIds = resolvedIds ?? Object.create(null);
|
|
14586
15422
|
// By default, `id` is the file name. Custom resolvers and loaders
|
|
14587
15423
|
// can change that, but it makes sense to use it for the source file name
|
|
@@ -14621,13 +15457,17 @@ class Module {
|
|
|
14621
15457
|
};
|
|
14622
15458
|
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
14623
15459
|
this.namespace = new NamespaceVariable(this.astContext);
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
this.info.ast = moduleAst;
|
|
15460
|
+
const programParent = { context: this.astContext, type: 'Module' };
|
|
15461
|
+
if (ast) {
|
|
15462
|
+
this.ast = new nodeConstructors[ast.type](programParent, this.scope).parseNode(ast);
|
|
15463
|
+
this.info.ast = ast;
|
|
14629
15464
|
}
|
|
14630
15465
|
else {
|
|
15466
|
+
// Measuring asynchronous code does not provide reasonable results
|
|
15467
|
+
timeEnd('generate ast', 3);
|
|
15468
|
+
const astBuffer = await native_js.parseAsync(code, false);
|
|
15469
|
+
timeStart('generate ast', 3);
|
|
15470
|
+
this.ast = convertProgram(astBuffer, programParent, this.scope);
|
|
14631
15471
|
// Make lazy and apply LRU cache to not hog the memory
|
|
14632
15472
|
Object.defineProperty(this.info, 'ast', {
|
|
14633
15473
|
get: () => {
|
|
@@ -14636,13 +15476,23 @@ class Module {
|
|
|
14636
15476
|
}
|
|
14637
15477
|
else {
|
|
14638
15478
|
const parsedAst = this.tryParse();
|
|
15479
|
+
// If the cache is not disabled, we need to keep the AST in memory
|
|
15480
|
+
// until the end when the cache is generated
|
|
15481
|
+
if (this.options.cache !== false) {
|
|
15482
|
+
Object.defineProperty(this.info, 'ast', {
|
|
15483
|
+
value: parsedAst
|
|
15484
|
+
});
|
|
15485
|
+
return parsedAst;
|
|
15486
|
+
}
|
|
15487
|
+
// Otherwise, we keep it in a small LRU cache to not hog too much
|
|
15488
|
+
// memory but allow the same AST to be requested several times.
|
|
14639
15489
|
this.graph.astLru.set(fileName, parsedAst);
|
|
14640
15490
|
return parsedAst;
|
|
14641
15491
|
}
|
|
14642
15492
|
}
|
|
14643
15493
|
});
|
|
14644
15494
|
}
|
|
14645
|
-
timeEnd('
|
|
15495
|
+
timeEnd('generate ast', 3);
|
|
14646
15496
|
}
|
|
14647
15497
|
toJSON() {
|
|
14648
15498
|
return {
|
|
@@ -14695,13 +15545,15 @@ class Module {
|
|
|
14695
15545
|
}
|
|
14696
15546
|
}
|
|
14697
15547
|
addDynamicImport(node) {
|
|
14698
|
-
let argument = node.
|
|
14699
|
-
if (argument
|
|
14700
|
-
if (argument.quasis.length === 1 &&
|
|
15548
|
+
let argument = node.sourceAstNode;
|
|
15549
|
+
if (argument.type === parseAst_js.TemplateLiteral) {
|
|
15550
|
+
if (argument.quasis.length === 1 &&
|
|
15551
|
+
typeof argument.quasis[0].value.cooked === 'string') {
|
|
14701
15552
|
argument = argument.quasis[0].value.cooked;
|
|
14702
15553
|
}
|
|
14703
15554
|
}
|
|
14704
|
-
else if (argument
|
|
15555
|
+
else if (argument.type === parseAst_js.Literal &&
|
|
15556
|
+
typeof argument.value === 'string') {
|
|
14705
15557
|
argument = argument.value;
|
|
14706
15558
|
}
|
|
14707
15559
|
this.dynamicImports.push({ argument, id: null, node, resolution: null });
|
|
@@ -14996,14 +15848,6 @@ class Module {
|
|
|
14996
15848
|
return this.error(parseAst_js.logModuleParseError(error_, this.id), error_.pos);
|
|
14997
15849
|
}
|
|
14998
15850
|
}
|
|
14999
|
-
async tryParseAsync() {
|
|
15000
|
-
try {
|
|
15001
|
-
return await parseAst_js.parseAstAsync(this.info.code);
|
|
15002
|
-
}
|
|
15003
|
-
catch (error_) {
|
|
15004
|
-
return this.error(parseAst_js.logModuleParseError(error_, this.id), error_.pos);
|
|
15005
|
-
}
|
|
15006
|
-
}
|
|
15007
15851
|
}
|
|
15008
15852
|
// if there is a cyclic import in the reexport chain, we should not
|
|
15009
15853
|
// import from the original module but from the cyclic module to not
|
|
@@ -15037,7 +15881,7 @@ function getCompleteAmdId(options, chunkId) {
|
|
|
15037
15881
|
return options.id ?? '';
|
|
15038
15882
|
}
|
|
15039
15883
|
|
|
15040
|
-
function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, mechanism = 'return ') {
|
|
15884
|
+
function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, reexportProtoFromExternal, mechanism = 'return ') {
|
|
15041
15885
|
const { _, getDirectReturnFunction, getFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
15042
15886
|
if (!namedExportsMode) {
|
|
15043
15887
|
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings, getPropertyAccess)};`;
|
|
@@ -15094,6 +15938,16 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
15094
15938
|
if (specifier.reexported === '*') {
|
|
15095
15939
|
if (exportBlock)
|
|
15096
15940
|
exportBlock += n;
|
|
15941
|
+
if (!specifier.needsLiveBinding && reexportProtoFromExternal) {
|
|
15942
|
+
const protoString = "'__proto__'";
|
|
15943
|
+
exportBlock +=
|
|
15944
|
+
`Object.prototype.hasOwnProperty.call(${name},${_}${protoString})${_}&&${n}` +
|
|
15945
|
+
`${t}!Object.prototype.hasOwnProperty.call(exports,${_}${protoString})${_}&&${n}` +
|
|
15946
|
+
`${t}Object.defineProperty(exports,${_}${protoString},${_}{${n}` +
|
|
15947
|
+
`${t}${t}enumerable:${_}true,${n}` +
|
|
15948
|
+
`${t}${t}value:${_}${name}[${protoString}]${n}` +
|
|
15949
|
+
`${t}});${n}${n}`;
|
|
15950
|
+
}
|
|
15097
15951
|
const copyPropertyIfNecessary = `{${n}${t}if${_}(k${_}!==${_}'default'${_}&&${_}!Object.prototype.hasOwnProperty.call(exports,${_}k))${_}${getDefineProperty(name, specifier.needsLiveBinding, t, snippets)}${s}${n}}`;
|
|
15098
15952
|
exportBlock += `Object.keys(${name}).forEach(${getFunctionIntro(['k'], {
|
|
15099
15953
|
isAsync: false,
|
|
@@ -15177,9 +16031,7 @@ const getDefineProperty = (name, needsLiveBinding, t, { _, getDirectReturnFuncti
|
|
|
15177
16031
|
`${t}${t}enumerable:${_}true,${n}` +
|
|
15178
16032
|
`${t}${t}get:${_}${left}${name}[k]${right}${n}${t}})`);
|
|
15179
16033
|
}
|
|
15180
|
-
return
|
|
15181
|
-
`${t}${t}enumerable:${_}true,${n}` +
|
|
15182
|
-
`${t}${t}value:${_}${name}[k]${n}${t}})${_}:${_}exports[k]${_}=${_}${name}[k]`);
|
|
16034
|
+
return `exports[k]${_}=${_}${name}[k]`;
|
|
15183
16035
|
};
|
|
15184
16036
|
|
|
15185
16037
|
function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, symbols, accessedGlobals, indent, snippets) {
|
|
@@ -15324,7 +16176,7 @@ function warnOnBuiltins(log, dependencies) {
|
|
|
15324
16176
|
log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logMissingNodeBuiltins(externalBuiltins));
|
|
15325
16177
|
}
|
|
15326
16178
|
|
|
15327
|
-
function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, log, outro, snippets }, { amd, esModule, externalLiveBindings, freeze, generatedCode: { symbols }, interop, strict }) {
|
|
16179
|
+
function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, log, outro, snippets }, { amd, esModule, externalLiveBindings, freeze, generatedCode: { symbols }, interop, reexportProtoFromExternal, strict }) {
|
|
15328
16180
|
warnOnBuiltins(log, dependencies);
|
|
15329
16181
|
const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
|
|
15330
16182
|
const parameters = dependencies.map(m => m.name);
|
|
@@ -15346,7 +16198,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
15346
16198
|
(deps.length > 0 ? `[${deps.join(`,${_}`)}],${_}` : ``);
|
|
15347
16199
|
const useStrict = strict ? `${_}'use strict';` : '';
|
|
15348
16200
|
magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, symbols, accessedGlobals, t, snippets)}`);
|
|
15349
|
-
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
|
|
16201
|
+
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, reexportProtoFromExternal);
|
|
15350
16202
|
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), isModuleFacade && symbols, snippets);
|
|
15351
16203
|
if (namespaceMarkers) {
|
|
15352
16204
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
@@ -15363,7 +16215,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
15363
16215
|
.append(`${n}${n}}));`);
|
|
15364
16216
|
}
|
|
15365
16217
|
|
|
15366
|
-
function cjs(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, generatedCode: { symbols }, strict }) {
|
|
16218
|
+
function cjs(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, generatedCode: { symbols }, reexportProtoFromExternal, strict }) {
|
|
15367
16219
|
const { _, n } = snippets;
|
|
15368
16220
|
const useStrict = strict ? `'use strict';${n}${n}` : '';
|
|
15369
16221
|
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), isModuleFacade && symbols, snippets);
|
|
@@ -15373,7 +16225,7 @@ function cjs(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
15373
16225
|
const importBlock = getImportBlock$1(dependencies, snippets, compact);
|
|
15374
16226
|
const interopBlock = getInteropBlock(dependencies, interop, externalLiveBindings, freeze, symbols, accessedGlobals, t, snippets);
|
|
15375
16227
|
magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`);
|
|
15376
|
-
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, `module.exports${_}=${_}`);
|
|
16228
|
+
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, reexportProtoFromExternal, `module.exports${_}=${_}`);
|
|
15377
16229
|
magicString.append(`${exportBlock}${outro}`);
|
|
15378
16230
|
}
|
|
15379
16231
|
function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
|
|
@@ -15552,7 +16404,7 @@ function trimEmptyImports(dependencies) {
|
|
|
15552
16404
|
return [];
|
|
15553
16405
|
}
|
|
15554
16406
|
|
|
15555
|
-
function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, log, outro, snippets }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, generatedCode: { symbols }, strict }) {
|
|
16407
|
+
function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, log, outro, snippets }, { compact, esModule, extend, freeze, externalLiveBindings, reexportProtoFromExternal, globals, interop, name, generatedCode: { symbols }, strict }) {
|
|
15556
16408
|
const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
|
|
15557
16409
|
const isNamespaced = name && name.includes('.');
|
|
15558
16410
|
const useVariableAssignment = !extend && !isNamespaced;
|
|
@@ -15597,7 +16449,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultE
|
|
|
15597
16449
|
if (hasExports && !extend && namedExportsMode) {
|
|
15598
16450
|
wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`;
|
|
15599
16451
|
}
|
|
15600
|
-
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
|
|
16452
|
+
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, reexportProtoFromExternal);
|
|
15601
16453
|
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), symbols, snippets);
|
|
15602
16454
|
if (namespaceMarkers) {
|
|
15603
16455
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
@@ -15770,7 +16622,7 @@ function safeAccess(name, globalVariable, { _, getPropertyAccess }) {
|
|
|
15770
16622
|
.map(part => (propertyPath += getPropertyAccess(part)))
|
|
15771
16623
|
.join(`${_}&&${_}`);
|
|
15772
16624
|
}
|
|
15773
|
-
function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, log, outro, snippets }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, generatedCode: { symbols }, globals, noConflict, strict }) {
|
|
16625
|
+
function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, log, outro, snippets }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, generatedCode: { symbols }, globals, noConflict, reexportProtoFromExternal, strict }) {
|
|
15774
16626
|
const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
15775
16627
|
const factoryVariable = compact ? 'f' : 'factory';
|
|
15776
16628
|
const globalVariable = compact ? 'g' : 'global';
|
|
@@ -15851,7 +16703,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
15851
16703
|
})}{${useStrict}${n}`;
|
|
15852
16704
|
const wrapperOutro = n + n + '}));';
|
|
15853
16705
|
magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, symbols, accessedGlobals, t, snippets)}`);
|
|
15854
|
-
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
|
|
16706
|
+
const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, reexportProtoFromExternal);
|
|
15855
16707
|
let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), symbols, snippets);
|
|
15856
16708
|
if (namespaceMarkers) {
|
|
15857
16709
|
namespaceMarkers = n + n + namespaceMarkers;
|
|
@@ -18892,7 +19744,6 @@ class ModuleLoader {
|
|
|
18892
19744
|
? source
|
|
18893
19745
|
: parseAst_js.error(parseAst_js.logBadLoader(id));
|
|
18894
19746
|
const code = sourceDescription.code;
|
|
18895
|
-
/* eslint-disable-next-line unicorn/number-literal-case */
|
|
18896
19747
|
if (code.charCodeAt(0) === 65279) {
|
|
18897
19748
|
sourceDescription.code = code.slice(1);
|
|
18898
19749
|
}
|
|
@@ -19076,9 +19927,7 @@ class ModuleLoader {
|
|
|
19076
19927
|
}
|
|
19077
19928
|
getResolveDynamicImportPromises(module) {
|
|
19078
19929
|
return module.dynamicImports.map(async (dynamicImport) => {
|
|
19079
|
-
const resolvedId = await this.resolveDynamicImport(module,
|
|
19080
|
-
? dynamicImport.argument
|
|
19081
|
-
: dynamicImport.argument.esTreeNode, module.id, getAttributesFromImportExpression(dynamicImport.node));
|
|
19930
|
+
const resolvedId = await this.resolveDynamicImport(module, dynamicImport.argument, module.id, getAttributesFromImportExpression(dynamicImport.node));
|
|
19082
19931
|
if (resolvedId && typeof resolvedId === 'object') {
|
|
19083
19932
|
dynamicImport.id = resolvedId.id;
|
|
19084
19933
|
}
|
|
@@ -19691,6 +20540,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
19691
20540
|
plugins: await normalizePluginOption(config.plugins),
|
|
19692
20541
|
preserveModules,
|
|
19693
20542
|
preserveModulesRoot: getPreserveModulesRoot(config),
|
|
20543
|
+
reexportProtoFromExternal: config.reexportProtoFromExternal ?? true,
|
|
19694
20544
|
sanitizeFileName: typeof config.sanitizeFileName === 'function'
|
|
19695
20545
|
? config.sanitizeFileName
|
|
19696
20546
|
: config.sanitizeFileName === false
|