rollup 2.52.0 → 2.52.4

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.52.0
4
- Wed, 16 Jun 2021 05:23:55 GMT - commit c4f9d13bd284a6b483b1a087917ed3f0bc93cd18
3
+ Rollup.js v2.52.4
4
+ Wed, 30 Jun 2021 04:06:36 GMT - commit c3ad218caeeafa8a1b6ff8d4dde0db2556a3309a
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.0
4
- Wed, 16 Jun 2021 05:23:55 GMT - commit c4f9d13bd284a6b483b1a087917ed3f0bc93cd18
3
+ Rollup.js v2.52.4
4
+ Wed, 30 Jun 2021 04:06:36 GMT - commit c3ad218caeeafa8a1b6ff8d4dde0db2556a3309a
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.52.0";
17
+ var version$1 = "2.52.4";
18
18
 
19
19
  var charToInteger = {};
20
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -4105,7 +4105,11 @@ class Identifier extends NodeBase {
4105
4105
  const { treeshake } = this.context.options;
4106
4106
  switch (kind) {
4107
4107
  case 'var':
4108
- variable = this.scope.addDeclaration(this, this.context, treeshake && treeshake.correctVarValueBeforeDeclaration ? UNKNOWN_EXPRESSION : init, true);
4108
+ variable = this.scope.addDeclaration(this, this.context, init, true);
4109
+ if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
4110
+ // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
4111
+ this.scope.addDeclaration(this, this.context, UNDEFINED_EXPRESSION, true);
4112
+ }
4109
4113
  break;
4110
4114
  case 'function':
4111
4115
  // in strict mode, functions are only hoisted within a scope but not across block scopes
@@ -4279,9 +4283,10 @@ const INTEGER_REG_EXP = /^\d+$/;
4279
4283
  class ObjectEntity extends ExpressionEntity {
4280
4284
  // If a PropertyMap is used, this will be taken as propertiesAndGettersByKey
4281
4285
  // and we assume there are no setters or getters
4282
- constructor(properties, prototypeExpression) {
4286
+ constructor(properties, prototypeExpression, immutable = false) {
4283
4287
  super();
4284
4288
  this.prototypeExpression = prototypeExpression;
4289
+ this.immutable = immutable;
4285
4290
  this.allProperties = [];
4286
4291
  this.deoptimizedPaths = Object.create(null);
4287
4292
  this.expressionsToBeDeoptimizedByKey = Object.create(null);
@@ -4337,7 +4342,7 @@ class ObjectEntity extends ExpressionEntity {
4337
4342
  }
4338
4343
  deoptimizePath(path) {
4339
4344
  var _a;
4340
- if (this.hasUnknownDeoptimizedProperty)
4345
+ if (this.hasUnknownDeoptimizedProperty || this.immutable)
4341
4346
  return;
4342
4347
  const key = path[0];
4343
4348
  if (path.length === 1) {
@@ -4369,9 +4374,6 @@ class ObjectEntity extends ExpressionEntity {
4369
4374
  }
4370
4375
  deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
4371
4376
  var _a;
4372
- if (path.length === 0) {
4373
- return;
4374
- }
4375
4377
  const [key, ...subPath] = path;
4376
4378
  if (this.hasUnknownDeoptimizedProperty ||
4377
4379
  // single paths that are deoptimized will not become getters or setters
@@ -4398,7 +4400,9 @@ class ObjectEntity extends ExpressionEntity {
4398
4400
  property.deoptimizeThisOnEventAtPath(event, subPath, thisParameter, recursionTracker);
4399
4401
  }
4400
4402
  }
4401
- this.thisParametersToBeDeoptimized.add(thisParameter);
4403
+ if (!this.immutable) {
4404
+ this.thisParametersToBeDeoptimized.add(thisParameter);
4405
+ }
4402
4406
  return;
4403
4407
  }
4404
4408
  for (const property of relevantUnmatchableProperties) {
@@ -4422,7 +4426,9 @@ class ObjectEntity extends ExpressionEntity {
4422
4426
  property.deoptimizeThisOnEventAtPath(event, subPath, thisParameter, recursionTracker);
4423
4427
  }
4424
4428
  }
4425
- this.thisParametersToBeDeoptimized.add(thisParameter);
4429
+ if (!this.immutable) {
4430
+ this.thisParametersToBeDeoptimized.add(thisParameter);
4431
+ }
4426
4432
  (_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
4427
4433
  }
4428
4434
  getLiteralValueAtPath(path, recursionTracker, origin) {
@@ -4485,8 +4491,9 @@ class ObjectEntity extends ExpressionEntity {
4485
4491
  return false;
4486
4492
  }
4487
4493
  for (const getter of this.unmatchableGetters) {
4488
- if (getter.hasEffectsWhenAccessedAtPath(subPath, context))
4494
+ if (getter.hasEffectsWhenAccessedAtPath(subPath, context)) {
4489
4495
  return true;
4496
+ }
4490
4497
  }
4491
4498
  }
4492
4499
  else {
@@ -4519,6 +4526,7 @@ class ObjectEntity extends ExpressionEntity {
4519
4526
  }
4520
4527
  if (this.hasUnknownDeoptimizedProperty)
4521
4528
  return true;
4529
+ // We do not need to test for unknown properties as in that case, hasUnknownDeoptimizedProperty is true
4522
4530
  if (typeof key === 'string') {
4523
4531
  if (this.propertiesAndSettersByKey[key]) {
4524
4532
  const setters = this.settersByKey[key];
@@ -4531,15 +4539,8 @@ class ObjectEntity extends ExpressionEntity {
4531
4539
  return false;
4532
4540
  }
4533
4541
  for (const property of this.unmatchableSetters) {
4534
- if (property.hasEffectsWhenAssignedAtPath(subPath, context))
4542
+ if (property.hasEffectsWhenAssignedAtPath(subPath, context)) {
4535
4543
  return true;
4536
- }
4537
- }
4538
- else {
4539
- for (const setters of Object.values(this.settersByKey).concat([this.unmatchableSetters])) {
4540
- for (const setter of setters) {
4541
- if (setter.hasEffectsWhenAssignedAtPath(subPath, context))
4542
- return true;
4543
4544
  }
4544
4545
  }
4545
4546
  }
@@ -4598,11 +4599,6 @@ class ObjectEntity extends ExpressionEntity {
4598
4599
  }
4599
4600
  if (!propertiesAndGettersByKey[key]) {
4600
4601
  propertiesAndGettersByKey[key] = [property, ...unmatchablePropertiesAndGetters];
4601
- if (INTEGER_REG_EXP.test(key)) {
4602
- for (const integerProperty of unknownIntegerProps) {
4603
- propertiesAndGettersByKey[key].push(integerProperty);
4604
- }
4605
- }
4606
4602
  }
4607
4603
  }
4608
4604
  }
@@ -4653,7 +4649,7 @@ class ObjectEntity extends ExpressionEntity {
4653
4649
  return UNKNOWN_EXPRESSION;
4654
4650
  }
4655
4651
  const expression = this.getMemberExpression(key);
4656
- if (expression !== UNKNOWN_EXPRESSION) {
4652
+ if (!(expression === UNKNOWN_EXPRESSION || this.immutable)) {
4657
4653
  const expressionsToBeDeoptimized = (this.expressionsToBeDeoptimizedByKey[key] =
4658
4654
  this.expressionsToBeDeoptimizedByKey[key] || []);
4659
4655
  expressionsToBeDeoptimized.push(origin);
@@ -4786,7 +4782,7 @@ const OBJECT_PROTOTYPE = new ObjectEntity({
4786
4782
  toLocaleString: METHOD_RETURNS_STRING,
4787
4783
  toString: METHOD_RETURNS_STRING,
4788
4784
  valueOf: METHOD_RETURNS_UNKNOWN
4789
- }, null);
4785
+ }, null, true);
4790
4786
 
4791
4787
  class ClassNode extends NodeBase {
4792
4788
  constructor() {
@@ -5765,7 +5761,7 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
5765
5761
  splice: METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY,
5766
5762
  unshift: METHOD_MUTATES_SELF_RETURNS_NUMBER,
5767
5763
  values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
5768
- }, OBJECT_PROTOTYPE);
5764
+ }, OBJECT_PROTOTYPE, true);
5769
5765
 
5770
5766
  class ArrayExpression extends NodeBase {
5771
5767
  constructor() {
@@ -5800,10 +5796,14 @@ class ArrayExpression extends NodeBase {
5800
5796
  const properties = [
5801
5797
  { key: 'length', kind: 'init', property: UNKNOWN_LITERAL_NUMBER }
5802
5798
  ];
5799
+ let hasSpread = false;
5803
5800
  for (let index = 0; index < this.elements.length; index++) {
5804
5801
  const element = this.elements[index];
5805
- if (element instanceof SpreadElement) {
5806
- properties.unshift({ key: UnknownInteger, kind: 'init', property: element });
5802
+ if (element instanceof SpreadElement || hasSpread) {
5803
+ if (element) {
5804
+ hasSpread = true;
5805
+ properties.unshift({ key: UnknownInteger, kind: 'init', property: element });
5806
+ }
5807
5807
  }
5808
5808
  else if (!element) {
5809
5809
  properties.push({ key: String(index), kind: 'init', property: UNDEFINED_EXPRESSION });
@@ -5856,7 +5856,9 @@ class ArrayPattern extends NodeBase {
5856
5856
  class BlockScope extends ChildScope {
5857
5857
  addDeclaration(identifier, context, init, isHoisted) {
5858
5858
  if (isHoisted) {
5859
- return this.parent.addDeclaration(identifier, context, UNKNOWN_EXPRESSION, isHoisted);
5859
+ this.parent.addDeclaration(identifier, context, init, isHoisted);
5860
+ // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
5861
+ return this.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, isHoisted);
5860
5862
  }
5861
5863
  else {
5862
5864
  return super.addDeclaration(identifier, context, init, false);
@@ -6698,8 +6700,7 @@ class CatchScope extends ParameterScope {
6698
6700
  existingParameter.addDeclaration(identifier, init);
6699
6701
  return existingParameter;
6700
6702
  }
6701
- // as parameters are handled differently, all remaining declarations are
6702
- // hoisted
6703
+ // as parameters are handled differently, all remaining declarations are hoisted
6703
6704
  return this.parent.addDeclaration(identifier, context, init, isHoisted);
6704
6705
  }
6705
6706
  }
@@ -9976,7 +9977,10 @@ class Module {
9976
9977
  if (name !== 'default') {
9977
9978
  const foundNamespaceReexport = name in this.namespaceReexportsByName
9978
9979
  ? this.namespaceReexportsByName[name]
9979
- : (this.namespaceReexportsByName[name] = this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, skipExternalNamespaceReexports));
9980
+ : this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, skipExternalNamespaceReexports);
9981
+ if (!skipExternalNamespaceReexports) {
9982
+ this.namespaceReexportsByName[name] = foundNamespaceReexport;
9983
+ }
9980
9984
  if (foundNamespaceReexport) {
9981
9985
  return foundNamespaceReexport;
9982
9986
  }
@@ -10368,8 +10372,18 @@ class Module {
10368
10372
  }
10369
10373
  getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules, skipExternalNamespaceReexports = false) {
10370
10374
  let foundSyntheticDeclaration = null;
10371
- const skipExternalNamespaceValues = new Set([true, skipExternalNamespaceReexports]);
10372
- for (const skipExternalNamespaces of skipExternalNamespaceValues) {
10375
+ const skipExternalNamespaceValues = [{ searchedNamesAndModules, skipExternalNamespaces: true }];
10376
+ if (!skipExternalNamespaceReexports) {
10377
+ const clonedSearchedNamesAndModules = new Map();
10378
+ for (const [name, modules] of searchedNamesAndModules || []) {
10379
+ clonedSearchedNamesAndModules.set(name, new Set(modules));
10380
+ }
10381
+ skipExternalNamespaceValues.push({
10382
+ searchedNamesAndModules: clonedSearchedNamesAndModules,
10383
+ skipExternalNamespaces: false
10384
+ });
10385
+ }
10386
+ for (const { skipExternalNamespaces, searchedNamesAndModules } of skipExternalNamespaceValues) {
10373
10387
  const foundDeclarations = new Set();
10374
10388
  for (const module of this.exportAllModules) {
10375
10389
  if (module instanceof Module || !skipExternalNamespaces) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.0
4
- Wed, 16 Jun 2021 05:23:55 GMT - commit c4f9d13bd284a6b483b1a087917ed3f0bc93cd18
3
+ Rollup.js v2.52.4
4
+ Wed, 30 Jun 2021 04:06:36 GMT - commit c3ad218caeeafa8a1b6ff8d4dde0db2556a3309a
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.0
4
- Wed, 16 Jun 2021 05:23:55 GMT - commit c4f9d13bd284a6b483b1a087917ed3f0bc93cd18
3
+ Rollup.js v2.52.4
4
+ Wed, 30 Jun 2021 04:06:36 GMT - commit c3ad218caeeafa8a1b6ff8d4dde0db2556a3309a
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup