rollup 2.74.1 → 2.75.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.74.1
4
- Thu, 19 May 2022 17:50:11 GMT - commit e823eded9920d6082cc8c1afcf591b716ab6b160
3
+ Rollup.js v2.75.0
4
+ Fri, 27 May 2022 08:24:10 GMT - commit c1d62262beb6e743a1b507aecad99cb03f446741
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -14,7 +14,7 @@ import { createHash as createHash$1 } from 'crypto';
14
14
  import { promises } from 'fs';
15
15
  import { EventEmitter } from 'events';
16
16
 
17
- var version$1 = "2.74.1";
17
+ var version$1 = "2.75.0";
18
18
 
19
19
  var charToInteger = {};
20
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -1588,6 +1588,7 @@ class DiscriminatedPathTracker {
1588
1588
  }
1589
1589
 
1590
1590
  const UnknownValue = Symbol('Unknown Value');
1591
+ const UnknownTruthyValue = Symbol('Unknown Truthy Value');
1591
1592
  class ExpressionEntity {
1592
1593
  constructor() {
1593
1594
  this.included = false;
@@ -1616,7 +1617,7 @@ class ExpressionEntity {
1616
1617
  hasEffectsWhenCalledAtPath(_path, _callOptions, _context) {
1617
1618
  return true;
1618
1619
  }
1619
- include(_context, _includeChildrenRecursively) {
1620
+ include(_context, _includeChildrenRecursively, _options) {
1620
1621
  this.included = true;
1621
1622
  }
1622
1623
  includeCallArguments(context, args) {
@@ -1624,6 +1625,9 @@ class ExpressionEntity {
1624
1625
  arg.include(context, false);
1625
1626
  }
1626
1627
  }
1628
+ shouldBeIncluded(_context) {
1629
+ return true;
1630
+ }
1627
1631
  }
1628
1632
  const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
1629
1633
  })();
@@ -4665,9 +4669,9 @@ const stringReplace = {
4665
4669
  hasEffectsWhenCalled(callOptions, context) {
4666
4670
  const arg1 = callOptions.args[1];
4667
4671
  return (callOptions.args.length < 2 ||
4668
- (arg1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
4672
+ (typeof arg1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
4669
4673
  deoptimizeCache() { }
4670
- }) === UnknownValue &&
4674
+ }) === 'symbol' &&
4671
4675
  arg1.hasEffectsWhenCalledAtPath(EMPTY_PATH, {
4672
4676
  args: NO_ARGS,
4673
4677
  thisParam: null,
@@ -5222,8 +5226,7 @@ class NodeBase extends ExpressionEntity {
5222
5226
  continue;
5223
5227
  if (Array.isArray(value)) {
5224
5228
  for (const child of value) {
5225
- if (child !== null)
5226
- child.bind();
5229
+ child === null || child === void 0 ? void 0 : child.bind();
5227
5230
  }
5228
5231
  }
5229
5232
  else {
@@ -5246,7 +5249,7 @@ class NodeBase extends ExpressionEntity {
5246
5249
  continue;
5247
5250
  if (Array.isArray(value)) {
5248
5251
  for (const child of value) {
5249
- if (child !== null && child.hasEffects(context))
5252
+ if (child === null || child === void 0 ? void 0 : child.hasEffects(context))
5250
5253
  return true;
5251
5254
  }
5252
5255
  }
@@ -5255,7 +5258,7 @@ class NodeBase extends ExpressionEntity {
5255
5258
  }
5256
5259
  return false;
5257
5260
  }
5258
- include(context, includeChildrenRecursively) {
5261
+ include(context, includeChildrenRecursively, _options) {
5259
5262
  if (this.deoptimized === false)
5260
5263
  this.applyDeoptimizations();
5261
5264
  this.included = true;
@@ -5265,8 +5268,7 @@ class NodeBase extends ExpressionEntity {
5265
5268
  continue;
5266
5269
  if (Array.isArray(value)) {
5267
5270
  for (const child of value) {
5268
- if (child !== null)
5269
- child.include(context, includeChildrenRecursively);
5271
+ child === null || child === void 0 ? void 0 : child.include(context, includeChildrenRecursively);
5270
5272
  }
5271
5273
  }
5272
5274
  else {
@@ -5274,9 +5276,6 @@ class NodeBase extends ExpressionEntity {
5274
5276
  }
5275
5277
  }
5276
5278
  }
5277
- includeAsSingleStatement(context, includeChildrenRecursively) {
5278
- this.include(context, includeChildrenRecursively);
5279
- }
5280
5279
  /**
5281
5280
  * Override to perform special initialisation steps after the scope is initialised
5282
5281
  */
@@ -5323,8 +5322,7 @@ class NodeBase extends ExpressionEntity {
5323
5322
  continue;
5324
5323
  if (Array.isArray(value)) {
5325
5324
  for (const child of value) {
5326
- if (child !== null)
5327
- child.render(code, options);
5325
+ child === null || child === void 0 ? void 0 : child.render(code, options);
5328
5326
  }
5329
5327
  }
5330
5328
  else {
@@ -5335,7 +5333,28 @@ class NodeBase extends ExpressionEntity {
5335
5333
  shouldBeIncluded(context) {
5336
5334
  return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
5337
5335
  }
5338
- applyDeoptimizations() { }
5336
+ /**
5337
+ * Just deoptimize everything by default so that when e.g. we do not track
5338
+ * something properly, it is deoptimized.
5339
+ * @protected
5340
+ */
5341
+ applyDeoptimizations() {
5342
+ this.deoptimized = true;
5343
+ for (const key of this.keys) {
5344
+ const value = this[key];
5345
+ if (value === null)
5346
+ continue;
5347
+ if (Array.isArray(value)) {
5348
+ for (const child of value) {
5349
+ child === null || child === void 0 ? void 0 : child.deoptimizePath(UNKNOWN_PATH);
5350
+ }
5351
+ }
5352
+ else {
5353
+ value.deoptimizePath(UNKNOWN_PATH);
5354
+ }
5355
+ }
5356
+ this.context.requestTreeshakingPass();
5357
+ }
5339
5358
  }
5340
5359
 
5341
5360
  class SpreadElement extends NodeBase {
@@ -5417,11 +5436,6 @@ class Method extends ExpressionEntity {
5417
5436
  }
5418
5437
  return false;
5419
5438
  }
5420
- includeCallArguments(context, args) {
5421
- for (const arg of args) {
5422
- arg.include(context, false);
5423
- }
5424
- }
5425
5439
  }
5426
5440
  const METHOD_RETURNS_BOOLEAN = [
5427
5441
  new Method({
@@ -5621,7 +5635,7 @@ class ObjectEntity extends ExpressionEntity {
5621
5635
  }
5622
5636
  getLiteralValueAtPath(path, recursionTracker, origin) {
5623
5637
  if (path.length === 0) {
5624
- return UnknownValue;
5638
+ return UnknownTruthyValue;
5625
5639
  }
5626
5640
  const key = path[0];
5627
5641
  const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
@@ -6026,6 +6040,7 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
6026
6040
  class ArrayExpression extends NodeBase {
6027
6041
  constructor() {
6028
6042
  super(...arguments);
6043
+ this.deoptimized = false;
6029
6044
  this.objectEntity = null;
6030
6045
  }
6031
6046
  deoptimizePath(path) {
@@ -6049,6 +6064,20 @@ class ArrayExpression extends NodeBase {
6049
6064
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
6050
6065
  return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
6051
6066
  }
6067
+ applyDeoptimizations() {
6068
+ this.deoptimized = true;
6069
+ let hasSpread = false;
6070
+ for (let index = 0; index < this.elements.length; index++) {
6071
+ const element = this.elements[index];
6072
+ if (hasSpread || element instanceof SpreadElement) {
6073
+ if (element) {
6074
+ hasSpread = true;
6075
+ element.deoptimizePath(UNKNOWN_PATH);
6076
+ }
6077
+ }
6078
+ }
6079
+ this.context.requestTreeshakingPass();
6080
+ }
6052
6081
  getObjectEntity() {
6053
6082
  if (this.objectEntity !== null) {
6054
6083
  return this.objectEntity;
@@ -6059,7 +6088,7 @@ class ArrayExpression extends NodeBase {
6059
6088
  let hasSpread = false;
6060
6089
  for (let index = 0; index < this.elements.length; index++) {
6061
6090
  const element = this.elements[index];
6062
- if (element instanceof SpreadElement || hasSpread) {
6091
+ if (hasSpread || element instanceof SpreadElement) {
6063
6092
  if (element) {
6064
6093
  hasSpread = true;
6065
6094
  properties.unshift({ key: UnknownInteger, kind: 'init', property: element });
@@ -6079,9 +6108,7 @@ class ArrayExpression extends NodeBase {
6079
6108
  class ArrayPattern extends NodeBase {
6080
6109
  addExportedVariables(variables, exportNamesByVariable) {
6081
6110
  for (const element of this.elements) {
6082
- if (element !== null) {
6083
- element.addExportedVariables(variables, exportNamesByVariable);
6084
- }
6111
+ element === null || element === void 0 ? void 0 : element.addExportedVariables(variables, exportNamesByVariable);
6085
6112
  }
6086
6113
  }
6087
6114
  declare(kind) {
@@ -6093,29 +6120,23 @@ class ArrayPattern extends NodeBase {
6093
6120
  }
6094
6121
  return variables;
6095
6122
  }
6096
- deoptimizePath(path) {
6097
- if (path.length === 0) {
6098
- for (const element of this.elements) {
6099
- if (element !== null) {
6100
- element.deoptimizePath(path);
6101
- }
6102
- }
6123
+ // Patterns can only be deoptimized at the empty path at the moment
6124
+ deoptimizePath() {
6125
+ for (const element of this.elements) {
6126
+ element === null || element === void 0 ? void 0 : element.deoptimizePath(EMPTY_PATH);
6103
6127
  }
6104
6128
  }
6105
- hasEffectsWhenAssignedAtPath(path, context) {
6106
- if (path.length > 0)
6107
- return true;
6129
+ // Patterns are only checked at the emtpy path at the moment
6130
+ hasEffectsWhenAssignedAtPath(_path, context) {
6108
6131
  for (const element of this.elements) {
6109
- if (element !== null && element.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))
6132
+ if (element === null || element === void 0 ? void 0 : element.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))
6110
6133
  return true;
6111
6134
  }
6112
6135
  return false;
6113
6136
  }
6114
6137
  markDeclarationReached() {
6115
6138
  for (const element of this.elements) {
6116
- if (element !== null) {
6117
- element.markDeclarationReached();
6118
- }
6139
+ element === null || element === void 0 ? void 0 : element.markDeclarationReached();
6119
6140
  }
6120
6141
  }
6121
6142
  }
@@ -6491,1579 +6512,1661 @@ class ReturnValueScope extends ParameterScope {
6491
6512
  }
6492
6513
  }
6493
6514
 
6494
- //@ts-check
6495
- /** @typedef { import('estree').Node} Node */
6496
- /** @typedef {Node | {
6497
- * type: 'PropertyDefinition';
6498
- * computed: boolean;
6499
- * value: Node
6500
- * }} NodeWithPropertyDefinition */
6501
-
6502
- /**
6503
- *
6504
- * @param {NodeWithPropertyDefinition} node
6505
- * @param {NodeWithPropertyDefinition} parent
6506
- * @returns boolean
6507
- */
6508
- function is_reference (node, parent) {
6509
- if (node.type === 'MemberExpression') {
6510
- return !node.computed && is_reference(node.object, node);
6511
- }
6512
-
6513
- if (node.type === 'Identifier') {
6514
- if (!parent) return true;
6515
-
6516
- switch (parent.type) {
6517
- // disregard `bar` in `foo.bar`
6518
- case 'MemberExpression': return parent.computed || node === parent.object;
6519
-
6520
- // disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
6521
- case 'MethodDefinition': return parent.computed;
6522
-
6523
- // disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
6524
- case 'PropertyDefinition': return parent.computed || node === parent.value;
6525
-
6526
- // disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
6527
- case 'Property': return parent.computed || node === parent.value;
6528
-
6529
- // disregard the `bar` in `export { foo as bar }` or
6530
- // the foo in `import { foo as bar }`
6531
- case 'ExportSpecifier':
6532
- case 'ImportSpecifier': return node === parent.local;
6533
-
6534
- // disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
6535
- case 'LabeledStatement':
6536
- case 'BreakStatement':
6537
- case 'ContinueStatement': return false;
6538
- default: return true;
6539
- }
6540
- }
6541
-
6542
- return false;
6515
+ class AssignmentPattern extends NodeBase {
6516
+ constructor() {
6517
+ super(...arguments);
6518
+ this.deoptimized = false;
6519
+ }
6520
+ addExportedVariables(variables, exportNamesByVariable) {
6521
+ this.left.addExportedVariables(variables, exportNamesByVariable);
6522
+ }
6523
+ declare(kind, init) {
6524
+ return this.left.declare(kind, init);
6525
+ }
6526
+ deoptimizePath(path) {
6527
+ path.length === 0 && this.left.deoptimizePath(path);
6528
+ }
6529
+ hasEffectsWhenAssignedAtPath(path, context) {
6530
+ return path.length > 0 || this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
6531
+ }
6532
+ // Note that FunctionBase may directly include .left and .right without
6533
+ // including the pattern itself. This is how default parameter tree-shaking
6534
+ // works at the moment.
6535
+ include(context, includeChildrenRecursively) {
6536
+ this.included = true;
6537
+ this.left.include(context, includeChildrenRecursively);
6538
+ this.right.include(context, includeChildrenRecursively);
6539
+ }
6540
+ markDeclarationReached() {
6541
+ this.left.markDeclarationReached();
6542
+ }
6543
+ render(code, options, { isShorthandProperty } = BLANK) {
6544
+ this.left.render(code, options, { isShorthandProperty });
6545
+ if (this.right.included) {
6546
+ this.right.render(code, options);
6547
+ }
6548
+ else {
6549
+ code.remove(this.left.end, this.end);
6550
+ }
6551
+ }
6552
+ applyDeoptimizations() {
6553
+ this.deoptimized = true;
6554
+ this.left.deoptimizePath(EMPTY_PATH);
6555
+ this.right.deoptimizePath(UNKNOWN_PATH);
6556
+ this.context.requestTreeshakingPass();
6557
+ }
6543
6558
  }
6544
6559
 
6545
- /* eslint sort-keys: "off" */
6546
- const ValueProperties = Symbol('Value Properties');
6547
- const PURE = {
6548
- hasEffectsWhenCalled() {
6549
- return false;
6560
+ function treeshakeNode(node, code, start, end) {
6561
+ code.remove(start, end);
6562
+ if (node.annotations) {
6563
+ for (const annotation of node.annotations) {
6564
+ if (annotation.start < start) {
6565
+ code.remove(annotation.start, annotation.end);
6566
+ }
6567
+ else {
6568
+ return;
6569
+ }
6570
+ }
6550
6571
  }
6551
- };
6552
- const IMPURE = {
6553
- hasEffectsWhenCalled() {
6554
- return true;
6572
+ }
6573
+ function removeAnnotations(node, code) {
6574
+ if (!node.annotations && node.parent.type === ExpressionStatement$1) {
6575
+ node = node.parent;
6555
6576
  }
6556
- };
6557
- // We use shortened variables to reduce file size here
6558
- /* OBJECT */
6559
- const O = {
6560
- __proto__: null,
6561
- [ValueProperties]: IMPURE
6562
- };
6563
- /* PURE FUNCTION */
6564
- const PF = {
6565
- __proto__: null,
6566
- [ValueProperties]: PURE
6567
- };
6568
- /* FUNCTION THAT MUTATES FIRST ARG WITHOUT TRIGGERING ACCESSORS */
6569
- const MUTATES_ARG_WITHOUT_ACCESSOR = {
6570
- __proto__: null,
6571
- [ValueProperties]: {
6572
- hasEffectsWhenCalled(callOptions, context) {
6573
- return (!callOptions.args.length ||
6574
- callOptions.args[0].hasEffectsWhenAssignedAtPath(UNKNOWN_NON_ACCESSOR_PATH, context));
6577
+ if (node.annotations) {
6578
+ for (const annotation of node.annotations) {
6579
+ code.remove(annotation.start, annotation.end);
6575
6580
  }
6576
6581
  }
6577
- };
6578
- /* CONSTRUCTOR */
6579
- const C = {
6580
- __proto__: null,
6581
- [ValueProperties]: IMPURE,
6582
- prototype: O
6583
- };
6584
- /* PURE CONSTRUCTOR */
6585
- const PC = {
6586
- __proto__: null,
6587
- [ValueProperties]: PURE,
6588
- prototype: O
6589
- };
6590
- const ARRAY_TYPE = {
6591
- __proto__: null,
6592
- [ValueProperties]: PURE,
6593
- from: PF,
6594
- of: PF,
6595
- prototype: O
6596
- };
6597
- const INTL_MEMBER = {
6598
- __proto__: null,
6599
- [ValueProperties]: PURE,
6600
- supportedLocalesOf: PC
6601
- };
6602
- const knownGlobals = {
6603
- // Placeholders for global objects to avoid shape mutations
6604
- global: O,
6605
- globalThis: O,
6606
- self: O,
6607
- window: O,
6608
- // Common globals
6609
- __proto__: null,
6610
- [ValueProperties]: IMPURE,
6611
- Array: {
6612
- __proto__: null,
6613
- [ValueProperties]: IMPURE,
6614
- from: O,
6615
- isArray: PF,
6616
- of: PF,
6617
- prototype: O
6618
- },
6619
- ArrayBuffer: {
6620
- __proto__: null,
6621
- [ValueProperties]: PURE,
6622
- isView: PF,
6623
- prototype: O
6624
- },
6625
- Atomics: O,
6626
- BigInt: C,
6627
- BigInt64Array: C,
6628
- BigUint64Array: C,
6629
- Boolean: PC,
6630
- constructor: C,
6631
- DataView: PC,
6632
- Date: {
6633
- __proto__: null,
6634
- [ValueProperties]: PURE,
6635
- now: PF,
6636
- parse: PF,
6637
- prototype: O,
6638
- UTC: PF
6639
- },
6640
- decodeURI: PF,
6641
- decodeURIComponent: PF,
6642
- encodeURI: PF,
6643
- encodeURIComponent: PF,
6644
- Error: PC,
6645
- escape: PF,
6646
- eval: O,
6647
- EvalError: PC,
6648
- Float32Array: ARRAY_TYPE,
6649
- Float64Array: ARRAY_TYPE,
6650
- Function: C,
6651
- hasOwnProperty: O,
6652
- Infinity: O,
6653
- Int16Array: ARRAY_TYPE,
6654
- Int32Array: ARRAY_TYPE,
6655
- Int8Array: ARRAY_TYPE,
6656
- isFinite: PF,
6657
- isNaN: PF,
6658
- isPrototypeOf: O,
6659
- JSON: O,
6660
- Map: PC,
6661
- Math: {
6662
- __proto__: null,
6663
- [ValueProperties]: IMPURE,
6664
- abs: PF,
6665
- acos: PF,
6666
- acosh: PF,
6667
- asin: PF,
6668
- asinh: PF,
6669
- atan: PF,
6670
- atan2: PF,
6671
- atanh: PF,
6672
- cbrt: PF,
6673
- ceil: PF,
6674
- clz32: PF,
6675
- cos: PF,
6676
- cosh: PF,
6677
- exp: PF,
6678
- expm1: PF,
6679
- floor: PF,
6680
- fround: PF,
6681
- hypot: PF,
6682
- imul: PF,
6683
- log: PF,
6684
- log10: PF,
6685
- log1p: PF,
6686
- log2: PF,
6687
- max: PF,
6688
- min: PF,
6689
- pow: PF,
6690
- random: PF,
6691
- round: PF,
6692
- sign: PF,
6693
- sin: PF,
6694
- sinh: PF,
6695
- sqrt: PF,
6696
- tan: PF,
6697
- tanh: PF,
6698
- trunc: PF
6699
- },
6700
- NaN: O,
6701
- Number: {
6702
- __proto__: null,
6703
- [ValueProperties]: PURE,
6704
- isFinite: PF,
6705
- isInteger: PF,
6706
- isNaN: PF,
6707
- isSafeInteger: PF,
6708
- parseFloat: PF,
6709
- parseInt: PF,
6710
- prototype: O
6711
- },
6712
- Object: {
6713
- __proto__: null,
6714
- [ValueProperties]: PURE,
6715
- create: PF,
6716
- // Technically those can throw in certain situations, but we ignore this as
6717
- // code that relies on this will hopefully wrap this in a try-catch, which
6718
- // deoptimizes everything anyway
6719
- defineProperty: MUTATES_ARG_WITHOUT_ACCESSOR,
6720
- defineProperties: MUTATES_ARG_WITHOUT_ACCESSOR,
6721
- getOwnPropertyDescriptor: PF,
6722
- getOwnPropertyNames: PF,
6723
- getOwnPropertySymbols: PF,
6724
- getPrototypeOf: PF,
6725
- hasOwn: PF,
6726
- is: PF,
6727
- isExtensible: PF,
6728
- isFrozen: PF,
6729
- isSealed: PF,
6730
- keys: PF,
6731
- fromEntries: PF,
6732
- entries: PF,
6733
- prototype: O
6734
- },
6735
- parseFloat: PF,
6736
- parseInt: PF,
6737
- Promise: {
6738
- __proto__: null,
6739
- [ValueProperties]: IMPURE,
6740
- all: O,
6741
- prototype: O,
6742
- race: O,
6743
- reject: O,
6744
- resolve: O
6745
- },
6746
- propertyIsEnumerable: O,
6747
- Proxy: O,
6748
- RangeError: PC,
6749
- ReferenceError: PC,
6750
- Reflect: O,
6751
- RegExp: PC,
6752
- Set: PC,
6753
- SharedArrayBuffer: C,
6754
- String: {
6755
- __proto__: null,
6756
- [ValueProperties]: PURE,
6757
- fromCharCode: PF,
6758
- fromCodePoint: PF,
6759
- prototype: O,
6760
- raw: PF
6761
- },
6762
- Symbol: {
6763
- __proto__: null,
6764
- [ValueProperties]: PURE,
6765
- for: PF,
6766
- keyFor: PF,
6767
- prototype: O
6768
- },
6769
- SyntaxError: PC,
6770
- toLocaleString: O,
6771
- toString: O,
6772
- TypeError: PC,
6773
- Uint16Array: ARRAY_TYPE,
6774
- Uint32Array: ARRAY_TYPE,
6775
- Uint8Array: ARRAY_TYPE,
6776
- Uint8ClampedArray: ARRAY_TYPE,
6777
- // Technically, this is a global, but it needs special handling
6778
- // undefined: ?,
6779
- unescape: PF,
6780
- URIError: PC,
6781
- valueOf: O,
6782
- WeakMap: PC,
6783
- WeakSet: PC,
6784
- // Additional globals shared by Node and Browser that are not strictly part of the language
6785
- clearInterval: C,
6786
- clearTimeout: C,
6787
- console: O,
6788
- Intl: {
6789
- __proto__: null,
6790
- [ValueProperties]: IMPURE,
6791
- Collator: INTL_MEMBER,
6792
- DateTimeFormat: INTL_MEMBER,
6793
- ListFormat: INTL_MEMBER,
6794
- NumberFormat: INTL_MEMBER,
6795
- PluralRules: INTL_MEMBER,
6796
- RelativeTimeFormat: INTL_MEMBER
6797
- },
6798
- setInterval: C,
6799
- setTimeout: C,
6800
- TextDecoder: C,
6801
- TextEncoder: C,
6802
- URL: C,
6803
- URLSearchParams: C,
6804
- // Browser specific globals
6805
- AbortController: C,
6806
- AbortSignal: C,
6807
- addEventListener: O,
6808
- alert: O,
6809
- AnalyserNode: C,
6810
- Animation: C,
6811
- AnimationEvent: C,
6812
- applicationCache: O,
6813
- ApplicationCache: C,
6814
- ApplicationCacheErrorEvent: C,
6815
- atob: O,
6816
- Attr: C,
6817
- Audio: C,
6818
- AudioBuffer: C,
6819
- AudioBufferSourceNode: C,
6820
- AudioContext: C,
6821
- AudioDestinationNode: C,
6822
- AudioListener: C,
6823
- AudioNode: C,
6824
- AudioParam: C,
6825
- AudioProcessingEvent: C,
6826
- AudioScheduledSourceNode: C,
6827
- AudioWorkletNode: C,
6828
- BarProp: C,
6829
- BaseAudioContext: C,
6830
- BatteryManager: C,
6831
- BeforeUnloadEvent: C,
6832
- BiquadFilterNode: C,
6833
- Blob: C,
6834
- BlobEvent: C,
6835
- blur: O,
6836
- BroadcastChannel: C,
6837
- btoa: O,
6838
- ByteLengthQueuingStrategy: C,
6839
- Cache: C,
6840
- caches: O,
6841
- CacheStorage: C,
6842
- cancelAnimationFrame: O,
6843
- cancelIdleCallback: O,
6844
- CanvasCaptureMediaStreamTrack: C,
6845
- CanvasGradient: C,
6846
- CanvasPattern: C,
6847
- CanvasRenderingContext2D: C,
6848
- ChannelMergerNode: C,
6849
- ChannelSplitterNode: C,
6850
- CharacterData: C,
6851
- clientInformation: O,
6852
- ClipboardEvent: C,
6853
- close: O,
6854
- closed: O,
6855
- CloseEvent: C,
6856
- Comment: C,
6857
- CompositionEvent: C,
6858
- confirm: O,
6859
- ConstantSourceNode: C,
6860
- ConvolverNode: C,
6861
- CountQueuingStrategy: C,
6862
- createImageBitmap: O,
6863
- Credential: C,
6864
- CredentialsContainer: C,
6865
- crypto: O,
6866
- Crypto: C,
6867
- CryptoKey: C,
6868
- CSS: C,
6869
- CSSConditionRule: C,
6870
- CSSFontFaceRule: C,
6871
- CSSGroupingRule: C,
6872
- CSSImportRule: C,
6873
- CSSKeyframeRule: C,
6874
- CSSKeyframesRule: C,
6875
- CSSMediaRule: C,
6876
- CSSNamespaceRule: C,
6877
- CSSPageRule: C,
6878
- CSSRule: C,
6879
- CSSRuleList: C,
6880
- CSSStyleDeclaration: C,
6881
- CSSStyleRule: C,
6882
- CSSStyleSheet: C,
6883
- CSSSupportsRule: C,
6884
- CustomElementRegistry: C,
6885
- customElements: O,
6886
- CustomEvent: C,
6887
- DataTransfer: C,
6888
- DataTransferItem: C,
6889
- DataTransferItemList: C,
6890
- defaultstatus: O,
6891
- defaultStatus: O,
6892
- DelayNode: C,
6893
- DeviceMotionEvent: C,
6894
- DeviceOrientationEvent: C,
6895
- devicePixelRatio: O,
6896
- dispatchEvent: O,
6897
- document: O,
6898
- Document: C,
6899
- DocumentFragment: C,
6900
- DocumentType: C,
6901
- DOMError: C,
6902
- DOMException: C,
6903
- DOMImplementation: C,
6904
- DOMMatrix: C,
6905
- DOMMatrixReadOnly: C,
6906
- DOMParser: C,
6907
- DOMPoint: C,
6908
- DOMPointReadOnly: C,
6909
- DOMQuad: C,
6910
- DOMRect: C,
6911
- DOMRectReadOnly: C,
6912
- DOMStringList: C,
6913
- DOMStringMap: C,
6914
- DOMTokenList: C,
6915
- DragEvent: C,
6916
- DynamicsCompressorNode: C,
6917
- Element: C,
6918
- ErrorEvent: C,
6919
- Event: C,
6920
- EventSource: C,
6921
- EventTarget: C,
6922
- external: O,
6923
- fetch: O,
6924
- File: C,
6925
- FileList: C,
6926
- FileReader: C,
6927
- find: O,
6928
- focus: O,
6929
- FocusEvent: C,
6930
- FontFace: C,
6931
- FontFaceSetLoadEvent: C,
6932
- FormData: C,
6933
- frames: O,
6934
- GainNode: C,
6935
- Gamepad: C,
6936
- GamepadButton: C,
6937
- GamepadEvent: C,
6938
- getComputedStyle: O,
6939
- getSelection: O,
6940
- HashChangeEvent: C,
6941
- Headers: C,
6942
- history: O,
6943
- History: C,
6944
- HTMLAllCollection: C,
6945
- HTMLAnchorElement: C,
6946
- HTMLAreaElement: C,
6947
- HTMLAudioElement: C,
6948
- HTMLBaseElement: C,
6949
- HTMLBodyElement: C,
6950
- HTMLBRElement: C,
6951
- HTMLButtonElement: C,
6952
- HTMLCanvasElement: C,
6953
- HTMLCollection: C,
6954
- HTMLContentElement: C,
6955
- HTMLDataElement: C,
6956
- HTMLDataListElement: C,
6957
- HTMLDetailsElement: C,
6958
- HTMLDialogElement: C,
6959
- HTMLDirectoryElement: C,
6960
- HTMLDivElement: C,
6961
- HTMLDListElement: C,
6962
- HTMLDocument: C,
6963
- HTMLElement: C,
6964
- HTMLEmbedElement: C,
6965
- HTMLFieldSetElement: C,
6966
- HTMLFontElement: C,
6967
- HTMLFormControlsCollection: C,
6968
- HTMLFormElement: C,
6969
- HTMLFrameElement: C,
6970
- HTMLFrameSetElement: C,
6971
- HTMLHeadElement: C,
6972
- HTMLHeadingElement: C,
6973
- HTMLHRElement: C,
6974
- HTMLHtmlElement: C,
6975
- HTMLIFrameElement: C,
6976
- HTMLImageElement: C,
6977
- HTMLInputElement: C,
6978
- HTMLLabelElement: C,
6979
- HTMLLegendElement: C,
6980
- HTMLLIElement: C,
6981
- HTMLLinkElement: C,
6982
- HTMLMapElement: C,
6983
- HTMLMarqueeElement: C,
6984
- HTMLMediaElement: C,
6985
- HTMLMenuElement: C,
6986
- HTMLMetaElement: C,
6987
- HTMLMeterElement: C,
6988
- HTMLModElement: C,
6989
- HTMLObjectElement: C,
6990
- HTMLOListElement: C,
6991
- HTMLOptGroupElement: C,
6992
- HTMLOptionElement: C,
6993
- HTMLOptionsCollection: C,
6994
- HTMLOutputElement: C,
6995
- HTMLParagraphElement: C,
6996
- HTMLParamElement: C,
6997
- HTMLPictureElement: C,
6998
- HTMLPreElement: C,
6999
- HTMLProgressElement: C,
7000
- HTMLQuoteElement: C,
7001
- HTMLScriptElement: C,
7002
- HTMLSelectElement: C,
7003
- HTMLShadowElement: C,
7004
- HTMLSlotElement: C,
7005
- HTMLSourceElement: C,
7006
- HTMLSpanElement: C,
7007
- HTMLStyleElement: C,
7008
- HTMLTableCaptionElement: C,
7009
- HTMLTableCellElement: C,
7010
- HTMLTableColElement: C,
7011
- HTMLTableElement: C,
7012
- HTMLTableRowElement: C,
7013
- HTMLTableSectionElement: C,
7014
- HTMLTemplateElement: C,
7015
- HTMLTextAreaElement: C,
7016
- HTMLTimeElement: C,
7017
- HTMLTitleElement: C,
7018
- HTMLTrackElement: C,
7019
- HTMLUListElement: C,
7020
- HTMLUnknownElement: C,
7021
- HTMLVideoElement: C,
7022
- IDBCursor: C,
7023
- IDBCursorWithValue: C,
7024
- IDBDatabase: C,
7025
- IDBFactory: C,
7026
- IDBIndex: C,
7027
- IDBKeyRange: C,
7028
- IDBObjectStore: C,
7029
- IDBOpenDBRequest: C,
7030
- IDBRequest: C,
7031
- IDBTransaction: C,
7032
- IDBVersionChangeEvent: C,
7033
- IdleDeadline: C,
7034
- IIRFilterNode: C,
7035
- Image: C,
7036
- ImageBitmap: C,
7037
- ImageBitmapRenderingContext: C,
7038
- ImageCapture: C,
7039
- ImageData: C,
7040
- indexedDB: O,
7041
- innerHeight: O,
7042
- innerWidth: O,
7043
- InputEvent: C,
7044
- IntersectionObserver: C,
7045
- IntersectionObserverEntry: C,
7046
- isSecureContext: O,
7047
- KeyboardEvent: C,
7048
- KeyframeEffect: C,
7049
- length: O,
7050
- localStorage: O,
7051
- location: O,
7052
- Location: C,
7053
- locationbar: O,
7054
- matchMedia: O,
7055
- MediaDeviceInfo: C,
7056
- MediaDevices: C,
7057
- MediaElementAudioSourceNode: C,
7058
- MediaEncryptedEvent: C,
7059
- MediaError: C,
7060
- MediaKeyMessageEvent: C,
7061
- MediaKeySession: C,
7062
- MediaKeyStatusMap: C,
7063
- MediaKeySystemAccess: C,
7064
- MediaList: C,
7065
- MediaQueryList: C,
7066
- MediaQueryListEvent: C,
7067
- MediaRecorder: C,
7068
- MediaSettingsRange: C,
7069
- MediaSource: C,
7070
- MediaStream: C,
7071
- MediaStreamAudioDestinationNode: C,
7072
- MediaStreamAudioSourceNode: C,
7073
- MediaStreamEvent: C,
7074
- MediaStreamTrack: C,
7075
- MediaStreamTrackEvent: C,
7076
- menubar: O,
7077
- MessageChannel: C,
7078
- MessageEvent: C,
7079
- MessagePort: C,
7080
- MIDIAccess: C,
7081
- MIDIConnectionEvent: C,
7082
- MIDIInput: C,
7083
- MIDIInputMap: C,
7084
- MIDIMessageEvent: C,
7085
- MIDIOutput: C,
7086
- MIDIOutputMap: C,
7087
- MIDIPort: C,
7088
- MimeType: C,
7089
- MimeTypeArray: C,
7090
- MouseEvent: C,
7091
- moveBy: O,
7092
- moveTo: O,
7093
- MutationEvent: C,
7094
- MutationObserver: C,
7095
- MutationRecord: C,
7096
- name: O,
7097
- NamedNodeMap: C,
7098
- NavigationPreloadManager: C,
7099
- navigator: O,
7100
- Navigator: C,
7101
- NetworkInformation: C,
7102
- Node: C,
7103
- NodeFilter: O,
7104
- NodeIterator: C,
7105
- NodeList: C,
7106
- Notification: C,
7107
- OfflineAudioCompletionEvent: C,
7108
- OfflineAudioContext: C,
7109
- offscreenBuffering: O,
7110
- OffscreenCanvas: C,
7111
- open: O,
7112
- openDatabase: O,
7113
- Option: C,
7114
- origin: O,
7115
- OscillatorNode: C,
7116
- outerHeight: O,
7117
- outerWidth: O,
7118
- PageTransitionEvent: C,
7119
- pageXOffset: O,
7120
- pageYOffset: O,
7121
- PannerNode: C,
7122
- parent: O,
7123
- Path2D: C,
7124
- PaymentAddress: C,
7125
- PaymentRequest: C,
7126
- PaymentRequestUpdateEvent: C,
7127
- PaymentResponse: C,
7128
- performance: O,
7129
- Performance: C,
7130
- PerformanceEntry: C,
7131
- PerformanceLongTaskTiming: C,
7132
- PerformanceMark: C,
7133
- PerformanceMeasure: C,
7134
- PerformanceNavigation: C,
7135
- PerformanceNavigationTiming: C,
7136
- PerformanceObserver: C,
7137
- PerformanceObserverEntryList: C,
7138
- PerformancePaintTiming: C,
7139
- PerformanceResourceTiming: C,
7140
- PerformanceTiming: C,
7141
- PeriodicWave: C,
7142
- Permissions: C,
7143
- PermissionStatus: C,
7144
- personalbar: O,
7145
- PhotoCapabilities: C,
7146
- Plugin: C,
7147
- PluginArray: C,
7148
- PointerEvent: C,
7149
- PopStateEvent: C,
7150
- postMessage: O,
7151
- Presentation: C,
7152
- PresentationAvailability: C,
7153
- PresentationConnection: C,
7154
- PresentationConnectionAvailableEvent: C,
7155
- PresentationConnectionCloseEvent: C,
7156
- PresentationConnectionList: C,
7157
- PresentationReceiver: C,
7158
- PresentationRequest: C,
7159
- print: O,
7160
- ProcessingInstruction: C,
7161
- ProgressEvent: C,
7162
- PromiseRejectionEvent: C,
7163
- prompt: O,
7164
- PushManager: C,
7165
- PushSubscription: C,
7166
- PushSubscriptionOptions: C,
7167
- queueMicrotask: O,
7168
- RadioNodeList: C,
7169
- Range: C,
7170
- ReadableStream: C,
7171
- RemotePlayback: C,
7172
- removeEventListener: O,
7173
- Request: C,
7174
- requestAnimationFrame: O,
7175
- requestIdleCallback: O,
7176
- resizeBy: O,
7177
- ResizeObserver: C,
7178
- ResizeObserverEntry: C,
7179
- resizeTo: O,
7180
- Response: C,
7181
- RTCCertificate: C,
7182
- RTCDataChannel: C,
7183
- RTCDataChannelEvent: C,
7184
- RTCDtlsTransport: C,
7185
- RTCIceCandidate: C,
7186
- RTCIceTransport: C,
7187
- RTCPeerConnection: C,
7188
- RTCPeerConnectionIceEvent: C,
7189
- RTCRtpReceiver: C,
7190
- RTCRtpSender: C,
7191
- RTCSctpTransport: C,
7192
- RTCSessionDescription: C,
7193
- RTCStatsReport: C,
7194
- RTCTrackEvent: C,
7195
- screen: O,
7196
- Screen: C,
7197
- screenLeft: O,
7198
- ScreenOrientation: C,
7199
- screenTop: O,
7200
- screenX: O,
7201
- screenY: O,
7202
- ScriptProcessorNode: C,
7203
- scroll: O,
7204
- scrollbars: O,
7205
- scrollBy: O,
7206
- scrollTo: O,
7207
- scrollX: O,
7208
- scrollY: O,
7209
- SecurityPolicyViolationEvent: C,
7210
- Selection: C,
7211
- ServiceWorker: C,
7212
- ServiceWorkerContainer: C,
7213
- ServiceWorkerRegistration: C,
7214
- sessionStorage: O,
7215
- ShadowRoot: C,
7216
- SharedWorker: C,
7217
- SourceBuffer: C,
7218
- SourceBufferList: C,
7219
- speechSynthesis: O,
7220
- SpeechSynthesisEvent: C,
7221
- SpeechSynthesisUtterance: C,
7222
- StaticRange: C,
7223
- status: O,
7224
- statusbar: O,
7225
- StereoPannerNode: C,
7226
- stop: O,
7227
- Storage: C,
7228
- StorageEvent: C,
7229
- StorageManager: C,
7230
- styleMedia: O,
7231
- StyleSheet: C,
7232
- StyleSheetList: C,
7233
- SubtleCrypto: C,
7234
- SVGAElement: C,
7235
- SVGAngle: C,
7236
- SVGAnimatedAngle: C,
7237
- SVGAnimatedBoolean: C,
7238
- SVGAnimatedEnumeration: C,
7239
- SVGAnimatedInteger: C,
7240
- SVGAnimatedLength: C,
7241
- SVGAnimatedLengthList: C,
7242
- SVGAnimatedNumber: C,
7243
- SVGAnimatedNumberList: C,
7244
- SVGAnimatedPreserveAspectRatio: C,
7245
- SVGAnimatedRect: C,
7246
- SVGAnimatedString: C,
7247
- SVGAnimatedTransformList: C,
7248
- SVGAnimateElement: C,
7249
- SVGAnimateMotionElement: C,
7250
- SVGAnimateTransformElement: C,
7251
- SVGAnimationElement: C,
7252
- SVGCircleElement: C,
7253
- SVGClipPathElement: C,
7254
- SVGComponentTransferFunctionElement: C,
7255
- SVGDefsElement: C,
7256
- SVGDescElement: C,
7257
- SVGDiscardElement: C,
7258
- SVGElement: C,
7259
- SVGEllipseElement: C,
7260
- SVGFEBlendElement: C,
7261
- SVGFEColorMatrixElement: C,
7262
- SVGFEComponentTransferElement: C,
7263
- SVGFECompositeElement: C,
7264
- SVGFEConvolveMatrixElement: C,
7265
- SVGFEDiffuseLightingElement: C,
7266
- SVGFEDisplacementMapElement: C,
7267
- SVGFEDistantLightElement: C,
7268
- SVGFEDropShadowElement: C,
7269
- SVGFEFloodElement: C,
7270
- SVGFEFuncAElement: C,
7271
- SVGFEFuncBElement: C,
7272
- SVGFEFuncGElement: C,
7273
- SVGFEFuncRElement: C,
7274
- SVGFEGaussianBlurElement: C,
7275
- SVGFEImageElement: C,
7276
- SVGFEMergeElement: C,
7277
- SVGFEMergeNodeElement: C,
7278
- SVGFEMorphologyElement: C,
7279
- SVGFEOffsetElement: C,
7280
- SVGFEPointLightElement: C,
7281
- SVGFESpecularLightingElement: C,
7282
- SVGFESpotLightElement: C,
7283
- SVGFETileElement: C,
7284
- SVGFETurbulenceElement: C,
7285
- SVGFilterElement: C,
7286
- SVGForeignObjectElement: C,
7287
- SVGGElement: C,
7288
- SVGGeometryElement: C,
7289
- SVGGradientElement: C,
7290
- SVGGraphicsElement: C,
7291
- SVGImageElement: C,
7292
- SVGLength: C,
7293
- SVGLengthList: C,
7294
- SVGLinearGradientElement: C,
7295
- SVGLineElement: C,
7296
- SVGMarkerElement: C,
7297
- SVGMaskElement: C,
7298
- SVGMatrix: C,
7299
- SVGMetadataElement: C,
7300
- SVGMPathElement: C,
7301
- SVGNumber: C,
7302
- SVGNumberList: C,
7303
- SVGPathElement: C,
7304
- SVGPatternElement: C,
7305
- SVGPoint: C,
7306
- SVGPointList: C,
7307
- SVGPolygonElement: C,
7308
- SVGPolylineElement: C,
7309
- SVGPreserveAspectRatio: C,
7310
- SVGRadialGradientElement: C,
7311
- SVGRect: C,
7312
- SVGRectElement: C,
7313
- SVGScriptElement: C,
7314
- SVGSetElement: C,
7315
- SVGStopElement: C,
7316
- SVGStringList: C,
7317
- SVGStyleElement: C,
7318
- SVGSVGElement: C,
7319
- SVGSwitchElement: C,
7320
- SVGSymbolElement: C,
7321
- SVGTextContentElement: C,
7322
- SVGTextElement: C,
7323
- SVGTextPathElement: C,
7324
- SVGTextPositioningElement: C,
7325
- SVGTitleElement: C,
7326
- SVGTransform: C,
7327
- SVGTransformList: C,
7328
- SVGTSpanElement: C,
7329
- SVGUnitTypes: C,
7330
- SVGUseElement: C,
7331
- SVGViewElement: C,
7332
- TaskAttributionTiming: C,
7333
- Text: C,
7334
- TextEvent: C,
7335
- TextMetrics: C,
7336
- TextTrack: C,
7337
- TextTrackCue: C,
7338
- TextTrackCueList: C,
7339
- TextTrackList: C,
7340
- TimeRanges: C,
7341
- toolbar: O,
7342
- top: O,
7343
- Touch: C,
7344
- TouchEvent: C,
7345
- TouchList: C,
7346
- TrackEvent: C,
7347
- TransitionEvent: C,
7348
- TreeWalker: C,
7349
- UIEvent: C,
7350
- ValidityState: C,
7351
- visualViewport: O,
7352
- VisualViewport: C,
7353
- VTTCue: C,
7354
- WaveShaperNode: C,
7355
- WebAssembly: O,
7356
- WebGL2RenderingContext: C,
7357
- WebGLActiveInfo: C,
7358
- WebGLBuffer: C,
7359
- WebGLContextEvent: C,
7360
- WebGLFramebuffer: C,
7361
- WebGLProgram: C,
7362
- WebGLQuery: C,
7363
- WebGLRenderbuffer: C,
7364
- WebGLRenderingContext: C,
7365
- WebGLSampler: C,
7366
- WebGLShader: C,
7367
- WebGLShaderPrecisionFormat: C,
7368
- WebGLSync: C,
7369
- WebGLTexture: C,
7370
- WebGLTransformFeedback: C,
7371
- WebGLUniformLocation: C,
7372
- WebGLVertexArrayObject: C,
7373
- WebSocket: C,
7374
- WheelEvent: C,
7375
- Window: C,
7376
- Worker: C,
7377
- WritableStream: C,
7378
- XMLDocument: C,
7379
- XMLHttpRequest: C,
7380
- XMLHttpRequestEventTarget: C,
7381
- XMLHttpRequestUpload: C,
7382
- XMLSerializer: C,
7383
- XPathEvaluator: C,
7384
- XPathExpression: C,
7385
- XPathResult: C,
7386
- XSLTProcessor: C
7387
- };
7388
- for (const global of ['window', 'global', 'self', 'globalThis']) {
7389
- knownGlobals[global] = knownGlobals;
7390
6582
  }
7391
- function getGlobalAtPath(path) {
7392
- let currentGlobal = knownGlobals;
7393
- for (const pathSegment of path) {
7394
- if (typeof pathSegment !== 'string') {
7395
- return null;
6583
+
6584
+ const NO_SEMICOLON = { isNoStatement: true };
6585
+ // This assumes there are only white-space and comments between start and the string we are looking for
6586
+ function findFirstOccurrenceOutsideComment(code, searchString, start = 0) {
6587
+ let searchPos, charCodeAfterSlash;
6588
+ searchPos = code.indexOf(searchString, start);
6589
+ while (true) {
6590
+ start = code.indexOf('/', start);
6591
+ if (start === -1 || start >= searchPos)
6592
+ return searchPos;
6593
+ charCodeAfterSlash = code.charCodeAt(++start);
6594
+ ++start;
6595
+ // With our assumption, '/' always starts a comment. Determine comment type:
6596
+ start =
6597
+ charCodeAfterSlash === 47 /*"/"*/
6598
+ ? code.indexOf('\n', start) + 1
6599
+ : code.indexOf('*/', start) + 2;
6600
+ if (start > searchPos) {
6601
+ searchPos = code.indexOf(searchString, start);
7396
6602
  }
7397
- currentGlobal = currentGlobal[pathSegment];
7398
- if (!currentGlobal) {
7399
- return null;
6603
+ }
6604
+ }
6605
+ const NON_WHITESPACE = /\S/g;
6606
+ function findNonWhiteSpace(code, index) {
6607
+ NON_WHITESPACE.lastIndex = index;
6608
+ const result = NON_WHITESPACE.exec(code);
6609
+ return result.index;
6610
+ }
6611
+ // This assumes "code" only contains white-space and comments
6612
+ // Returns position of line-comment if applicable
6613
+ function findFirstLineBreakOutsideComment(code) {
6614
+ let lineBreakPos, charCodeAfterSlash, start = 0;
6615
+ lineBreakPos = code.indexOf('\n', start);
6616
+ while (true) {
6617
+ start = code.indexOf('/', start);
6618
+ if (start === -1 || start > lineBreakPos)
6619
+ return [lineBreakPos, lineBreakPos + 1];
6620
+ // With our assumption, '/' always starts a comment. Determine comment type:
6621
+ charCodeAfterSlash = code.charCodeAt(start + 1);
6622
+ if (charCodeAfterSlash === 47 /*"/"*/)
6623
+ return [start, lineBreakPos + 1];
6624
+ start = code.indexOf('*/', start + 3) + 2;
6625
+ if (start > lineBreakPos) {
6626
+ lineBreakPos = code.indexOf('\n', start);
6627
+ }
6628
+ }
6629
+ }
6630
+ function renderStatementList(statements, code, start, end, options) {
6631
+ let currentNode, currentNodeStart, currentNodeNeedsBoundaries, nextNodeStart;
6632
+ let nextNode = statements[0];
6633
+ let nextNodeNeedsBoundaries = !nextNode.included || nextNode.needsBoundaries;
6634
+ if (nextNodeNeedsBoundaries) {
6635
+ nextNodeStart =
6636
+ start + findFirstLineBreakOutsideComment(code.original.slice(start, nextNode.start))[1];
6637
+ }
6638
+ for (let nextIndex = 1; nextIndex <= statements.length; nextIndex++) {
6639
+ currentNode = nextNode;
6640
+ currentNodeStart = nextNodeStart;
6641
+ currentNodeNeedsBoundaries = nextNodeNeedsBoundaries;
6642
+ nextNode = statements[nextIndex];
6643
+ nextNodeNeedsBoundaries =
6644
+ nextNode === undefined ? false : !nextNode.included || nextNode.needsBoundaries;
6645
+ if (currentNodeNeedsBoundaries || nextNodeNeedsBoundaries) {
6646
+ nextNodeStart =
6647
+ currentNode.end +
6648
+ findFirstLineBreakOutsideComment(code.original.slice(currentNode.end, nextNode === undefined ? end : nextNode.start))[1];
6649
+ if (currentNode.included) {
6650
+ currentNodeNeedsBoundaries
6651
+ ? currentNode.render(code, options, {
6652
+ end: nextNodeStart,
6653
+ start: currentNodeStart
6654
+ })
6655
+ : currentNode.render(code, options);
6656
+ }
6657
+ else {
6658
+ treeshakeNode(currentNode, code, currentNodeStart, nextNodeStart);
6659
+ }
6660
+ }
6661
+ else {
6662
+ currentNode.render(code, options);
6663
+ }
6664
+ }
6665
+ }
6666
+ // This assumes that the first character is not part of the first node
6667
+ function getCommaSeparatedNodesWithBoundaries(nodes, code, start, end) {
6668
+ const splitUpNodes = [];
6669
+ let node, nextNode, nextNodeStart, contentEnd, char;
6670
+ let separator = start - 1;
6671
+ for (let nextIndex = 0; nextIndex < nodes.length; nextIndex++) {
6672
+ nextNode = nodes[nextIndex];
6673
+ if (node !== undefined) {
6674
+ separator =
6675
+ node.end +
6676
+ findFirstOccurrenceOutsideComment(code.original.slice(node.end, nextNode.start), ',');
6677
+ }
6678
+ nextNodeStart = contentEnd =
6679
+ separator +
6680
+ 1 +
6681
+ findFirstLineBreakOutsideComment(code.original.slice(separator + 1, nextNode.start))[1];
6682
+ while (((char = code.original.charCodeAt(nextNodeStart)),
6683
+ char === 32 /*" "*/ || char === 9 /*"\t"*/ || char === 10 /*"\n"*/ || char === 13) /*"\r"*/)
6684
+ nextNodeStart++;
6685
+ if (node !== undefined) {
6686
+ splitUpNodes.push({
6687
+ contentEnd,
6688
+ end: nextNodeStart,
6689
+ node,
6690
+ separator,
6691
+ start
6692
+ });
6693
+ }
6694
+ node = nextNode;
6695
+ start = nextNodeStart;
6696
+ }
6697
+ splitUpNodes.push({
6698
+ contentEnd: end,
6699
+ end,
6700
+ node: node,
6701
+ separator: null,
6702
+ start
6703
+ });
6704
+ return splitUpNodes;
6705
+ }
6706
+ // This assumes there are only white-space and comments between start and end
6707
+ function removeLineBreaks(code, start, end) {
6708
+ while (true) {
6709
+ const [removeStart, removeEnd] = findFirstLineBreakOutsideComment(code.original.slice(start, end));
6710
+ if (removeStart === -1) {
6711
+ break;
6712
+ }
6713
+ code.remove(start + removeStart, (start += removeEnd));
6714
+ }
6715
+ }
6716
+
6717
+ class BlockScope extends ChildScope {
6718
+ addDeclaration(identifier, context, init, isHoisted) {
6719
+ if (isHoisted) {
6720
+ const variable = this.parent.addDeclaration(identifier, context, init, isHoisted);
6721
+ // Necessary to make sure the init is deoptimized for conditional declarations.
6722
+ // We cannot call deoptimizePath here.
6723
+ variable.markInitializersForDeoptimization();
6724
+ return variable;
6725
+ }
6726
+ else {
6727
+ return super.addDeclaration(identifier, context, init, false);
6728
+ }
6729
+ }
6730
+ }
6731
+
6732
+ class ExpressionStatement extends NodeBase {
6733
+ initialise() {
6734
+ if (this.directive &&
6735
+ this.directive !== 'use strict' &&
6736
+ this.parent.type === Program$1) {
6737
+ this.context.warn(
6738
+ // This is necessary, because either way (deleting or not) can lead to errors.
6739
+ {
6740
+ code: 'MODULE_LEVEL_DIRECTIVE',
6741
+ message: `Module level directives cause errors when bundled, '${this.directive}' was ignored.`
6742
+ }, this.start);
6743
+ }
6744
+ }
6745
+ render(code, options) {
6746
+ super.render(code, options);
6747
+ if (this.included)
6748
+ this.insertSemicolon(code);
6749
+ }
6750
+ shouldBeIncluded(context) {
6751
+ if (this.directive && this.directive !== 'use strict')
6752
+ return this.parent.type !== Program$1;
6753
+ return super.shouldBeIncluded(context);
6754
+ }
6755
+ }
6756
+
6757
+ class BlockStatement extends NodeBase {
6758
+ constructor() {
6759
+ super(...arguments);
6760
+ this.directlyIncluded = false;
6761
+ }
6762
+ addImplicitReturnExpressionToScope() {
6763
+ const lastStatement = this.body[this.body.length - 1];
6764
+ if (!lastStatement || lastStatement.type !== ReturnStatement$1) {
6765
+ this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
6766
+ }
6767
+ }
6768
+ createScope(parentScope) {
6769
+ this.scope = this.parent.preventChildBlockScope
6770
+ ? parentScope
6771
+ : new BlockScope(parentScope);
6772
+ }
6773
+ hasEffects(context) {
6774
+ if (this.deoptimizeBody)
6775
+ return true;
6776
+ for (const node of this.body) {
6777
+ if (context.brokenFlow)
6778
+ break;
6779
+ if (node.hasEffects(context))
6780
+ return true;
6781
+ }
6782
+ return false;
6783
+ }
6784
+ include(context, includeChildrenRecursively) {
6785
+ if (!(this.deoptimizeBody && this.directlyIncluded)) {
6786
+ this.included = true;
6787
+ this.directlyIncluded = true;
6788
+ if (this.deoptimizeBody)
6789
+ includeChildrenRecursively = true;
6790
+ for (const node of this.body) {
6791
+ if (includeChildrenRecursively || node.shouldBeIncluded(context))
6792
+ node.include(context, includeChildrenRecursively);
6793
+ }
7400
6794
  }
7401
6795
  }
7402
- return currentGlobal[ValueProperties];
7403
- }
7404
-
7405
- class GlobalVariable extends Variable {
7406
- constructor() {
7407
- super(...arguments);
7408
- // Ensure we use live-bindings for globals as we do not know if they have
7409
- // been reassigned
7410
- this.isReassigned = true;
6796
+ initialise() {
6797
+ const firstBodyStatement = this.body[0];
6798
+ this.deoptimizeBody =
6799
+ firstBodyStatement instanceof ExpressionStatement &&
6800
+ firstBodyStatement.directive === 'use asm';
7411
6801
  }
7412
- hasEffectsWhenAccessedAtPath(path) {
7413
- if (path.length === 0) {
7414
- // Technically, "undefined" is a global variable of sorts
7415
- return this.name !== 'undefined' && getGlobalAtPath([this.name]) === null;
6802
+ render(code, options) {
6803
+ if (this.body.length) {
6804
+ renderStatementList(this.body, code, this.start + 1, this.end - 1, options);
6805
+ }
6806
+ else {
6807
+ super.render(code, options);
7416
6808
  }
7417
- return getGlobalAtPath([this.name, ...path].slice(0, -1)) === null;
7418
- }
7419
- hasEffectsWhenCalledAtPath(path, callOptions, context) {
7420
- const globalAtPath = getGlobalAtPath([this.name, ...path]);
7421
- return globalAtPath === null || globalAtPath.hasEffectsWhenCalled(callOptions, context);
7422
6809
  }
7423
6810
  }
7424
6811
 
7425
- const tdzVariableKinds = {
7426
- __proto__: null,
7427
- class: true,
7428
- const: true,
7429
- let: true,
7430
- var: true
7431
- };
7432
- class Identifier extends NodeBase {
6812
+ class RestElement extends NodeBase {
7433
6813
  constructor() {
7434
6814
  super(...arguments);
7435
- this.variable = null;
7436
6815
  this.deoptimized = false;
7437
- this.isTDZAccess = null;
6816
+ this.declarationInit = null;
7438
6817
  }
7439
6818
  addExportedVariables(variables, exportNamesByVariable) {
7440
- if (this.variable !== null && exportNamesByVariable.has(this.variable)) {
7441
- variables.push(this.variable);
7442
- }
7443
- }
7444
- bind() {
7445
- if (this.variable === null && is_reference(this, this.parent)) {
7446
- this.variable = this.scope.findVariable(this.name);
7447
- this.variable.addReference(this);
7448
- }
6819
+ this.argument.addExportedVariables(variables, exportNamesByVariable);
7449
6820
  }
7450
6821
  declare(kind, init) {
7451
- let variable;
7452
- const { treeshake } = this.context.options;
7453
- switch (kind) {
7454
- case 'var':
7455
- variable = this.scope.addDeclaration(this, this.context, init, true);
7456
- if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
7457
- // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
7458
- variable.markInitializersForDeoptimization();
7459
- }
7460
- break;
7461
- case 'function':
7462
- // in strict mode, functions are only hoisted within a scope but not across block scopes
7463
- variable = this.scope.addDeclaration(this, this.context, init, false);
7464
- break;
7465
- case 'let':
7466
- case 'const':
7467
- case 'class':
7468
- variable = this.scope.addDeclaration(this, this.context, init, false);
7469
- break;
7470
- case 'parameter':
7471
- variable = this.scope.addParameterDeclaration(this);
7472
- break;
7473
- /* istanbul ignore next */
7474
- default:
7475
- /* istanbul ignore next */
7476
- throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
6822
+ this.declarationInit = init;
6823
+ return this.argument.declare(kind, UNKNOWN_EXPRESSION);
6824
+ }
6825
+ deoptimizePath(path) {
6826
+ path.length === 0 && this.argument.deoptimizePath(EMPTY_PATH);
6827
+ }
6828
+ hasEffectsWhenAssignedAtPath(path, context) {
6829
+ return path.length > 0 || this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
6830
+ }
6831
+ markDeclarationReached() {
6832
+ this.argument.markDeclarationReached();
6833
+ }
6834
+ applyDeoptimizations() {
6835
+ this.deoptimized = true;
6836
+ if (this.declarationInit !== null) {
6837
+ this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
6838
+ this.context.requestTreeshakingPass();
7477
6839
  }
7478
- variable.kind = kind;
7479
- return [(this.variable = variable)];
6840
+ }
6841
+ }
6842
+
6843
+ class FunctionBase extends NodeBase {
6844
+ constructor() {
6845
+ super(...arguments);
6846
+ this.objectEntity = null;
6847
+ this.deoptimizedReturn = false;
6848
+ this.forceIncludeParameters = false;
6849
+ }
6850
+ deoptimizeCache() {
6851
+ this.forceIncludeParameters = true;
7480
6852
  }
7481
6853
  deoptimizePath(path) {
7482
- if (path.length === 0 && !this.scope.contains(this.name)) {
7483
- this.disallowImportReassignment();
6854
+ this.getObjectEntity().deoptimizePath(path);
6855
+ if (path.length === 1 && path[0] === UnknownKey) {
6856
+ // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
6857
+ // which means the return expression needs to be reassigned
6858
+ this.forceIncludeParameters = true;
6859
+ this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
7484
6860
  }
7485
- this.variable.deoptimizePath(path);
7486
6861
  }
7487
6862
  deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
7488
- this.variable.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
6863
+ if (path.length > 0) {
6864
+ this.getObjectEntity().deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
6865
+ }
7489
6866
  }
7490
6867
  getLiteralValueAtPath(path, recursionTracker, origin) {
7491
- return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
6868
+ return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
7492
6869
  }
7493
6870
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
7494
- return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
7495
- }
7496
- hasEffects() {
7497
- if (!this.deoptimized)
7498
- this.applyDeoptimizations();
7499
- if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
7500
- return true;
6871
+ if (path.length > 0) {
6872
+ return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
7501
6873
  }
7502
- return (this.context.options.treeshake.unknownGlobalSideEffects &&
7503
- this.variable instanceof GlobalVariable &&
7504
- this.variable.hasEffectsWhenAccessedAtPath(EMPTY_PATH));
6874
+ if (this.async) {
6875
+ if (!this.deoptimizedReturn) {
6876
+ this.deoptimizedReturn = true;
6877
+ this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
6878
+ this.context.requestTreeshakingPass();
6879
+ }
6880
+ return UNKNOWN_EXPRESSION;
6881
+ }
6882
+ return this.scope.getReturnExpression();
7505
6883
  }
7506
6884
  hasEffectsWhenAccessedAtPath(path, context) {
7507
- return (this.variable !== null &&
7508
- this.getVariableRespectingTDZ().hasEffectsWhenAccessedAtPath(path, context));
6885
+ return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
7509
6886
  }
7510
6887
  hasEffectsWhenAssignedAtPath(path, context) {
7511
- return (!this.variable ||
7512
- (path.length > 0
7513
- ? this.getVariableRespectingTDZ()
7514
- : this.variable).hasEffectsWhenAssignedAtPath(path, context));
6888
+ return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
7515
6889
  }
7516
6890
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
7517
- return (!this.variable ||
7518
- this.getVariableRespectingTDZ().hasEffectsWhenCalledAtPath(path, callOptions, context));
7519
- }
7520
- include() {
7521
- if (!this.deoptimized)
7522
- this.applyDeoptimizations();
7523
- if (!this.included) {
7524
- this.included = true;
7525
- if (this.variable !== null) {
7526
- this.context.includeVariableInModule(this.variable);
7527
- }
7528
- }
7529
- }
7530
- includeCallArguments(context, args) {
7531
- this.getVariableRespectingTDZ().includeCallArguments(context, args);
7532
- }
7533
- isPossibleTDZ() {
7534
- // return cached value to avoid issues with the next tree-shaking pass
7535
- if (this.isTDZAccess !== null)
7536
- return this.isTDZAccess;
7537
- if (!(this.variable instanceof LocalVariable) ||
7538
- !this.variable.kind ||
7539
- !(this.variable.kind in tdzVariableKinds)) {
7540
- return (this.isTDZAccess = false);
7541
- }
7542
- let decl_id;
7543
- if (this.variable.declarations &&
7544
- this.variable.declarations.length === 1 &&
7545
- (decl_id = this.variable.declarations[0]) &&
7546
- this.start < decl_id.start &&
7547
- closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
7548
- // a variable accessed before its declaration
7549
- // in the same function or at top level of module
7550
- return (this.isTDZAccess = true);
6891
+ var _a;
6892
+ if (path.length > 0) {
6893
+ return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
7551
6894
  }
7552
- if (!this.variable.initReached) {
7553
- // Either a const/let TDZ violation or
7554
- // var use before declaration was encountered.
7555
- return (this.isTDZAccess = true);
6895
+ if (this.async) {
6896
+ const { propertyReadSideEffects } = this.context.options
6897
+ .treeshake;
6898
+ const returnExpression = this.scope.getReturnExpression();
6899
+ if (returnExpression.hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context) ||
6900
+ (propertyReadSideEffects &&
6901
+ (propertyReadSideEffects === 'always' ||
6902
+ returnExpression.hasEffectsWhenAccessedAtPath(['then'], context)))) {
6903
+ return true;
6904
+ }
7556
6905
  }
7557
- return (this.isTDZAccess = false);
7558
- }
7559
- markDeclarationReached() {
7560
- this.variable.initReached = true;
7561
- }
7562
- render(code, { snippets: { getPropertyAccess } }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
7563
- if (this.variable) {
7564
- const name = this.variable.getName(getPropertyAccess);
7565
- if (name !== this.name) {
7566
- code.overwrite(this.start, this.end, name, {
7567
- contentOnly: true,
7568
- storeName: true
7569
- });
7570
- if (isShorthandProperty) {
7571
- code.prependRight(this.start, `${this.name}: `);
6906
+ for (let position = 0; position < this.params.length; position++) {
6907
+ const parameter = this.params[position];
6908
+ if (parameter instanceof AssignmentPattern) {
6909
+ if (parameter.left.hasEffects(context)) {
6910
+ return true;
6911
+ }
6912
+ const argumentValue = (_a = callOptions.args[position]) === null || _a === void 0 ? void 0 : _a.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
6913
+ if ((argumentValue === undefined || argumentValue === UnknownValue) &&
6914
+ parameter.right.hasEffects(context)) {
6915
+ return true;
7572
6916
  }
7573
6917
  }
7574
- // In strict mode, any variable named "eval" must be the actual "eval" function
7575
- if (name === 'eval' &&
7576
- renderedParentType === CallExpression$1 &&
7577
- isCalleeOfRenderedParent) {
7578
- code.appendRight(this.start, '0, ');
6918
+ else if (parameter.hasEffects(context)) {
6919
+ return true;
7579
6920
  }
7580
6921
  }
6922
+ return false;
7581
6923
  }
7582
- applyDeoptimizations() {
7583
- this.deoptimized = true;
7584
- if (this.variable !== null && this.variable instanceof LocalVariable) {
7585
- this.variable.consolidateInitializers();
7586
- this.context.requestTreeshakingPass();
7587
- }
7588
- }
7589
- disallowImportReassignment() {
7590
- return this.context.error({
7591
- code: 'ILLEGAL_REASSIGNMENT',
7592
- message: `Illegal reassignment to import '${this.name}'`
7593
- }, this.start);
7594
- }
7595
- getVariableRespectingTDZ() {
7596
- if (this.isPossibleTDZ()) {
7597
- return UNKNOWN_EXPRESSION;
7598
- }
7599
- return this.variable;
7600
- }
7601
- }
7602
- function closestParentFunctionOrProgram(node) {
7603
- while (node && !/^Program|Function/.test(node.type)) {
7604
- node = node.parent;
7605
- }
7606
- // one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program
7607
- return node;
7608
- }
7609
-
7610
- function treeshakeNode(node, code, start, end) {
7611
- code.remove(start, end);
7612
- if (node.annotations) {
7613
- for (const annotation of node.annotations) {
7614
- if (annotation.start < start) {
7615
- code.remove(annotation.start, annotation.end);
6924
+ include(context, includeChildrenRecursively, { includeWithoutParameterDefaults } = BLANK) {
6925
+ this.included = true;
6926
+ const { brokenFlow } = context;
6927
+ context.brokenFlow = BROKEN_FLOW_NONE;
6928
+ this.body.include(context, includeChildrenRecursively);
6929
+ context.brokenFlow = brokenFlow;
6930
+ if (!includeWithoutParameterDefaults ||
6931
+ includeChildrenRecursively ||
6932
+ this.forceIncludeParameters) {
6933
+ for (const param of this.params) {
6934
+ param.include(context, includeChildrenRecursively);
7616
6935
  }
7617
- else {
7618
- return;
6936
+ }
6937
+ }
6938
+ includeCallArguments(context, args) {
6939
+ var _a;
6940
+ for (let position = 0; position < this.params.length; position++) {
6941
+ const parameter = this.params[position];
6942
+ if (parameter instanceof AssignmentPattern) {
6943
+ if (parameter.left.shouldBeIncluded(context)) {
6944
+ parameter.left.include(context, false);
6945
+ }
6946
+ const argumentValue = (_a = args[position]) === null || _a === void 0 ? void 0 : _a.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
6947
+ // If argumentValue === UnknownTruthyValue, then we do not need to
6948
+ // include the default
6949
+ if ((argumentValue === undefined || argumentValue === UnknownValue) &&
6950
+ (this.parameterVariables[position].some(variable => variable.included) ||
6951
+ parameter.right.shouldBeIncluded(context))) {
6952
+ parameter.right.include(context, false);
6953
+ }
6954
+ }
6955
+ else if (parameter.shouldBeIncluded(context)) {
6956
+ parameter.include(context, false);
7619
6957
  }
7620
6958
  }
6959
+ this.scope.includeCallArguments(context, args);
7621
6960
  }
7622
- }
7623
- function removeAnnotations(node, code) {
7624
- if (!node.annotations && node.parent.type === ExpressionStatement$1) {
7625
- node = node.parent;
6961
+ initialise() {
6962
+ this.parameterVariables = this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION));
6963
+ this.scope.addParameterVariables(this.parameterVariables, this.params[this.params.length - 1] instanceof RestElement);
6964
+ if (this.body instanceof BlockStatement) {
6965
+ this.body.addImplicitReturnExpressionToScope();
6966
+ }
6967
+ else {
6968
+ this.scope.addReturnExpression(this.body);
6969
+ }
7626
6970
  }
7627
- if (node.annotations) {
7628
- for (const annotation of node.annotations) {
7629
- code.remove(annotation.start, annotation.end);
6971
+ parseNode(esTreeNode) {
6972
+ if (esTreeNode.body.type === BlockStatement$1) {
6973
+ this.body = new BlockStatement(esTreeNode.body, this, this.scope.hoistedBodyVarScope);
7630
6974
  }
6975
+ super.parseNode(esTreeNode);
7631
6976
  }
7632
6977
  }
6978
+ FunctionBase.prototype.preventChildBlockScope = true;
7633
6979
 
7634
- const NO_SEMICOLON = { isNoStatement: true };
7635
- // This assumes there are only white-space and comments between start and the string we are looking for
7636
- function findFirstOccurrenceOutsideComment(code, searchString, start = 0) {
7637
- let searchPos, charCodeAfterSlash;
7638
- searchPos = code.indexOf(searchString, start);
7639
- while (true) {
7640
- start = code.indexOf('/', start);
7641
- if (start === -1 || start >= searchPos)
7642
- return searchPos;
7643
- charCodeAfterSlash = code.charCodeAt(++start);
7644
- ++start;
7645
- // With our assumption, '/' always starts a comment. Determine comment type:
7646
- start =
7647
- charCodeAfterSlash === 47 /*"/"*/
7648
- ? code.indexOf('\n', start) + 1
7649
- : code.indexOf('*/', start) + 2;
7650
- if (start > searchPos) {
7651
- searchPos = code.indexOf(searchString, start);
7652
- }
6980
+ class ArrowFunctionExpression extends FunctionBase {
6981
+ constructor() {
6982
+ super(...arguments);
6983
+ this.objectEntity = null;
7653
6984
  }
7654
- }
7655
- const NON_WHITESPACE = /\S/g;
7656
- function findNonWhiteSpace(code, index) {
7657
- NON_WHITESPACE.lastIndex = index;
7658
- const result = NON_WHITESPACE.exec(code);
7659
- return result.index;
7660
- }
7661
- // This assumes "code" only contains white-space and comments
7662
- // Returns position of line-comment if applicable
7663
- function findFirstLineBreakOutsideComment(code) {
7664
- let lineBreakPos, charCodeAfterSlash, start = 0;
7665
- lineBreakPos = code.indexOf('\n', start);
7666
- while (true) {
7667
- start = code.indexOf('/', start);
7668
- if (start === -1 || start > lineBreakPos)
7669
- return [lineBreakPos, lineBreakPos + 1];
7670
- // With our assumption, '/' always starts a comment. Determine comment type:
7671
- charCodeAfterSlash = code.charCodeAt(start + 1);
7672
- if (charCodeAfterSlash === 47 /*"/"*/)
7673
- return [start, lineBreakPos + 1];
7674
- start = code.indexOf('*/', start + 3) + 2;
7675
- if (start > lineBreakPos) {
7676
- lineBreakPos = code.indexOf('\n', start);
6985
+ createScope(parentScope) {
6986
+ this.scope = new ReturnValueScope(parentScope, this.context);
6987
+ }
6988
+ hasEffects() {
6989
+ return false;
6990
+ }
6991
+ hasEffectsWhenCalledAtPath(path, callOptions, context) {
6992
+ if (super.hasEffectsWhenCalledAtPath(path, callOptions, context))
6993
+ return true;
6994
+ const { ignore, brokenFlow } = context;
6995
+ context.ignore = {
6996
+ breaks: false,
6997
+ continues: false,
6998
+ labels: new Set(),
6999
+ returnYield: true
7000
+ };
7001
+ if (this.body.hasEffects(context))
7002
+ return true;
7003
+ context.ignore = ignore;
7004
+ context.brokenFlow = brokenFlow;
7005
+ return false;
7006
+ }
7007
+ getObjectEntity() {
7008
+ if (this.objectEntity !== null) {
7009
+ return this.objectEntity;
7677
7010
  }
7011
+ return (this.objectEntity = new ObjectEntity([], OBJECT_PROTOTYPE));
7678
7012
  }
7679
7013
  }
7680
- function renderStatementList(statements, code, start, end, options) {
7681
- let currentNode, currentNodeStart, currentNodeNeedsBoundaries, nextNodeStart;
7682
- let nextNode = statements[0];
7683
- let nextNodeNeedsBoundaries = !nextNode.included || nextNode.needsBoundaries;
7684
- if (nextNodeNeedsBoundaries) {
7685
- nextNodeStart =
7686
- start + findFirstLineBreakOutsideComment(code.original.slice(start, nextNode.start))[1];
7014
+
7015
+ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, snippets: { _, getObject, getPropertyAccess } }, modifier = '') {
7016
+ if (exportedVariables.length === 1 &&
7017
+ exportNamesByVariable.get(exportedVariables[0]).length === 1) {
7018
+ const variable = exportedVariables[0];
7019
+ return `exports('${exportNamesByVariable.get(variable)}',${_}${variable.getName(getPropertyAccess)}${modifier})`;
7687
7020
  }
7688
- for (let nextIndex = 1; nextIndex <= statements.length; nextIndex++) {
7689
- currentNode = nextNode;
7690
- currentNodeStart = nextNodeStart;
7691
- currentNodeNeedsBoundaries = nextNodeNeedsBoundaries;
7692
- nextNode = statements[nextIndex];
7693
- nextNodeNeedsBoundaries =
7694
- nextNode === undefined ? false : !nextNode.included || nextNode.needsBoundaries;
7695
- if (currentNodeNeedsBoundaries || nextNodeNeedsBoundaries) {
7696
- nextNodeStart =
7697
- currentNode.end +
7698
- findFirstLineBreakOutsideComment(code.original.slice(currentNode.end, nextNode === undefined ? end : nextNode.start))[1];
7699
- if (currentNode.included) {
7700
- currentNodeNeedsBoundaries
7701
- ? currentNode.render(code, options, {
7702
- end: nextNodeStart,
7703
- start: currentNodeStart
7704
- })
7705
- : currentNode.render(code, options);
7706
- }
7707
- else {
7708
- treeshakeNode(currentNode, code, currentNodeStart, nextNodeStart);
7021
+ else {
7022
+ const fields = [];
7023
+ for (const variable of exportedVariables) {
7024
+ for (const exportName of exportNamesByVariable.get(variable)) {
7025
+ fields.push([exportName, variable.getName(getPropertyAccess) + modifier]);
7709
7026
  }
7710
7027
  }
7711
- else {
7712
- currentNode.render(code, options);
7713
- }
7028
+ return `exports(${getObject(fields, { lineBreakIndent: null })})`;
7714
7029
  }
7715
7030
  }
7716
- // This assumes that the first character is not part of the first node
7717
- function getCommaSeparatedNodesWithBoundaries(nodes, code, start, end) {
7718
- const splitUpNodes = [];
7719
- let node, nextNode, nextNodeStart, contentEnd, char;
7720
- let separator = start - 1;
7721
- for (let nextIndex = 0; nextIndex < nodes.length; nextIndex++) {
7722
- nextNode = nodes[nextIndex];
7723
- if (node !== undefined) {
7724
- separator =
7725
- node.end +
7726
- findFirstOccurrenceOutsideComment(code.original.slice(node.end, nextNode.start), ',');
7727
- }
7728
- nextNodeStart = contentEnd =
7729
- separator +
7730
- 1 +
7731
- findFirstLineBreakOutsideComment(code.original.slice(separator + 1, nextNode.start))[1];
7732
- while (((char = code.original.charCodeAt(nextNodeStart)),
7733
- char === 32 /*" "*/ || char === 9 /*"\t"*/ || char === 10 /*"\n"*/ || char === 13) /*"\r"*/)
7734
- nextNodeStart++;
7735
- if (node !== undefined) {
7736
- splitUpNodes.push({
7737
- contentEnd,
7738
- end: nextNodeStart,
7739
- node,
7740
- separator,
7741
- start
7742
- });
7743
- }
7744
- node = nextNode;
7745
- start = nextNodeStart;
7031
+ function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
7032
+ code.prependRight(expressionStart, `exports('${exportNamesByVariable.get(exportedVariable)}',${_}`);
7033
+ code.appendLeft(expressionEnd, ')');
7034
+ }
7035
+ function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
7036
+ const { _, getDirectReturnIifeLeft } = options.snippets;
7037
+ code.prependRight(expressionStart, getDirectReturnIifeLeft(['v'], `${getSystemExportStatement(exportedVariables, options)},${_}v`, { needsArrowReturnParens: true, needsWrappedFunction: needsParens }));
7038
+ code.appendLeft(expressionEnd, ')');
7039
+ }
7040
+ function renderSystemExportSequenceAfterExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options) {
7041
+ const { _, getPropertyAccess } = options.snippets;
7042
+ code.appendLeft(expressionEnd, `,${_}${getSystemExportStatement([exportedVariable], options)},${_}${exportedVariable.getName(getPropertyAccess)}`);
7043
+ if (needsParens) {
7044
+ code.prependRight(expressionStart, '(');
7045
+ code.appendLeft(expressionEnd, ')');
7746
7046
  }
7747
- splitUpNodes.push({
7748
- contentEnd: end,
7749
- end,
7750
- node: node,
7751
- separator: null,
7752
- start
7753
- });
7754
- return splitUpNodes;
7755
7047
  }
7756
- // This assumes there are only white-space and comments between start and end
7757
- function removeLineBreaks(code, start, end) {
7758
- while (true) {
7759
- const [removeStart, removeEnd] = findFirstLineBreakOutsideComment(code.original.slice(start, end));
7760
- if (removeStart === -1) {
7761
- break;
7048
+ function renderSystemExportSequenceBeforeExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options, modifier) {
7049
+ const { _ } = options.snippets;
7050
+ code.prependRight(expressionStart, `${getSystemExportStatement([exportedVariable], options, modifier)},${_}`);
7051
+ if (needsParens) {
7052
+ code.prependRight(expressionStart, '(');
7053
+ code.appendLeft(expressionEnd, ')');
7054
+ }
7055
+ }
7056
+
7057
+ //@ts-check
7058
+ /** @typedef { import('estree').Node} Node */
7059
+ /** @typedef {Node | {
7060
+ * type: 'PropertyDefinition';
7061
+ * computed: boolean;
7062
+ * value: Node
7063
+ * }} NodeWithPropertyDefinition */
7064
+
7065
+ /**
7066
+ *
7067
+ * @param {NodeWithPropertyDefinition} node
7068
+ * @param {NodeWithPropertyDefinition} parent
7069
+ * @returns boolean
7070
+ */
7071
+ function is_reference (node, parent) {
7072
+ if (node.type === 'MemberExpression') {
7073
+ return !node.computed && is_reference(node.object, node);
7074
+ }
7075
+
7076
+ if (node.type === 'Identifier') {
7077
+ if (!parent) return true;
7078
+
7079
+ switch (parent.type) {
7080
+ // disregard `bar` in `foo.bar`
7081
+ case 'MemberExpression': return parent.computed || node === parent.object;
7082
+
7083
+ // disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
7084
+ case 'MethodDefinition': return parent.computed;
7085
+
7086
+ // disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
7087
+ case 'PropertyDefinition': return parent.computed || node === parent.value;
7088
+
7089
+ // disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
7090
+ case 'Property': return parent.computed || node === parent.value;
7091
+
7092
+ // disregard the `bar` in `export { foo as bar }` or
7093
+ // the foo in `import { foo as bar }`
7094
+ case 'ExportSpecifier':
7095
+ case 'ImportSpecifier': return node === parent.local;
7096
+
7097
+ // disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
7098
+ case 'LabeledStatement':
7099
+ case 'BreakStatement':
7100
+ case 'ContinueStatement': return false;
7101
+ default: return true;
7102
+ }
7103
+ }
7104
+
7105
+ return false;
7106
+ }
7107
+
7108
+ /* eslint sort-keys: "off" */
7109
+ const ValueProperties = Symbol('Value Properties');
7110
+ const PURE = {
7111
+ hasEffectsWhenCalled() {
7112
+ return false;
7113
+ }
7114
+ };
7115
+ const IMPURE = {
7116
+ hasEffectsWhenCalled() {
7117
+ return true;
7118
+ }
7119
+ };
7120
+ // We use shortened variables to reduce file size here
7121
+ /* OBJECT */
7122
+ const O = {
7123
+ __proto__: null,
7124
+ [ValueProperties]: IMPURE
7125
+ };
7126
+ /* PURE FUNCTION */
7127
+ const PF = {
7128
+ __proto__: null,
7129
+ [ValueProperties]: PURE
7130
+ };
7131
+ /* FUNCTION THAT MUTATES FIRST ARG WITHOUT TRIGGERING ACCESSORS */
7132
+ const MUTATES_ARG_WITHOUT_ACCESSOR = {
7133
+ __proto__: null,
7134
+ [ValueProperties]: {
7135
+ hasEffectsWhenCalled(callOptions, context) {
7136
+ return (!callOptions.args.length ||
7137
+ callOptions.args[0].hasEffectsWhenAssignedAtPath(UNKNOWN_NON_ACCESSOR_PATH, context));
7762
7138
  }
7763
- code.remove(start + removeStart, (start += removeEnd));
7764
7139
  }
7140
+ };
7141
+ /* CONSTRUCTOR */
7142
+ const C = {
7143
+ __proto__: null,
7144
+ [ValueProperties]: IMPURE,
7145
+ prototype: O
7146
+ };
7147
+ /* PURE CONSTRUCTOR */
7148
+ const PC = {
7149
+ __proto__: null,
7150
+ [ValueProperties]: PURE,
7151
+ prototype: O
7152
+ };
7153
+ const ARRAY_TYPE = {
7154
+ __proto__: null,
7155
+ [ValueProperties]: PURE,
7156
+ from: PF,
7157
+ of: PF,
7158
+ prototype: O
7159
+ };
7160
+ const INTL_MEMBER = {
7161
+ __proto__: null,
7162
+ [ValueProperties]: PURE,
7163
+ supportedLocalesOf: PC
7164
+ };
7165
+ const knownGlobals = {
7166
+ // Placeholders for global objects to avoid shape mutations
7167
+ global: O,
7168
+ globalThis: O,
7169
+ self: O,
7170
+ window: O,
7171
+ // Common globals
7172
+ __proto__: null,
7173
+ [ValueProperties]: IMPURE,
7174
+ Array: {
7175
+ __proto__: null,
7176
+ [ValueProperties]: IMPURE,
7177
+ from: O,
7178
+ isArray: PF,
7179
+ of: PF,
7180
+ prototype: O
7181
+ },
7182
+ ArrayBuffer: {
7183
+ __proto__: null,
7184
+ [ValueProperties]: PURE,
7185
+ isView: PF,
7186
+ prototype: O
7187
+ },
7188
+ Atomics: O,
7189
+ BigInt: C,
7190
+ BigInt64Array: C,
7191
+ BigUint64Array: C,
7192
+ Boolean: PC,
7193
+ constructor: C,
7194
+ DataView: PC,
7195
+ Date: {
7196
+ __proto__: null,
7197
+ [ValueProperties]: PURE,
7198
+ now: PF,
7199
+ parse: PF,
7200
+ prototype: O,
7201
+ UTC: PF
7202
+ },
7203
+ decodeURI: PF,
7204
+ decodeURIComponent: PF,
7205
+ encodeURI: PF,
7206
+ encodeURIComponent: PF,
7207
+ Error: PC,
7208
+ escape: PF,
7209
+ eval: O,
7210
+ EvalError: PC,
7211
+ Float32Array: ARRAY_TYPE,
7212
+ Float64Array: ARRAY_TYPE,
7213
+ Function: C,
7214
+ hasOwnProperty: O,
7215
+ Infinity: O,
7216
+ Int16Array: ARRAY_TYPE,
7217
+ Int32Array: ARRAY_TYPE,
7218
+ Int8Array: ARRAY_TYPE,
7219
+ isFinite: PF,
7220
+ isNaN: PF,
7221
+ isPrototypeOf: O,
7222
+ JSON: O,
7223
+ Map: PC,
7224
+ Math: {
7225
+ __proto__: null,
7226
+ [ValueProperties]: IMPURE,
7227
+ abs: PF,
7228
+ acos: PF,
7229
+ acosh: PF,
7230
+ asin: PF,
7231
+ asinh: PF,
7232
+ atan: PF,
7233
+ atan2: PF,
7234
+ atanh: PF,
7235
+ cbrt: PF,
7236
+ ceil: PF,
7237
+ clz32: PF,
7238
+ cos: PF,
7239
+ cosh: PF,
7240
+ exp: PF,
7241
+ expm1: PF,
7242
+ floor: PF,
7243
+ fround: PF,
7244
+ hypot: PF,
7245
+ imul: PF,
7246
+ log: PF,
7247
+ log10: PF,
7248
+ log1p: PF,
7249
+ log2: PF,
7250
+ max: PF,
7251
+ min: PF,
7252
+ pow: PF,
7253
+ random: PF,
7254
+ round: PF,
7255
+ sign: PF,
7256
+ sin: PF,
7257
+ sinh: PF,
7258
+ sqrt: PF,
7259
+ tan: PF,
7260
+ tanh: PF,
7261
+ trunc: PF
7262
+ },
7263
+ NaN: O,
7264
+ Number: {
7265
+ __proto__: null,
7266
+ [ValueProperties]: PURE,
7267
+ isFinite: PF,
7268
+ isInteger: PF,
7269
+ isNaN: PF,
7270
+ isSafeInteger: PF,
7271
+ parseFloat: PF,
7272
+ parseInt: PF,
7273
+ prototype: O
7274
+ },
7275
+ Object: {
7276
+ __proto__: null,
7277
+ [ValueProperties]: PURE,
7278
+ create: PF,
7279
+ // Technically those can throw in certain situations, but we ignore this as
7280
+ // code that relies on this will hopefully wrap this in a try-catch, which
7281
+ // deoptimizes everything anyway
7282
+ defineProperty: MUTATES_ARG_WITHOUT_ACCESSOR,
7283
+ defineProperties: MUTATES_ARG_WITHOUT_ACCESSOR,
7284
+ getOwnPropertyDescriptor: PF,
7285
+ getOwnPropertyNames: PF,
7286
+ getOwnPropertySymbols: PF,
7287
+ getPrototypeOf: PF,
7288
+ hasOwn: PF,
7289
+ is: PF,
7290
+ isExtensible: PF,
7291
+ isFrozen: PF,
7292
+ isSealed: PF,
7293
+ keys: PF,
7294
+ fromEntries: PF,
7295
+ entries: PF,
7296
+ prototype: O
7297
+ },
7298
+ parseFloat: PF,
7299
+ parseInt: PF,
7300
+ Promise: {
7301
+ __proto__: null,
7302
+ [ValueProperties]: IMPURE,
7303
+ all: O,
7304
+ prototype: O,
7305
+ race: O,
7306
+ reject: O,
7307
+ resolve: O
7308
+ },
7309
+ propertyIsEnumerable: O,
7310
+ Proxy: O,
7311
+ RangeError: PC,
7312
+ ReferenceError: PC,
7313
+ Reflect: O,
7314
+ RegExp: PC,
7315
+ Set: PC,
7316
+ SharedArrayBuffer: C,
7317
+ String: {
7318
+ __proto__: null,
7319
+ [ValueProperties]: PURE,
7320
+ fromCharCode: PF,
7321
+ fromCodePoint: PF,
7322
+ prototype: O,
7323
+ raw: PF
7324
+ },
7325
+ Symbol: {
7326
+ __proto__: null,
7327
+ [ValueProperties]: PURE,
7328
+ for: PF,
7329
+ keyFor: PF,
7330
+ prototype: O
7331
+ },
7332
+ SyntaxError: PC,
7333
+ toLocaleString: O,
7334
+ toString: O,
7335
+ TypeError: PC,
7336
+ Uint16Array: ARRAY_TYPE,
7337
+ Uint32Array: ARRAY_TYPE,
7338
+ Uint8Array: ARRAY_TYPE,
7339
+ Uint8ClampedArray: ARRAY_TYPE,
7340
+ // Technically, this is a global, but it needs special handling
7341
+ // undefined: ?,
7342
+ unescape: PF,
7343
+ URIError: PC,
7344
+ valueOf: O,
7345
+ WeakMap: PC,
7346
+ WeakSet: PC,
7347
+ // Additional globals shared by Node and Browser that are not strictly part of the language
7348
+ clearInterval: C,
7349
+ clearTimeout: C,
7350
+ console: O,
7351
+ Intl: {
7352
+ __proto__: null,
7353
+ [ValueProperties]: IMPURE,
7354
+ Collator: INTL_MEMBER,
7355
+ DateTimeFormat: INTL_MEMBER,
7356
+ ListFormat: INTL_MEMBER,
7357
+ NumberFormat: INTL_MEMBER,
7358
+ PluralRules: INTL_MEMBER,
7359
+ RelativeTimeFormat: INTL_MEMBER
7360
+ },
7361
+ setInterval: C,
7362
+ setTimeout: C,
7363
+ TextDecoder: C,
7364
+ TextEncoder: C,
7365
+ URL: C,
7366
+ URLSearchParams: C,
7367
+ // Browser specific globals
7368
+ AbortController: C,
7369
+ AbortSignal: C,
7370
+ addEventListener: O,
7371
+ alert: O,
7372
+ AnalyserNode: C,
7373
+ Animation: C,
7374
+ AnimationEvent: C,
7375
+ applicationCache: O,
7376
+ ApplicationCache: C,
7377
+ ApplicationCacheErrorEvent: C,
7378
+ atob: O,
7379
+ Attr: C,
7380
+ Audio: C,
7381
+ AudioBuffer: C,
7382
+ AudioBufferSourceNode: C,
7383
+ AudioContext: C,
7384
+ AudioDestinationNode: C,
7385
+ AudioListener: C,
7386
+ AudioNode: C,
7387
+ AudioParam: C,
7388
+ AudioProcessingEvent: C,
7389
+ AudioScheduledSourceNode: C,
7390
+ AudioWorkletNode: C,
7391
+ BarProp: C,
7392
+ BaseAudioContext: C,
7393
+ BatteryManager: C,
7394
+ BeforeUnloadEvent: C,
7395
+ BiquadFilterNode: C,
7396
+ Blob: C,
7397
+ BlobEvent: C,
7398
+ blur: O,
7399
+ BroadcastChannel: C,
7400
+ btoa: O,
7401
+ ByteLengthQueuingStrategy: C,
7402
+ Cache: C,
7403
+ caches: O,
7404
+ CacheStorage: C,
7405
+ cancelAnimationFrame: O,
7406
+ cancelIdleCallback: O,
7407
+ CanvasCaptureMediaStreamTrack: C,
7408
+ CanvasGradient: C,
7409
+ CanvasPattern: C,
7410
+ CanvasRenderingContext2D: C,
7411
+ ChannelMergerNode: C,
7412
+ ChannelSplitterNode: C,
7413
+ CharacterData: C,
7414
+ clientInformation: O,
7415
+ ClipboardEvent: C,
7416
+ close: O,
7417
+ closed: O,
7418
+ CloseEvent: C,
7419
+ Comment: C,
7420
+ CompositionEvent: C,
7421
+ confirm: O,
7422
+ ConstantSourceNode: C,
7423
+ ConvolverNode: C,
7424
+ CountQueuingStrategy: C,
7425
+ createImageBitmap: O,
7426
+ Credential: C,
7427
+ CredentialsContainer: C,
7428
+ crypto: O,
7429
+ Crypto: C,
7430
+ CryptoKey: C,
7431
+ CSS: C,
7432
+ CSSConditionRule: C,
7433
+ CSSFontFaceRule: C,
7434
+ CSSGroupingRule: C,
7435
+ CSSImportRule: C,
7436
+ CSSKeyframeRule: C,
7437
+ CSSKeyframesRule: C,
7438
+ CSSMediaRule: C,
7439
+ CSSNamespaceRule: C,
7440
+ CSSPageRule: C,
7441
+ CSSRule: C,
7442
+ CSSRuleList: C,
7443
+ CSSStyleDeclaration: C,
7444
+ CSSStyleRule: C,
7445
+ CSSStyleSheet: C,
7446
+ CSSSupportsRule: C,
7447
+ CustomElementRegistry: C,
7448
+ customElements: O,
7449
+ CustomEvent: C,
7450
+ DataTransfer: C,
7451
+ DataTransferItem: C,
7452
+ DataTransferItemList: C,
7453
+ defaultstatus: O,
7454
+ defaultStatus: O,
7455
+ DelayNode: C,
7456
+ DeviceMotionEvent: C,
7457
+ DeviceOrientationEvent: C,
7458
+ devicePixelRatio: O,
7459
+ dispatchEvent: O,
7460
+ document: O,
7461
+ Document: C,
7462
+ DocumentFragment: C,
7463
+ DocumentType: C,
7464
+ DOMError: C,
7465
+ DOMException: C,
7466
+ DOMImplementation: C,
7467
+ DOMMatrix: C,
7468
+ DOMMatrixReadOnly: C,
7469
+ DOMParser: C,
7470
+ DOMPoint: C,
7471
+ DOMPointReadOnly: C,
7472
+ DOMQuad: C,
7473
+ DOMRect: C,
7474
+ DOMRectReadOnly: C,
7475
+ DOMStringList: C,
7476
+ DOMStringMap: C,
7477
+ DOMTokenList: C,
7478
+ DragEvent: C,
7479
+ DynamicsCompressorNode: C,
7480
+ Element: C,
7481
+ ErrorEvent: C,
7482
+ Event: C,
7483
+ EventSource: C,
7484
+ EventTarget: C,
7485
+ external: O,
7486
+ fetch: O,
7487
+ File: C,
7488
+ FileList: C,
7489
+ FileReader: C,
7490
+ find: O,
7491
+ focus: O,
7492
+ FocusEvent: C,
7493
+ FontFace: C,
7494
+ FontFaceSetLoadEvent: C,
7495
+ FormData: C,
7496
+ frames: O,
7497
+ GainNode: C,
7498
+ Gamepad: C,
7499
+ GamepadButton: C,
7500
+ GamepadEvent: C,
7501
+ getComputedStyle: O,
7502
+ getSelection: O,
7503
+ HashChangeEvent: C,
7504
+ Headers: C,
7505
+ history: O,
7506
+ History: C,
7507
+ HTMLAllCollection: C,
7508
+ HTMLAnchorElement: C,
7509
+ HTMLAreaElement: C,
7510
+ HTMLAudioElement: C,
7511
+ HTMLBaseElement: C,
7512
+ HTMLBodyElement: C,
7513
+ HTMLBRElement: C,
7514
+ HTMLButtonElement: C,
7515
+ HTMLCanvasElement: C,
7516
+ HTMLCollection: C,
7517
+ HTMLContentElement: C,
7518
+ HTMLDataElement: C,
7519
+ HTMLDataListElement: C,
7520
+ HTMLDetailsElement: C,
7521
+ HTMLDialogElement: C,
7522
+ HTMLDirectoryElement: C,
7523
+ HTMLDivElement: C,
7524
+ HTMLDListElement: C,
7525
+ HTMLDocument: C,
7526
+ HTMLElement: C,
7527
+ HTMLEmbedElement: C,
7528
+ HTMLFieldSetElement: C,
7529
+ HTMLFontElement: C,
7530
+ HTMLFormControlsCollection: C,
7531
+ HTMLFormElement: C,
7532
+ HTMLFrameElement: C,
7533
+ HTMLFrameSetElement: C,
7534
+ HTMLHeadElement: C,
7535
+ HTMLHeadingElement: C,
7536
+ HTMLHRElement: C,
7537
+ HTMLHtmlElement: C,
7538
+ HTMLIFrameElement: C,
7539
+ HTMLImageElement: C,
7540
+ HTMLInputElement: C,
7541
+ HTMLLabelElement: C,
7542
+ HTMLLegendElement: C,
7543
+ HTMLLIElement: C,
7544
+ HTMLLinkElement: C,
7545
+ HTMLMapElement: C,
7546
+ HTMLMarqueeElement: C,
7547
+ HTMLMediaElement: C,
7548
+ HTMLMenuElement: C,
7549
+ HTMLMetaElement: C,
7550
+ HTMLMeterElement: C,
7551
+ HTMLModElement: C,
7552
+ HTMLObjectElement: C,
7553
+ HTMLOListElement: C,
7554
+ HTMLOptGroupElement: C,
7555
+ HTMLOptionElement: C,
7556
+ HTMLOptionsCollection: C,
7557
+ HTMLOutputElement: C,
7558
+ HTMLParagraphElement: C,
7559
+ HTMLParamElement: C,
7560
+ HTMLPictureElement: C,
7561
+ HTMLPreElement: C,
7562
+ HTMLProgressElement: C,
7563
+ HTMLQuoteElement: C,
7564
+ HTMLScriptElement: C,
7565
+ HTMLSelectElement: C,
7566
+ HTMLShadowElement: C,
7567
+ HTMLSlotElement: C,
7568
+ HTMLSourceElement: C,
7569
+ HTMLSpanElement: C,
7570
+ HTMLStyleElement: C,
7571
+ HTMLTableCaptionElement: C,
7572
+ HTMLTableCellElement: C,
7573
+ HTMLTableColElement: C,
7574
+ HTMLTableElement: C,
7575
+ HTMLTableRowElement: C,
7576
+ HTMLTableSectionElement: C,
7577
+ HTMLTemplateElement: C,
7578
+ HTMLTextAreaElement: C,
7579
+ HTMLTimeElement: C,
7580
+ HTMLTitleElement: C,
7581
+ HTMLTrackElement: C,
7582
+ HTMLUListElement: C,
7583
+ HTMLUnknownElement: C,
7584
+ HTMLVideoElement: C,
7585
+ IDBCursor: C,
7586
+ IDBCursorWithValue: C,
7587
+ IDBDatabase: C,
7588
+ IDBFactory: C,
7589
+ IDBIndex: C,
7590
+ IDBKeyRange: C,
7591
+ IDBObjectStore: C,
7592
+ IDBOpenDBRequest: C,
7593
+ IDBRequest: C,
7594
+ IDBTransaction: C,
7595
+ IDBVersionChangeEvent: C,
7596
+ IdleDeadline: C,
7597
+ IIRFilterNode: C,
7598
+ Image: C,
7599
+ ImageBitmap: C,
7600
+ ImageBitmapRenderingContext: C,
7601
+ ImageCapture: C,
7602
+ ImageData: C,
7603
+ indexedDB: O,
7604
+ innerHeight: O,
7605
+ innerWidth: O,
7606
+ InputEvent: C,
7607
+ IntersectionObserver: C,
7608
+ IntersectionObserverEntry: C,
7609
+ isSecureContext: O,
7610
+ KeyboardEvent: C,
7611
+ KeyframeEffect: C,
7612
+ length: O,
7613
+ localStorage: O,
7614
+ location: O,
7615
+ Location: C,
7616
+ locationbar: O,
7617
+ matchMedia: O,
7618
+ MediaDeviceInfo: C,
7619
+ MediaDevices: C,
7620
+ MediaElementAudioSourceNode: C,
7621
+ MediaEncryptedEvent: C,
7622
+ MediaError: C,
7623
+ MediaKeyMessageEvent: C,
7624
+ MediaKeySession: C,
7625
+ MediaKeyStatusMap: C,
7626
+ MediaKeySystemAccess: C,
7627
+ MediaList: C,
7628
+ MediaQueryList: C,
7629
+ MediaQueryListEvent: C,
7630
+ MediaRecorder: C,
7631
+ MediaSettingsRange: C,
7632
+ MediaSource: C,
7633
+ MediaStream: C,
7634
+ MediaStreamAudioDestinationNode: C,
7635
+ MediaStreamAudioSourceNode: C,
7636
+ MediaStreamEvent: C,
7637
+ MediaStreamTrack: C,
7638
+ MediaStreamTrackEvent: C,
7639
+ menubar: O,
7640
+ MessageChannel: C,
7641
+ MessageEvent: C,
7642
+ MessagePort: C,
7643
+ MIDIAccess: C,
7644
+ MIDIConnectionEvent: C,
7645
+ MIDIInput: C,
7646
+ MIDIInputMap: C,
7647
+ MIDIMessageEvent: C,
7648
+ MIDIOutput: C,
7649
+ MIDIOutputMap: C,
7650
+ MIDIPort: C,
7651
+ MimeType: C,
7652
+ MimeTypeArray: C,
7653
+ MouseEvent: C,
7654
+ moveBy: O,
7655
+ moveTo: O,
7656
+ MutationEvent: C,
7657
+ MutationObserver: C,
7658
+ MutationRecord: C,
7659
+ name: O,
7660
+ NamedNodeMap: C,
7661
+ NavigationPreloadManager: C,
7662
+ navigator: O,
7663
+ Navigator: C,
7664
+ NetworkInformation: C,
7665
+ Node: C,
7666
+ NodeFilter: O,
7667
+ NodeIterator: C,
7668
+ NodeList: C,
7669
+ Notification: C,
7670
+ OfflineAudioCompletionEvent: C,
7671
+ OfflineAudioContext: C,
7672
+ offscreenBuffering: O,
7673
+ OffscreenCanvas: C,
7674
+ open: O,
7675
+ openDatabase: O,
7676
+ Option: C,
7677
+ origin: O,
7678
+ OscillatorNode: C,
7679
+ outerHeight: O,
7680
+ outerWidth: O,
7681
+ PageTransitionEvent: C,
7682
+ pageXOffset: O,
7683
+ pageYOffset: O,
7684
+ PannerNode: C,
7685
+ parent: O,
7686
+ Path2D: C,
7687
+ PaymentAddress: C,
7688
+ PaymentRequest: C,
7689
+ PaymentRequestUpdateEvent: C,
7690
+ PaymentResponse: C,
7691
+ performance: O,
7692
+ Performance: C,
7693
+ PerformanceEntry: C,
7694
+ PerformanceLongTaskTiming: C,
7695
+ PerformanceMark: C,
7696
+ PerformanceMeasure: C,
7697
+ PerformanceNavigation: C,
7698
+ PerformanceNavigationTiming: C,
7699
+ PerformanceObserver: C,
7700
+ PerformanceObserverEntryList: C,
7701
+ PerformancePaintTiming: C,
7702
+ PerformanceResourceTiming: C,
7703
+ PerformanceTiming: C,
7704
+ PeriodicWave: C,
7705
+ Permissions: C,
7706
+ PermissionStatus: C,
7707
+ personalbar: O,
7708
+ PhotoCapabilities: C,
7709
+ Plugin: C,
7710
+ PluginArray: C,
7711
+ PointerEvent: C,
7712
+ PopStateEvent: C,
7713
+ postMessage: O,
7714
+ Presentation: C,
7715
+ PresentationAvailability: C,
7716
+ PresentationConnection: C,
7717
+ PresentationConnectionAvailableEvent: C,
7718
+ PresentationConnectionCloseEvent: C,
7719
+ PresentationConnectionList: C,
7720
+ PresentationReceiver: C,
7721
+ PresentationRequest: C,
7722
+ print: O,
7723
+ ProcessingInstruction: C,
7724
+ ProgressEvent: C,
7725
+ PromiseRejectionEvent: C,
7726
+ prompt: O,
7727
+ PushManager: C,
7728
+ PushSubscription: C,
7729
+ PushSubscriptionOptions: C,
7730
+ queueMicrotask: O,
7731
+ RadioNodeList: C,
7732
+ Range: C,
7733
+ ReadableStream: C,
7734
+ RemotePlayback: C,
7735
+ removeEventListener: O,
7736
+ Request: C,
7737
+ requestAnimationFrame: O,
7738
+ requestIdleCallback: O,
7739
+ resizeBy: O,
7740
+ ResizeObserver: C,
7741
+ ResizeObserverEntry: C,
7742
+ resizeTo: O,
7743
+ Response: C,
7744
+ RTCCertificate: C,
7745
+ RTCDataChannel: C,
7746
+ RTCDataChannelEvent: C,
7747
+ RTCDtlsTransport: C,
7748
+ RTCIceCandidate: C,
7749
+ RTCIceTransport: C,
7750
+ RTCPeerConnection: C,
7751
+ RTCPeerConnectionIceEvent: C,
7752
+ RTCRtpReceiver: C,
7753
+ RTCRtpSender: C,
7754
+ RTCSctpTransport: C,
7755
+ RTCSessionDescription: C,
7756
+ RTCStatsReport: C,
7757
+ RTCTrackEvent: C,
7758
+ screen: O,
7759
+ Screen: C,
7760
+ screenLeft: O,
7761
+ ScreenOrientation: C,
7762
+ screenTop: O,
7763
+ screenX: O,
7764
+ screenY: O,
7765
+ ScriptProcessorNode: C,
7766
+ scroll: O,
7767
+ scrollbars: O,
7768
+ scrollBy: O,
7769
+ scrollTo: O,
7770
+ scrollX: O,
7771
+ scrollY: O,
7772
+ SecurityPolicyViolationEvent: C,
7773
+ Selection: C,
7774
+ ServiceWorker: C,
7775
+ ServiceWorkerContainer: C,
7776
+ ServiceWorkerRegistration: C,
7777
+ sessionStorage: O,
7778
+ ShadowRoot: C,
7779
+ SharedWorker: C,
7780
+ SourceBuffer: C,
7781
+ SourceBufferList: C,
7782
+ speechSynthesis: O,
7783
+ SpeechSynthesisEvent: C,
7784
+ SpeechSynthesisUtterance: C,
7785
+ StaticRange: C,
7786
+ status: O,
7787
+ statusbar: O,
7788
+ StereoPannerNode: C,
7789
+ stop: O,
7790
+ Storage: C,
7791
+ StorageEvent: C,
7792
+ StorageManager: C,
7793
+ styleMedia: O,
7794
+ StyleSheet: C,
7795
+ StyleSheetList: C,
7796
+ SubtleCrypto: C,
7797
+ SVGAElement: C,
7798
+ SVGAngle: C,
7799
+ SVGAnimatedAngle: C,
7800
+ SVGAnimatedBoolean: C,
7801
+ SVGAnimatedEnumeration: C,
7802
+ SVGAnimatedInteger: C,
7803
+ SVGAnimatedLength: C,
7804
+ SVGAnimatedLengthList: C,
7805
+ SVGAnimatedNumber: C,
7806
+ SVGAnimatedNumberList: C,
7807
+ SVGAnimatedPreserveAspectRatio: C,
7808
+ SVGAnimatedRect: C,
7809
+ SVGAnimatedString: C,
7810
+ SVGAnimatedTransformList: C,
7811
+ SVGAnimateElement: C,
7812
+ SVGAnimateMotionElement: C,
7813
+ SVGAnimateTransformElement: C,
7814
+ SVGAnimationElement: C,
7815
+ SVGCircleElement: C,
7816
+ SVGClipPathElement: C,
7817
+ SVGComponentTransferFunctionElement: C,
7818
+ SVGDefsElement: C,
7819
+ SVGDescElement: C,
7820
+ SVGDiscardElement: C,
7821
+ SVGElement: C,
7822
+ SVGEllipseElement: C,
7823
+ SVGFEBlendElement: C,
7824
+ SVGFEColorMatrixElement: C,
7825
+ SVGFEComponentTransferElement: C,
7826
+ SVGFECompositeElement: C,
7827
+ SVGFEConvolveMatrixElement: C,
7828
+ SVGFEDiffuseLightingElement: C,
7829
+ SVGFEDisplacementMapElement: C,
7830
+ SVGFEDistantLightElement: C,
7831
+ SVGFEDropShadowElement: C,
7832
+ SVGFEFloodElement: C,
7833
+ SVGFEFuncAElement: C,
7834
+ SVGFEFuncBElement: C,
7835
+ SVGFEFuncGElement: C,
7836
+ SVGFEFuncRElement: C,
7837
+ SVGFEGaussianBlurElement: C,
7838
+ SVGFEImageElement: C,
7839
+ SVGFEMergeElement: C,
7840
+ SVGFEMergeNodeElement: C,
7841
+ SVGFEMorphologyElement: C,
7842
+ SVGFEOffsetElement: C,
7843
+ SVGFEPointLightElement: C,
7844
+ SVGFESpecularLightingElement: C,
7845
+ SVGFESpotLightElement: C,
7846
+ SVGFETileElement: C,
7847
+ SVGFETurbulenceElement: C,
7848
+ SVGFilterElement: C,
7849
+ SVGForeignObjectElement: C,
7850
+ SVGGElement: C,
7851
+ SVGGeometryElement: C,
7852
+ SVGGradientElement: C,
7853
+ SVGGraphicsElement: C,
7854
+ SVGImageElement: C,
7855
+ SVGLength: C,
7856
+ SVGLengthList: C,
7857
+ SVGLinearGradientElement: C,
7858
+ SVGLineElement: C,
7859
+ SVGMarkerElement: C,
7860
+ SVGMaskElement: C,
7861
+ SVGMatrix: C,
7862
+ SVGMetadataElement: C,
7863
+ SVGMPathElement: C,
7864
+ SVGNumber: C,
7865
+ SVGNumberList: C,
7866
+ SVGPathElement: C,
7867
+ SVGPatternElement: C,
7868
+ SVGPoint: C,
7869
+ SVGPointList: C,
7870
+ SVGPolygonElement: C,
7871
+ SVGPolylineElement: C,
7872
+ SVGPreserveAspectRatio: C,
7873
+ SVGRadialGradientElement: C,
7874
+ SVGRect: C,
7875
+ SVGRectElement: C,
7876
+ SVGScriptElement: C,
7877
+ SVGSetElement: C,
7878
+ SVGStopElement: C,
7879
+ SVGStringList: C,
7880
+ SVGStyleElement: C,
7881
+ SVGSVGElement: C,
7882
+ SVGSwitchElement: C,
7883
+ SVGSymbolElement: C,
7884
+ SVGTextContentElement: C,
7885
+ SVGTextElement: C,
7886
+ SVGTextPathElement: C,
7887
+ SVGTextPositioningElement: C,
7888
+ SVGTitleElement: C,
7889
+ SVGTransform: C,
7890
+ SVGTransformList: C,
7891
+ SVGTSpanElement: C,
7892
+ SVGUnitTypes: C,
7893
+ SVGUseElement: C,
7894
+ SVGViewElement: C,
7895
+ TaskAttributionTiming: C,
7896
+ Text: C,
7897
+ TextEvent: C,
7898
+ TextMetrics: C,
7899
+ TextTrack: C,
7900
+ TextTrackCue: C,
7901
+ TextTrackCueList: C,
7902
+ TextTrackList: C,
7903
+ TimeRanges: C,
7904
+ toolbar: O,
7905
+ top: O,
7906
+ Touch: C,
7907
+ TouchEvent: C,
7908
+ TouchList: C,
7909
+ TrackEvent: C,
7910
+ TransitionEvent: C,
7911
+ TreeWalker: C,
7912
+ UIEvent: C,
7913
+ ValidityState: C,
7914
+ visualViewport: O,
7915
+ VisualViewport: C,
7916
+ VTTCue: C,
7917
+ WaveShaperNode: C,
7918
+ WebAssembly: O,
7919
+ WebGL2RenderingContext: C,
7920
+ WebGLActiveInfo: C,
7921
+ WebGLBuffer: C,
7922
+ WebGLContextEvent: C,
7923
+ WebGLFramebuffer: C,
7924
+ WebGLProgram: C,
7925
+ WebGLQuery: C,
7926
+ WebGLRenderbuffer: C,
7927
+ WebGLRenderingContext: C,
7928
+ WebGLSampler: C,
7929
+ WebGLShader: C,
7930
+ WebGLShaderPrecisionFormat: C,
7931
+ WebGLSync: C,
7932
+ WebGLTexture: C,
7933
+ WebGLTransformFeedback: C,
7934
+ WebGLUniformLocation: C,
7935
+ WebGLVertexArrayObject: C,
7936
+ WebSocket: C,
7937
+ WheelEvent: C,
7938
+ Window: C,
7939
+ Worker: C,
7940
+ WritableStream: C,
7941
+ XMLDocument: C,
7942
+ XMLHttpRequest: C,
7943
+ XMLHttpRequestEventTarget: C,
7944
+ XMLHttpRequestUpload: C,
7945
+ XMLSerializer: C,
7946
+ XPathEvaluator: C,
7947
+ XPathExpression: C,
7948
+ XPathResult: C,
7949
+ XSLTProcessor: C
7950
+ };
7951
+ for (const global of ['window', 'global', 'self', 'globalThis']) {
7952
+ knownGlobals[global] = knownGlobals;
7765
7953
  }
7766
-
7767
- class BlockScope extends ChildScope {
7768
- addDeclaration(identifier, context, init, isHoisted) {
7769
- if (isHoisted) {
7770
- const variable = this.parent.addDeclaration(identifier, context, init, isHoisted);
7771
- // Necessary to make sure the init is deoptimized for conditional declarations.
7772
- // We cannot call deoptimizePath here.
7773
- variable.markInitializersForDeoptimization();
7774
- return variable;
7775
- }
7776
- else {
7777
- return super.addDeclaration(identifier, context, init, false);
7954
+ function getGlobalAtPath(path) {
7955
+ let currentGlobal = knownGlobals;
7956
+ for (const pathSegment of path) {
7957
+ if (typeof pathSegment !== 'string') {
7958
+ return null;
7778
7959
  }
7779
- }
7780
- }
7781
-
7782
- class ExpressionStatement extends NodeBase {
7783
- initialise() {
7784
- if (this.directive &&
7785
- this.directive !== 'use strict' &&
7786
- this.parent.type === Program$1) {
7787
- this.context.warn(
7788
- // This is necessary, because either way (deleting or not) can lead to errors.
7789
- {
7790
- code: 'MODULE_LEVEL_DIRECTIVE',
7791
- message: `Module level directives cause errors when bundled, '${this.directive}' was ignored.`
7792
- }, this.start);
7960
+ currentGlobal = currentGlobal[pathSegment];
7961
+ if (!currentGlobal) {
7962
+ return null;
7793
7963
  }
7794
7964
  }
7795
- render(code, options) {
7796
- super.render(code, options);
7797
- if (this.included)
7798
- this.insertSemicolon(code);
7799
- }
7800
- shouldBeIncluded(context) {
7801
- if (this.directive && this.directive !== 'use strict')
7802
- return this.parent.type !== Program$1;
7803
- return super.shouldBeIncluded(context);
7804
- }
7965
+ return currentGlobal[ValueProperties];
7805
7966
  }
7806
7967
 
7807
- class BlockStatement extends NodeBase {
7968
+ class GlobalVariable extends Variable {
7808
7969
  constructor() {
7809
7970
  super(...arguments);
7810
- this.directlyIncluded = false;
7811
- }
7812
- addImplicitReturnExpressionToScope() {
7813
- const lastStatement = this.body[this.body.length - 1];
7814
- if (!lastStatement || lastStatement.type !== ReturnStatement$1) {
7815
- this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
7816
- }
7817
- }
7818
- createScope(parentScope) {
7819
- this.scope = this.parent.preventChildBlockScope
7820
- ? parentScope
7821
- : new BlockScope(parentScope);
7971
+ // Ensure we use live-bindings for globals as we do not know if they have
7972
+ // been reassigned
7973
+ this.isReassigned = true;
7822
7974
  }
7823
- hasEffects(context) {
7824
- if (this.deoptimizeBody)
7825
- return true;
7826
- for (const node of this.body) {
7827
- if (context.brokenFlow)
7828
- break;
7829
- if (node.hasEffects(context))
7830
- return true;
7831
- }
7832
- return false;
7975
+ getLiteralValueAtPath(path, _recursionTracker, _origin) {
7976
+ return getGlobalAtPath([this.name, ...path]) ? UnknownTruthyValue : UnknownValue;
7833
7977
  }
7834
- include(context, includeChildrenRecursively) {
7835
- if (!(this.deoptimizeBody && this.directlyIncluded)) {
7836
- this.included = true;
7837
- this.directlyIncluded = true;
7838
- if (this.deoptimizeBody)
7839
- includeChildrenRecursively = true;
7840
- for (const node of this.body) {
7841
- if (includeChildrenRecursively || node.shouldBeIncluded(context))
7842
- node.include(context, includeChildrenRecursively);
7843
- }
7978
+ hasEffectsWhenAccessedAtPath(path) {
7979
+ if (path.length === 0) {
7980
+ // Technically, "undefined" is a global variable of sorts
7981
+ return this.name !== 'undefined' && !getGlobalAtPath([this.name]);
7844
7982
  }
7983
+ return !getGlobalAtPath([this.name, ...path].slice(0, -1));
7845
7984
  }
7846
- initialise() {
7847
- const firstBodyStatement = this.body[0];
7848
- this.deoptimizeBody =
7849
- firstBodyStatement instanceof ExpressionStatement &&
7850
- firstBodyStatement.directive === 'use asm';
7851
- }
7852
- render(code, options) {
7853
- if (this.body.length) {
7854
- renderStatementList(this.body, code, this.start + 1, this.end - 1, options);
7855
- }
7856
- else {
7857
- super.render(code, options);
7858
- }
7985
+ hasEffectsWhenCalledAtPath(path, callOptions, context) {
7986
+ const globalAtPath = getGlobalAtPath([this.name, ...path]);
7987
+ return !globalAtPath || globalAtPath.hasEffectsWhenCalled(callOptions, context);
7859
7988
  }
7860
7989
  }
7861
7990
 
7862
- class RestElement extends NodeBase {
7991
+ const tdzVariableKinds = {
7992
+ __proto__: null,
7993
+ class: true,
7994
+ const: true,
7995
+ let: true,
7996
+ var: true
7997
+ };
7998
+ class Identifier extends NodeBase {
7863
7999
  constructor() {
7864
8000
  super(...arguments);
8001
+ this.variable = null;
7865
8002
  this.deoptimized = false;
7866
- this.declarationInit = null;
8003
+ this.isTDZAccess = null;
7867
8004
  }
7868
8005
  addExportedVariables(variables, exportNamesByVariable) {
7869
- this.argument.addExportedVariables(variables, exportNamesByVariable);
7870
- }
7871
- declare(kind, init) {
7872
- this.declarationInit = init;
7873
- return this.argument.declare(kind, UNKNOWN_EXPRESSION);
7874
- }
7875
- deoptimizePath(path) {
7876
- path.length === 0 && this.argument.deoptimizePath(EMPTY_PATH);
7877
- }
7878
- hasEffectsWhenAssignedAtPath(path, context) {
7879
- return path.length > 0 || this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
7880
- }
7881
- markDeclarationReached() {
7882
- this.argument.markDeclarationReached();
8006
+ if (exportNamesByVariable.has(this.variable)) {
8007
+ variables.push(this.variable);
8008
+ }
7883
8009
  }
7884
- applyDeoptimizations() {
7885
- this.deoptimized = true;
7886
- if (this.declarationInit !== null) {
7887
- this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
7888
- this.context.requestTreeshakingPass();
8010
+ bind() {
8011
+ if (!this.variable && is_reference(this, this.parent)) {
8012
+ this.variable = this.scope.findVariable(this.name);
8013
+ this.variable.addReference(this);
7889
8014
  }
7890
8015
  }
7891
- }
7892
-
7893
- class FunctionBase extends NodeBase {
7894
- constructor() {
7895
- super(...arguments);
7896
- this.objectEntity = null;
7897
- this.deoptimizedReturn = false;
8016
+ declare(kind, init) {
8017
+ let variable;
8018
+ const { treeshake } = this.context.options;
8019
+ switch (kind) {
8020
+ case 'var':
8021
+ variable = this.scope.addDeclaration(this, this.context, init, true);
8022
+ if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
8023
+ // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
8024
+ variable.markInitializersForDeoptimization();
8025
+ }
8026
+ break;
8027
+ case 'function':
8028
+ // in strict mode, functions are only hoisted within a scope but not across block scopes
8029
+ variable = this.scope.addDeclaration(this, this.context, init, false);
8030
+ break;
8031
+ case 'let':
8032
+ case 'const':
8033
+ case 'class':
8034
+ variable = this.scope.addDeclaration(this, this.context, init, false);
8035
+ break;
8036
+ case 'parameter':
8037
+ variable = this.scope.addParameterDeclaration(this);
8038
+ break;
8039
+ /* istanbul ignore next */
8040
+ default:
8041
+ /* istanbul ignore next */
8042
+ throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
8043
+ }
8044
+ variable.kind = kind;
8045
+ return [(this.variable = variable)];
7898
8046
  }
7899
8047
  deoptimizePath(path) {
7900
- this.getObjectEntity().deoptimizePath(path);
7901
- if (path.length === 1 && path[0] === UnknownKey) {
7902
- // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
7903
- // which means the return expression needs to be reassigned
7904
- this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
8048
+ if (path.length === 0 && !this.scope.contains(this.name)) {
8049
+ this.disallowImportReassignment();
7905
8050
  }
8051
+ this.variable.deoptimizePath(path);
7906
8052
  }
7907
8053
  deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
7908
- if (path.length > 0) {
7909
- this.getObjectEntity().deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
7910
- }
8054
+ this.variable.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
7911
8055
  }
7912
8056
  getLiteralValueAtPath(path, recursionTracker, origin) {
7913
- return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
8057
+ return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
7914
8058
  }
7915
8059
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
7916
- if (path.length > 0) {
7917
- return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
7918
- }
7919
- if (this.async) {
7920
- if (!this.deoptimizedReturn) {
7921
- this.deoptimizedReturn = true;
7922
- this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
7923
- this.context.requestTreeshakingPass();
7924
- }
7925
- return UNKNOWN_EXPRESSION;
8060
+ return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
8061
+ }
8062
+ hasEffects() {
8063
+ if (!this.deoptimized)
8064
+ this.applyDeoptimizations();
8065
+ if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
8066
+ return true;
7926
8067
  }
7927
- return this.scope.getReturnExpression();
8068
+ return (this.context.options.treeshake.unknownGlobalSideEffects &&
8069
+ this.variable instanceof GlobalVariable &&
8070
+ this.variable.hasEffectsWhenAccessedAtPath(EMPTY_PATH));
7928
8071
  }
7929
8072
  hasEffectsWhenAccessedAtPath(path, context) {
7930
- return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
8073
+ return (this.variable !== null &&
8074
+ this.getVariableRespectingTDZ().hasEffectsWhenAccessedAtPath(path, context));
7931
8075
  }
7932
8076
  hasEffectsWhenAssignedAtPath(path, context) {
7933
- return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
8077
+ return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsWhenAssignedAtPath(path, context);
7934
8078
  }
7935
8079
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
7936
- if (path.length > 0) {
7937
- return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
7938
- }
7939
- if (this.async) {
7940
- const { propertyReadSideEffects } = this.context.options
7941
- .treeshake;
7942
- const returnExpression = this.scope.getReturnExpression();
7943
- if (returnExpression.hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context) ||
7944
- (propertyReadSideEffects &&
7945
- (propertyReadSideEffects === 'always' ||
7946
- returnExpression.hasEffectsWhenAccessedAtPath(['then'], context)))) {
7947
- return true;
8080
+ return this.getVariableRespectingTDZ().hasEffectsWhenCalledAtPath(path, callOptions, context);
8081
+ }
8082
+ include() {
8083
+ if (!this.deoptimized)
8084
+ this.applyDeoptimizations();
8085
+ if (!this.included) {
8086
+ this.included = true;
8087
+ if (this.variable !== null) {
8088
+ this.context.includeVariableInModule(this.variable);
7948
8089
  }
7949
8090
  }
7950
- for (const param of this.params) {
7951
- if (param.hasEffects(context))
7952
- return true;
7953
- }
7954
- return false;
7955
- }
7956
- include(context, includeChildrenRecursively) {
7957
- this.included = true;
7958
- const { brokenFlow } = context;
7959
- context.brokenFlow = BROKEN_FLOW_NONE;
7960
- this.body.include(context, includeChildrenRecursively);
7961
- context.brokenFlow = brokenFlow;
7962
8091
  }
7963
8092
  includeCallArguments(context, args) {
7964
- this.scope.includeCallArguments(context, args);
8093
+ this.variable.includeCallArguments(context, args);
7965
8094
  }
7966
- initialise() {
7967
- this.scope.addParameterVariables(this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION)), this.params[this.params.length - 1] instanceof RestElement);
7968
- if (this.body instanceof BlockStatement) {
7969
- this.body.addImplicitReturnExpressionToScope();
8095
+ isPossibleTDZ() {
8096
+ // return cached value to avoid issues with the next tree-shaking pass
8097
+ if (this.isTDZAccess !== null)
8098
+ return this.isTDZAccess;
8099
+ if (!(this.variable instanceof LocalVariable) ||
8100
+ !this.variable.kind ||
8101
+ !(this.variable.kind in tdzVariableKinds)) {
8102
+ return (this.isTDZAccess = false);
7970
8103
  }
7971
- else {
7972
- this.scope.addReturnExpression(this.body);
8104
+ let decl_id;
8105
+ if (this.variable.declarations &&
8106
+ this.variable.declarations.length === 1 &&
8107
+ (decl_id = this.variable.declarations[0]) &&
8108
+ this.start < decl_id.start &&
8109
+ closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
8110
+ // a variable accessed before its declaration
8111
+ // in the same function or at top level of module
8112
+ return (this.isTDZAccess = true);
7973
8113
  }
7974
- }
7975
- parseNode(esTreeNode) {
7976
- if (esTreeNode.body.type === BlockStatement$1) {
7977
- this.body = new BlockStatement(esTreeNode.body, this, this.scope.hoistedBodyVarScope);
8114
+ if (!this.variable.initReached) {
8115
+ // Either a const/let TDZ violation or
8116
+ // var use before declaration was encountered.
8117
+ return (this.isTDZAccess = true);
7978
8118
  }
7979
- super.parseNode(esTreeNode);
7980
- }
7981
- }
7982
- FunctionBase.prototype.preventChildBlockScope = true;
7983
-
7984
- class ArrowFunctionExpression extends FunctionBase {
7985
- constructor() {
7986
- super(...arguments);
7987
- this.objectEntity = null;
7988
- }
7989
- createScope(parentScope) {
7990
- this.scope = new ReturnValueScope(parentScope, this.context);
7991
- }
7992
- hasEffects() {
7993
- return false;
8119
+ return (this.isTDZAccess = false);
7994
8120
  }
7995
- hasEffectsWhenCalledAtPath(path, callOptions, context) {
7996
- if (super.hasEffectsWhenCalledAtPath(path, callOptions, context))
7997
- return true;
7998
- const { ignore, brokenFlow } = context;
7999
- context.ignore = {
8000
- breaks: false,
8001
- continues: false,
8002
- labels: new Set(),
8003
- returnYield: true
8004
- };
8005
- if (this.body.hasEffects(context))
8006
- return true;
8007
- context.ignore = ignore;
8008
- context.brokenFlow = brokenFlow;
8009
- return false;
8121
+ markDeclarationReached() {
8122
+ this.variable.initReached = true;
8010
8123
  }
8011
- include(context, includeChildrenRecursively) {
8012
- super.include(context, includeChildrenRecursively);
8013
- for (const param of this.params) {
8014
- if (!(param instanceof Identifier)) {
8015
- param.include(context, includeChildrenRecursively);
8124
+ render(code, { snippets: { getPropertyAccess } }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
8125
+ if (this.variable) {
8126
+ const name = this.variable.getName(getPropertyAccess);
8127
+ if (name !== this.name) {
8128
+ code.overwrite(this.start, this.end, name, {
8129
+ contentOnly: true,
8130
+ storeName: true
8131
+ });
8132
+ if (isShorthandProperty) {
8133
+ code.prependRight(this.start, `${this.name}: `);
8134
+ }
8135
+ }
8136
+ // In strict mode, any variable named "eval" must be the actual "eval" function
8137
+ if (name === 'eval' &&
8138
+ renderedParentType === CallExpression$1 &&
8139
+ isCalleeOfRenderedParent) {
8140
+ code.appendRight(this.start, '0, ');
8016
8141
  }
8017
8142
  }
8018
8143
  }
8019
- getObjectEntity() {
8020
- if (this.objectEntity !== null) {
8021
- return this.objectEntity;
8144
+ applyDeoptimizations() {
8145
+ this.deoptimized = true;
8146
+ if (this.variable instanceof LocalVariable) {
8147
+ this.variable.consolidateInitializers();
8148
+ this.context.requestTreeshakingPass();
8022
8149
  }
8023
- return (this.objectEntity = new ObjectEntity([], OBJECT_PROTOTYPE));
8024
8150
  }
8025
- }
8026
-
8027
- function getSystemExportStatement(exportedVariables, { exportNamesByVariable, snippets: { _, getObject, getPropertyAccess } }, modifier = '') {
8028
- if (exportedVariables.length === 1 &&
8029
- exportNamesByVariable.get(exportedVariables[0]).length === 1) {
8030
- const variable = exportedVariables[0];
8031
- return `exports('${exportNamesByVariable.get(variable)}',${_}${variable.getName(getPropertyAccess)}${modifier})`;
8151
+ disallowImportReassignment() {
8152
+ return this.context.error({
8153
+ code: 'ILLEGAL_REASSIGNMENT',
8154
+ message: `Illegal reassignment to import '${this.name}'`
8155
+ }, this.start);
8032
8156
  }
8033
- else {
8034
- const fields = [];
8035
- for (const variable of exportedVariables) {
8036
- for (const exportName of exportNamesByVariable.get(variable)) {
8037
- fields.push([exportName, variable.getName(getPropertyAccess) + modifier]);
8038
- }
8157
+ getVariableRespectingTDZ() {
8158
+ if (this.isPossibleTDZ()) {
8159
+ return UNKNOWN_EXPRESSION;
8039
8160
  }
8040
- return `exports(${getObject(fields, { lineBreakIndent: null })})`;
8041
- }
8042
- }
8043
- function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
8044
- code.prependRight(expressionStart, `exports('${exportNamesByVariable.get(exportedVariable)}',${_}`);
8045
- code.appendLeft(expressionEnd, ')');
8046
- }
8047
- function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
8048
- const { _, getDirectReturnIifeLeft } = options.snippets;
8049
- code.prependRight(expressionStart, getDirectReturnIifeLeft(['v'], `${getSystemExportStatement(exportedVariables, options)},${_}v`, { needsArrowReturnParens: true, needsWrappedFunction: needsParens }));
8050
- code.appendLeft(expressionEnd, ')');
8051
- }
8052
- function renderSystemExportSequenceAfterExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options) {
8053
- const { _, getPropertyAccess } = options.snippets;
8054
- code.appendLeft(expressionEnd, `,${_}${getSystemExportStatement([exportedVariable], options)},${_}${exportedVariable.getName(getPropertyAccess)}`);
8055
- if (needsParens) {
8056
- code.prependRight(expressionStart, '(');
8057
- code.appendLeft(expressionEnd, ')');
8161
+ return this.variable;
8058
8162
  }
8059
8163
  }
8060
- function renderSystemExportSequenceBeforeExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options, modifier) {
8061
- const { _ } = options.snippets;
8062
- code.prependRight(expressionStart, `${getSystemExportStatement([exportedVariable], options, modifier)},${_}`);
8063
- if (needsParens) {
8064
- code.prependRight(expressionStart, '(');
8065
- code.appendLeft(expressionEnd, ')');
8164
+ function closestParentFunctionOrProgram(node) {
8165
+ while (node && !/^Program|Function/.test(node.type)) {
8166
+ node = node.parent;
8066
8167
  }
8168
+ // one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program
8169
+ return node;
8067
8170
  }
8068
8171
 
8069
8172
  class ObjectPattern extends NodeBase {
@@ -8174,47 +8277,15 @@ class AssignmentExpression extends NodeBase {
8174
8277
  renderSystemExportFunction(systemPatternExports, this.start, this.end, renderedSurroundingElement === ExpressionStatement$1, code, options);
8175
8278
  return;
8176
8279
  }
8177
- }
8178
- }
8179
- if (this.left.included &&
8180
- this.left instanceof ObjectPattern &&
8181
- (renderedSurroundingElement === ExpressionStatement$1 ||
8182
- renderedSurroundingElement === ArrowFunctionExpression$1)) {
8183
- code.appendRight(this.start, '(');
8184
- code.prependLeft(this.end, ')');
8185
- }
8186
- }
8187
- applyDeoptimizations() {
8188
- this.deoptimized = true;
8189
- this.left.deoptimizePath(EMPTY_PATH);
8190
- this.right.deoptimizePath(UNKNOWN_PATH);
8191
- this.context.requestTreeshakingPass();
8192
- }
8193
- }
8194
-
8195
- class AssignmentPattern extends NodeBase {
8196
- constructor() {
8197
- super(...arguments);
8198
- this.deoptimized = false;
8199
- }
8200
- addExportedVariables(variables, exportNamesByVariable) {
8201
- this.left.addExportedVariables(variables, exportNamesByVariable);
8202
- }
8203
- declare(kind, init) {
8204
- return this.left.declare(kind, init);
8205
- }
8206
- deoptimizePath(path) {
8207
- path.length === 0 && this.left.deoptimizePath(path);
8208
- }
8209
- hasEffectsWhenAssignedAtPath(path, context) {
8210
- return path.length > 0 || this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
8211
- }
8212
- markDeclarationReached() {
8213
- this.left.markDeclarationReached();
8214
- }
8215
- render(code, options, { isShorthandProperty } = BLANK) {
8216
- this.left.render(code, options, { isShorthandProperty });
8217
- this.right.render(code, options);
8280
+ }
8281
+ }
8282
+ if (this.left.included &&
8283
+ this.left instanceof ObjectPattern &&
8284
+ (renderedSurroundingElement === ExpressionStatement$1 ||
8285
+ renderedSurroundingElement === ArrowFunctionExpression$1)) {
8286
+ code.appendRight(this.start, '(');
8287
+ code.prependLeft(this.end, ')');
8288
+ }
8218
8289
  }
8219
8290
  applyDeoptimizations() {
8220
8291
  this.deoptimized = true;
@@ -8331,7 +8402,8 @@ class FunctionNode extends FunctionBase {
8331
8402
  }
8332
8403
  }
8333
8404
  hasEffects() {
8334
- return this.id !== null && this.id.hasEffects();
8405
+ var _a;
8406
+ return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects());
8335
8407
  }
8336
8408
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
8337
8409
  if (super.hasEffectsWhenCalledAtPath(path, callOptions, context))
@@ -8359,16 +8431,12 @@ class FunctionNode extends FunctionBase {
8359
8431
  context.ignore = ignore;
8360
8432
  return false;
8361
8433
  }
8362
- include(context, includeChildrenRecursively) {
8363
- super.include(context, includeChildrenRecursively);
8364
- if (this.id)
8365
- this.id.include();
8366
- const hasArguments = this.scope.argumentsVariable.included;
8367
- for (const param of this.params) {
8368
- if (!(param instanceof Identifier) || hasArguments) {
8369
- param.include(context, includeChildrenRecursively);
8370
- }
8371
- }
8434
+ include(context, includeChildrenRecursively, { includeWithoutParameterDefaults } = BLANK) {
8435
+ var _a;
8436
+ (_a = this.id) === null || _a === void 0 ? void 0 : _a.include();
8437
+ super.include(context, includeChildrenRecursively, {
8438
+ includeWithoutParameterDefaults: includeWithoutParameterDefaults && !this.scope.argumentsVariable.included
8439
+ });
8372
8440
  }
8373
8441
  initialise() {
8374
8442
  var _a;
@@ -8415,11 +8483,6 @@ class AwaitExpression extends NodeBase {
8415
8483
  }
8416
8484
  this.argument.include(context, includeChildrenRecursively);
8417
8485
  }
8418
- applyDeoptimizations() {
8419
- this.deoptimized = true;
8420
- this.argument.deoptimizePath(UNKNOWN_PATH);
8421
- this.context.requestTreeshakingPass();
8422
- }
8423
8486
  }
8424
8487
 
8425
8488
  const binaryOperators = {
@@ -8443,9 +8506,10 @@ const binaryOperators = {
8443
8506
  '>>': (left, right) => left >> right,
8444
8507
  '>>>': (left, right) => left >>> right,
8445
8508
  '^': (left, right) => left ^ right,
8446
- in: () => UnknownValue,
8447
- instanceof: () => UnknownValue,
8448
8509
  '|': (left, right) => left | right
8510
+ // We use the fallback for cases where we return something unknown
8511
+ // in: () => UnknownValue,
8512
+ // instanceof: () => UnknownValue,
8449
8513
  };
8450
8514
  class BinaryExpression extends NodeBase {
8451
8515
  deoptimizeCache() { }
@@ -8453,10 +8517,10 @@ class BinaryExpression extends NodeBase {
8453
8517
  if (path.length > 0)
8454
8518
  return UnknownValue;
8455
8519
  const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin);
8456
- if (leftValue === UnknownValue)
8520
+ if (typeof leftValue === 'symbol')
8457
8521
  return UnknownValue;
8458
8522
  const rightValue = this.right.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin);
8459
- if (rightValue === UnknownValue)
8523
+ if (typeof rightValue === 'symbol')
8460
8524
  return UnknownValue;
8461
8525
  const operatorFn = binaryOperators[this.operator];
8462
8526
  if (!operatorFn)
@@ -8529,9 +8593,6 @@ class Literal extends NodeBase {
8529
8593
  }
8530
8594
  return path.length > 1;
8531
8595
  }
8532
- hasEffectsWhenAssignedAtPath(path) {
8533
- return path.length > 0;
8534
- }
8535
8596
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
8536
8597
  if (path.length === 1) {
8537
8598
  return hasMemberEffectWhenCalled(this.members, path[0], callOptions, context);
@@ -8814,7 +8875,7 @@ class MemberExpression extends NodeBase {
8814
8875
  if (this.propertyKey === null) {
8815
8876
  this.propertyKey = UnknownKey;
8816
8877
  const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
8817
- return (this.propertyKey = value === UnknownValue ? UnknownKey : String(value));
8878
+ return (this.propertyKey = typeof value === 'symbol' ? UnknownKey : String(value));
8818
8879
  }
8819
8880
  return this.propertyKey;
8820
8881
  }
@@ -8841,39 +8902,13 @@ class MemberExpression extends NodeBase {
8841
8902
  }
8842
8903
  }
8843
8904
 
8844
- class CallExpression extends NodeBase {
8905
+ class CallExpressionBase extends NodeBase {
8845
8906
  constructor() {
8846
8907
  super(...arguments);
8847
8908
  this.deoptimized = false;
8909
+ this.returnExpression = null;
8848
8910
  this.deoptimizableDependentExpressions = [];
8849
8911
  this.expressionsToBeDeoptimized = new Set();
8850
- this.returnExpression = null;
8851
- }
8852
- bind() {
8853
- super.bind();
8854
- if (this.callee instanceof Identifier) {
8855
- const variable = this.scope.findVariable(this.callee.name);
8856
- if (variable.isNamespace) {
8857
- this.context.warn({
8858
- code: 'CANNOT_CALL_NAMESPACE',
8859
- message: `Cannot call a namespace ('${this.callee.name}')`
8860
- }, this.start);
8861
- }
8862
- if (this.callee.name === 'eval') {
8863
- this.context.warn({
8864
- code: 'EVAL',
8865
- message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
8866
- url: 'https://rollupjs.org/guide/en/#avoiding-eval'
8867
- }, this.start);
8868
- }
8869
- }
8870
- this.callOptions = {
8871
- args: this.arguments,
8872
- thisParam: this.callee instanceof MemberExpression && !this.callee.variable
8873
- ? this.callee.object
8874
- : null,
8875
- withNew: false
8876
- };
8877
8912
  }
8878
8913
  deoptimizeCache() {
8879
8914
  if (this.returnExpression !== UNKNOWN_EXPRESSION) {
@@ -8928,6 +8963,47 @@ class CallExpression extends NodeBase {
8928
8963
  return returnExpression.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
8929
8964
  }, UNKNOWN_EXPRESSION);
8930
8965
  }
8966
+ hasEffectsWhenAccessedAtPath(path, context) {
8967
+ return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
8968
+ this.getReturnExpression().hasEffectsWhenAccessedAtPath(path, context));
8969
+ }
8970
+ hasEffectsWhenAssignedAtPath(path, context) {
8971
+ return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
8972
+ this.getReturnExpression().hasEffectsWhenAssignedAtPath(path, context));
8973
+ }
8974
+ hasEffectsWhenCalledAtPath(path, callOptions, context) {
8975
+ return (!(callOptions.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, callOptions, this) &&
8976
+ this.getReturnExpression().hasEffectsWhenCalledAtPath(path, callOptions, context));
8977
+ }
8978
+ }
8979
+
8980
+ class CallExpression extends CallExpressionBase {
8981
+ bind() {
8982
+ super.bind();
8983
+ if (this.callee instanceof Identifier) {
8984
+ const variable = this.scope.findVariable(this.callee.name);
8985
+ if (variable.isNamespace) {
8986
+ this.context.warn({
8987
+ code: 'CANNOT_CALL_NAMESPACE',
8988
+ message: `Cannot call a namespace ('${this.callee.name}')`
8989
+ }, this.start);
8990
+ }
8991
+ if (this.callee.name === 'eval') {
8992
+ this.context.warn({
8993
+ code: 'EVAL',
8994
+ message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
8995
+ url: 'https://rollupjs.org/guide/en/#avoiding-eval'
8996
+ }, this.start);
8997
+ }
8998
+ }
8999
+ this.callOptions = {
9000
+ args: this.arguments,
9001
+ thisParam: this.callee instanceof MemberExpression && !this.callee.variable
9002
+ ? this.callee.object
9003
+ : null,
9004
+ withNew: false
9005
+ };
9006
+ }
8931
9007
  hasEffects(context) {
8932
9008
  try {
8933
9009
  for (const argument of this.arguments) {
@@ -8945,18 +9021,6 @@ class CallExpression extends NodeBase {
8945
9021
  this.applyDeoptimizations();
8946
9022
  }
8947
9023
  }
8948
- hasEffectsWhenAccessedAtPath(path, context) {
8949
- return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
8950
- this.getReturnExpression().hasEffectsWhenAccessedAtPath(path, context));
8951
- }
8952
- hasEffectsWhenAssignedAtPath(path, context) {
8953
- return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
8954
- this.getReturnExpression().hasEffectsWhenAssignedAtPath(path, context));
8955
- }
8956
- hasEffectsWhenCalledAtPath(path, callOptions, context) {
8957
- return (!(callOptions.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, callOptions, this) &&
8958
- this.getReturnExpression().hasEffectsWhenCalledAtPath(path, callOptions, context));
8959
- }
8960
9024
  include(context, includeChildrenRecursively) {
8961
9025
  if (!this.deoptimized)
8962
9026
  this.applyDeoptimizations();
@@ -8970,7 +9034,7 @@ class CallExpression extends NodeBase {
8970
9034
  }
8971
9035
  else {
8972
9036
  this.included = true;
8973
- this.callee.include(context, false);
9037
+ this.callee.include(context, false, { includeWithoutParameterDefaults: true });
8974
9038
  }
8975
9039
  this.callee.includeCallArguments(context, this.arguments);
8976
9040
  const returnExpression = this.getReturnExpression();
@@ -9179,8 +9243,6 @@ class ObjectMember extends ExpressionEntity {
9179
9243
  return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], callOptions, recursionTracker, origin);
9180
9244
  }
9181
9245
  hasEffectsWhenAccessedAtPath(path, context) {
9182
- if (path.length === 0)
9183
- return false;
9184
9246
  return this.object.hasEffectsWhenAccessedAtPath([this.key, ...path], context);
9185
9247
  }
9186
9248
  hasEffectsWhenAssignedAtPath(path, context) {
@@ -9194,6 +9256,7 @@ class ObjectMember extends ExpressionEntity {
9194
9256
  class ClassNode extends NodeBase {
9195
9257
  constructor() {
9196
9258
  super(...arguments);
9259
+ this.deoptimized = false;
9197
9260
  this.objectEntity = null;
9198
9261
  }
9199
9262
  createScope(parentScope) {
@@ -9203,7 +9266,14 @@ class ClassNode extends NodeBase {
9203
9266
  this.getObjectEntity().deoptimizeAllProperties();
9204
9267
  }
9205
9268
  deoptimizePath(path) {
9269
+ var _a, _b;
9206
9270
  this.getObjectEntity().deoptimizePath(path);
9271
+ if (path.length === 1 && path[0] === UnknownKey) {
9272
+ // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
9273
+ // which means the constructor needs to be reassigned
9274
+ (_a = this.classConstructor) === null || _a === void 0 ? void 0 : _a.deoptimizePath(UNKNOWN_PATH);
9275
+ (_b = this.superClass) === null || _b === void 0 ? void 0 : _b.deoptimizePath(UNKNOWN_PATH);
9276
+ }
9207
9277
  }
9208
9278
  deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
9209
9279
  this.getObjectEntity().deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
@@ -9216,6 +9286,8 @@ class ClassNode extends NodeBase {
9216
9286
  }
9217
9287
  hasEffects(context) {
9218
9288
  var _a, _b;
9289
+ if (!this.deoptimized)
9290
+ this.applyDeoptimizations();
9219
9291
  const initEffect = ((_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffects(context)) || this.body.hasEffects(context);
9220
9292
  (_b = this.id) === null || _b === void 0 ? void 0 : _b.markDeclarationReached();
9221
9293
  return initEffect || super.hasEffects(context);
@@ -9227,12 +9299,13 @@ class ClassNode extends NodeBase {
9227
9299
  return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
9228
9300
  }
9229
9301
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
9302
+ var _a;
9230
9303
  if (path.length === 0) {
9231
9304
  return (!callOptions.withNew ||
9232
9305
  (this.classConstructor !== null
9233
9306
  ? this.classConstructor.hasEffectsWhenCalledAtPath(EMPTY_PATH, callOptions, context)
9234
- : this.superClass !== null &&
9235
- this.superClass.hasEffectsWhenCalledAtPath(path, callOptions, context)));
9307
+ : (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffectsWhenCalledAtPath(path, callOptions, context)) ||
9308
+ false);
9236
9309
  }
9237
9310
  else {
9238
9311
  return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
@@ -9240,6 +9313,8 @@ class ClassNode extends NodeBase {
9240
9313
  }
9241
9314
  include(context, includeChildrenRecursively) {
9242
9315
  var _a;
9316
+ if (!this.deoptimized)
9317
+ this.applyDeoptimizations();
9243
9318
  this.included = true;
9244
9319
  (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
9245
9320
  this.body.include(context, includeChildrenRecursively);
@@ -9259,6 +9334,17 @@ class ClassNode extends NodeBase {
9259
9334
  }
9260
9335
  this.classConstructor = null;
9261
9336
  }
9337
+ applyDeoptimizations() {
9338
+ this.deoptimized = true;
9339
+ for (const definition of this.body.body) {
9340
+ if (!(definition.static ||
9341
+ (definition instanceof MethodDefinition && definition.kind === 'constructor'))) {
9342
+ // Calls to methods are not tracked, ensure that the return value is deoptimized
9343
+ definition.deoptimizePath(UNKNOWN_PATH);
9344
+ }
9345
+ }
9346
+ this.context.requestTreeshakingPass();
9347
+ }
9262
9348
  getObjectEntity() {
9263
9349
  if (this.objectEntity !== null) {
9264
9350
  return this.objectEntity;
@@ -9275,7 +9361,7 @@ class ClassNode extends NodeBase {
9275
9361
  let key;
9276
9362
  if (definition.computed) {
9277
9363
  const keyValue = definition.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
9278
- if (keyValue === UnknownValue) {
9364
+ if (typeof keyValue === 'symbol') {
9279
9365
  properties.push({ key: UnknownKey, kind, property: definition });
9280
9366
  continue;
9281
9367
  }
@@ -9397,7 +9483,7 @@ class ConditionalExpression extends NodeBase {
9397
9483
  }
9398
9484
  deoptimizePath(path) {
9399
9485
  const usedBranch = this.getUsedBranch();
9400
- if (usedBranch === null) {
9486
+ if (!usedBranch) {
9401
9487
  this.consequent.deoptimizePath(path);
9402
9488
  this.alternate.deoptimizePath(path);
9403
9489
  }
@@ -9411,14 +9497,14 @@ class ConditionalExpression extends NodeBase {
9411
9497
  }
9412
9498
  getLiteralValueAtPath(path, recursionTracker, origin) {
9413
9499
  const usedBranch = this.getUsedBranch();
9414
- if (usedBranch === null)
9500
+ if (!usedBranch)
9415
9501
  return UnknownValue;
9416
9502
  this.expressionsToBeDeoptimized.push(origin);
9417
9503
  return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
9418
9504
  }
9419
9505
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
9420
9506
  const usedBranch = this.getUsedBranch();
9421
- if (usedBranch === null)
9507
+ if (!usedBranch)
9422
9508
  return new MultiExpression([
9423
9509
  this.consequent.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin),
9424
9510
  this.alternate.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin)
@@ -9430,14 +9516,14 @@ class ConditionalExpression extends NodeBase {
9430
9516
  if (this.test.hasEffects(context))
9431
9517
  return true;
9432
9518
  const usedBranch = this.getUsedBranch();
9433
- if (usedBranch === null) {
9519
+ if (!usedBranch) {
9434
9520
  return this.consequent.hasEffects(context) || this.alternate.hasEffects(context);
9435
9521
  }
9436
9522
  return usedBranch.hasEffects(context);
9437
9523
  }
9438
9524
  hasEffectsWhenAccessedAtPath(path, context) {
9439
9525
  const usedBranch = this.getUsedBranch();
9440
- if (usedBranch === null) {
9526
+ if (!usedBranch) {
9441
9527
  return (this.consequent.hasEffectsWhenAccessedAtPath(path, context) ||
9442
9528
  this.alternate.hasEffectsWhenAccessedAtPath(path, context));
9443
9529
  }
@@ -9445,7 +9531,7 @@ class ConditionalExpression extends NodeBase {
9445
9531
  }
9446
9532
  hasEffectsWhenAssignedAtPath(path, context) {
9447
9533
  const usedBranch = this.getUsedBranch();
9448
- if (usedBranch === null) {
9534
+ if (!usedBranch) {
9449
9535
  return (this.consequent.hasEffectsWhenAssignedAtPath(path, context) ||
9450
9536
  this.alternate.hasEffectsWhenAssignedAtPath(path, context));
9451
9537
  }
@@ -9453,7 +9539,7 @@ class ConditionalExpression extends NodeBase {
9453
9539
  }
9454
9540
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
9455
9541
  const usedBranch = this.getUsedBranch();
9456
- if (usedBranch === null) {
9542
+ if (!usedBranch) {
9457
9543
  return (this.consequent.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
9458
9544
  this.alternate.hasEffectsWhenCalledAtPath(path, callOptions, context));
9459
9545
  }
@@ -9473,7 +9559,7 @@ class ConditionalExpression extends NodeBase {
9473
9559
  }
9474
9560
  includeCallArguments(context, args) {
9475
9561
  const usedBranch = this.getUsedBranch();
9476
- if (usedBranch === null) {
9562
+ if (!usedBranch) {
9477
9563
  this.consequent.includeCallArguments(context, args);
9478
9564
  this.alternate.includeCallArguments(context, args);
9479
9565
  }
@@ -9515,7 +9601,7 @@ class ConditionalExpression extends NodeBase {
9515
9601
  }
9516
9602
  this.isBranchResolutionAnalysed = true;
9517
9603
  const testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
9518
- return testValue === UnknownValue
9604
+ return typeof testValue === 'symbol'
9519
9605
  ? null
9520
9606
  : (this.usedBranch = testValue ? this.consequent : this.alternate);
9521
9607
  }
@@ -9564,7 +9650,7 @@ class DoWhileStatement extends NodeBase {
9564
9650
  this.included = true;
9565
9651
  this.test.include(context, includeChildrenRecursively);
9566
9652
  const { brokenFlow } = context;
9567
- this.body.includeAsSingleStatement(context, includeChildrenRecursively);
9653
+ this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
9568
9654
  context.brokenFlow = brokenFlow;
9569
9655
  }
9570
9656
  }
@@ -9589,6 +9675,9 @@ class ExportAllDeclaration extends NodeBase {
9589
9675
  ExportAllDeclaration.prototype.needsBoundaries = true;
9590
9676
 
9591
9677
  class FunctionDeclaration extends FunctionNode {
9678
+ include(context, includeChildrenRecursively) {
9679
+ super.include(context, includeChildrenRecursively, { includeWithoutParameterDefaults: true });
9680
+ }
9592
9681
  initialise() {
9593
9682
  super.initialise();
9594
9683
  if (this.id !== null) {
@@ -9692,12 +9781,13 @@ ExportDefaultDeclaration.prototype.needsBoundaries = true;
9692
9781
 
9693
9782
  class ExportNamedDeclaration extends NodeBase {
9694
9783
  bind() {
9784
+ var _a;
9695
9785
  // Do not bind specifiers
9696
- if (this.declaration !== null)
9697
- this.declaration.bind();
9786
+ (_a = this.declaration) === null || _a === void 0 ? void 0 : _a.bind();
9698
9787
  }
9699
9788
  hasEffects(context) {
9700
- return this.declaration !== null && this.declaration.hasEffects(context);
9789
+ var _a;
9790
+ return !!((_a = this.declaration) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
9701
9791
  }
9702
9792
  initialise() {
9703
9793
  this.context.addExport(this);
@@ -9751,7 +9841,7 @@ class ForInStatement extends NodeBase {
9751
9841
  this.left.include(context, includeChildrenRecursively || true);
9752
9842
  this.right.include(context, includeChildrenRecursively);
9753
9843
  const { brokenFlow } = context;
9754
- this.body.includeAsSingleStatement(context, includeChildrenRecursively);
9844
+ this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
9755
9845
  context.brokenFlow = brokenFlow;
9756
9846
  }
9757
9847
  render(code, options) {
@@ -9791,7 +9881,7 @@ class ForOfStatement extends NodeBase {
9791
9881
  this.left.include(context, includeChildrenRecursively || true);
9792
9882
  this.right.include(context, includeChildrenRecursively);
9793
9883
  const { brokenFlow } = context;
9794
- this.body.includeAsSingleStatement(context, includeChildrenRecursively);
9884
+ this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
9795
9885
  context.brokenFlow = brokenFlow;
9796
9886
  }
9797
9887
  render(code, options) {
@@ -9815,9 +9905,10 @@ class ForStatement extends NodeBase {
9815
9905
  this.scope = new BlockScope(parentScope);
9816
9906
  }
9817
9907
  hasEffects(context) {
9818
- if ((this.init && this.init.hasEffects(context)) ||
9819
- (this.test && this.test.hasEffects(context)) ||
9820
- (this.update && this.update.hasEffects(context)))
9908
+ var _a, _b, _c;
9909
+ if (((_a = this.init) === null || _a === void 0 ? void 0 : _a.hasEffects(context)) ||
9910
+ ((_b = this.test) === null || _b === void 0 ? void 0 : _b.hasEffects(context)) ||
9911
+ ((_c = this.update) === null || _c === void 0 ? void 0 : _c.hasEffects(context)))
9821
9912
  return true;
9822
9913
  const { brokenFlow, ignore: { breaks, continues } } = context;
9823
9914
  context.ignore.breaks = true;
@@ -9830,24 +9921,20 @@ class ForStatement extends NodeBase {
9830
9921
  return false;
9831
9922
  }
9832
9923
  include(context, includeChildrenRecursively) {
9924
+ var _a, _b, _c;
9833
9925
  this.included = true;
9834
- if (this.init)
9835
- this.init.includeAsSingleStatement(context, includeChildrenRecursively);
9836
- if (this.test)
9837
- this.test.include(context, includeChildrenRecursively);
9926
+ (_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively, { asSingleStatement: true });
9927
+ (_b = this.test) === null || _b === void 0 ? void 0 : _b.include(context, includeChildrenRecursively);
9838
9928
  const { brokenFlow } = context;
9839
- if (this.update)
9840
- this.update.include(context, includeChildrenRecursively);
9841
- this.body.includeAsSingleStatement(context, includeChildrenRecursively);
9929
+ (_c = this.update) === null || _c === void 0 ? void 0 : _c.include(context, includeChildrenRecursively);
9930
+ this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
9842
9931
  context.brokenFlow = brokenFlow;
9843
9932
  }
9844
9933
  render(code, options) {
9845
- if (this.init)
9846
- this.init.render(code, options, NO_SEMICOLON);
9847
- if (this.test)
9848
- this.test.render(code, options, NO_SEMICOLON);
9849
- if (this.update)
9850
- this.update.render(code, options, NO_SEMICOLON);
9934
+ var _a, _b, _c;
9935
+ (_a = this.init) === null || _a === void 0 ? void 0 : _a.render(code, options, NO_SEMICOLON);
9936
+ (_b = this.test) === null || _b === void 0 ? void 0 : _b.render(code, options, NO_SEMICOLON);
9937
+ (_c = this.update) === null || _c === void 0 ? void 0 : _c.render(code, options, NO_SEMICOLON);
9851
9938
  this.body.render(code, options);
9852
9939
  }
9853
9940
  }
@@ -9883,11 +9970,12 @@ class IfStatement extends NodeBase {
9883
9970
  this.testValue = UnknownValue;
9884
9971
  }
9885
9972
  hasEffects(context) {
9973
+ var _a;
9886
9974
  if (this.test.hasEffects(context)) {
9887
9975
  return true;
9888
9976
  }
9889
9977
  const testValue = this.getTestValue();
9890
- if (testValue === UnknownValue) {
9978
+ if (typeof testValue === 'symbol') {
9891
9979
  const { brokenFlow } = context;
9892
9980
  if (this.consequent.hasEffects(context))
9893
9981
  return true;
@@ -9901,9 +9989,7 @@ class IfStatement extends NodeBase {
9901
9989
  context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
9902
9990
  return false;
9903
9991
  }
9904
- return testValue
9905
- ? this.consequent.hasEffects(context)
9906
- : this.alternate !== null && this.alternate.hasEffects(context);
9992
+ return testValue ? this.consequent.hasEffects(context) : !!((_a = this.alternate) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
9907
9993
  }
9908
9994
  include(context, includeChildrenRecursively) {
9909
9995
  this.included = true;
@@ -9912,7 +9998,7 @@ class IfStatement extends NodeBase {
9912
9998
  }
9913
9999
  else {
9914
10000
  const testValue = this.getTestValue();
9915
- if (testValue === UnknownValue) {
10001
+ if (typeof testValue === 'symbol') {
9916
10002
  this.includeUnknownTest(context);
9917
10003
  }
9918
10004
  else {
@@ -9942,7 +10028,7 @@ class IfStatement extends NodeBase {
9942
10028
  else {
9943
10029
  code.remove(this.start, this.consequent.start);
9944
10030
  }
9945
- if (this.consequent.included && (noTreeshake || testValue === UnknownValue || testValue)) {
10031
+ if (this.consequent.included && (noTreeshake || typeof testValue === 'symbol' || testValue)) {
9946
10032
  this.consequent.render(code, options);
9947
10033
  }
9948
10034
  else {
@@ -9950,7 +10036,7 @@ class IfStatement extends NodeBase {
9950
10036
  hoistedDeclarations.push(...this.consequentScope.hoistedDeclarations);
9951
10037
  }
9952
10038
  if (this.alternate) {
9953
- if (this.alternate.included && (noTreeshake || testValue === UnknownValue || !testValue)) {
10039
+ if (this.alternate.included && (noTreeshake || typeof testValue === 'symbol' || !testValue)) {
9954
10040
  if (includesIfElse) {
9955
10041
  if (code.original.charCodeAt(this.alternate.start - 1) === 101) {
9956
10042
  code.prependLeft(this.alternate.start, ' ');
@@ -9980,34 +10066,35 @@ class IfStatement extends NodeBase {
9980
10066
  return this.testValue;
9981
10067
  }
9982
10068
  includeKnownTest(context, testValue) {
10069
+ var _a;
9983
10070
  if (this.test.shouldBeIncluded(context)) {
9984
10071
  this.test.include(context, false);
9985
10072
  }
9986
10073
  if (testValue && this.consequent.shouldBeIncluded(context)) {
9987
- this.consequent.includeAsSingleStatement(context, false);
10074
+ this.consequent.include(context, false, { asSingleStatement: true });
9988
10075
  }
9989
- if (this.alternate !== null && !testValue && this.alternate.shouldBeIncluded(context)) {
9990
- this.alternate.includeAsSingleStatement(context, false);
10076
+ if (!testValue && ((_a = this.alternate) === null || _a === void 0 ? void 0 : _a.shouldBeIncluded(context))) {
10077
+ this.alternate.include(context, false, { asSingleStatement: true });
9991
10078
  }
9992
10079
  }
9993
10080
  includeRecursively(includeChildrenRecursively, context) {
10081
+ var _a;
9994
10082
  this.test.include(context, includeChildrenRecursively);
9995
10083
  this.consequent.include(context, includeChildrenRecursively);
9996
- if (this.alternate !== null) {
9997
- this.alternate.include(context, includeChildrenRecursively);
9998
- }
10084
+ (_a = this.alternate) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
9999
10085
  }
10000
10086
  includeUnknownTest(context) {
10087
+ var _a;
10001
10088
  this.test.include(context, false);
10002
10089
  const { brokenFlow } = context;
10003
10090
  let consequentBrokenFlow = BROKEN_FLOW_NONE;
10004
10091
  if (this.consequent.shouldBeIncluded(context)) {
10005
- this.consequent.includeAsSingleStatement(context, false);
10092
+ this.consequent.include(context, false, { asSingleStatement: true });
10006
10093
  consequentBrokenFlow = context.brokenFlow;
10007
10094
  context.brokenFlow = brokenFlow;
10008
10095
  }
10009
- if (this.alternate !== null && this.alternate.shouldBeIncluded(context)) {
10010
- this.alternate.includeAsSingleStatement(context, false);
10096
+ if ((_a = this.alternate) === null || _a === void 0 ? void 0 : _a.shouldBeIncluded(context)) {
10097
+ this.alternate.include(context, false, { asSingleStatement: true });
10011
10098
  context.brokenFlow =
10012
10099
  context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
10013
10100
  }
@@ -10486,7 +10573,7 @@ class LogicalExpression extends NodeBase {
10486
10573
  }
10487
10574
  deoptimizePath(path) {
10488
10575
  const usedBranch = this.getUsedBranch();
10489
- if (usedBranch === null) {
10576
+ if (!usedBranch) {
10490
10577
  this.left.deoptimizePath(path);
10491
10578
  this.right.deoptimizePath(path);
10492
10579
  }
@@ -10500,14 +10587,14 @@ class LogicalExpression extends NodeBase {
10500
10587
  }
10501
10588
  getLiteralValueAtPath(path, recursionTracker, origin) {
10502
10589
  const usedBranch = this.getUsedBranch();
10503
- if (usedBranch === null)
10590
+ if (!usedBranch)
10504
10591
  return UnknownValue;
10505
10592
  this.expressionsToBeDeoptimized.push(origin);
10506
10593
  return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
10507
10594
  }
10508
10595
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
10509
10596
  const usedBranch = this.getUsedBranch();
10510
- if (usedBranch === null)
10597
+ if (!usedBranch)
10511
10598
  return new MultiExpression([
10512
10599
  this.left.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin),
10513
10600
  this.right.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin)
@@ -10526,7 +10613,7 @@ class LogicalExpression extends NodeBase {
10526
10613
  }
10527
10614
  hasEffectsWhenAccessedAtPath(path, context) {
10528
10615
  const usedBranch = this.getUsedBranch();
10529
- if (usedBranch === null) {
10616
+ if (!usedBranch) {
10530
10617
  return (this.left.hasEffectsWhenAccessedAtPath(path, context) ||
10531
10618
  this.right.hasEffectsWhenAccessedAtPath(path, context));
10532
10619
  }
@@ -10534,7 +10621,7 @@ class LogicalExpression extends NodeBase {
10534
10621
  }
10535
10622
  hasEffectsWhenAssignedAtPath(path, context) {
10536
10623
  const usedBranch = this.getUsedBranch();
10537
- if (usedBranch === null) {
10624
+ if (!usedBranch) {
10538
10625
  return (this.left.hasEffectsWhenAssignedAtPath(path, context) ||
10539
10626
  this.right.hasEffectsWhenAssignedAtPath(path, context));
10540
10627
  }
@@ -10542,7 +10629,7 @@ class LogicalExpression extends NodeBase {
10542
10629
  }
10543
10630
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
10544
10631
  const usedBranch = this.getUsedBranch();
10545
- if (usedBranch === null) {
10632
+ if (!usedBranch) {
10546
10633
  return (this.left.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
10547
10634
  this.right.hasEffectsWhenCalledAtPath(path, callOptions, context));
10548
10635
  }
@@ -10553,7 +10640,7 @@ class LogicalExpression extends NodeBase {
10553
10640
  const usedBranch = this.getUsedBranch();
10554
10641
  if (includeChildrenRecursively ||
10555
10642
  (usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
10556
- usedBranch === null) {
10643
+ !usedBranch) {
10557
10644
  this.left.include(context, includeChildrenRecursively);
10558
10645
  this.right.include(context, includeChildrenRecursively);
10559
10646
  }
@@ -10594,7 +10681,7 @@ class LogicalExpression extends NodeBase {
10594
10681
  if (!this.isBranchResolutionAnalysed) {
10595
10682
  this.isBranchResolutionAnalysed = true;
10596
10683
  const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
10597
- if (leftValue === UnknownValue) {
10684
+ if (typeof leftValue === 'symbol') {
10598
10685
  return null;
10599
10686
  }
10600
10687
  else {
@@ -10780,21 +10867,37 @@ class NewExpression extends NodeBase {
10780
10867
  this.deoptimized = false;
10781
10868
  }
10782
10869
  hasEffects(context) {
10783
- if (!this.deoptimized)
10784
- this.applyDeoptimizations();
10785
- for (const argument of this.arguments) {
10786
- if (argument.hasEffects(context))
10787
- return true;
10870
+ try {
10871
+ for (const argument of this.arguments) {
10872
+ if (argument.hasEffects(context))
10873
+ return true;
10874
+ }
10875
+ if (this.context.options.treeshake.annotations &&
10876
+ this.annotations)
10877
+ return false;
10878
+ return (this.callee.hasEffects(context) ||
10879
+ this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
10880
+ }
10881
+ finally {
10882
+ if (!this.deoptimized)
10883
+ this.applyDeoptimizations();
10788
10884
  }
10789
- if (this.context.options.treeshake.annotations &&
10790
- this.annotations)
10791
- return false;
10792
- return (this.callee.hasEffects(context) ||
10793
- this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
10794
10885
  }
10795
10886
  hasEffectsWhenAccessedAtPath(path) {
10796
10887
  return path.length > 0;
10797
10888
  }
10889
+ include(context, includeChildrenRecursively) {
10890
+ if (!this.deoptimized)
10891
+ this.applyDeoptimizations();
10892
+ if (includeChildrenRecursively) {
10893
+ super.include(context, includeChildrenRecursively);
10894
+ }
10895
+ else {
10896
+ this.included = true;
10897
+ this.callee.include(context, false);
10898
+ }
10899
+ this.callee.includeCallArguments(context, this.arguments);
10900
+ }
10798
10901
  initialise() {
10799
10902
  this.callOptions = {
10800
10903
  args: this.arguments,
@@ -10863,7 +10966,7 @@ class ObjectExpression extends NodeBase {
10863
10966
  let key;
10864
10967
  if (property.computed) {
10865
10968
  const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
10866
- if (keyValue === UnknownValue) {
10969
+ if (typeof keyValue === 'symbol') {
10867
10970
  properties.push({ key: UnknownKey, kind: property.kind, property });
10868
10971
  continue;
10869
10972
  }
@@ -10984,8 +11087,8 @@ class PropertyDefinition extends NodeBase {
10984
11087
  : UNKNOWN_EXPRESSION;
10985
11088
  }
10986
11089
  hasEffects(context) {
10987
- return (this.key.hasEffects(context) ||
10988
- (this.static && this.value !== null && this.value.hasEffects(context)));
11090
+ var _a;
11091
+ return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
10989
11092
  }
10990
11093
  hasEffectsWhenAccessedAtPath(path, context) {
10991
11094
  return !this.value || this.value.hasEffectsWhenAccessedAtPath(path, context);
@@ -11000,17 +11103,16 @@ class PropertyDefinition extends NodeBase {
11000
11103
 
11001
11104
  class ReturnStatement extends NodeBase {
11002
11105
  hasEffects(context) {
11003
- if (!context.ignore.returnYield ||
11004
- (this.argument !== null && this.argument.hasEffects(context)))
11106
+ var _a;
11107
+ if (!context.ignore.returnYield || ((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context)))
11005
11108
  return true;
11006
11109
  context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
11007
11110
  return false;
11008
11111
  }
11009
11112
  include(context, includeChildrenRecursively) {
11113
+ var _a;
11010
11114
  this.included = true;
11011
- if (this.argument) {
11012
- this.argument.include(context, includeChildrenRecursively);
11013
- }
11115
+ (_a = this.argument) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
11014
11116
  context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
11015
11117
  }
11016
11118
  initialise() {
@@ -11130,6 +11232,9 @@ class Super extends NodeBase {
11130
11232
  deoptimizePath(path) {
11131
11233
  this.variable.deoptimizePath(path);
11132
11234
  }
11235
+ deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
11236
+ this.variable.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
11237
+ }
11133
11238
  include() {
11134
11239
  if (!this.included) {
11135
11240
  this.included = true;
@@ -11140,7 +11245,8 @@ class Super extends NodeBase {
11140
11245
 
11141
11246
  class SwitchCase extends NodeBase {
11142
11247
  hasEffects(context) {
11143
- if (this.test && this.test.hasEffects(context))
11248
+ var _a;
11249
+ if ((_a = this.test) === null || _a === void 0 ? void 0 : _a.hasEffects(context))
11144
11250
  return true;
11145
11251
  for (const node of this.consequent) {
11146
11252
  if (context.brokenFlow)
@@ -11151,9 +11257,9 @@ class SwitchCase extends NodeBase {
11151
11257
  return false;
11152
11258
  }
11153
11259
  include(context, includeChildrenRecursively) {
11260
+ var _a;
11154
11261
  this.included = true;
11155
- if (this.test)
11156
- this.test.include(context, includeChildrenRecursively);
11262
+ (_a = this.test) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
11157
11263
  for (const node of this.consequent) {
11158
11264
  if (includeChildrenRecursively || node.shouldBeIncluded(context))
11159
11265
  node.include(context, includeChildrenRecursively);
@@ -11246,7 +11352,7 @@ class SwitchStatement extends NodeBase {
11246
11352
  }
11247
11353
  }
11248
11354
 
11249
- class TaggedTemplateExpression extends NodeBase {
11355
+ class TaggedTemplateExpression extends CallExpressionBase {
11250
11356
  bind() {
11251
11357
  super.bind();
11252
11358
  if (this.tag.type === Identifier$1) {
@@ -11261,13 +11367,40 @@ class TaggedTemplateExpression extends NodeBase {
11261
11367
  }
11262
11368
  }
11263
11369
  hasEffects(context) {
11264
- return (super.hasEffects(context) ||
11265
- this.tag.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
11370
+ try {
11371
+ for (const argument of this.quasi.expressions) {
11372
+ if (argument.hasEffects(context))
11373
+ return true;
11374
+ }
11375
+ return (this.tag.hasEffects(context) ||
11376
+ this.tag.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
11377
+ }
11378
+ finally {
11379
+ if (!this.deoptimized)
11380
+ this.applyDeoptimizations();
11381
+ }
11382
+ }
11383
+ include(context, includeChildrenRecursively) {
11384
+ if (!this.deoptimized)
11385
+ this.applyDeoptimizations();
11386
+ if (includeChildrenRecursively) {
11387
+ super.include(context, includeChildrenRecursively);
11388
+ }
11389
+ else {
11390
+ this.included = true;
11391
+ this.tag.include(context, includeChildrenRecursively);
11392
+ this.quasi.include(context, includeChildrenRecursively);
11393
+ }
11394
+ this.tag.includeCallArguments(context, this.callOptions.args);
11395
+ const returnExpression = this.getReturnExpression();
11396
+ if (!returnExpression.included) {
11397
+ returnExpression.include(context, false);
11398
+ }
11266
11399
  }
11267
11400
  initialise() {
11268
11401
  this.callOptions = {
11269
- args: NO_ARGS,
11270
- thisParam: null,
11402
+ args: [UNKNOWN_EXPRESSION, ...this.quasi.expressions],
11403
+ thisParam: this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null,
11271
11404
  withNew: false
11272
11405
  };
11273
11406
  }
@@ -11275,6 +11408,25 @@ class TaggedTemplateExpression extends NodeBase {
11275
11408
  this.tag.render(code, options, { isCalleeOfRenderedParent: true });
11276
11409
  this.quasi.render(code, options);
11277
11410
  }
11411
+ applyDeoptimizations() {
11412
+ this.deoptimized = true;
11413
+ const { thisParam } = this.callOptions;
11414
+ if (thisParam) {
11415
+ this.tag.deoptimizeThisOnEventAtPath(EVENT_CALLED, EMPTY_PATH, thisParam, SHARED_RECURSION_TRACKER);
11416
+ }
11417
+ for (const argument of this.quasi.expressions) {
11418
+ // This will make sure all properties of parameters behave as "unknown"
11419
+ argument.deoptimizePath(UNKNOWN_PATH);
11420
+ }
11421
+ this.context.requestTreeshakingPass();
11422
+ }
11423
+ getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
11424
+ if (this.returnExpression === null) {
11425
+ this.returnExpression = UNKNOWN_EXPRESSION;
11426
+ return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.callOptions, recursionTracker, this));
11427
+ }
11428
+ return this.returnExpression;
11429
+ }
11278
11430
  }
11279
11431
 
11280
11432
  class TemplateElement extends NodeBase {
@@ -11294,12 +11446,28 @@ class TemplateElement extends NodeBase {
11294
11446
  }
11295
11447
 
11296
11448
  class TemplateLiteral extends NodeBase {
11449
+ deoptimizeThisOnEventAtPath() { }
11297
11450
  getLiteralValueAtPath(path) {
11298
11451
  if (path.length > 0 || this.quasis.length !== 1) {
11299
11452
  return UnknownValue;
11300
11453
  }
11301
11454
  return this.quasis[0].value.cooked;
11302
11455
  }
11456
+ getReturnExpressionWhenCalledAtPath(path) {
11457
+ if (path.length !== 1) {
11458
+ return UNKNOWN_EXPRESSION;
11459
+ }
11460
+ return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
11461
+ }
11462
+ hasEffectsWhenAccessedAtPath(path) {
11463
+ return path.length > 1;
11464
+ }
11465
+ hasEffectsWhenCalledAtPath(path, callOptions, context) {
11466
+ if (path.length === 1) {
11467
+ return hasMemberEffectWhenCalled(literalStringMembers, path[0], callOptions, context);
11468
+ }
11469
+ return true;
11470
+ }
11303
11471
  render(code, options) {
11304
11472
  code.indentExclusionRanges.push([this.start, this.end]);
11305
11473
  super.render(code, options);
@@ -11486,13 +11654,13 @@ class TryStatement extends NodeBase {
11486
11654
  this.includedLabelsAfterBlock = null;
11487
11655
  }
11488
11656
  hasEffects(context) {
11657
+ var _a;
11489
11658
  return ((this.context.options.treeshake.tryCatchDeoptimization
11490
11659
  ? this.block.body.length > 0
11491
- : this.block.hasEffects(context)) ||
11492
- (this.finalizer !== null && this.finalizer.hasEffects(context)));
11660
+ : this.block.hasEffects(context)) || !!((_a = this.finalizer) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
11493
11661
  }
11494
11662
  include(context, includeChildrenRecursively) {
11495
- var _a;
11663
+ var _a, _b;
11496
11664
  const tryCatchDeoptimization = (_a = this.context.options.treeshake) === null || _a === void 0 ? void 0 : _a.tryCatchDeoptimization;
11497
11665
  const { brokenFlow } = context;
11498
11666
  if (!this.directlyIncluded || !tryCatchDeoptimization) {
@@ -11513,9 +11681,7 @@ class TryStatement extends NodeBase {
11513
11681
  this.handler.include(context, includeChildrenRecursively);
11514
11682
  context.brokenFlow = brokenFlow;
11515
11683
  }
11516
- if (this.finalizer !== null) {
11517
- this.finalizer.include(context, includeChildrenRecursively);
11518
- }
11684
+ (_b = this.finalizer) === null || _b === void 0 ? void 0 : _b.include(context, includeChildrenRecursively);
11519
11685
  }
11520
11686
  }
11521
11687
 
@@ -11537,7 +11703,7 @@ class UnaryExpression extends NodeBase {
11537
11703
  if (path.length > 0)
11538
11704
  return UnknownValue;
11539
11705
  const argumentValue = this.argument.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin);
11540
- if (argumentValue === UnknownValue)
11706
+ if (typeof argumentValue === 'symbol')
11541
11707
  return UnknownValue;
11542
11708
  return unaryOperators[this.operator](argumentValue);
11543
11709
  }
@@ -11651,18 +11817,12 @@ class VariableDeclaration extends NodeBase {
11651
11817
  hasEffectsWhenAssignedAtPath() {
11652
11818
  return false;
11653
11819
  }
11654
- include(context, includeChildrenRecursively) {
11820
+ include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
11655
11821
  this.included = true;
11656
11822
  for (const declarator of this.declarations) {
11657
11823
  if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
11658
11824
  declarator.include(context, includeChildrenRecursively);
11659
- }
11660
- }
11661
- includeAsSingleStatement(context, includeChildrenRecursively) {
11662
- this.included = true;
11663
- for (const declarator of this.declarations) {
11664
- if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) {
11665
- declarator.include(context, includeChildrenRecursively);
11825
+ if (asSingleStatement) {
11666
11826
  declarator.id.include(context, includeChildrenRecursively);
11667
11827
  }
11668
11828
  }
@@ -11683,16 +11843,14 @@ class VariableDeclaration extends NodeBase {
11683
11843
  }
11684
11844
  }
11685
11845
  else {
11686
- this.renderReplacedDeclarations(code, options, nodeRenderOptions);
11846
+ this.renderReplacedDeclarations(code, options);
11687
11847
  }
11688
11848
  }
11689
- renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, isNoStatement) {
11849
+ renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
11690
11850
  if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
11691
11851
  code.remove(this.end - 1, this.end);
11692
11852
  }
11693
- if (!isNoStatement) {
11694
- separatorString += ';';
11695
- }
11853
+ separatorString += ';';
11696
11854
  if (lastSeparatorPos !== null) {
11697
11855
  if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
11698
11856
  (code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
@@ -11717,7 +11875,7 @@ class VariableDeclaration extends NodeBase {
11717
11875
  code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
11718
11876
  }
11719
11877
  }
11720
- renderReplacedDeclarations(code, options, { isNoStatement }) {
11878
+ renderReplacedDeclarations(code, options) {
11721
11879
  const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
11722
11880
  let actualContentEnd, renderedContentEnd;
11723
11881
  renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
@@ -11773,7 +11931,7 @@ class VariableDeclaration extends NodeBase {
11773
11931
  lastSeparatorPos = separator;
11774
11932
  separatorString = nextSeparatorString;
11775
11933
  }
11776
- this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options, isNoStatement);
11934
+ this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options);
11777
11935
  }
11778
11936
  }
11779
11937
  function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
@@ -11810,15 +11968,17 @@ class VariableDeclarator extends NodeBase {
11810
11968
  this.id.deoptimizePath(path);
11811
11969
  }
11812
11970
  hasEffects(context) {
11813
- const initEffect = this.init !== null && this.init.hasEffects(context);
11971
+ var _a;
11972
+ const initEffect = (_a = this.init) === null || _a === void 0 ? void 0 : _a.hasEffects(context);
11814
11973
  this.id.markDeclarationReached();
11815
11974
  return initEffect || this.id.hasEffects(context);
11816
11975
  }
11817
11976
  include(context, includeChildrenRecursively) {
11977
+ var _a;
11818
11978
  this.included = true;
11819
- if (this.init) {
11820
- this.init.include(context, includeChildrenRecursively);
11821
- }
11979
+ (_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively, {
11980
+ includeWithoutParameterDefaults: true
11981
+ });
11822
11982
  this.id.markDeclarationReached();
11823
11983
  if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
11824
11984
  this.id.include(context, includeChildrenRecursively);
@@ -11862,7 +12022,7 @@ class WhileStatement extends NodeBase {
11862
12022
  this.included = true;
11863
12023
  this.test.include(context, includeChildrenRecursively);
11864
12024
  const { brokenFlow } = context;
11865
- this.body.includeAsSingleStatement(context, includeChildrenRecursively);
12025
+ this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
11866
12026
  context.brokenFlow = brokenFlow;
11867
12027
  }
11868
12028
  }
@@ -11873,9 +12033,10 @@ class YieldExpression extends NodeBase {
11873
12033
  this.deoptimized = false;
11874
12034
  }
11875
12035
  hasEffects(context) {
12036
+ var _a;
11876
12037
  if (!this.deoptimized)
11877
12038
  this.applyDeoptimizations();
11878
- return (!context.ignore.returnYield || (this.argument !== null && this.argument.hasEffects(context)));
12039
+ return !context.ignore.returnYield || !!((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
11879
12040
  }
11880
12041
  render(code, options) {
11881
12042
  if (this.argument) {
@@ -11885,14 +12046,6 @@ class YieldExpression extends NodeBase {
11885
12046
  }
11886
12047
  }
11887
12048
  }
11888
- applyDeoptimizations() {
11889
- this.deoptimized = true;
11890
- const { argument } = this;
11891
- if (argument) {
11892
- argument.deoptimizePath(UNKNOWN_PATH);
11893
- this.context.requestTreeshakingPass();
11894
- }
11895
- }
11896
12049
  }
11897
12050
 
11898
12051
  const nodeConstructors = {