rollup 2.47.0 → 2.48.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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.47.0
4
- Tue, 04 May 2021 05:02:40 GMT - commit 6cc9d6b5137dd80fef9618e97471f89f8fbc54ad
3
+ Rollup.js v2.48.0
4
+ Sat, 15 May 2021 04:50:11 GMT - commit 07b3a02069594147665daa95d3fa3e041a82b2d0
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -14,7 +14,7 @@ import * as fs from 'fs';
14
14
  import { lstatSync, realpathSync, readdirSync } from 'fs';
15
15
  import { EventEmitter } from 'events';
16
16
 
17
- var version$1 = "2.47.0";
17
+ var version$1 = "2.48.0";
18
18
 
19
19
  var charToInteger = {};
20
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -4352,17 +4352,18 @@ class NamespaceVariable extends Variable {
4352
4352
  this.name = identifier.name;
4353
4353
  }
4354
4354
  deoptimizePath(path) {
4355
+ var _a;
4355
4356
  const memberVariables = this.getMemberVariables();
4356
4357
  const memberPath = path.length <= 1 ? UNKNOWN_PATH : path.slice(1);
4357
4358
  const key = path[0];
4358
- if (typeof key !== 'string') {
4359
+ if (typeof key === 'string') {
4360
+ (_a = memberVariables[key]) === null || _a === void 0 ? void 0 : _a.deoptimizePath(memberPath);
4361
+ }
4362
+ else {
4359
4363
  for (const key of Object.keys(memberVariables)) {
4360
4364
  memberVariables[key].deoptimizePath(memberPath);
4361
4365
  }
4362
4366
  }
4363
- else {
4364
- memberVariables[key].deoptimizePath(memberPath);
4365
- }
4366
4367
  }
4367
4368
  getMemberVariables() {
4368
4369
  if (this.memberVariables) {
@@ -6779,7 +6780,8 @@ class CallExpression extends NodeBase {
6779
6780
  if (argument.hasEffects(context))
6780
6781
  return true;
6781
6782
  }
6782
- if (this.context.options.treeshake.annotations && ((_a = this.annotations) === null || _a === void 0 ? void 0 : _a.some((a) => a.pure)))
6783
+ if (this.context.options.treeshake.annotations &&
6784
+ ((_a = this.annotations) === null || _a === void 0 ? void 0 : _a.some((a) => a.pure)))
6783
6785
  return false;
6784
6786
  return (this.callee.hasEffects(context) ||
6785
6787
  this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
@@ -8072,7 +8074,8 @@ class NewExpression extends NodeBase {
8072
8074
  if (argument.hasEffects(context))
8073
8075
  return true;
8074
8076
  }
8075
- if (this.context.options.treeshake.annotations && ((_a = this.annotations) === null || _a === void 0 ? void 0 : _a.some((a) => a.pure)))
8077
+ if (this.context.options.treeshake.annotations &&
8078
+ ((_a = this.annotations) === null || _a === void 0 ? void 0 : _a.some((a) => a.pure)))
8076
8079
  return false;
8077
8080
  return (this.callee.hasEffects(context) ||
8078
8081
  this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
@@ -11099,12 +11102,11 @@ class Chunk {
11099
11102
  if (isAbsolute(id)) {
11100
11103
  const extension = extname(id);
11101
11104
  const pattern = unsetOptions.has('entryFileNames')
11102
- ? NON_ASSET_EXTENSIONS.includes(extension)
11103
- ? '[name].js'
11104
- : '[name][extname].js'
11105
+ ? '[name][assetExtname].js'
11105
11106
  : options.entryFileNames;
11106
11107
  const currentDir = dirname(sanitizedId);
11107
11108
  const fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getChunkInfo()) : pattern, 'output.entryFileNames', {
11109
+ assetExtname: () => NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension,
11108
11110
  ext: () => extension.substr(1),
11109
11111
  extname: () => extension,
11110
11112
  format: () => options.format,
@@ -12740,6 +12742,7 @@ var types = {
12740
12742
  regexp: new TokenType("regexp", startsExpr),
12741
12743
  string: new TokenType("string", startsExpr),
12742
12744
  name: new TokenType("name", startsExpr),
12745
+ privateId: new TokenType("privateId", startsExpr),
12743
12746
  eof: new TokenType("eof"),
12744
12747
 
12745
12748
  // Punctuation token types.
@@ -12934,7 +12937,8 @@ var defaultOptions = {
12934
12937
  // error.
12935
12938
  allowReturnOutsideFunction: false,
12936
12939
  // When enabled, import/export statements are not constrained to
12937
- // appearing at the top of the program.
12940
+ // appearing at the top of the program, and an import.meta expression
12941
+ // in a script isn't considered an error.
12938
12942
  allowImportExportEverywhere: false,
12939
12943
  // When enabled, await identifiers are allowed to appear at the top-level scope,
12940
12944
  // but they are still not allowed in non-async functions.
@@ -13125,6 +13129,7 @@ var Parser = function Parser(options, input, startPos) {
13125
13129
 
13126
13130
  // Used to signify the start of a potential arrow function
13127
13131
  this.potentialArrowAt = -1;
13132
+ this.potentialArrowInForAwait = false;
13128
13133
 
13129
13134
  // Positions to delayed-check that yield/await does not exist in default parameters.
13130
13135
  this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
@@ -13143,6 +13148,11 @@ var Parser = function Parser(options, input, startPos) {
13143
13148
 
13144
13149
  // For RegExp validation
13145
13150
  this.regexpState = null;
13151
+
13152
+ // The stack of private names.
13153
+ // Each element has two properties: 'declared' and 'used'.
13154
+ // When it exited from the outermost class definition, all used private names must be declared.
13155
+ this.privateNameStack = [];
13146
13156
  };
13147
13157
 
13148
13158
  var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },inNonArrowFunction: { configurable: true } };
@@ -13154,12 +13164,22 @@ Parser.prototype.parse = function parse () {
13154
13164
  };
13155
13165
 
13156
13166
  prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
13157
- prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 };
13158
- prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 };
13159
- prototypeAccessors.allowSuper.get = function () { return (this.currentThisScope().flags & SCOPE_SUPER) > 0 };
13167
+ prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
13168
+ prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
13169
+ prototypeAccessors.allowSuper.get = function () {
13170
+ var ref = this.currentThisScope();
13171
+ var flags = ref.flags;
13172
+ var inClassFieldInit = ref.inClassFieldInit;
13173
+ return (flags & SCOPE_SUPER) > 0 || inClassFieldInit
13174
+ };
13160
13175
  prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
13161
13176
  prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
13162
- prototypeAccessors.inNonArrowFunction.get = function () { return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0 };
13177
+ prototypeAccessors.inNonArrowFunction.get = function () {
13178
+ var ref = this.currentThisScope();
13179
+ var flags = ref.flags;
13180
+ var inClassFieldInit = ref.inClassFieldInit;
13181
+ return (flags & SCOPE_FUNCTION) > 0 || inClassFieldInit
13182
+ };
13163
13183
 
13164
13184
  Parser.extend = function extend () {
13165
13185
  var plugins = [], len = arguments.length;
@@ -13566,7 +13586,7 @@ pp$1.parseForStatement = function(node) {
13566
13586
  return this.parseFor(node, init$1)
13567
13587
  }
13568
13588
  var refDestructuringErrors = new DestructuringErrors;
13569
- var init = this.parseExpression(true, refDestructuringErrors);
13589
+ var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
13570
13590
  if (this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
13571
13591
  if (this.options.ecmaVersion >= 9) {
13572
13592
  if (this.type === types._in) {
@@ -13912,6 +13932,7 @@ pp$1.parseClass = function(node, isStatement) {
13912
13932
 
13913
13933
  this.parseClassId(node, isStatement);
13914
13934
  this.parseClassSuper(node);
13935
+ var privateNameMap = this.enterClassBody();
13915
13936
  var classBody = this.startNode();
13916
13937
  var hadConstructor = false;
13917
13938
  classBody.body = [];
@@ -13923,77 +13944,154 @@ pp$1.parseClass = function(node, isStatement) {
13923
13944
  if (element.type === "MethodDefinition" && element.kind === "constructor") {
13924
13945
  if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
13925
13946
  hadConstructor = true;
13947
+ } else if (element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
13948
+ this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
13926
13949
  }
13927
13950
  }
13928
13951
  }
13929
13952
  this.strict = oldStrict;
13930
13953
  this.next();
13931
13954
  node.body = this.finishNode(classBody, "ClassBody");
13955
+ this.exitClassBody();
13932
13956
  return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
13933
13957
  };
13934
13958
 
13935
13959
  pp$1.parseClassElement = function(constructorAllowsSuper) {
13936
- var this$1 = this;
13937
-
13938
13960
  if (this.eat(types.semi)) { return null }
13939
13961
 
13940
- var method = this.startNode();
13941
- var tryContextual = function (k, noLineBreak) {
13942
- if ( noLineBreak === void 0 ) noLineBreak = false;
13943
-
13944
- var start = this$1.start, startLoc = this$1.startLoc;
13945
- if (!this$1.eatContextual(k)) { return false }
13946
- if (this$1.type !== types.parenL && (!noLineBreak || !this$1.canInsertSemicolon())) { return true }
13947
- if (method.key) { this$1.unexpected(); }
13948
- method.computed = false;
13949
- method.key = this$1.startNodeAt(start, startLoc);
13950
- method.key.name = k;
13951
- this$1.finishNode(method.key, "Identifier");
13952
- return false
13953
- };
13954
-
13955
- method.kind = "method";
13956
- method.static = tryContextual("static");
13957
- var isGenerator = this.eat(types.star);
13962
+ var ecmaVersion = this.options.ecmaVersion;
13963
+ var node = this.startNode();
13964
+ var keyName = "";
13965
+ var isGenerator = false;
13958
13966
  var isAsync = false;
13959
- if (!isGenerator) {
13960
- if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) {
13967
+ var kind = "method";
13968
+
13969
+ // Parse modifiers
13970
+ node.static = false;
13971
+ if (this.eatContextual("static")) {
13972
+ if (this.isClassElementNameStart() || this.type === types.star) {
13973
+ node.static = true;
13974
+ } else {
13975
+ keyName = "static";
13976
+ }
13977
+ }
13978
+ if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
13979
+ if ((this.isClassElementNameStart() || this.type === types.star) && !this.canInsertSemicolon()) {
13961
13980
  isAsync = true;
13962
- isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
13963
- } else if (tryContextual("get")) {
13964
- method.kind = "get";
13965
- } else if (tryContextual("set")) {
13966
- method.kind = "set";
13981
+ } else {
13982
+ keyName = "async";
13983
+ }
13984
+ }
13985
+ if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types.star)) {
13986
+ isGenerator = true;
13987
+ }
13988
+ if (!keyName && !isAsync && !isGenerator) {
13989
+ var lastValue = this.value;
13990
+ if (this.eatContextual("get") || this.eatContextual("set")) {
13991
+ if (this.isClassElementNameStart()) {
13992
+ kind = lastValue;
13993
+ } else {
13994
+ keyName = lastValue;
13995
+ }
13996
+ }
13997
+ }
13998
+
13999
+ // Parse element name
14000
+ if (keyName) {
14001
+ // 'async', 'get', 'set', or 'static' were not a keyword contextually.
14002
+ // The last token is any of those. Make it the element name.
14003
+ node.computed = false;
14004
+ node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
14005
+ node.key.name = keyName;
14006
+ this.finishNode(node.key, "Identifier");
14007
+ } else {
14008
+ this.parseClassElementName(node);
14009
+ }
14010
+
14011
+ // Parse element value
14012
+ if (ecmaVersion < 13 || this.type === types.parenL || kind !== "method" || isGenerator || isAsync) {
14013
+ var isConstructor = !node.static && checkKeyName(node, "constructor");
14014
+ var allowsDirectSuper = isConstructor && constructorAllowsSuper;
14015
+ // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
14016
+ if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); }
14017
+ node.kind = isConstructor ? "constructor" : kind;
14018
+ this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
14019
+ } else {
14020
+ this.parseClassField(node);
14021
+ }
14022
+
14023
+ return node
14024
+ };
14025
+
14026
+ pp$1.isClassElementNameStart = function() {
14027
+ return (
14028
+ this.type === types.name ||
14029
+ this.type === types.privateId ||
14030
+ this.type === types.num ||
14031
+ this.type === types.string ||
14032
+ this.type === types.bracketL ||
14033
+ this.type.keyword
14034
+ )
14035
+ };
14036
+
14037
+ pp$1.parseClassElementName = function(element) {
14038
+ if (this.type === types.privateId) {
14039
+ if (this.value === "constructor") {
14040
+ this.raise(this.start, "Classes can't have an element named '#constructor'");
13967
14041
  }
14042
+ element.computed = false;
14043
+ element.key = this.parsePrivateIdent();
14044
+ } else {
14045
+ this.parsePropertyName(element);
13968
14046
  }
13969
- if (!method.key) { this.parsePropertyName(method); }
14047
+ };
14048
+
14049
+ pp$1.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
14050
+ // Check key and flags
13970
14051
  var key = method.key;
13971
- var allowsDirectSuper = false;
13972
- if (!method.computed && !method.static && (key.type === "Identifier" && key.name === "constructor" ||
13973
- key.type === "Literal" && key.value === "constructor")) {
13974
- if (method.kind !== "method") { this.raise(key.start, "Constructor can't have get/set modifier"); }
14052
+ if (method.kind === "constructor") {
13975
14053
  if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
13976
14054
  if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
13977
- method.kind = "constructor";
13978
- allowsDirectSuper = constructorAllowsSuper;
13979
- } else if (method.static && key.type === "Identifier" && key.name === "prototype") {
14055
+ } else if (method.static && checkKeyName(method, "prototype")) {
13980
14056
  this.raise(key.start, "Classes may not have a static property named prototype");
13981
14057
  }
13982
- this.parseClassMethod(method, isGenerator, isAsync, allowsDirectSuper);
13983
- if (method.kind === "get" && method.value.params.length !== 0)
13984
- { this.raiseRecoverable(method.value.start, "getter should have no params"); }
13985
- if (method.kind === "set" && method.value.params.length !== 1)
13986
- { this.raiseRecoverable(method.value.start, "setter should have exactly one param"); }
13987
- if (method.kind === "set" && method.value.params[0].type === "RestElement")
13988
- { this.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params"); }
13989
- return method
13990
- };
13991
14058
 
13992
- pp$1.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
13993
- method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
14059
+ // Parse value
14060
+ var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
14061
+
14062
+ // Check value
14063
+ if (method.kind === "get" && value.params.length !== 0)
14064
+ { this.raiseRecoverable(value.start, "getter should have no params"); }
14065
+ if (method.kind === "set" && value.params.length !== 1)
14066
+ { this.raiseRecoverable(value.start, "setter should have exactly one param"); }
14067
+ if (method.kind === "set" && value.params[0].type === "RestElement")
14068
+ { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); }
14069
+
13994
14070
  return this.finishNode(method, "MethodDefinition")
13995
14071
  };
13996
14072
 
14073
+ pp$1.parseClassField = function(field) {
14074
+ if (checkKeyName(field, "constructor")) {
14075
+ this.raise(field.key.start, "Classes can't have a field named 'constructor'");
14076
+ } else if (field.static && checkKeyName(field, "prototype")) {
14077
+ this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
14078
+ }
14079
+
14080
+ if (this.eat(types.eq)) {
14081
+ // To raise SyntaxError if 'arguments' exists in the initializer.
14082
+ var scope = this.currentThisScope();
14083
+ var inClassFieldInit = scope.inClassFieldInit;
14084
+ scope.inClassFieldInit = true;
14085
+ field.value = this.parseMaybeAssign();
14086
+ scope.inClassFieldInit = inClassFieldInit;
14087
+ } else {
14088
+ field.value = null;
14089
+ }
14090
+ this.semicolon();
14091
+
14092
+ return this.finishNode(field, "PropertyDefinition")
14093
+ };
14094
+
13997
14095
  pp$1.parseClassId = function(node, isStatement) {
13998
14096
  if (this.type === types.name) {
13999
14097
  node.id = this.parseIdent();
@@ -14010,6 +14108,65 @@ pp$1.parseClassSuper = function(node) {
14010
14108
  node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
14011
14109
  };
14012
14110
 
14111
+ pp$1.enterClassBody = function() {
14112
+ var element = {declared: Object.create(null), used: []};
14113
+ this.privateNameStack.push(element);
14114
+ return element.declared
14115
+ };
14116
+
14117
+ pp$1.exitClassBody = function() {
14118
+ var ref = this.privateNameStack.pop();
14119
+ var declared = ref.declared;
14120
+ var used = ref.used;
14121
+ var len = this.privateNameStack.length;
14122
+ var parent = len === 0 ? null : this.privateNameStack[len - 1];
14123
+ for (var i = 0; i < used.length; ++i) {
14124
+ var id = used[i];
14125
+ if (!has(declared, id.name)) {
14126
+ if (parent) {
14127
+ parent.used.push(id);
14128
+ } else {
14129
+ this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class"));
14130
+ }
14131
+ }
14132
+ }
14133
+ };
14134
+
14135
+ function isPrivateNameConflicted(privateNameMap, element) {
14136
+ var name = element.key.name;
14137
+ var curr = privateNameMap[name];
14138
+
14139
+ var next = "true";
14140
+ if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
14141
+ next = (element.static ? "s" : "i") + element.kind;
14142
+ }
14143
+
14144
+ // `class { get #a(){}; static set #a(_){} }` is also conflict.
14145
+ if (
14146
+ curr === "iget" && next === "iset" ||
14147
+ curr === "iset" && next === "iget" ||
14148
+ curr === "sget" && next === "sset" ||
14149
+ curr === "sset" && next === "sget"
14150
+ ) {
14151
+ privateNameMap[name] = "true";
14152
+ return false
14153
+ } else if (!curr) {
14154
+ privateNameMap[name] = next;
14155
+ return false
14156
+ } else {
14157
+ return true
14158
+ }
14159
+ }
14160
+
14161
+ function checkKeyName(node, name) {
14162
+ var computed = node.computed;
14163
+ var key = node.key;
14164
+ return !computed && (
14165
+ key.type === "Identifier" && key.name === name ||
14166
+ key.type === "Literal" && key.value === name
14167
+ )
14168
+ }
14169
+
14013
14170
  // Parses module export declaration.
14014
14171
 
14015
14172
  pp$1.parseExport = function(node, exports) {
@@ -14628,13 +14785,13 @@ pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) {
14628
14785
  // and object pattern might appear (so it's possible to raise
14629
14786
  // delayed syntax error at correct position).
14630
14787
 
14631
- pp$3.parseExpression = function(noIn, refDestructuringErrors) {
14788
+ pp$3.parseExpression = function(forInit, refDestructuringErrors) {
14632
14789
  var startPos = this.start, startLoc = this.startLoc;
14633
- var expr = this.parseMaybeAssign(noIn, refDestructuringErrors);
14790
+ var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
14634
14791
  if (this.type === types.comma) {
14635
14792
  var node = this.startNodeAt(startPos, startLoc);
14636
14793
  node.expressions = [expr];
14637
- while (this.eat(types.comma)) { node.expressions.push(this.parseMaybeAssign(noIn, refDestructuringErrors)); }
14794
+ while (this.eat(types.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
14638
14795
  return this.finishNode(node, "SequenceExpression")
14639
14796
  }
14640
14797
  return expr
@@ -14643,9 +14800,9 @@ pp$3.parseExpression = function(noIn, refDestructuringErrors) {
14643
14800
  // Parse an assignment expression. This includes applications of
14644
14801
  // operators like `+=`.
14645
14802
 
14646
- pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
14803
+ pp$3.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
14647
14804
  if (this.isContextual("yield")) {
14648
- if (this.inGenerator) { return this.parseYield(noIn) }
14805
+ if (this.inGenerator) { return this.parseYield(forInit) }
14649
14806
  // The tokenizer will assume an expression is allowed after
14650
14807
  // `yield`, but this isn't that kind of yield
14651
14808
  else { this.exprAllowed = false; }
@@ -14662,9 +14819,11 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
14662
14819
  }
14663
14820
 
14664
14821
  var startPos = this.start, startLoc = this.startLoc;
14665
- if (this.type === types.parenL || this.type === types.name)
14666
- { this.potentialArrowAt = this.start; }
14667
- var left = this.parseMaybeConditional(noIn, refDestructuringErrors);
14822
+ if (this.type === types.parenL || this.type === types.name) {
14823
+ this.potentialArrowAt = this.start;
14824
+ this.potentialArrowInForAwait = forInit === "await";
14825
+ }
14826
+ var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
14668
14827
  if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
14669
14828
  if (this.type.isAssign) {
14670
14829
  var node = this.startNodeAt(startPos, startLoc);
@@ -14682,7 +14841,7 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
14682
14841
  { this.checkLValSimple(left); }
14683
14842
  node.left = left;
14684
14843
  this.next();
14685
- node.right = this.parseMaybeAssign(noIn);
14844
+ node.right = this.parseMaybeAssign(forInit);
14686
14845
  return this.finishNode(node, "AssignmentExpression")
14687
14846
  } else {
14688
14847
  if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
@@ -14694,16 +14853,16 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
14694
14853
 
14695
14854
  // Parse a ternary conditional (`?:`) operator.
14696
14855
 
14697
- pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) {
14856
+ pp$3.parseMaybeConditional = function(forInit, refDestructuringErrors) {
14698
14857
  var startPos = this.start, startLoc = this.startLoc;
14699
- var expr = this.parseExprOps(noIn, refDestructuringErrors);
14858
+ var expr = this.parseExprOps(forInit, refDestructuringErrors);
14700
14859
  if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
14701
14860
  if (this.eat(types.question)) {
14702
14861
  var node = this.startNodeAt(startPos, startLoc);
14703
14862
  node.test = expr;
14704
14863
  node.consequent = this.parseMaybeAssign();
14705
14864
  this.expect(types.colon);
14706
- node.alternate = this.parseMaybeAssign(noIn);
14865
+ node.alternate = this.parseMaybeAssign(forInit);
14707
14866
  return this.finishNode(node, "ConditionalExpression")
14708
14867
  }
14709
14868
  return expr
@@ -14711,11 +14870,11 @@ pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) {
14711
14870
 
14712
14871
  // Start the precedence parser.
14713
14872
 
14714
- pp$3.parseExprOps = function(noIn, refDestructuringErrors) {
14873
+ pp$3.parseExprOps = function(forInit, refDestructuringErrors) {
14715
14874
  var startPos = this.start, startLoc = this.startLoc;
14716
14875
  var expr = this.parseMaybeUnary(refDestructuringErrors, false);
14717
14876
  if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
14718
- return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn)
14877
+ return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
14719
14878
  };
14720
14879
 
14721
14880
  // Parse binary operators with the operator precedence parsing
@@ -14724,9 +14883,9 @@ pp$3.parseExprOps = function(noIn, refDestructuringErrors) {
14724
14883
  // defer further parser to one of its callers when it encounters an
14725
14884
  // operator that has a lower precedence than the set it is parsing.
14726
14885
 
14727
- pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
14886
+ pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
14728
14887
  var prec = this.type.binop;
14729
- if (prec != null && (!noIn || this.type !== types._in)) {
14888
+ if (prec != null && (!forInit || this.type !== types._in)) {
14730
14889
  if (prec > minPrec) {
14731
14890
  var logical = this.type === types.logicalOR || this.type === types.logicalAND;
14732
14891
  var coalesce = this.type === types.coalesce;
@@ -14738,12 +14897,12 @@ pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
14738
14897
  var op = this.value;
14739
14898
  this.next();
14740
14899
  var startPos = this.start, startLoc = this.startLoc;
14741
- var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
14900
+ var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, forInit);
14742
14901
  var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
14743
14902
  if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) {
14744
14903
  this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
14745
14904
  }
14746
- return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)
14905
+ return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
14747
14906
  }
14748
14907
  }
14749
14908
  return left
@@ -14759,7 +14918,7 @@ pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {
14759
14918
 
14760
14919
  // Parse unary operators, both prefix and postfix.
14761
14920
 
14762
- pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
14921
+ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec) {
14763
14922
  var startPos = this.start, startLoc = this.startLoc, expr;
14764
14923
  if (this.isContextual("await") && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction))) {
14765
14924
  expr = this.parseAwait();
@@ -14769,12 +14928,14 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
14769
14928
  node.operator = this.value;
14770
14929
  node.prefix = true;
14771
14930
  this.next();
14772
- node.argument = this.parseMaybeUnary(null, true);
14931
+ node.argument = this.parseMaybeUnary(null, true, update);
14773
14932
  this.checkExpressionErrors(refDestructuringErrors, true);
14774
14933
  if (update) { this.checkLValSimple(node.argument); }
14775
14934
  else if (this.strict && node.operator === "delete" &&
14776
14935
  node.argument.type === "Identifier")
14777
14936
  { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
14937
+ else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
14938
+ { this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
14778
14939
  else { sawUnary = true; }
14779
14940
  expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
14780
14941
  } else {
@@ -14791,12 +14952,23 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
14791
14952
  }
14792
14953
  }
14793
14954
 
14794
- if (!sawUnary && this.eat(types.starstar))
14795
- { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) }
14796
- else
14797
- { return expr }
14955
+ if (!incDec && this.eat(types.starstar)) {
14956
+ if (sawUnary)
14957
+ { this.unexpected(this.lastTokStart); }
14958
+ else
14959
+ { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) }
14960
+ } else {
14961
+ return expr
14962
+ }
14798
14963
  };
14799
14964
 
14965
+ function isPrivateFieldAccess(node) {
14966
+ return (
14967
+ node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
14968
+ node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
14969
+ )
14970
+ }
14971
+
14800
14972
  // Parse call, dot, and `[]`-subscript expressions.
14801
14973
 
14802
14974
  pp$3.parseExprSubscripts = function(refDestructuringErrors) {
@@ -14808,6 +14980,7 @@ pp$3.parseExprSubscripts = function(refDestructuringErrors) {
14808
14980
  if (refDestructuringErrors && result.type === "MemberExpression") {
14809
14981
  if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
14810
14982
  if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
14983
+ if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }
14811
14984
  }
14812
14985
  return result
14813
14986
  };
@@ -14844,9 +15017,15 @@ pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
14844
15017
  if (computed || (optional && this.type !== types.parenL && this.type !== types.backQuote) || this.eat(types.dot)) {
14845
15018
  var node = this.startNodeAt(startPos, startLoc);
14846
15019
  node.object = base;
14847
- node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never");
15020
+ if (computed) {
15021
+ node.property = this.parseExpression();
15022
+ this.expect(types.bracketR);
15023
+ } else if (this.type === types.privateId && base.type !== "Super") {
15024
+ node.property = this.parsePrivateIdent();
15025
+ } else {
15026
+ node.property = this.parseIdent(this.options.allowReserved !== "never");
15027
+ }
14848
15028
  node.computed = !!computed;
14849
- if (computed) { this.expect(types.bracketR); }
14850
15029
  if (optionalSupported) {
14851
15030
  node.optional = optional;
14852
15031
  }
@@ -14932,7 +15111,8 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
14932
15111
  if (canBeArrow && !this.canInsertSemicolon()) {
14933
15112
  if (this.eat(types.arrow))
14934
15113
  { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) }
14935
- if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc) {
15114
+ if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc &&
15115
+ (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
14936
15116
  id = this.parseIdent(false);
14937
15117
  if (this.canInsertSemicolon() || !this.eat(types.arrow))
14938
15118
  { this.unexpected(); }
@@ -15050,7 +15230,7 @@ pp$3.parseImportMeta = function(node) {
15050
15230
  { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
15051
15231
  if (containsEsc)
15052
15232
  { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
15053
- if (this.options.sourceType !== "module")
15233
+ if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere)
15054
15234
  { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
15055
15235
 
15056
15236
  return this.finishNode(node, "MetaProperty")
@@ -15518,6 +15698,8 @@ pp$3.checkUnreserved = function(ref) {
15518
15698
  { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
15519
15699
  if (this.inAsync && name === "await")
15520
15700
  { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
15701
+ if (this.currentThisScope().inClassFieldInit && name === "arguments")
15702
+ { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
15521
15703
  if (this.keywords.test(name))
15522
15704
  { this.raise(start, ("Unexpected keyword '" + name + "'")); }
15523
15705
  if (this.options.ecmaVersion < 6 &&
@@ -15562,9 +15744,29 @@ pp$3.parseIdent = function(liberal, isBinding) {
15562
15744
  return node
15563
15745
  };
15564
15746
 
15747
+ pp$3.parsePrivateIdent = function() {
15748
+ var node = this.startNode();
15749
+ if (this.type === types.privateId) {
15750
+ node.name = this.value;
15751
+ } else {
15752
+ this.unexpected();
15753
+ }
15754
+ this.next();
15755
+ this.finishNode(node, "PrivateIdentifier");
15756
+
15757
+ // For validating existence
15758
+ if (this.privateNameStack.length === 0) {
15759
+ this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
15760
+ } else {
15761
+ this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
15762
+ }
15763
+
15764
+ return node
15765
+ };
15766
+
15565
15767
  // Parses yield expression inside generator.
15566
15768
 
15567
- pp$3.parseYield = function(noIn) {
15769
+ pp$3.parseYield = function(forInit) {
15568
15770
  if (!this.yieldPos) { this.yieldPos = this.start; }
15569
15771
 
15570
15772
  var node = this.startNode();
@@ -15574,7 +15776,7 @@ pp$3.parseYield = function(noIn) {
15574
15776
  node.argument = null;
15575
15777
  } else {
15576
15778
  node.delegate = this.eat(types.star);
15577
- node.argument = this.parseMaybeAssign(noIn);
15779
+ node.argument = this.parseMaybeAssign(forInit);
15578
15780
  }
15579
15781
  return this.finishNode(node, "YieldExpression")
15580
15782
  };
@@ -15622,6 +15824,8 @@ var Scope = function Scope(flags) {
15622
15824
  this.lexical = [];
15623
15825
  // A list of lexically-declared FunctionDeclaration names in the current lexical scope
15624
15826
  this.functions = [];
15827
+ // A switch to disallow the identifier reference 'arguments'
15828
+ this.inClassFieldInit = false;
15625
15829
  };
15626
15830
 
15627
15831
  // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
@@ -17098,9 +17302,9 @@ pp$9.readToken = function(code) {
17098
17302
 
17099
17303
  pp$9.fullCharCodeAtPos = function() {
17100
17304
  var code = this.input.charCodeAt(this.pos);
17101
- if (code <= 0xd7ff || code >= 0xe000) { return code }
17305
+ if (code <= 0xd7ff || code >= 0xdc00) { return code }
17102
17306
  var next = this.input.charCodeAt(this.pos + 1);
17103
- return (code << 10) + next - 0x35fdc00
17307
+ return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
17104
17308
  };
17105
17309
 
17106
17310
  pp$9.skipBlockComment = function() {
@@ -17319,6 +17523,20 @@ pp$9.readToken_question = function() { // '?'
17319
17523
  return this.finishOp(types.question, 1)
17320
17524
  };
17321
17525
 
17526
+ pp$9.readToken_numberSign = function() { // '#'
17527
+ var ecmaVersion = this.options.ecmaVersion;
17528
+ var code = 35; // '#'
17529
+ if (ecmaVersion >= 13) {
17530
+ ++this.pos;
17531
+ code = this.fullCharCodeAtPos();
17532
+ if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
17533
+ return this.finishToken(types.privateId, this.readWord1())
17534
+ }
17535
+ }
17536
+
17537
+ this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
17538
+ };
17539
+
17322
17540
  pp$9.getTokenFromCode = function(code) {
17323
17541
  switch (code) {
17324
17542
  // The interpretation of a dot depends on whether it is followed
@@ -17390,6 +17608,9 @@ pp$9.getTokenFromCode = function(code) {
17390
17608
 
17391
17609
  case 126: // '~'
17392
17610
  return this.finishOp(types.prefix, 1)
17611
+
17612
+ case 35: // '#'
17613
+ return this.readToken_numberSign()
17393
17614
  }
17394
17615
 
17395
17616
  this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
@@ -17801,7 +18022,7 @@ pp$9.readWord = function() {
17801
18022
 
17802
18023
  // Acorn is a tiny, fast JavaScript parser written in JavaScript.
17803
18024
 
17804
- var version = "8.0.5";
18025
+ var version = "8.2.4";
17805
18026
 
17806
18027
  Parser.acorn = {
17807
18028
  Parser: Parser,
@@ -17836,47 +18057,6 @@ function parse(input, options) {
17836
18057
  return Parser.parse(input, options)
17837
18058
  }
17838
18059
 
17839
- // This function tries to parse a single expression at a given
17840
- // offset in a string. Useful for parsing mixed-language formats
17841
- // that embed JavaScript expressions.
17842
-
17843
- function parseExpressionAt(input, pos, options) {
17844
- return Parser.parseExpressionAt(input, pos, options)
17845
- }
17846
-
17847
- // Acorn is organized as a tokenizer and a recursive-descent parser.
17848
- // The `tokenizer` export provides an interface to the tokenizer.
17849
-
17850
- function tokenizer(input, options) {
17851
- return Parser.tokenizer(input, options)
17852
- }
17853
-
17854
- var acorn = {
17855
- __proto__: null,
17856
- Node: Node,
17857
- Parser: Parser,
17858
- Position: Position,
17859
- SourceLocation: SourceLocation,
17860
- TokContext: TokContext,
17861
- Token: Token,
17862
- TokenType: TokenType,
17863
- defaultOptions: defaultOptions,
17864
- getLineInfo: getLineInfo,
17865
- isIdentifierChar: isIdentifierChar,
17866
- isIdentifierStart: isIdentifierStart,
17867
- isNewLine: isNewLine,
17868
- keywordTypes: keywords$1,
17869
- lineBreak: lineBreak,
17870
- lineBreakG: lineBreakG,
17871
- nonASCIIwhitespace: nonASCIIwhitespace,
17872
- parse: parse,
17873
- parseExpressionAt: parseExpressionAt,
17874
- tokContexts: types$1,
17875
- tokTypes: types,
17876
- tokenizer: tokenizer,
17877
- version: version
17878
- };
17879
-
17880
18060
  class GlobalScope extends Scope$1 {
17881
18061
  constructor() {
17882
18062
  super();
@@ -19104,7 +19284,7 @@ base.ImportDeclaration = function (node, st, c) {
19104
19284
  base.ImportExpression = function (node, st, c) {
19105
19285
  c(node.source, st, "Expression");
19106
19286
  };
19107
- base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore;
19287
+ base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
19108
19288
 
19109
19289
  base.TaggedTemplateExpression = function (node, st, c) {
19110
19290
  c(node.tag, st, "Expression");
@@ -19124,9 +19304,9 @@ base.ClassBody = function (node, st, c) {
19124
19304
  c(elt, st);
19125
19305
  }
19126
19306
  };
19127
- base.MethodDefinition = base.Property = function (node, st, c) {
19307
+ base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
19128
19308
  if (node.computed) { c(node.key, st, "Expression"); }
19129
- c(node.value, st, "Expression");
19309
+ if (node.value) { c(node.value, st, "Expression"); }
19130
19310
  };
19131
19311
 
19132
19312
  // patch up acorn-walk until class-fields are officially supported
@@ -19138,10 +19318,30 @@ base.PropertyDefinition = function (node, st, c) {
19138
19318
  c(node.value, st, 'Expression');
19139
19319
  }
19140
19320
  };
19321
+ function isOnlyWhitespaceOrComments(code) {
19322
+ // streamline the typical case
19323
+ if (/^\s*$/.test(code))
19324
+ return true;
19325
+ try {
19326
+ // successful only if it's a valid Program without statements
19327
+ const ast = parse(code, { ecmaVersion: 'latest' });
19328
+ return ast.body && ast.body.length === 0;
19329
+ }
19330
+ catch (_a) {
19331
+ // should only be reached by invalid annotations like:
19332
+ //
19333
+ // foo() /*@__PURE__*/ /* other */, bar();
19334
+ //
19335
+ // where `code` is " /* other */, "
19336
+ }
19337
+ return false;
19338
+ }
19141
19339
  function handlePureAnnotationsOfNode(node, state, type = node.type) {
19142
19340
  let commentNode = state.commentNodes[state.commentIndex];
19143
19341
  while (commentNode && node.start >= commentNode.end) {
19144
- markPureNode(node, commentNode);
19342
+ const between = state.code.substring(commentNode.end, node.start);
19343
+ if (isOnlyWhitespaceOrComments(between))
19344
+ markPureNode(node, commentNode);
19145
19345
  commentNode = state.commentNodes[++state.commentIndex];
19146
19346
  }
19147
19347
  if (commentNode && commentNode.end <= node.end) {
@@ -19169,8 +19369,9 @@ function markPureNode(node, comment) {
19169
19369
  }
19170
19370
  const pureCommentRegex = /[@#]__PURE__/;
19171
19371
  const isPureComment = (comment) => pureCommentRegex.test(comment.value);
19172
- function markPureCallExpressions(comments, esTreeAst) {
19372
+ function markPureCallExpressions(comments, esTreeAst, code) {
19173
19373
  handlePureAnnotationsOfNode(esTreeAst, {
19374
+ code,
19174
19375
  commentIndex: 0,
19175
19376
  commentNodes: comments.filter(isPureComment)
19176
19377
  });
@@ -19277,7 +19478,7 @@ class Graph {
19277
19478
  onCommentOrig.push(...comments);
19278
19479
  }
19279
19480
  options.onComment = onCommentOrig;
19280
- markPureCallExpressions(comments, ast);
19481
+ markPureCallExpressions(comments, ast, code);
19281
19482
  return ast;
19282
19483
  }
19283
19484
  getCache() {
@@ -19401,363 +19602,6 @@ function ensureArray(items) {
19401
19602
  return [];
19402
19603
  }
19403
19604
 
19404
- function getAugmentedNamespace(n) {
19405
- if (n.__esModule) return n;
19406
- var a = Object.defineProperty({}, '__esModule', {value: true});
19407
- Object.keys(n).forEach(function (k) {
19408
- var d = Object.getOwnPropertyDescriptor(n, k);
19409
- Object.defineProperty(a, k, d.get ? d : {
19410
- enumerable: true,
19411
- get: function () {
19412
- return n[k];
19413
- }
19414
- });
19415
- });
19416
- return a;
19417
- }
19418
-
19419
- var require$$1 = /*@__PURE__*/getAugmentedNamespace(acorn);
19420
-
19421
- const getPrototype = Object.getPrototypeOf || (o => o.__proto__);
19422
-
19423
- const getAcorn$1 = Parser => {
19424
- if (Parser.acorn) return Parser.acorn
19425
-
19426
- const acorn = require$$1;
19427
-
19428
- if (acorn.version.indexOf("6.") != 0 && acorn.version.indexOf("6.0.") == 0 && acorn.version.indexOf("7.") != 0) {
19429
- throw new Error(`acorn-private-class-elements requires acorn@^6.1.0 or acorn@7.0.0, not ${acorn.version}`)
19430
- }
19431
-
19432
- // Make sure `Parser` comes from the same acorn as we `require`d,
19433
- // otherwise the comparisons fail.
19434
- for (let cur = Parser; cur && cur !== acorn.Parser; cur = getPrototype(cur)) {
19435
- if (cur !== acorn.Parser) {
19436
- throw new Error("acorn-private-class-elements does not support mixing different acorn copies")
19437
- }
19438
- }
19439
- return acorn
19440
- };
19441
-
19442
- var acornPrivateClassElements = function(Parser) {
19443
- // Only load this plugin once.
19444
- if (Parser.prototype.parsePrivateName) {
19445
- return Parser
19446
- }
19447
-
19448
- const acorn = getAcorn$1(Parser);
19449
-
19450
- Parser = class extends Parser {
19451
- _branch() {
19452
- this.__branch = this.__branch || new Parser({ecmaVersion: this.options.ecmaVersion}, this.input);
19453
- this.__branch.end = this.end;
19454
- this.__branch.pos = this.pos;
19455
- this.__branch.type = this.type;
19456
- this.__branch.value = this.value;
19457
- this.__branch.containsEsc = this.containsEsc;
19458
- return this.__branch
19459
- }
19460
-
19461
- parsePrivateClassElementName(element) {
19462
- element.computed = false;
19463
- element.key = this.parsePrivateName();
19464
- if (element.key.name == "constructor") this.raise(element.key.start, "Classes may not have a private element named constructor");
19465
- const accept = {get: "set", set: "get"}[element.kind];
19466
- const privateBoundNames = this._privateBoundNames;
19467
- if (Object.prototype.hasOwnProperty.call(privateBoundNames, element.key.name) && privateBoundNames[element.key.name] !== accept) {
19468
- this.raise(element.start, "Duplicate private element");
19469
- }
19470
- privateBoundNames[element.key.name] = element.kind || true;
19471
- delete this._unresolvedPrivateNames[element.key.name];
19472
- return element.key
19473
- }
19474
-
19475
- parsePrivateName() {
19476
- const node = this.startNode();
19477
- node.name = this.value;
19478
- this.next();
19479
- this.finishNode(node, "PrivateIdentifier");
19480
- if (this.options.allowReserved == "never") this.checkUnreserved(node);
19481
- return node
19482
- }
19483
-
19484
- // Parse # token
19485
- getTokenFromCode(code) {
19486
- if (code === 35) {
19487
- ++this.pos;
19488
- const word = this.readWord1();
19489
- return this.finishToken(this.privateIdentifierToken, word)
19490
- }
19491
- return super.getTokenFromCode(code)
19492
- }
19493
-
19494
- // Manage stacks and check for undeclared private names
19495
- parseClass(node, isStatement) {
19496
- const oldOuterPrivateBoundNames = this._outerPrivateBoundNames;
19497
- this._outerPrivateBoundNames = this._privateBoundNames;
19498
- this._privateBoundNames = Object.create(this._privateBoundNames || null);
19499
- const oldOuterUnresolvedPrivateNames = this._outerUnresolvedPrivateNames;
19500
- this._outerUnresolvedPrivateNames = this._unresolvedPrivateNames;
19501
- this._unresolvedPrivateNames = Object.create(null);
19502
-
19503
- const _return = super.parseClass(node, isStatement);
19504
-
19505
- const unresolvedPrivateNames = this._unresolvedPrivateNames;
19506
- this._privateBoundNames = this._outerPrivateBoundNames;
19507
- this._outerPrivateBoundNames = oldOuterPrivateBoundNames;
19508
- this._unresolvedPrivateNames = this._outerUnresolvedPrivateNames;
19509
- this._outerUnresolvedPrivateNames = oldOuterUnresolvedPrivateNames;
19510
- if (!this._unresolvedPrivateNames) {
19511
- const names = Object.keys(unresolvedPrivateNames);
19512
- if (names.length) {
19513
- names.sort((n1, n2) => unresolvedPrivateNames[n1] - unresolvedPrivateNames[n2]);
19514
- this.raise(unresolvedPrivateNames[names[0]], "Usage of undeclared private name");
19515
- }
19516
- } else Object.assign(this._unresolvedPrivateNames, unresolvedPrivateNames);
19517
- return _return
19518
- }
19519
-
19520
- // Class heritage is evaluated with outer private environment
19521
- parseClassSuper(node) {
19522
- const privateBoundNames = this._privateBoundNames;
19523
- this._privateBoundNames = this._outerPrivateBoundNames;
19524
- const unresolvedPrivateNames = this._unresolvedPrivateNames;
19525
- this._unresolvedPrivateNames = this._outerUnresolvedPrivateNames;
19526
- const _return = super.parseClassSuper(node);
19527
- this._privateBoundNames = privateBoundNames;
19528
- this._unresolvedPrivateNames = unresolvedPrivateNames;
19529
- return _return
19530
- }
19531
-
19532
- // Parse private element access
19533
- parseSubscript(base, startPos, startLoc, _noCalls, _maybeAsyncArrow, _optionalChained) {
19534
- const optionalSupported = this.options.ecmaVersion >= 11 && acorn.tokTypes.questionDot;
19535
- const branch = this._branch();
19536
- if (!(
19537
- (branch.eat(acorn.tokTypes.dot) || (optionalSupported && branch.eat(acorn.tokTypes.questionDot))) &&
19538
- branch.type == this.privateIdentifierToken
19539
- )) {
19540
- return super.parseSubscript.apply(this, arguments)
19541
- }
19542
- let optional = false;
19543
- if (!this.eat(acorn.tokTypes.dot)) {
19544
- this.expect(acorn.tokTypes.questionDot);
19545
- optional = true;
19546
- }
19547
- let node = this.startNodeAt(startPos, startLoc);
19548
- node.object = base;
19549
- node.computed = false;
19550
- if (optionalSupported) {
19551
- node.optional = optional;
19552
- }
19553
- if (this.type == this.privateIdentifierToken) {
19554
- if (base.type == "Super") {
19555
- this.raise(this.start, "Cannot access private element on super");
19556
- }
19557
- node.property = this.parsePrivateName();
19558
- if (!this._privateBoundNames || !this._privateBoundNames[node.property.name]) {
19559
- if (!this._unresolvedPrivateNames) {
19560
- this.raise(node.property.start, "Usage of undeclared private name");
19561
- }
19562
- this._unresolvedPrivateNames[node.property.name] = node.property.start;
19563
- }
19564
- } else {
19565
- node.property = this.parseIdent(true);
19566
- }
19567
- return this.finishNode(node, "MemberExpression")
19568
- }
19569
-
19570
- // Prohibit delete of private class elements
19571
- parseMaybeUnary(refDestructuringErrors, sawUnary) {
19572
- const _return = super.parseMaybeUnary(refDestructuringErrors, sawUnary);
19573
- if (_return.operator == "delete") {
19574
- if (_return.argument.type == "MemberExpression" && _return.argument.property.type == "PrivateIdentifier") {
19575
- this.raise(_return.start, "Private elements may not be deleted");
19576
- }
19577
- }
19578
- return _return
19579
- }
19580
- };
19581
- Parser.prototype.privateIdentifierToken = new acorn.TokenType("privateIdentifier");
19582
- return Parser
19583
- };
19584
-
19585
- const privateClassElements$1 = acornPrivateClassElements;
19586
-
19587
- var acornClassFields = function(Parser) {
19588
- const acorn = Parser.acorn || require$$1;
19589
- const tt = acorn.tokTypes;
19590
-
19591
- Parser = privateClassElements$1(Parser);
19592
- return class extends Parser {
19593
- _maybeParseFieldValue(field) {
19594
- if (this.eat(tt.eq)) {
19595
- const oldInFieldValue = this._inFieldValue;
19596
- this._inFieldValue = true;
19597
- if (this.type === tt.name && this.value === "await" && (this.inAsync || this.options.allowAwaitOutsideFunction)) {
19598
- field.value = this.parseAwait();
19599
- } else field.value = this.parseExpression();
19600
- this._inFieldValue = oldInFieldValue;
19601
- } else field.value = null;
19602
- }
19603
-
19604
- // Parse fields
19605
- parseClassElement(_constructorAllowsSuper) {
19606
- if (this.options.ecmaVersion >= 8 && (this.type == tt.name || this.type.keyword || this.type == this.privateIdentifierToken || this.type == tt.bracketL || this.type == tt.string || this.type == tt.num)) {
19607
- const branch = this._branch();
19608
- if (branch.type == tt.bracketL) {
19609
- let count = 0;
19610
- do {
19611
- if (branch.eat(tt.bracketL)) ++count;
19612
- else if (branch.eat(tt.bracketR)) --count;
19613
- else branch.next();
19614
- } while (count > 0)
19615
- } else branch.next(true);
19616
- let isField = branch.type == tt.eq || branch.type == tt.semi;
19617
- if (!isField && branch.canInsertSemicolon()) {
19618
- isField = branch.type != tt.parenL;
19619
- }
19620
- if (isField) {
19621
- const node = this.startNode();
19622
- if (this.type == this.privateIdentifierToken) {
19623
- this.parsePrivateClassElementName(node);
19624
- } else {
19625
- this.parsePropertyName(node);
19626
- }
19627
- if ((node.key.type === "Identifier" && node.key.name === "constructor") ||
19628
- (node.key.type === "Literal" && node.key.value === "constructor")) {
19629
- this.raise(node.key.start, "Classes may not have a field called constructor");
19630
- }
19631
- this.enterScope(64 | 2 | 1); // See acorn's scopeflags.js
19632
- this._maybeParseFieldValue(node);
19633
- this.exitScope();
19634
- this.finishNode(node, "PropertyDefinition");
19635
- this.semicolon();
19636
- return node
19637
- }
19638
- }
19639
-
19640
- return super.parseClassElement.apply(this, arguments)
19641
- }
19642
-
19643
- // Prohibit arguments in class field initializers
19644
- parseIdent(liberal, isBinding) {
19645
- const ident = super.parseIdent(liberal, isBinding);
19646
- if (this._inFieldValue && ident.name == "arguments") this.raise(ident.start, "A class field initializer may not contain arguments");
19647
- return ident
19648
- }
19649
- }
19650
- };
19651
-
19652
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
19653
-
19654
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
19655
- function privateMethods(Parser) {
19656
- const ExtendedParser = acornPrivateClassElements(Parser);
19657
-
19658
- return class extends ExtendedParser {
19659
- // Parse private methods
19660
- parseClassElement(_constructorAllowsSuper) {
19661
- const oldInClassMemberName = this._inClassMemberName;
19662
- this._inClassMemberName = true;
19663
- const result = super.parseClassElement.apply(this, arguments);
19664
- this._inClassMemberName = oldInClassMemberName;
19665
- return result
19666
- }
19667
-
19668
- parsePropertyName(prop) {
19669
- const isPrivate = this.options.ecmaVersion >= 8 && this._inClassMemberName && this.type == this.privateIdentifierToken && !prop.static;
19670
- this._inClassMemberName = false;
19671
- if (!isPrivate) return super.parsePropertyName(prop)
19672
- return this.parsePrivateClassElementName(prop)
19673
- }
19674
- }
19675
- }
19676
-
19677
- const privateClassElements = acornPrivateClassElements;
19678
-
19679
- var acornStaticClassFeatures = function(Parser) {
19680
- const ExtendedParser = privateClassElements(Parser);
19681
-
19682
- const acorn = Parser.acorn || require$$1;
19683
- const tt = acorn.tokTypes;
19684
-
19685
- return class extends ExtendedParser {
19686
- _maybeParseFieldValue(field) {
19687
- if (this.eat(tt.eq)) {
19688
- const oldInFieldValue = this._inStaticFieldScope;
19689
- this._inStaticFieldScope = this.currentThisScope();
19690
- field.value = this.parseExpression();
19691
- this._inStaticFieldScope = oldInFieldValue;
19692
- } else field.value = null;
19693
- }
19694
-
19695
- // Parse fields
19696
- parseClassElement(_constructorAllowsSuper) {
19697
- if (this.options.ecmaVersion < 8 || !this.isContextual("static")) {
19698
- return super.parseClassElement.apply(this, arguments)
19699
- }
19700
-
19701
- const branch = this._branch();
19702
- branch.next();
19703
- if ([tt.name, tt.bracketL, tt.string, tt.num, this.privateIdentifierToken].indexOf(branch.type) == -1 && !branch.type.keyword) {
19704
- return super.parseClassElement.apply(this, arguments)
19705
- }
19706
- if (branch.type == tt.bracketL) {
19707
- let count = 0;
19708
- do {
19709
- if (branch.eat(tt.bracketL)) ++count;
19710
- else if (branch.eat(tt.bracketR)) --count;
19711
- else branch.next();
19712
- } while (count > 0)
19713
- } else branch.next();
19714
- if (branch.type != tt.eq && !branch.canInsertSemicolon() && branch.type != tt.semi) {
19715
- return super.parseClassElement.apply(this, arguments)
19716
- }
19717
-
19718
- const node = this.startNode();
19719
- node.static = this.eatContextual("static");
19720
- if (this.type == this.privateIdentifierToken) {
19721
- this.parsePrivateClassElementName(node);
19722
- } else {
19723
- this.parsePropertyName(node);
19724
- }
19725
- if ((node.key.type === "Identifier" && node.key.name === "constructor") ||
19726
- (node.key.type === "Literal" && !node.computed && node.key.value === "constructor")) {
19727
- this.raise(node.key.start, "Classes may not have a field called constructor");
19728
- }
19729
- if ((node.key.name || node.key.value) === "prototype" && !node.computed) {
19730
- this.raise(node.key.start, "Classes may not have a static property named prototype");
19731
- }
19732
-
19733
- this.enterScope(64 | 2 | 1); // See acorn's scopeflags.js
19734
- this._maybeParseFieldValue(node);
19735
- this.exitScope();
19736
- this.finishNode(node, "PropertyDefinition");
19737
- this.semicolon();
19738
- return node
19739
- }
19740
-
19741
- // Parse private static methods
19742
- parsePropertyName(prop) {
19743
- if (prop.static && this.type == this.privateIdentifierToken) {
19744
- this.parsePrivateClassElementName(prop);
19745
- } else {
19746
- super.parsePropertyName(prop);
19747
- }
19748
- }
19749
-
19750
- // Prohibit arguments in class field initializers
19751
- parseIdent(liberal, isBinding) {
19752
- const ident = super.parseIdent(liberal, isBinding);
19753
- if (this._inStaticFieldScope && this.currentThisScope() === this._inStaticFieldScope && ident.name == "arguments") {
19754
- this.raise(ident.start, "A static class field initializer may not contain arguments");
19755
- }
19756
- return ident
19757
- }
19758
- }
19759
- };
19760
-
19761
19605
  const defaultOnWarn = warning => console.warn(warning.message || warning);
19762
19606
  function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignoredKeys = /$./) {
19763
19607
  const validOptionSet = new Set(validOptions);
@@ -19830,12 +19674,7 @@ const getAcorn = (config) => ({
19830
19674
  sourceType: 'module',
19831
19675
  ...config.acorn
19832
19676
  });
19833
- const getAcornInjectPlugins = (config) => [
19834
- acornClassFields,
19835
- privateMethods,
19836
- acornStaticClassFeatures,
19837
- ...ensureArray(config.acornInjectPlugins)
19838
- ];
19677
+ const getAcornInjectPlugins = (config) => ensureArray(config.acornInjectPlugins);
19839
19678
  const getCache = (config) => {
19840
19679
  var _a;
19841
19680
  return ((_a = config.cache) === null || _a === void 0 ? void 0 : _a.cache) || config.cache;
@@ -20236,7 +20075,10 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
20236
20075
  }
20237
20076
  return configManualChunks || {};
20238
20077
  };
20239
- const getMinifyInternalExports = (config, format, compact) => { var _a; return (_a = config.minifyInternalExports) !== null && _a !== void 0 ? _a : (compact || format === 'es' || format === 'system'); };
20078
+ const getMinifyInternalExports = (config, format, compact) => {
20079
+ var _a;
20080
+ return (_a = config.minifyInternalExports) !== null && _a !== void 0 ? _a : (compact || format === 'es' || format === 'system');
20081
+ };
20240
20082
 
20241
20083
  function rollup(rawInputOptions) {
20242
20084
  return rollupInternal(rawInputOptions, null);
@@ -20453,4 +20295,4 @@ function watch(configs) {
20453
20295
  return emitter;
20454
20296
  }
20455
20297
 
20456
- export { defaultOnWarn, ensureArray, fseventsImporter, getAugmentedNamespace, rollup, rollupInternal, version$1 as version, warnUnknownOptions, watch };
20298
+ export { defaultOnWarn, ensureArray, fseventsImporter, rollup, rollupInternal, version$1 as version, warnUnknownOptions, watch };