rollup 2.52.7 → 2.52.8

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/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.7
4
- Fri, 02 Jul 2021 03:59:47 GMT - commit b2218ccda2765c48ae1db8bade9ec6889aaab250
3
+ Rollup.js v2.52.8
4
+ Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.7
4
- Fri, 02 Jul 2021 03:59:47 GMT - commit b2218ccda2765c48ae1db8bade9ec6889aaab250
3
+ Rollup.js v2.52.8
4
+ Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.7
4
- Fri, 02 Jul 2021 03:59:47 GMT - commit b2218ccda2765c48ae1db8bade9ec6889aaab250
3
+ Rollup.js v2.52.8
4
+ Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.7
4
- Fri, 02 Jul 2021 03:59:47 GMT - commit b2218ccda2765c48ae1db8bade9ec6889aaab250
3
+ Rollup.js v2.52.8
4
+ Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.7
4
- Fri, 02 Jul 2021 03:59:47 GMT - commit b2218ccda2765c48ae1db8bade9ec6889aaab250
3
+ Rollup.js v2.52.8
4
+ Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -32,7 +32,7 @@ function _interopNamespaceDefault(e) {
32
32
 
33
33
  var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
34
34
 
35
- var version$1 = "2.52.7";
35
+ var version$1 = "2.52.8";
36
36
 
37
37
  function ensureArray(items) {
38
38
  if (Array.isArray(items)) {
@@ -2184,8 +2184,10 @@ class Variable extends ExpressionEntity {
2184
2184
  super();
2185
2185
  this.name = name;
2186
2186
  this.alwaysRendered = false;
2187
+ this.initReached = false;
2187
2188
  this.isId = false;
2188
2189
  this.isReassigned = false;
2190
+ this.kind = null;
2189
2191
  this.renderBaseName = null;
2190
2192
  this.renderName = null;
2191
2193
  }
@@ -4556,11 +4558,19 @@ class GlobalVariable extends Variable {
4556
4558
  }
4557
4559
  }
4558
4560
 
4561
+ const tdzVariableKinds = {
4562
+ __proto__: null,
4563
+ class: true,
4564
+ const: true,
4565
+ let: true,
4566
+ var: true
4567
+ };
4559
4568
  class Identifier extends NodeBase {
4560
4569
  constructor() {
4561
4570
  super(...arguments);
4562
4571
  this.variable = null;
4563
4572
  this.deoptimized = false;
4573
+ this.isTDZAccess = null;
4564
4574
  }
4565
4575
  addExportedVariables(variables, exportNamesByVariable) {
4566
4576
  if (this.variable !== null && exportNamesByVariable.has(this.variable)) {
@@ -4601,6 +4611,7 @@ class Identifier extends NodeBase {
4601
4611
  /* istanbul ignore next */
4602
4612
  throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
4603
4613
  }
4614
+ variable.kind = kind;
4604
4615
  return [(this.variable = variable)];
4605
4616
  }
4606
4617
  deoptimizePath(path) {
@@ -4613,26 +4624,34 @@ class Identifier extends NodeBase {
4613
4624
  this.variable.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
4614
4625
  }
4615
4626
  getLiteralValueAtPath(path, recursionTracker, origin) {
4616
- return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
4627
+ return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
4617
4628
  }
4618
4629
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
4619
- return this.variable.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
4630
+ return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
4620
4631
  }
4621
4632
  hasEffects() {
4622
4633
  if (!this.deoptimized)
4623
4634
  this.applyDeoptimizations();
4635
+ if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
4636
+ return true;
4637
+ }
4624
4638
  return (this.context.options.treeshake.unknownGlobalSideEffects &&
4625
4639
  this.variable instanceof GlobalVariable &&
4626
4640
  this.variable.hasEffectsWhenAccessedAtPath(EMPTY_PATH));
4627
4641
  }
4628
4642
  hasEffectsWhenAccessedAtPath(path, context) {
4629
- return this.variable !== null && this.variable.hasEffectsWhenAccessedAtPath(path, context);
4643
+ return (this.variable !== null &&
4644
+ this.getVariableRespectingTDZ().hasEffectsWhenAccessedAtPath(path, context));
4630
4645
  }
4631
4646
  hasEffectsWhenAssignedAtPath(path, context) {
4632
- return !this.variable || this.variable.hasEffectsWhenAssignedAtPath(path, context);
4647
+ return (!this.variable ||
4648
+ (path.length > 0
4649
+ ? this.getVariableRespectingTDZ()
4650
+ : this.variable).hasEffectsWhenAssignedAtPath(path, context));
4633
4651
  }
4634
4652
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
4635
- return !this.variable || this.variable.hasEffectsWhenCalledAtPath(path, callOptions, context);
4653
+ return (!this.variable ||
4654
+ this.getVariableRespectingTDZ().hasEffectsWhenCalledAtPath(path, callOptions, context));
4636
4655
  }
4637
4656
  include() {
4638
4657
  if (!this.deoptimized)
@@ -4645,7 +4664,10 @@ class Identifier extends NodeBase {
4645
4664
  }
4646
4665
  }
4647
4666
  includeCallArguments(context, args) {
4648
- this.variable.includeCallArguments(context, args);
4667
+ this.getVariableRespectingTDZ().includeCallArguments(context, args);
4668
+ }
4669
+ markDeclarationReached() {
4670
+ this.variable.initReached = true;
4649
4671
  }
4650
4672
  render(code, _options, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
4651
4673
  if (this.variable) {
@@ -4680,6 +4702,28 @@ class Identifier extends NodeBase {
4680
4702
  message: `Illegal reassignment to import '${this.name}'`
4681
4703
  }, this.start);
4682
4704
  }
4705
+ getVariableRespectingTDZ() {
4706
+ if (this.isPossibleTDZ()) {
4707
+ return UNKNOWN_EXPRESSION;
4708
+ }
4709
+ return this.variable;
4710
+ }
4711
+ isPossibleTDZ() {
4712
+ // return cached value to avoid issues with the next tree-shaking pass
4713
+ if (this.isTDZAccess !== null)
4714
+ return this.isTDZAccess;
4715
+ if (!(this.variable instanceof LocalVariable) ||
4716
+ !this.variable.kind ||
4717
+ !(this.variable.kind in tdzVariableKinds)) {
4718
+ return (this.isTDZAccess = false);
4719
+ }
4720
+ if (!this.variable.initReached) {
4721
+ // Either a const/let TDZ violation or
4722
+ // var use before declaration was encountered.
4723
+ return (this.isTDZAccess = true);
4724
+ }
4725
+ return (this.isTDZAccess = false);
4726
+ }
4683
4727
  }
4684
4728
 
4685
4729
  const EVENT_ACCESSED = 0;
@@ -5280,6 +5324,12 @@ class ClassNode extends NodeBase {
5280
5324
  getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
5281
5325
  return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
5282
5326
  }
5327
+ hasEffects(context) {
5328
+ var _a, _b;
5329
+ const initEffect = ((_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffects(context)) || this.body.hasEffects(context);
5330
+ (_b = this.id) === null || _b === void 0 ? void 0 : _b.markDeclarationReached();
5331
+ return initEffect || super.hasEffects(context);
5332
+ }
5283
5333
  hasEffectsWhenAccessedAtPath(path, context) {
5284
5334
  return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
5285
5335
  }
@@ -5298,10 +5348,19 @@ class ClassNode extends NodeBase {
5298
5348
  return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
5299
5349
  }
5300
5350
  }
5301
- initialise() {
5302
- if (this.id !== null) {
5303
- this.id.declare('class', this);
5351
+ include(context, includeChildrenRecursively) {
5352
+ var _a;
5353
+ this.included = true;
5354
+ (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
5355
+ this.body.include(context, includeChildrenRecursively);
5356
+ if (this.id) {
5357
+ this.id.markDeclarationReached();
5358
+ this.id.include();
5304
5359
  }
5360
+ }
5361
+ initialise() {
5362
+ var _a;
5363
+ (_a = this.id) === null || _a === void 0 ? void 0 : _a.declare('class', this);
5305
5364
  for (const method of this.body.body) {
5306
5365
  if (method instanceof MethodDefinition && method.kind === 'constructor') {
5307
5366
  this.classConstructor = method;
@@ -5616,6 +5675,9 @@ class RestElement extends NodeBase {
5616
5675
  hasEffectsWhenAssignedAtPath(path, context) {
5617
5676
  return path.length > 0 || this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
5618
5677
  }
5678
+ markDeclarationReached() {
5679
+ this.argument.markDeclarationReached();
5680
+ }
5619
5681
  applyDeoptimizations() {
5620
5682
  this.deoptimized = true;
5621
5683
  if (this.declarationInit !== null) {
@@ -6336,13 +6398,21 @@ class ArrayPattern extends NodeBase {
6336
6398
  }
6337
6399
  return false;
6338
6400
  }
6401
+ markDeclarationReached() {
6402
+ for (const element of this.elements) {
6403
+ if (element !== null) {
6404
+ element.markDeclarationReached();
6405
+ }
6406
+ }
6407
+ }
6339
6408
  }
6340
6409
 
6341
6410
  class BlockScope extends ChildScope {
6342
6411
  addDeclaration(identifier, context, init, isHoisted) {
6343
6412
  if (isHoisted) {
6344
6413
  this.parent.addDeclaration(identifier, context, init, isHoisted);
6345
- // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
6414
+ // Necessary to make sure the init is deoptimized for conditional declarations.
6415
+ // We cannot call deoptimizePath here.
6346
6416
  return this.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, isHoisted);
6347
6417
  }
6348
6418
  else {
@@ -6626,6 +6696,9 @@ class AssignmentPattern extends NodeBase {
6626
6696
  hasEffectsWhenAssignedAtPath(path, context) {
6627
6697
  return path.length > 0 || this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
6628
6698
  }
6699
+ markDeclarationReached() {
6700
+ this.left.markDeclarationReached();
6701
+ }
6629
6702
  render(code, options, { isShorthandProperty } = BLANK) {
6630
6703
  this.left.render(code, options, { isShorthandProperty });
6631
6704
  this.right.render(code, options);
@@ -7104,17 +7177,21 @@ class CallExpression extends NodeBase {
7104
7177
  }, UNKNOWN_EXPRESSION);
7105
7178
  }
7106
7179
  hasEffects(context) {
7107
- if (!this.deoptimized)
7108
- this.applyDeoptimizations();
7109
- for (const argument of this.arguments) {
7110
- if (argument.hasEffects(context))
7111
- return true;
7180
+ try {
7181
+ for (const argument of this.arguments) {
7182
+ if (argument.hasEffects(context))
7183
+ return true;
7184
+ }
7185
+ if (this.context.options.treeshake.annotations &&
7186
+ this.annotations)
7187
+ return false;
7188
+ return (this.callee.hasEffects(context) ||
7189
+ this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
7190
+ }
7191
+ finally {
7192
+ if (!this.deoptimized)
7193
+ this.applyDeoptimizations();
7112
7194
  }
7113
- if (this.context.options.treeshake.annotations &&
7114
- this.annotations)
7115
- return false;
7116
- return (this.callee.hasEffects(context) ||
7117
- this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context));
7118
7195
  }
7119
7196
  hasEffectsWhenAccessedAtPath(path, context) {
7120
7197
  return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
@@ -8629,6 +8706,11 @@ class ObjectPattern extends NodeBase {
8629
8706
  }
8630
8707
  return false;
8631
8708
  }
8709
+ markDeclarationReached() {
8710
+ for (const property of this.properties) {
8711
+ property.markDeclarationReached();
8712
+ }
8713
+ }
8632
8714
  }
8633
8715
 
8634
8716
  class PrivateIdentifier extends NodeBase {
@@ -8653,6 +8735,9 @@ class Property extends MethodBase {
8653
8735
  this.key.hasEffects(context) ||
8654
8736
  this.value.hasEffects(context));
8655
8737
  }
8738
+ markDeclarationReached() {
8739
+ this.value.markDeclarationReached();
8740
+ }
8656
8741
  render(code, options) {
8657
8742
  if (!this.shorthand) {
8658
8743
  this.key.render(code, options);
@@ -9308,16 +9393,19 @@ class VariableDeclarator extends NodeBase {
9308
9393
  this.id.deoptimizePath(path);
9309
9394
  }
9310
9395
  hasEffects(context) {
9311
- return this.id.hasEffects(context) || (this.init !== null && this.init.hasEffects(context));
9396
+ const initEffect = this.init !== null && this.init.hasEffects(context);
9397
+ this.id.markDeclarationReached();
9398
+ return initEffect || this.id.hasEffects(context);
9312
9399
  }
9313
9400
  include(context, includeChildrenRecursively) {
9314
9401
  this.included = true;
9315
- if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
9316
- this.id.include(context, includeChildrenRecursively);
9317
- }
9318
9402
  if (this.init) {
9319
9403
  this.init.include(context, includeChildrenRecursively);
9320
9404
  }
9405
+ this.id.markDeclarationReached();
9406
+ if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
9407
+ this.id.include(context, includeChildrenRecursively);
9408
+ }
9321
9409
  }
9322
9410
  render(code, options) {
9323
9411
  const renderId = this.id.included;
@@ -10142,8 +10230,8 @@ class Module {
10142
10230
  }
10143
10231
  includeAllExports(includeNamespaceMembers) {
10144
10232
  if (!this.isExecuted) {
10145
- this.graph.needsTreeshakingPass = true;
10146
10233
  markModuleAndImpureDependenciesAsExecuted(this);
10234
+ this.graph.needsTreeshakingPass = true;
10147
10235
  }
10148
10236
  for (const exportName of this.getExports()) {
10149
10237
  if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
@@ -20213,12 +20301,7 @@ class Graph {
20213
20301
  }
20214
20302
  includeStatements() {
20215
20303
  for (const module of [...this.entryModules, ...this.implicitEntryModules]) {
20216
- if (module.preserveSignature !== false) {
20217
- module.includeAllExports(false);
20218
- }
20219
- else {
20220
- markModuleAndImpureDependenciesAsExecuted(module);
20221
- }
20304
+ markModuleAndImpureDependenciesAsExecuted(module);
20222
20305
  }
20223
20306
  if (this.options.treeshake) {
20224
20307
  let treeshakingPass = 1;
@@ -20235,6 +20318,16 @@ class Graph {
20235
20318
  }
20236
20319
  }
20237
20320
  }
20321
+ if (treeshakingPass === 1) {
20322
+ // We only include exports after the first pass to avoid issues with
20323
+ // the TDZ detection logic
20324
+ for (const module of [...this.entryModules, ...this.implicitEntryModules]) {
20325
+ if (module.preserveSignature !== false) {
20326
+ module.includeAllExports(false);
20327
+ this.needsTreeshakingPass = true;
20328
+ }
20329
+ }
20330
+ }
20238
20331
  timeEnd(`treeshaking pass ${treeshakingPass++}`, 3);
20239
20332
  } while (this.needsTreeshakingPass);
20240
20333
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.7
4
- Fri, 02 Jul 2021 03:59:47 GMT - commit b2218ccda2765c48ae1db8bade9ec6889aaab250
3
+ Rollup.js v2.52.8
4
+ Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.7
4
- Fri, 02 Jul 2021 03:59:47 GMT - commit b2218ccda2765c48ae1db8bade9ec6889aaab250
3
+ Rollup.js v2.52.8
4
+ Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "2.52.7",
3
+ "version": "2.52.8",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",