rollup 2.50.1 → 2.50.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.1
4
- Wed, 26 May 2021 07:27:41 GMT - commit 9a50fbb35a0c5be4fc0a6ec37a06827bab99923b
3
+ Rollup.js v2.50.5
4
+ Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.1
4
- Wed, 26 May 2021 07:27:41 GMT - commit 9a50fbb35a0c5be4fc0a6ec37a06827bab99923b
3
+ Rollup.js v2.50.5
4
+ Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -14,7 +14,7 @@ import * as fs from 'fs';
14
14
  import { lstatSync, realpathSync, readdirSync } from 'fs';
15
15
  import { EventEmitter } from 'events';
16
16
 
17
- var version$1 = "2.50.1";
17
+ var version$1 = "2.50.5";
18
18
 
19
19
  var charToInteger = {};
20
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -3397,10 +3397,11 @@ const knownGlobals = {
3397
3397
  Promise: {
3398
3398
  __proto__: null,
3399
3399
  [ValueProperties]: IMPURE,
3400
- all: PF,
3400
+ all: O,
3401
3401
  prototype: O,
3402
- race: PF,
3403
- resolve: PF
3402
+ race: O,
3403
+ reject: O,
3404
+ resolve: O
3404
3405
  },
3405
3406
  propertyIsEnumerable: O,
3406
3407
  Proxy: O,
@@ -4194,6 +4195,7 @@ class Identifier extends NodeBase {
4194
4195
  this.deoptimized = true;
4195
4196
  if (this.variable !== null && this.variable instanceof LocalVariable) {
4196
4197
  this.variable.consolidateInitializers();
4198
+ this.context.requestTreeshakingPass();
4197
4199
  }
4198
4200
  }
4199
4201
  disallowImportReassignment() {
@@ -4720,7 +4722,7 @@ class Method extends ExpressionEntity {
4720
4722
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
4721
4723
  var _a, _b;
4722
4724
  if (path.length > 0 ||
4723
- (this.description.mutatesSelfAsArray &&
4725
+ (this.description.mutatesSelfAsArray === true &&
4724
4726
  ((_a = callOptions.thisParam) === null || _a === void 0 ? void 0 : _a.hasEffectsWhenAssignedAtPath(UNKNOWN_INTEGER_PATH, context)))) {
4725
4727
  return true;
4726
4728
  }
@@ -4985,11 +4987,16 @@ class SpreadElement extends NodeBase {
4985
4987
  this.argument.deoptimizeThisOnEventAtPath(event, [UnknownKey, ...path], thisParameter, recursionTracker);
4986
4988
  }
4987
4989
  }
4990
+ hasEffects(context) {
4991
+ return (this.argument.hasEffects(context) ||
4992
+ this.argument.hasEffectsWhenAccessedAtPath(UNKNOWN_PATH, context));
4993
+ }
4988
4994
  applyDeoptimizations() {
4989
4995
  this.deoptimized = true;
4990
4996
  // Only properties of properties of the argument could become subject to reassignment
4991
4997
  // This will also reassign the return values of iterators
4992
4998
  this.argument.deoptimizePath([UnknownKey, UnknownKey]);
4999
+ this.context.requestTreeshakingPass();
4993
5000
  }
4994
5001
  }
4995
5002
 
@@ -5139,6 +5146,7 @@ class RestElement extends NodeBase {
5139
5146
  this.deoptimized = true;
5140
5147
  if (this.declarationInit !== null) {
5141
5148
  this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
5149
+ this.context.requestTreeshakingPass();
5142
5150
  }
5143
5151
  }
5144
5152
  }
@@ -5176,7 +5184,7 @@ class FunctionNode extends NodeBase {
5176
5184
  }
5177
5185
  }
5178
5186
  getReturnExpressionWhenCalledAtPath(path) {
5179
- return path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5187
+ return !this.async && path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5180
5188
  }
5181
5189
  hasEffects() {
5182
5190
  return this.id !== null && this.id.hasEffects();
@@ -5195,6 +5203,12 @@ class FunctionNode extends NodeBase {
5195
5203
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
5196
5204
  if (path.length > 0)
5197
5205
  return true;
5206
+ if (this.async &&
5207
+ this.scope
5208
+ .getReturnExpression()
5209
+ .hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context)) {
5210
+ return true;
5211
+ }
5198
5212
  for (const param of this.params) {
5199
5213
  if (param.hasEffects(context))
5200
5214
  return true;
@@ -5622,42 +5636,42 @@ const NEW_ARRAY_PROPERTIES = [
5622
5636
  { key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION },
5623
5637
  { key: 'length', kind: 'init', property: UNKNOWN_LITERAL_NUMBER }
5624
5638
  ];
5625
- const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_BOOLEAN = [
5639
+ const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN = [
5626
5640
  new Method({
5627
5641
  callsArgs: [0],
5628
- mutatesSelfAsArray: true,
5642
+ mutatesSelfAsArray: 'deopt-only',
5629
5643
  returns: null,
5630
5644
  returnsPrimitive: UNKNOWN_LITERAL_BOOLEAN
5631
5645
  })
5632
5646
  ];
5633
- const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_NUMBER = [
5647
+ const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER = [
5634
5648
  new Method({
5635
5649
  callsArgs: [0],
5636
- mutatesSelfAsArray: true,
5650
+ mutatesSelfAsArray: 'deopt-only',
5637
5651
  returns: null,
5638
5652
  returnsPrimitive: UNKNOWN_LITERAL_NUMBER
5639
5653
  })
5640
5654
  ];
5641
- const METHOD_RETURNS_NEW_ARRAY = [
5655
+ const METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY = [
5642
5656
  new Method({
5643
5657
  callsArgs: null,
5644
- mutatesSelfAsArray: false,
5658
+ mutatesSelfAsArray: true,
5645
5659
  returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE),
5646
5660
  returnsPrimitive: null
5647
5661
  })
5648
5662
  ];
5649
- const METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY = [
5663
+ const METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY = [
5650
5664
  new Method({
5651
5665
  callsArgs: null,
5652
- mutatesSelfAsArray: true,
5666
+ mutatesSelfAsArray: 'deopt-only',
5653
5667
  returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE),
5654
5668
  returnsPrimitive: null
5655
5669
  })
5656
5670
  ];
5657
- const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_NEW_ARRAY = [
5671
+ const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY = [
5658
5672
  new Method({
5659
5673
  callsArgs: [0],
5660
- mutatesSelfAsArray: true,
5674
+ mutatesSelfAsArray: 'deopt-only',
5661
5675
  returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE),
5662
5676
  returnsPrimitive: null
5663
5677
  })
@@ -5678,10 +5692,18 @@ const METHOD_MUTATES_SELF_RETURNS_UNKNOWN = [
5678
5692
  returnsPrimitive: UNKNOWN_EXPRESSION
5679
5693
  })
5680
5694
  ];
5681
- const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_UNKNOWN = [
5695
+ const METHOD_DEOPTS_SELF_RETURNS_UNKNOWN = [
5696
+ new Method({
5697
+ callsArgs: null,
5698
+ mutatesSelfAsArray: 'deopt-only',
5699
+ returns: null,
5700
+ returnsPrimitive: UNKNOWN_EXPRESSION
5701
+ })
5702
+ ];
5703
+ const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN = [
5682
5704
  new Method({
5683
5705
  callsArgs: [0],
5684
- mutatesSelfAsArray: true,
5706
+ mutatesSelfAsArray: 'deopt-only',
5685
5707
  returns: null,
5686
5708
  returnsPrimitive: UNKNOWN_EXPRESSION
5687
5709
  })
@@ -5705,34 +5727,34 @@ const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF = [
5705
5727
  const ARRAY_PROTOTYPE = new ObjectEntity({
5706
5728
  __proto__: null,
5707
5729
  // We assume that accessors have effects as we do not track the accessed value afterwards
5708
- at: METHOD_MUTATES_SELF_RETURNS_UNKNOWN,
5709
- concat: METHOD_RETURNS_NEW_ARRAY,
5730
+ at: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN,
5731
+ concat: METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY,
5710
5732
  copyWithin: METHOD_MUTATES_SELF_RETURNS_SELF,
5711
- entries: METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY,
5712
- every: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_BOOLEAN,
5733
+ entries: METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY,
5734
+ every: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN,
5713
5735
  fill: METHOD_MUTATES_SELF_RETURNS_SELF,
5714
- filter: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_NEW_ARRAY,
5715
- find: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_UNKNOWN,
5716
- findIndex: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_NUMBER,
5717
- forEach: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_UNKNOWN,
5736
+ filter: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
5737
+ find: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
5738
+ findIndex: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER,
5739
+ forEach: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
5718
5740
  includes: METHOD_RETURNS_BOOLEAN,
5719
5741
  indexOf: METHOD_RETURNS_NUMBER,
5720
5742
  join: METHOD_RETURNS_STRING,
5721
5743
  keys: METHOD_RETURNS_UNKNOWN,
5722
5744
  lastIndexOf: METHOD_RETURNS_NUMBER,
5723
- map: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_NEW_ARRAY,
5745
+ map: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
5724
5746
  pop: METHOD_MUTATES_SELF_RETURNS_UNKNOWN,
5725
5747
  push: METHOD_MUTATES_SELF_RETURNS_NUMBER,
5726
- reduce: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_UNKNOWN,
5727
- reduceRight: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_UNKNOWN,
5748
+ reduce: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
5749
+ reduceRight: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
5728
5750
  reverse: METHOD_MUTATES_SELF_RETURNS_SELF,
5729
5751
  shift: METHOD_MUTATES_SELF_RETURNS_UNKNOWN,
5730
- slice: METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY,
5731
- some: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_BOOLEAN,
5752
+ slice: METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY,
5753
+ some: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN,
5732
5754
  sort: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF,
5733
5755
  splice: METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY,
5734
5756
  unshift: METHOD_MUTATES_SELF_RETURNS_NUMBER,
5735
- values: METHOD_MUTATES_SELF_RETURNS_UNKNOWN
5757
+ values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
5736
5758
  }, OBJECT_PROTOTYPE);
5737
5759
 
5738
5760
  class ArrayExpression extends NodeBase {
@@ -6060,6 +6082,7 @@ class AssignmentExpression extends NodeBase {
6060
6082
  this.deoptimized = true;
6061
6083
  this.left.deoptimizePath(EMPTY_PATH);
6062
6084
  this.right.deoptimizePath(UNKNOWN_PATH);
6085
+ this.context.requestTreeshakingPass();
6063
6086
  }
6064
6087
  }
6065
6088
 
@@ -6088,12 +6111,20 @@ class AssignmentPattern extends NodeBase {
6088
6111
  this.deoptimized = true;
6089
6112
  this.left.deoptimizePath(EMPTY_PATH);
6090
6113
  this.right.deoptimizePath(UNKNOWN_PATH);
6114
+ this.context.requestTreeshakingPass();
6091
6115
  }
6092
6116
  }
6093
6117
 
6094
6118
  class AwaitExpression extends NodeBase {
6095
6119
  hasEffects(context) {
6096
- return !context.ignore.returnAwaitYield || this.argument.hasEffects(context);
6120
+ const { propertyReadSideEffects } = this.context.options
6121
+ .treeshake;
6122
+ return (!context.ignore.returnAwaitYield ||
6123
+ this.argument.hasEffects(context) ||
6124
+ this.argument.hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context) ||
6125
+ (propertyReadSideEffects &&
6126
+ (propertyReadSideEffects === 'always' ||
6127
+ this.argument.hasEffectsWhenAccessedAtPath(['then'], context))));
6097
6128
  }
6098
6129
  include(context, includeChildrenRecursively) {
6099
6130
  if (!this.included) {
@@ -6374,10 +6405,9 @@ class MemberExpression extends NodeBase {
6374
6405
  this.propertyKey = getResolvablePropertyKey(this);
6375
6406
  }
6376
6407
  render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
6377
- const isCalleeOfDifferentParent = renderedParentType === CallExpression$1 && isCalleeOfRenderedParent;
6378
6408
  if (this.variable || this.replacement) {
6379
6409
  let replacement = this.variable ? this.variable.getName() : this.replacement;
6380
- if (isCalleeOfDifferentParent)
6410
+ if (renderedParentType && isCalleeOfRenderedParent)
6381
6411
  replacement = '0, ' + replacement;
6382
6412
  code.overwrite(this.start, this.end, replacement, {
6383
6413
  contentOnly: true,
@@ -6385,7 +6415,7 @@ class MemberExpression extends NodeBase {
6385
6415
  });
6386
6416
  }
6387
6417
  else {
6388
- if (isCalleeOfDifferentParent) {
6418
+ if (renderedParentType && isCalleeOfRenderedParent) {
6389
6419
  code.appendRight(this.start, '0, ');
6390
6420
  }
6391
6421
  const surroundingElement = renderedParentType || renderedSurroundingElement;
@@ -6409,6 +6439,7 @@ class MemberExpression extends NodeBase {
6409
6439
  if (this.parent instanceof AssignmentExpression) {
6410
6440
  this.object.deoptimizeThisOnEventAtPath(EVENT_ASSIGNED, [this.propertyKey], this.object, SHARED_RECURSION_TRACKER);
6411
6441
  }
6442
+ this.context.requestTreeshakingPass();
6412
6443
  }
6413
6444
  }
6414
6445
  disallowNamespaceReassignment() {
@@ -6593,7 +6624,10 @@ class CallExpression extends NodeBase {
6593
6624
  }
6594
6625
  render(code, options, { renderedParentType, renderedSurroundingElement } = BLANK) {
6595
6626
  const surroundingELement = renderedParentType || renderedSurroundingElement;
6596
- this.callee.render(code, options, surroundingELement ? { renderedSurroundingElement: surroundingELement } : BLANK);
6627
+ this.callee.render(code, options, {
6628
+ isCalleeOfRenderedParent: true,
6629
+ renderedSurroundingElement: surroundingELement
6630
+ });
6597
6631
  if (this.arguments.length > 0) {
6598
6632
  if (this.arguments[this.arguments.length - 1].included) {
6599
6633
  for (const arg of this.arguments) {
@@ -6627,6 +6661,7 @@ class CallExpression extends NodeBase {
6627
6661
  // This will make sure all properties of parameters behave as "unknown"
6628
6662
  argument.deoptimizePath(UNKNOWN_PATH);
6629
6663
  }
6664
+ this.context.requestTreeshakingPass();
6630
6665
  }
6631
6666
  getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
6632
6667
  if (this.returnExpression === null) {
@@ -6639,12 +6674,14 @@ class CallExpression extends NodeBase {
6639
6674
 
6640
6675
  class CatchScope extends ParameterScope {
6641
6676
  addDeclaration(identifier, context, init, isHoisted) {
6642
- if (isHoisted) {
6643
- return this.parent.addDeclaration(identifier, context, init, isHoisted);
6644
- }
6645
- else {
6646
- return super.addDeclaration(identifier, context, init, false);
6677
+ const existingParameter = this.variables.get(identifier.name);
6678
+ if (existingParameter) {
6679
+ existingParameter.addDeclaration(identifier, init);
6680
+ return existingParameter;
6647
6681
  }
6682
+ // as parameters are handled differently, all remaining declarations are
6683
+ // hoisted
6684
+ return this.parent.addDeclaration(identifier, context, init, isHoisted);
6648
6685
  }
6649
6686
  }
6650
6687
 
@@ -6652,17 +6689,19 @@ class CatchClause extends NodeBase {
6652
6689
  createScope(parentScope) {
6653
6690
  this.scope = new CatchScope(parentScope, this.context);
6654
6691
  }
6655
- initialise() {
6656
- if (this.param) {
6692
+ parseNode(esTreeNode) {
6693
+ // Parameters need to be declared first as the logic is that hoisted body
6694
+ // variables are associated with outside vars unless there is a parameter,
6695
+ // in which case they are associated with the parameter
6696
+ const { param } = esTreeNode;
6697
+ if (param) {
6698
+ this.param = new (this.context.nodeConstructors[param.type] ||
6699
+ this.context.nodeConstructors.UnknownNode)(param, this, this.scope);
6657
6700
  this.param.declare('parameter', UNKNOWN_EXPRESSION);
6658
6701
  }
6659
- }
6660
- parseNode(esTreeNode) {
6661
- this.body = new this.context.nodeConstructors.BlockStatement(esTreeNode.body, this, this.scope);
6662
6702
  super.parseNode(esTreeNode);
6663
6703
  }
6664
6704
  }
6665
- CatchClause.prototype.preventChildBlockScope = true;
6666
6705
 
6667
6706
  class ChainExpression extends NodeBase {
6668
6707
  }
@@ -6859,7 +6898,7 @@ class ConditionalExpression extends NodeBase {
6859
6898
  usedBranch.includeCallArguments(context, args);
6860
6899
  }
6861
6900
  }
6862
- render(code, options, { isCalleeOfRenderedParent, renderedParentType, preventASI } = BLANK) {
6901
+ render(code, options, { isCalleeOfRenderedParent, preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
6863
6902
  const usedBranch = this.getUsedBranch();
6864
6903
  if (!this.test.included) {
6865
6904
  const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end);
@@ -6875,16 +6914,16 @@ class ConditionalExpression extends NodeBase {
6875
6914
  }
6876
6915
  removeAnnotations(this, code);
6877
6916
  usedBranch.render(code, options, {
6878
- isCalleeOfRenderedParent: renderedParentType
6879
- ? isCalleeOfRenderedParent
6880
- : this.parent.callee === this,
6917
+ isCalleeOfRenderedParent,
6881
6918
  preventASI: true,
6882
- renderedParentType: renderedParentType || this.parent.type
6919
+ ...(renderedSurroundingElement
6920
+ ? { renderedSurroundingElement }
6921
+ : { renderedParentType: renderedParentType || this.parent.type })
6883
6922
  });
6884
6923
  }
6885
6924
  else {
6886
6925
  this.test.render(code, options, {
6887
- renderedSurroundingElement: renderedParentType
6926
+ renderedSurroundingElement: renderedParentType || renderedSurroundingElement
6888
6927
  });
6889
6928
  this.consequent.render(code, options);
6890
6929
  this.alternate.render(code, options);
@@ -7032,6 +7071,7 @@ class ForInStatement extends NodeBase {
7032
7071
  applyDeoptimizations() {
7033
7072
  this.deoptimized = true;
7034
7073
  this.left.deoptimizePath(EMPTY_PATH);
7074
+ this.context.requestTreeshakingPass();
7035
7075
  }
7036
7076
  }
7037
7077
 
@@ -7071,6 +7111,7 @@ class ForOfStatement extends NodeBase {
7071
7111
  applyDeoptimizations() {
7072
7112
  this.deoptimized = true;
7073
7113
  this.left.deoptimizePath(EMPTY_PATH);
7114
+ this.context.requestTreeshakingPass();
7074
7115
  }
7075
7116
  }
7076
7117
 
@@ -7712,11 +7753,11 @@ class LogicalExpression extends NodeBase {
7712
7753
  }
7713
7754
  removeAnnotations(this, code);
7714
7755
  this.getUsedBranch().render(code, options, {
7715
- isCalleeOfRenderedParent: renderedParentType
7716
- ? isCalleeOfRenderedParent
7717
- : this.parent.callee === this,
7756
+ isCalleeOfRenderedParent,
7718
7757
  preventASI,
7719
- renderedParentType: renderedParentType || this.parent.type
7758
+ ...(renderedSurroundingElement
7759
+ ? { renderedSurroundingElement }
7760
+ : { renderedParentType: renderedParentType || this.parent.type })
7720
7761
  });
7721
7762
  }
7722
7763
  else {
@@ -8320,6 +8361,7 @@ class NewExpression extends NodeBase {
8320
8361
  // This will make sure all properties of parameters behave as "unknown"
8321
8362
  argument.deoptimizePath(UNKNOWN_PATH);
8322
8363
  }
8364
+ this.context.requestTreeshakingPass();
8323
8365
  }
8324
8366
  }
8325
8367
 
@@ -8365,6 +8407,7 @@ class ObjectExpression extends NodeBase {
8365
8407
  if (this.objectEntity !== null) {
8366
8408
  return this.objectEntity;
8367
8409
  }
8410
+ let prototype = OBJECT_PROTOTYPE;
8368
8411
  const properties = [];
8369
8412
  for (const property of this.properties) {
8370
8413
  if (property instanceof SpreadElement) {
@@ -8388,13 +8431,16 @@ class ObjectExpression extends NodeBase {
8388
8431
  ? property.key.name
8389
8432
  : String(property.key.value);
8390
8433
  if (key === '__proto__' && property.kind === 'init') {
8391
- properties.unshift({ key: UnknownKey, kind: 'init', property: UNKNOWN_EXPRESSION });
8434
+ prototype =
8435
+ property.value instanceof Literal && property.value.value === null
8436
+ ? null
8437
+ : property.value;
8392
8438
  continue;
8393
8439
  }
8394
8440
  }
8395
8441
  properties.push({ key, kind: property.kind, property });
8396
8442
  }
8397
- return (this.objectEntity = new ObjectEntity(properties, OBJECT_PROTOTYPE));
8443
+ return (this.objectEntity = new ObjectEntity(properties, prototype));
8398
8444
  }
8399
8445
  }
8400
8446
 
@@ -8466,6 +8512,7 @@ class Property extends MethodBase {
8466
8512
  this.deoptimized = true;
8467
8513
  if (this.declarationInit !== null) {
8468
8514
  this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
8515
+ this.context.requestTreeshakingPass();
8469
8516
  }
8470
8517
  }
8471
8518
  }
@@ -8534,13 +8581,10 @@ class ReturnStatement extends NodeBase {
8534
8581
 
8535
8582
  class SequenceExpression extends NodeBase {
8536
8583
  deoptimizePath(path) {
8537
- if (path.length > 0)
8538
- this.expressions[this.expressions.length - 1].deoptimizePath(path);
8584
+ this.expressions[this.expressions.length - 1].deoptimizePath(path);
8539
8585
  }
8540
8586
  deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
8541
- if (event === EVENT_CALLED || path.length > 0) {
8542
- this.expressions[this.expressions.length - 1].deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
8543
- }
8587
+ this.expressions[this.expressions.length - 1].deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
8544
8588
  }
8545
8589
  getLiteralValueAtPath(path, recursionTracker, origin) {
8546
8590
  return this.expressions[this.expressions.length - 1].getLiteralValueAtPath(path, recursionTracker, origin);
@@ -8557,8 +8601,7 @@ class SequenceExpression extends NodeBase {
8557
8601
  this.expressions[this.expressions.length - 1].hasEffectsWhenAccessedAtPath(path, context));
8558
8602
  }
8559
8603
  hasEffectsWhenAssignedAtPath(path, context) {
8560
- return (path.length === 0 ||
8561
- this.expressions[this.expressions.length - 1].hasEffectsWhenAssignedAtPath(path, context));
8604
+ return this.expressions[this.expressions.length - 1].hasEffectsWhenAssignedAtPath(path, context);
8562
8605
  }
8563
8606
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
8564
8607
  return this.expressions[this.expressions.length - 1].hasEffectsWhenCalledAtPath(path, callOptions, context);
@@ -8587,13 +8630,18 @@ class SequenceExpression extends NodeBase {
8587
8630
  if (includedNodes === 1 && preventASI) {
8588
8631
  removeLineBreaks(code, start, node.start);
8589
8632
  }
8590
- if (node === lastNode && includedNodes === 1) {
8591
- node.render(code, options, {
8592
- isCalleeOfRenderedParent: renderedParentType
8593
- ? isCalleeOfRenderedParent
8594
- : this.parent.callee === this,
8595
- renderedParentType: renderedParentType || this.parent.type
8596
- });
8633
+ if (includedNodes === 1) {
8634
+ if (node === lastNode) {
8635
+ node.render(code, options, {
8636
+ isCalleeOfRenderedParent,
8637
+ renderedParentType: renderedParentType || this.parent.type
8638
+ });
8639
+ }
8640
+ else {
8641
+ node.render(code, options, {
8642
+ renderedSurroundingElement: renderedParentType || this.parent.type
8643
+ });
8644
+ }
8597
8645
  }
8598
8646
  else {
8599
8647
  node.render(code, options);
@@ -8740,13 +8788,6 @@ class TaggedTemplateExpression extends NodeBase {
8740
8788
  message: `Cannot call a namespace ('${name}')`
8741
8789
  }, this.start);
8742
8790
  }
8743
- if (name === 'eval') {
8744
- this.context.warn({
8745
- code: 'EVAL',
8746
- message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
8747
- url: 'https://rollupjs.org/guide/en/#avoiding-eval'
8748
- }, this.start);
8749
- }
8750
8791
  }
8751
8792
  }
8752
8793
  hasEffects(context) {
@@ -8760,6 +8801,10 @@ class TaggedTemplateExpression extends NodeBase {
8760
8801
  withNew: false
8761
8802
  };
8762
8803
  }
8804
+ render(code, options) {
8805
+ this.tag.render(code, options, { isCalleeOfRenderedParent: true });
8806
+ this.quasi.render(code, options);
8807
+ }
8763
8808
  }
8764
8809
 
8765
8810
  class TemplateElement extends NodeBase {
@@ -9031,6 +9076,7 @@ class UnaryExpression extends NodeBase {
9031
9076
  this.deoptimized = true;
9032
9077
  if (this.operator === 'delete') {
9033
9078
  this.argument.deoptimizePath(EMPTY_PATH);
9079
+ this.context.requestTreeshakingPass();
9034
9080
  }
9035
9081
  }
9036
9082
  }
@@ -9099,6 +9145,7 @@ class UpdateExpression extends NodeBase {
9099
9145
  const variable = this.scope.findVariable(this.argument.name);
9100
9146
  variable.isReassigned = true;
9101
9147
  }
9148
+ this.context.requestTreeshakingPass();
9102
9149
  }
9103
9150
  }
9104
9151
 
@@ -9184,9 +9231,12 @@ class YieldExpression extends NodeBase {
9184
9231
  }
9185
9232
  }
9186
9233
  applyDeoptimizations() {
9187
- var _a;
9188
9234
  this.deoptimized = true;
9189
- (_a = this.argument) === null || _a === void 0 ? void 0 : _a.deoptimizePath(UNKNOWN_PATH);
9235
+ const { argument } = this;
9236
+ if (argument) {
9237
+ argument.deoptimizePath(UNKNOWN_PATH);
9238
+ this.context.requestTreeshakingPass();
9239
+ }
9190
9240
  }
9191
9241
  }
9192
9242
 
@@ -9775,14 +9825,14 @@ class Module {
9775
9825
  }
9776
9826
  necessaryDependencies.add(variable.module);
9777
9827
  }
9778
- if (this.options.treeshake && this.info.hasModuleSideEffects !== 'no-treeshake') {
9779
- this.addRelevantSideEffectDependencies(relevantDependencies, necessaryDependencies, alwaysCheckedDependencies);
9780
- }
9781
- else {
9828
+ if (!this.options.treeshake || this.info.hasModuleSideEffects === 'no-treeshake') {
9782
9829
  for (const dependency of this.dependencies) {
9783
- relevantDependencies.add(dependency);
9830
+ if (dependency instanceof ExternalModule || dependency.isIncluded()) {
9831
+ relevantDependencies.add(dependency);
9832
+ }
9784
9833
  }
9785
9834
  }
9835
+ this.addRelevantSideEffectDependencies(relevantDependencies, necessaryDependencies, alwaysCheckedDependencies);
9786
9836
  for (const dependency of necessaryDependencies) {
9787
9837
  relevantDependencies.add(dependency);
9788
9838
  }
@@ -10052,6 +10102,7 @@ class Module {
10052
10102
  moduleContext: this.context,
10053
10103
  nodeConstructors,
10054
10104
  options: this.options,
10105
+ requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
10055
10106
  traceExport: this.getVariableForExportName.bind(this),
10056
10107
  traceVariable: this.traceVariable.bind(this),
10057
10108
  usesTopLevelAwait: false,
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.1
4
- Wed, 26 May 2021 07:27:41 GMT - commit 9a50fbb35a0c5be4fc0a6ec37a06827bab99923b
3
+ Rollup.js v2.50.5
4
+ Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.1
4
- Wed, 26 May 2021 07:27:41 GMT - commit 9a50fbb35a0c5be4fc0a6ec37a06827bab99923b
3
+ Rollup.js v2.50.5
4
+ Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup