rollup 2.74.0 → 2.75.1

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.0
4
- Thu, 19 May 2022 05:01:43 GMT - commit fc99e96e09d26798f1c0aabdd7429307cc908c8e
3
+ Rollup.js v2.75.1
4
+ Sat, 28 May 2022 13:06:58 GMT - commit 03088cc0ee948dcc51f26edde067cc2b2736a679
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -27,7 +27,7 @@ function _interopNamespaceDefault(e) {
27
27
  return n;
28
28
  }
29
29
 
30
- var version$1 = "2.74.0";
30
+ var version$1 = "2.75.1";
31
31
 
32
32
  function ensureArray$1(items) {
33
33
  if (Array.isArray(items)) {
@@ -1865,7 +1865,7 @@ class MagicString {
1865
1865
  const hasOwnProp = Object.prototype.hasOwnProperty;
1866
1866
 
1867
1867
  class Bundle$1 {
1868
- constructor(options) {
1868
+ constructor(options = {}) {
1869
1869
  this.intro = options.intro || '';
1870
1870
  this.separator = options.separator !== undefined ? options.separator : '\n';
1871
1871
  this.sources = [];
@@ -2254,7 +2254,7 @@ class ExpressionEntity {
2254
2254
  include(_context, _includeChildrenRecursively, _options) {
2255
2255
  this.included = true;
2256
2256
  }
2257
- includeArgumentsWhenCalledAtPath(_path, context, args) {
2257
+ includeCallArguments(context, args) {
2258
2258
  for (const arg of args) {
2259
2259
  arg.include(context, false);
2260
2260
  }
@@ -5567,11 +5567,6 @@ class Method extends ExpressionEntity {
5567
5567
  }
5568
5568
  return false;
5569
5569
  }
5570
- includeArgumentsWhenCalledAtPath(_path, context, args) {
5571
- for (const arg of args) {
5572
- arg.include(context, false);
5573
- }
5574
- }
5575
5570
  }
5576
5571
  const METHOD_RETURNS_BOOLEAN = [
5577
5572
  new Method({
@@ -5907,16 +5902,6 @@ class ObjectEntity extends ExpressionEntity {
5907
5902
  }
5908
5903
  return true;
5909
5904
  }
5910
- includeArgumentsWhenCalledAtPath(path, context, args) {
5911
- const key = path[0];
5912
- const expressionAtPath = this.getMemberExpression(key);
5913
- if (expressionAtPath) {
5914
- return expressionAtPath.includeArgumentsWhenCalledAtPath(path.slice(1), context, args);
5915
- }
5916
- if (this.prototypeExpression) {
5917
- return this.prototypeExpression.includeArgumentsWhenCalledAtPath(path, context, args);
5918
- }
5919
- }
5920
5905
  buildPropertyMaps(properties) {
5921
5906
  const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
5922
5907
  const unmatchablePropertiesAndSetters = [];
@@ -6210,9 +6195,6 @@ class ArrayExpression extends NodeBase {
6210
6195
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
6211
6196
  return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
6212
6197
  }
6213
- includeArgumentsWhenCalledAtPath(path, context, args) {
6214
- this.getObjectEntity().includeArgumentsWhenCalledAtPath(path, context, args);
6215
- }
6216
6198
  applyDeoptimizations() {
6217
6199
  this.deoptimized = true;
6218
6200
  let hasSpread = false;
@@ -6405,7 +6387,7 @@ class LocalVariable extends Variable {
6405
6387
  }
6406
6388
  }
6407
6389
  }
6408
- includeArgumentsWhenCalledAtPath(path, context, args) {
6390
+ includeCallArguments(context, args) {
6409
6391
  if (this.isReassigned || (this.init && context.includedCallArguments.has(this.init))) {
6410
6392
  for (const arg of args) {
6411
6393
  arg.include(context, false);
@@ -6413,7 +6395,7 @@ class LocalVariable extends Variable {
6413
6395
  }
6414
6396
  else if (this.init) {
6415
6397
  context.includedCallArguments.add(this.init);
6416
- this.init.includeArgumentsWhenCalledAtPath(path, context, args);
6398
+ this.init.includeCallArguments(context, args);
6417
6399
  context.includedCallArguments.delete(this.init);
6418
6400
  }
6419
6401
  }
@@ -6678,6 +6660,9 @@ class AssignmentPattern extends NodeBase {
6678
6660
  hasEffectsWhenAssignedAtPath(path, context) {
6679
6661
  return path.length > 0 || this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
6680
6662
  }
6663
+ // Note that FunctionBase may directly include .left and .right without
6664
+ // including the pattern itself. This is how default parameter tree-shaking
6665
+ // works at the moment.
6681
6666
  include(context, includeChildrenRecursively) {
6682
6667
  this.included = true;
6683
6668
  this.left.include(context, includeChildrenRecursively);
@@ -6989,20 +6974,19 @@ class RestElement extends NodeBase {
6989
6974
  class FunctionBase extends NodeBase {
6990
6975
  constructor() {
6991
6976
  super(...arguments);
6992
- // By default, parameters are included via includeArgumentsWhenCalledAtPath
6993
- this.alwaysIncludeParameters = false;
6994
6977
  this.objectEntity = null;
6995
6978
  this.deoptimizedReturn = false;
6979
+ this.forceIncludeParameters = false;
6996
6980
  }
6997
6981
  deoptimizeCache() {
6998
- this.alwaysIncludeParameters = true;
6982
+ this.forceIncludeParameters = true;
6999
6983
  }
7000
6984
  deoptimizePath(path) {
7001
6985
  this.getObjectEntity().deoptimizePath(path);
7002
6986
  if (path.length === 1 && path[0] === UnknownKey) {
7003
6987
  // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
7004
6988
  // which means the return expression needs to be reassigned
7005
- this.alwaysIncludeParameters = true;
6989
+ this.forceIncludeParameters = true;
7006
6990
  this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
7007
6991
  }
7008
6992
  }
@@ -7035,6 +7019,7 @@ class FunctionBase extends NodeBase {
7035
7019
  return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
7036
7020
  }
7037
7021
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
7022
+ var _a;
7038
7023
  if (path.length > 0) {
7039
7024
  return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
7040
7025
  }
@@ -7049,51 +7034,60 @@ class FunctionBase extends NodeBase {
7049
7034
  return true;
7050
7035
  }
7051
7036
  }
7052
- for (const param of this.params) {
7053
- if (param.hasEffects(context))
7037
+ for (let position = 0; position < this.params.length; position++) {
7038
+ const parameter = this.params[position];
7039
+ if (parameter instanceof AssignmentPattern) {
7040
+ if (parameter.left.hasEffects(context)) {
7041
+ return true;
7042
+ }
7043
+ const argumentValue = (_a = callOptions.args[position]) === null || _a === void 0 ? void 0 : _a.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
7044
+ if ((argumentValue === undefined || argumentValue === UnknownValue) &&
7045
+ parameter.right.hasEffects(context)) {
7046
+ return true;
7047
+ }
7048
+ }
7049
+ else if (parameter.hasEffects(context)) {
7054
7050
  return true;
7051
+ }
7055
7052
  }
7056
7053
  return false;
7057
7054
  }
7058
- include(context, includeChildrenRecursively) {
7055
+ include(context, includeChildrenRecursively, { includeWithoutParameterDefaults } = BLANK) {
7059
7056
  this.included = true;
7060
7057
  const { brokenFlow } = context;
7061
7058
  context.brokenFlow = BROKEN_FLOW_NONE;
7062
7059
  this.body.include(context, includeChildrenRecursively);
7063
7060
  context.brokenFlow = brokenFlow;
7064
- if (includeChildrenRecursively || this.alwaysIncludeParameters) {
7061
+ if (!includeWithoutParameterDefaults ||
7062
+ includeChildrenRecursively ||
7063
+ this.forceIncludeParameters) {
7065
7064
  for (const param of this.params) {
7066
7065
  param.include(context, includeChildrenRecursively);
7067
7066
  }
7068
7067
  }
7069
7068
  }
7070
- includeArgumentsWhenCalledAtPath(path, context, args) {
7069
+ includeCallArguments(context, args) {
7071
7070
  var _a;
7072
- if (path.length === 0) {
7073
- for (let position = 0; position < this.params.length; position++) {
7074
- const parameter = this.params[position];
7075
- if (parameter instanceof AssignmentPattern) {
7076
- if (parameter.left.shouldBeIncluded(context)) {
7077
- parameter.left.include(context, false);
7078
- }
7079
- const argumentValue = (_a = args[position]) === null || _a === void 0 ? void 0 : _a.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
7080
- // If argumentValue === UnknownTruthyValue, then we do not need to
7081
- // include the default
7082
- if ((argumentValue === undefined || argumentValue === UnknownValue) &&
7083
- (this.parameterVariables[position].some(variable => variable.included) ||
7084
- parameter.right.shouldBeIncluded(context))) {
7085
- parameter.right.include(context, false);
7086
- }
7071
+ for (let position = 0; position < this.params.length; position++) {
7072
+ const parameter = this.params[position];
7073
+ if (parameter instanceof AssignmentPattern) {
7074
+ if (parameter.left.shouldBeIncluded(context)) {
7075
+ parameter.left.include(context, false);
7087
7076
  }
7088
- else if (parameter.shouldBeIncluded(context)) {
7089
- parameter.include(context, false);
7077
+ const argumentValue = (_a = args[position]) === null || _a === void 0 ? void 0 : _a.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
7078
+ // If argumentValue === UnknownTruthyValue, then we do not need to
7079
+ // include the default
7080
+ if ((argumentValue === undefined || argumentValue === UnknownValue) &&
7081
+ (this.parameterVariables[position].some(variable => variable.included) ||
7082
+ parameter.right.shouldBeIncluded(context))) {
7083
+ parameter.right.include(context, false);
7090
7084
  }
7091
7085
  }
7092
- this.scope.includeCallArguments(context, args);
7093
- }
7094
- else {
7095
- this.getObjectEntity().includeArgumentsWhenCalledAtPath(path, context, args);
7086
+ else if (parameter.shouldBeIncluded(context)) {
7087
+ parameter.include(context, false);
7088
+ }
7096
7089
  }
7090
+ this.scope.includeCallArguments(context, args);
7097
7091
  }
7098
7092
  initialise() {
7099
7093
  this.parameterVariables = this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION));
@@ -8207,8 +8201,8 @@ class Identifier extends NodeBase {
8207
8201
  this.variable.hasEffectsWhenAccessedAtPath(EMPTY_PATH));
8208
8202
  }
8209
8203
  hasEffectsWhenAccessedAtPath(path, context) {
8210
- var _a;
8211
- return (_a = this.getVariableRespectingTDZ()) === null || _a === void 0 ? void 0 : _a.hasEffectsWhenAccessedAtPath(path, context);
8204
+ return (this.variable !== null &&
8205
+ this.getVariableRespectingTDZ().hasEffectsWhenAccessedAtPath(path, context));
8212
8206
  }
8213
8207
  hasEffectsWhenAssignedAtPath(path, context) {
8214
8208
  return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsWhenAssignedAtPath(path, context);
@@ -8226,8 +8220,8 @@ class Identifier extends NodeBase {
8226
8220
  }
8227
8221
  }
8228
8222
  }
8229
- includeArgumentsWhenCalledAtPath(path, context, args) {
8230
- this.variable.includeArgumentsWhenCalledAtPath(path, context, args);
8223
+ includeCallArguments(context, args) {
8224
+ this.variable.includeCallArguments(context, args);
8231
8225
  }
8232
8226
  isPossibleTDZ() {
8233
8227
  // return cached value to avoid issues with the next tree-shaking pass
@@ -8540,7 +8534,7 @@ class FunctionNode extends FunctionBase {
8540
8534
  }
8541
8535
  hasEffects() {
8542
8536
  var _a;
8543
- return (_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects();
8537
+ return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects());
8544
8538
  }
8545
8539
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
8546
8540
  if (super.hasEffectsWhenCalledAtPath(path, callOptions, context))
@@ -8568,14 +8562,12 @@ class FunctionNode extends FunctionBase {
8568
8562
  context.ignore = ignore;
8569
8563
  return false;
8570
8564
  }
8571
- include(context, includeChildrenRecursively) {
8565
+ include(context, includeChildrenRecursively, { includeWithoutParameterDefaults } = BLANK) {
8572
8566
  var _a;
8573
- // This ensures that super.include will also include all parameters
8574
- if (this.scope.argumentsVariable.included) {
8575
- this.alwaysIncludeParameters = true;
8576
- }
8577
8567
  (_a = this.id) === null || _a === void 0 ? void 0 : _a.include();
8578
- super.include(context, includeChildrenRecursively);
8568
+ super.include(context, includeChildrenRecursively, {
8569
+ includeWithoutParameterDefaults: includeWithoutParameterDefaults && !this.scope.argumentsVariable.included
8570
+ });
8579
8571
  }
8580
8572
  initialise() {
8581
8573
  var _a;
@@ -8645,9 +8637,10 @@ const binaryOperators = {
8645
8637
  '>>': (left, right) => left >> right,
8646
8638
  '>>>': (left, right) => left >>> right,
8647
8639
  '^': (left, right) => left ^ right,
8648
- in: () => UnknownValue,
8649
- instanceof: () => UnknownValue,
8650
8640
  '|': (left, right) => left | right
8641
+ // We use the fallback for cases where we return something unknown
8642
+ // in: () => UnknownValue,
8643
+ // instanceof: () => UnknownValue,
8651
8644
  };
8652
8645
  class BinaryExpression extends NodeBase {
8653
8646
  deoptimizeCache() { }
@@ -8731,9 +8724,6 @@ class Literal extends NodeBase {
8731
8724
  }
8732
8725
  return path.length > 1;
8733
8726
  }
8734
- hasEffectsWhenAssignedAtPath(path) {
8735
- return path.length > 0;
8736
- }
8737
8727
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
8738
8728
  if (path.length === 1) {
8739
8729
  return hasMemberEffectWhenCalled(this.members, path[0], callOptions, context);
@@ -8949,15 +8939,12 @@ class MemberExpression extends NodeBase {
8949
8939
  this.object.include(context, includeChildrenRecursively);
8950
8940
  this.property.include(context, includeChildrenRecursively);
8951
8941
  }
8952
- includeArgumentsWhenCalledAtPath(path, context, args) {
8942
+ includeCallArguments(context, args) {
8953
8943
  if (this.variable) {
8954
- this.variable.includeArgumentsWhenCalledAtPath(path, context, args);
8955
- }
8956
- else if (this.replacement) {
8957
- super.includeArgumentsWhenCalledAtPath(path, context, args);
8944
+ this.variable.includeCallArguments(context, args);
8958
8945
  }
8959
- else if (path.length < MAX_PATH_DEPTH) {
8960
- this.object.includeArgumentsWhenCalledAtPath([this.getPropertyKey(), ...path], context, args);
8946
+ else {
8947
+ super.includeCallArguments(context, args);
8961
8948
  }
8962
8949
  }
8963
8950
  initialise() {
@@ -9178,9 +9165,9 @@ class CallExpression extends CallExpressionBase {
9178
9165
  }
9179
9166
  else {
9180
9167
  this.included = true;
9181
- this.callee.include(context, false);
9168
+ this.callee.include(context, false, { includeWithoutParameterDefaults: true });
9182
9169
  }
9183
- this.callee.includeArgumentsWhenCalledAtPath(EMPTY_PATH, context, this.arguments);
9170
+ this.callee.includeCallArguments(context, this.arguments);
9184
9171
  const returnExpression = this.getReturnExpression();
9185
9172
  if (!returnExpression.included) {
9186
9173
  returnExpression.include(context, false);
@@ -9351,9 +9338,6 @@ class MethodBase extends NodeBase {
9351
9338
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
9352
9339
  return this.getAccessedValue().hasEffectsWhenCalledAtPath(path, callOptions, context);
9353
9340
  }
9354
- includeArgumentsWhenCalledAtPath(path, context, args) {
9355
- this.getAccessedValue().includeArgumentsWhenCalledAtPath(path, context, args);
9356
- }
9357
9341
  getAccessedValue() {
9358
9342
  if (this.accessedValue === null) {
9359
9343
  if (this.kind === 'get') {
@@ -9470,20 +9454,6 @@ class ClassNode extends NodeBase {
9470
9454
  this.id.include();
9471
9455
  }
9472
9456
  }
9473
- includeArgumentsWhenCalledAtPath(path, context, args) {
9474
- var _a;
9475
- if (path.length === 0) {
9476
- if (this.classConstructor) {
9477
- this.classConstructor.includeArgumentsWhenCalledAtPath(path, context, args);
9478
- }
9479
- else {
9480
- (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.includeArgumentsWhenCalledAtPath(path, context, args);
9481
- }
9482
- }
9483
- else {
9484
- this.getObjectEntity().includeArgumentsWhenCalledAtPath(path, context, args);
9485
- }
9486
- }
9487
9457
  initialise() {
9488
9458
  var _a;
9489
9459
  (_a = this.id) === null || _a === void 0 ? void 0 : _a.declare('class', this);
@@ -9500,8 +9470,7 @@ class ClassNode extends NodeBase {
9500
9470
  for (const definition of this.body.body) {
9501
9471
  if (!(definition.static ||
9502
9472
  (definition instanceof MethodDefinition && definition.kind === 'constructor'))) {
9503
- // Calls to methods are not tracked, ensure that parameter defaults are
9504
- // included and the return value is deoptimized
9473
+ // Calls to methods are not tracked, ensure that the return value is deoptimized
9505
9474
  definition.deoptimizePath(UNKNOWN_PATH);
9506
9475
  }
9507
9476
  }
@@ -9645,7 +9614,7 @@ class ConditionalExpression extends NodeBase {
9645
9614
  }
9646
9615
  deoptimizePath(path) {
9647
9616
  const usedBranch = this.getUsedBranch();
9648
- if (usedBranch === null) {
9617
+ if (!usedBranch) {
9649
9618
  this.consequent.deoptimizePath(path);
9650
9619
  this.alternate.deoptimizePath(path);
9651
9620
  }
@@ -9659,14 +9628,14 @@ class ConditionalExpression extends NodeBase {
9659
9628
  }
9660
9629
  getLiteralValueAtPath(path, recursionTracker, origin) {
9661
9630
  const usedBranch = this.getUsedBranch();
9662
- if (usedBranch === null)
9631
+ if (!usedBranch)
9663
9632
  return UnknownValue;
9664
9633
  this.expressionsToBeDeoptimized.push(origin);
9665
9634
  return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
9666
9635
  }
9667
9636
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
9668
9637
  const usedBranch = this.getUsedBranch();
9669
- if (usedBranch === null)
9638
+ if (!usedBranch)
9670
9639
  return new MultiExpression([
9671
9640
  this.consequent.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin),
9672
9641
  this.alternate.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin)
@@ -9678,14 +9647,14 @@ class ConditionalExpression extends NodeBase {
9678
9647
  if (this.test.hasEffects(context))
9679
9648
  return true;
9680
9649
  const usedBranch = this.getUsedBranch();
9681
- if (usedBranch === null) {
9650
+ if (!usedBranch) {
9682
9651
  return this.consequent.hasEffects(context) || this.alternate.hasEffects(context);
9683
9652
  }
9684
9653
  return usedBranch.hasEffects(context);
9685
9654
  }
9686
9655
  hasEffectsWhenAccessedAtPath(path, context) {
9687
9656
  const usedBranch = this.getUsedBranch();
9688
- if (usedBranch === null) {
9657
+ if (!usedBranch) {
9689
9658
  return (this.consequent.hasEffectsWhenAccessedAtPath(path, context) ||
9690
9659
  this.alternate.hasEffectsWhenAccessedAtPath(path, context));
9691
9660
  }
@@ -9693,7 +9662,7 @@ class ConditionalExpression extends NodeBase {
9693
9662
  }
9694
9663
  hasEffectsWhenAssignedAtPath(path, context) {
9695
9664
  const usedBranch = this.getUsedBranch();
9696
- if (usedBranch === null) {
9665
+ if (!usedBranch) {
9697
9666
  return (this.consequent.hasEffectsWhenAssignedAtPath(path, context) ||
9698
9667
  this.alternate.hasEffectsWhenAssignedAtPath(path, context));
9699
9668
  }
@@ -9701,7 +9670,7 @@ class ConditionalExpression extends NodeBase {
9701
9670
  }
9702
9671
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
9703
9672
  const usedBranch = this.getUsedBranch();
9704
- if (usedBranch === null) {
9673
+ if (!usedBranch) {
9705
9674
  return (this.consequent.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
9706
9675
  this.alternate.hasEffectsWhenCalledAtPath(path, callOptions, context));
9707
9676
  }
@@ -9719,14 +9688,14 @@ class ConditionalExpression extends NodeBase {
9719
9688
  usedBranch.include(context, includeChildrenRecursively);
9720
9689
  }
9721
9690
  }
9722
- includeArgumentsWhenCalledAtPath(path, context, args) {
9691
+ includeCallArguments(context, args) {
9723
9692
  const usedBranch = this.getUsedBranch();
9724
- if (usedBranch === null) {
9725
- this.consequent.includeArgumentsWhenCalledAtPath(path, context, args);
9726
- this.alternate.includeArgumentsWhenCalledAtPath(path, context, args);
9693
+ if (!usedBranch) {
9694
+ this.consequent.includeCallArguments(context, args);
9695
+ this.alternate.includeCallArguments(context, args);
9727
9696
  }
9728
9697
  else {
9729
- usedBranch.includeArgumentsWhenCalledAtPath(path, context, args);
9698
+ usedBranch.includeCallArguments(context, args);
9730
9699
  }
9731
9700
  }
9732
9701
  render(code, options, { isCalleeOfRenderedParent, preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
@@ -9837,6 +9806,9 @@ class ExportAllDeclaration extends NodeBase {
9837
9806
  ExportAllDeclaration.prototype.needsBoundaries = true;
9838
9807
 
9839
9808
  class FunctionDeclaration extends FunctionNode {
9809
+ include(context, includeChildrenRecursively) {
9810
+ super.include(context, includeChildrenRecursively, { includeWithoutParameterDefaults: true });
9811
+ }
9840
9812
  initialise() {
9841
9813
  super.initialise();
9842
9814
  if (this.id !== null) {
@@ -9946,7 +9918,7 @@ class ExportNamedDeclaration extends NodeBase {
9946
9918
  }
9947
9919
  hasEffects(context) {
9948
9920
  var _a;
9949
- return (_a = this.declaration) === null || _a === void 0 ? void 0 : _a.hasEffects(context);
9921
+ return !!((_a = this.declaration) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
9950
9922
  }
9951
9923
  initialise() {
9952
9924
  this.context.addExport(this);
@@ -10148,7 +10120,7 @@ class IfStatement extends NodeBase {
10148
10120
  context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
10149
10121
  return false;
10150
10122
  }
10151
- return testValue ? this.consequent.hasEffects(context) : (_a = this.alternate) === null || _a === void 0 ? void 0 : _a.hasEffects(context);
10123
+ return testValue ? this.consequent.hasEffects(context) : !!((_a = this.alternate) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
10152
10124
  }
10153
10125
  include(context, includeChildrenRecursively) {
10154
10126
  this.included = true;
@@ -10732,7 +10704,7 @@ class LogicalExpression extends NodeBase {
10732
10704
  }
10733
10705
  deoptimizePath(path) {
10734
10706
  const usedBranch = this.getUsedBranch();
10735
- if (usedBranch === null) {
10707
+ if (!usedBranch) {
10736
10708
  this.left.deoptimizePath(path);
10737
10709
  this.right.deoptimizePath(path);
10738
10710
  }
@@ -10746,14 +10718,14 @@ class LogicalExpression extends NodeBase {
10746
10718
  }
10747
10719
  getLiteralValueAtPath(path, recursionTracker, origin) {
10748
10720
  const usedBranch = this.getUsedBranch();
10749
- if (usedBranch === null)
10721
+ if (!usedBranch)
10750
10722
  return UnknownValue;
10751
10723
  this.expressionsToBeDeoptimized.push(origin);
10752
10724
  return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
10753
10725
  }
10754
10726
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
10755
10727
  const usedBranch = this.getUsedBranch();
10756
- if (usedBranch === null)
10728
+ if (!usedBranch)
10757
10729
  return new MultiExpression([
10758
10730
  this.left.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin),
10759
10731
  this.right.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin)
@@ -10772,7 +10744,7 @@ class LogicalExpression extends NodeBase {
10772
10744
  }
10773
10745
  hasEffectsWhenAccessedAtPath(path, context) {
10774
10746
  const usedBranch = this.getUsedBranch();
10775
- if (usedBranch === null) {
10747
+ if (!usedBranch) {
10776
10748
  return (this.left.hasEffectsWhenAccessedAtPath(path, context) ||
10777
10749
  this.right.hasEffectsWhenAccessedAtPath(path, context));
10778
10750
  }
@@ -10780,7 +10752,7 @@ class LogicalExpression extends NodeBase {
10780
10752
  }
10781
10753
  hasEffectsWhenAssignedAtPath(path, context) {
10782
10754
  const usedBranch = this.getUsedBranch();
10783
- if (usedBranch === null) {
10755
+ if (!usedBranch) {
10784
10756
  return (this.left.hasEffectsWhenAssignedAtPath(path, context) ||
10785
10757
  this.right.hasEffectsWhenAssignedAtPath(path, context));
10786
10758
  }
@@ -10788,7 +10760,7 @@ class LogicalExpression extends NodeBase {
10788
10760
  }
10789
10761
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
10790
10762
  const usedBranch = this.getUsedBranch();
10791
- if (usedBranch === null) {
10763
+ if (!usedBranch) {
10792
10764
  return (this.left.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
10793
10765
  this.right.hasEffectsWhenCalledAtPath(path, callOptions, context));
10794
10766
  }
@@ -10799,7 +10771,7 @@ class LogicalExpression extends NodeBase {
10799
10771
  const usedBranch = this.getUsedBranch();
10800
10772
  if (includeChildrenRecursively ||
10801
10773
  (usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
10802
- usedBranch === null) {
10774
+ !usedBranch) {
10803
10775
  this.left.include(context, includeChildrenRecursively);
10804
10776
  this.right.include(context, includeChildrenRecursively);
10805
10777
  }
@@ -11048,9 +11020,14 @@ class NewExpression extends NodeBase {
11048
11020
  include(context, includeChildrenRecursively) {
11049
11021
  if (!this.deoptimized)
11050
11022
  this.applyDeoptimizations();
11051
- this.included = true;
11052
- this.callee.include(context, includeChildrenRecursively);
11053
- this.callee.includeArgumentsWhenCalledAtPath(EMPTY_PATH, context, this.arguments);
11023
+ if (includeChildrenRecursively) {
11024
+ super.include(context, includeChildrenRecursively);
11025
+ }
11026
+ else {
11027
+ this.included = true;
11028
+ this.callee.include(context, false);
11029
+ }
11030
+ this.callee.includeCallArguments(context, this.arguments);
11054
11031
  }
11055
11032
  initialise() {
11056
11033
  this.callOptions = {
@@ -11098,9 +11075,6 @@ class ObjectExpression extends NodeBase {
11098
11075
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
11099
11076
  return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
11100
11077
  }
11101
- includeArgumentsWhenCalledAtPath(path, context, args) {
11102
- this.getObjectEntity().includeArgumentsWhenCalledAtPath(path, context, args);
11103
- }
11104
11078
  render(code, options, { renderedSurroundingElement } = BLANK) {
11105
11079
  super.render(code, options);
11106
11080
  if (renderedSurroundingElement === ExpressionStatement$1 ||
@@ -11245,7 +11219,7 @@ class PropertyDefinition extends NodeBase {
11245
11219
  }
11246
11220
  hasEffects(context) {
11247
11221
  var _a;
11248
- return this.key.hasEffects(context) || (this.static && ((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
11222
+ return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
11249
11223
  }
11250
11224
  hasEffectsWhenAccessedAtPath(path, context) {
11251
11225
  return !this.value || this.value.hasEffectsWhenAccessedAtPath(path, context);
@@ -11256,10 +11230,6 @@ class PropertyDefinition extends NodeBase {
11256
11230
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
11257
11231
  return !this.value || this.value.hasEffectsWhenCalledAtPath(path, callOptions, context);
11258
11232
  }
11259
- includeArgumentsWhenCalledAtPath(path, context, args) {
11260
- var _a;
11261
- (_a = this.value) === null || _a === void 0 ? void 0 : _a.includeArgumentsWhenCalledAtPath(path, context, args);
11262
- }
11263
11233
  }
11264
11234
 
11265
11235
  class ReturnStatement extends NodeBase {
@@ -11544,10 +11514,15 @@ class TaggedTemplateExpression extends CallExpressionBase {
11544
11514
  include(context, includeChildrenRecursively) {
11545
11515
  if (!this.deoptimized)
11546
11516
  this.applyDeoptimizations();
11547
- this.included = true;
11548
- this.tag.include(context, includeChildrenRecursively);
11549
- this.quasi.include(context, includeChildrenRecursively);
11550
- this.tag.includeArgumentsWhenCalledAtPath(EMPTY_PATH, context, this.callOptions.args);
11517
+ if (includeChildrenRecursively) {
11518
+ super.include(context, includeChildrenRecursively);
11519
+ }
11520
+ else {
11521
+ this.included = true;
11522
+ this.tag.include(context, includeChildrenRecursively);
11523
+ this.quasi.include(context, includeChildrenRecursively);
11524
+ }
11525
+ this.tag.includeCallArguments(context, this.callOptions.args);
11551
11526
  const returnExpression = this.getReturnExpression();
11552
11527
  if (!returnExpression.included) {
11553
11528
  returnExpression.include(context, false);
@@ -11602,12 +11577,28 @@ class TemplateElement extends NodeBase {
11602
11577
  }
11603
11578
 
11604
11579
  class TemplateLiteral extends NodeBase {
11580
+ deoptimizeThisOnEventAtPath() { }
11605
11581
  getLiteralValueAtPath(path) {
11606
11582
  if (path.length > 0 || this.quasis.length !== 1) {
11607
11583
  return UnknownValue;
11608
11584
  }
11609
11585
  return this.quasis[0].value.cooked;
11610
11586
  }
11587
+ getReturnExpressionWhenCalledAtPath(path) {
11588
+ if (path.length !== 1) {
11589
+ return UNKNOWN_EXPRESSION;
11590
+ }
11591
+ return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
11592
+ }
11593
+ hasEffectsWhenAccessedAtPath(path) {
11594
+ return path.length > 1;
11595
+ }
11596
+ hasEffectsWhenCalledAtPath(path, callOptions, context) {
11597
+ if (path.length === 1) {
11598
+ return hasMemberEffectWhenCalled(literalStringMembers, path[0], callOptions, context);
11599
+ }
11600
+ return true;
11601
+ }
11611
11602
  render(code, options) {
11612
11603
  code.indentExclusionRanges.push([this.start, this.end]);
11613
11604
  super.render(code, options);
@@ -11797,9 +11788,7 @@ class TryStatement extends NodeBase {
11797
11788
  var _a;
11798
11789
  return ((this.context.options.treeshake.tryCatchDeoptimization
11799
11790
  ? this.block.body.length > 0
11800
- : this.block.hasEffects(context)) ||
11801
- ((_a = this.finalizer) === null || _a === void 0 ? void 0 : _a.hasEffects(context)) ||
11802
- false);
11791
+ : this.block.hasEffects(context)) || !!((_a = this.finalizer) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
11803
11792
  }
11804
11793
  include(context, includeChildrenRecursively) {
11805
11794
  var _a, _b;
@@ -11985,16 +11974,14 @@ class VariableDeclaration extends NodeBase {
11985
11974
  }
11986
11975
  }
11987
11976
  else {
11988
- this.renderReplacedDeclarations(code, options, nodeRenderOptions);
11977
+ this.renderReplacedDeclarations(code, options);
11989
11978
  }
11990
11979
  }
11991
- renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options, isNoStatement) {
11980
+ renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
11992
11981
  if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
11993
11982
  code.remove(this.end - 1, this.end);
11994
11983
  }
11995
- if (!isNoStatement) {
11996
- separatorString += ';';
11997
- }
11984
+ separatorString += ';';
11998
11985
  if (lastSeparatorPos !== null) {
11999
11986
  if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
12000
11987
  (code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
@@ -12019,7 +12006,7 @@ class VariableDeclaration extends NodeBase {
12019
12006
  code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
12020
12007
  }
12021
12008
  }
12022
- renderReplacedDeclarations(code, options, { isNoStatement }) {
12009
+ renderReplacedDeclarations(code, options) {
12023
12010
  const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
12024
12011
  let actualContentEnd, renderedContentEnd;
12025
12012
  renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
@@ -12075,7 +12062,7 @@ class VariableDeclaration extends NodeBase {
12075
12062
  lastSeparatorPos = separator;
12076
12063
  separatorString = nextSeparatorString;
12077
12064
  }
12078
- this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options, isNoStatement);
12065
+ this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, aggregatedSystemExports, options);
12079
12066
  }
12080
12067
  }
12081
12068
  function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
@@ -12120,7 +12107,9 @@ class VariableDeclarator extends NodeBase {
12120
12107
  include(context, includeChildrenRecursively) {
12121
12108
  var _a;
12122
12109
  this.included = true;
12123
- (_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
12110
+ (_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively, {
12111
+ includeWithoutParameterDefaults: true
12112
+ });
12124
12113
  this.id.markDeclarationReached();
12125
12114
  if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
12126
12115
  this.id.include(context, includeChildrenRecursively);
@@ -12178,7 +12167,7 @@ class YieldExpression extends NodeBase {
12178
12167
  var _a;
12179
12168
  if (!this.deoptimized)
12180
12169
  this.applyDeoptimizations();
12181
- return !context.ignore.returnYield || ((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
12170
+ return !context.ignore.returnYield || !!((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
12182
12171
  }
12183
12172
  render(code, options) {
12184
12173
  if (this.argument) {
@@ -13641,7 +13630,7 @@ function warnOnBuiltins(warn, dependencies) {
13641
13630
  return;
13642
13631
  warn({
13643
13632
  code: 'MISSING_NODE_BUILTINS',
13644
- message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/snowpackjs/rollup-plugin-polyfill-node`,
13633
+ message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node`,
13645
13634
  modules: externalBuiltins
13646
13635
  });
13647
13636
  }