rollup 2.37.1 → 2.38.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.
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.37.1
4
- Wed, 20 Jan 2021 11:53:42 GMT - commit e23bb354cca08dbe32e3f6a3ba5c63d015e91ff9
3
+ Rollup.js v2.38.0
4
+ Fri, 22 Jan 2021 16:26:00 GMT - commit 889fa5267ad93cc706fdbff2024e9c4d4f273749
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.37.1
4
- Wed, 20 Jan 2021 11:53:42 GMT - commit e23bb354cca08dbe32e3f6a3ba5c63d015e91ff9
3
+ Rollup.js v2.38.0
4
+ Fri, 22 Jan 2021 16:26:00 GMT - commit 889fa5267ad93cc706fdbff2024e9c4d4f273749
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -13,7 +13,7 @@ import { createHash as createHash$1 } from 'crypto';
13
13
  import { writeFile as writeFile$1, readdirSync, mkdirSync, readFile as readFile$1, lstatSync, realpathSync } from 'fs';
14
14
  import { EventEmitter } from 'events';
15
15
 
16
- var version = "2.37.1";
16
+ var version = "2.38.0";
17
17
 
18
18
  var charToInteger = {};
19
19
  var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -2598,6 +2598,7 @@ class NodeBase {
2598
2598
  this.context.magicString.addSourcemapLocation(this.start);
2599
2599
  this.context.magicString.addSourcemapLocation(this.end);
2600
2600
  }
2601
+ addExportedVariables(_variables, _exportNamesByVariable) { }
2601
2602
  /**
2602
2603
  * Override this to bind assignments to variables and do any initialisations that
2603
2604
  * require the scopes to be populated with variables.
@@ -2624,9 +2625,6 @@ class NodeBase {
2624
2625
  createScope(parentScope) {
2625
2626
  this.scope = parentScope;
2626
2627
  }
2627
- declare(_kind, _init) {
2628
- return [];
2629
- }
2630
2628
  deoptimizePath(_path) { }
2631
2629
  getLiteralValueAtPath(_path, _recursionTracker, _origin) {
2632
2630
  return UnknownValue;
@@ -2676,14 +2674,14 @@ class NodeBase {
2676
2674
  }
2677
2675
  }
2678
2676
  }
2677
+ includeAllDeclaredVariables(context, includeChildrenRecursively) {
2678
+ this.include(context, includeChildrenRecursively);
2679
+ }
2679
2680
  includeCallArguments(context, args) {
2680
2681
  for (const arg of args) {
2681
2682
  arg.include(context, false);
2682
2683
  }
2683
2684
  }
2684
- includeWithAllDeclaredVariables(includeChildrenRecursively, context) {
2685
- this.include(context, includeChildrenRecursively);
2686
- }
2687
2685
  /**
2688
2686
  * Override to perform special initialisation steps after the scope is initialised
2689
2687
  */
@@ -2736,9 +2734,6 @@ class NodeBase {
2736
2734
  shouldBeIncluded(context) {
2737
2735
  return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
2738
2736
  }
2739
- toString() {
2740
- return this.context.code.slice(this.start, this.end);
2741
- }
2742
2737
  }
2743
2738
 
2744
2739
  class ClassNode extends NodeBase {
@@ -6428,7 +6423,6 @@ class MemberExpression extends NodeBase {
6428
6423
  this.replacement = null;
6429
6424
  this.wasPathDeoptimizedWhileOptimized = false;
6430
6425
  }
6431
- addExportedVariables() { }
6432
6426
  bind() {
6433
6427
  if (this.bound)
6434
6428
  return;
@@ -7203,7 +7197,7 @@ class ForInStatement extends NodeBase {
7203
7197
  }
7204
7198
  include(context, includeChildrenRecursively) {
7205
7199
  this.included = true;
7206
- this.left.includeWithAllDeclaredVariables(includeChildrenRecursively, context);
7200
+ this.left.includeAllDeclaredVariables(context, includeChildrenRecursively);
7207
7201
  this.left.deoptimizePath(EMPTY_PATH);
7208
7202
  this.right.include(context, includeChildrenRecursively);
7209
7203
  const { brokenFlow } = context;
@@ -7237,7 +7231,7 @@ class ForOfStatement extends NodeBase {
7237
7231
  }
7238
7232
  include(context, includeChildrenRecursively) {
7239
7233
  this.included = true;
7240
- this.left.includeWithAllDeclaredVariables(includeChildrenRecursively, context);
7234
+ this.left.includeAllDeclaredVariables(context, includeChildrenRecursively);
7241
7235
  this.left.deoptimizePath(EMPTY_PATH);
7242
7236
  this.right.include(context, includeChildrenRecursively);
7243
7237
  const { brokenFlow } = context;
@@ -8932,7 +8926,7 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
8932
8926
  }
8933
8927
  function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
8934
8928
  for (const declarator of declarations) {
8935
- if (!declarator.included)
8929
+ if (!declarator.id.included)
8936
8930
  return false;
8937
8931
  if (declarator.id.type === Identifier) {
8938
8932
  if (exportNamesByVariable.has(declarator.id.variable))
@@ -8963,10 +8957,11 @@ class VariableDeclaration extends NodeBase {
8963
8957
  declarator.include(context, includeChildrenRecursively);
8964
8958
  }
8965
8959
  }
8966
- includeWithAllDeclaredVariables(includeChildrenRecursively, context) {
8960
+ includeAllDeclaredVariables(context, includeChildrenRecursively) {
8967
8961
  this.included = true;
8968
8962
  for (const declarator of this.declarations) {
8969
- declarator.include(context, includeChildrenRecursively);
8963
+ declarator.id.included = true;
8964
+ declarator.includeAllDeclaredVariables(context, includeChildrenRecursively);
8970
8965
  }
8971
8966
  }
8972
8967
  initialise() {
@@ -8988,13 +8983,11 @@ class VariableDeclaration extends NodeBase {
8988
8983
  this.renderReplacedDeclarations(code, options, nodeRenderOptions);
8989
8984
  }
8990
8985
  }
8991
- renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, addSemicolon, systemPatternExports, options) {
8986
+ renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
8992
8987
  if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
8993
8988
  code.remove(this.end - 1, this.end);
8994
8989
  }
8995
- if (addSemicolon) {
8996
- separatorString += ';';
8997
- }
8990
+ separatorString += ';';
8998
8991
  if (lastSeparatorPos !== null) {
8999
8992
  if (code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ &&
9000
8993
  (code.original.charCodeAt(this.end) === 10 /*"\n"*/ ||
@@ -9019,15 +9012,10 @@ class VariableDeclaration extends NodeBase {
9019
9012
  code.appendLeft(renderedContentEnd, ` ${getSystemExportStatement(systemPatternExports, options)};`);
9020
9013
  }
9021
9014
  }
9022
- renderReplacedDeclarations(code, options, { start = this.start, end = this.end, isNoStatement }) {
9015
+ renderReplacedDeclarations(code, options, { start = this.start, end = this.end }) {
9023
9016
  const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.declarations, code, this.start + this.kind.length, this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0));
9024
9017
  let actualContentEnd, renderedContentEnd;
9025
- if (/\n\s*$/.test(code.slice(this.start, separatedNodes[0].start))) {
9026
- renderedContentEnd = this.start + this.kind.length;
9027
- }
9028
- else {
9029
- renderedContentEnd = separatedNodes[0].start;
9030
- }
9018
+ renderedContentEnd = findNonWhiteSpace(code.original, this.start + this.kind.length);
9031
9019
  let lastSeparatorPos = renderedContentEnd - 1;
9032
9020
  code.remove(this.start, lastSeparatorPos);
9033
9021
  let isInDeclaration = false;
@@ -9044,8 +9032,9 @@ class VariableDeclaration extends NodeBase {
9044
9032
  }
9045
9033
  leadingString = '';
9046
9034
  nextSeparatorString = '';
9047
- if (node.id instanceof Identifier$1 &&
9048
- isReassignedExportsMember(node.id.variable, options.exportNamesByVariable)) {
9035
+ if (!node.id.included ||
9036
+ (node.id instanceof Identifier$1 &&
9037
+ isReassignedExportsMember(node.id.variable, options.exportNamesByVariable))) {
9049
9038
  if (hasRenderedContent) {
9050
9039
  separatorString += ';';
9051
9040
  }
@@ -9094,7 +9083,7 @@ class VariableDeclaration extends NodeBase {
9094
9083
  separatorString = nextSeparatorString;
9095
9084
  }
9096
9085
  if (hasRenderedContent) {
9097
- this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, !isNoStatement, systemPatternExports, options);
9086
+ this.renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options);
9098
9087
  }
9099
9088
  else {
9100
9089
  code.remove(start, end);
@@ -9109,6 +9098,35 @@ class VariableDeclarator extends NodeBase {
9109
9098
  deoptimizePath(path) {
9110
9099
  this.id.deoptimizePath(path);
9111
9100
  }
9101
+ hasEffects(context) {
9102
+ return this.id.hasEffects(context) || (this.init !== null && this.init.hasEffects(context));
9103
+ }
9104
+ include(context, includeChildrenRecursively) {
9105
+ this.included = true;
9106
+ if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
9107
+ this.id.include(context, includeChildrenRecursively);
9108
+ }
9109
+ if (this.init) {
9110
+ this.init.include(context, includeChildrenRecursively);
9111
+ }
9112
+ }
9113
+ includeAllDeclaredVariables(context, includeChildrenRecursively) {
9114
+ this.included = true;
9115
+ this.id.include(context, includeChildrenRecursively);
9116
+ }
9117
+ render(code, options) {
9118
+ const renderId = this.id.included;
9119
+ if (renderId) {
9120
+ this.id.render(code, options);
9121
+ }
9122
+ else {
9123
+ const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', this.id.end);
9124
+ code.remove(this.start, findNonWhiteSpace(code.original, operatorPos + 1));
9125
+ }
9126
+ if (this.init) {
9127
+ this.init.render(code, options, renderId ? BLANK : { renderedParentType: ExpressionStatement });
9128
+ }
9129
+ }
9112
9130
  }
9113
9131
 
9114
9132
  class WhileStatement extends NodeBase {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.37.1
4
- Wed, 20 Jan 2021 11:53:42 GMT - commit e23bb354cca08dbe32e3f6a3ba5c63d015e91ff9
3
+ Rollup.js v2.38.0
4
+ Fri, 22 Jan 2021 16:26:00 GMT - commit 889fa5267ad93cc706fdbff2024e9c4d4f273749
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.37.1
4
- Wed, 20 Jan 2021 11:53:42 GMT - commit e23bb354cca08dbe32e3f6a3ba5c63d015e91ff9
3
+ Rollup.js v2.38.0
4
+ Fri, 22 Jan 2021 16:26:00 GMT - commit 889fa5267ad93cc706fdbff2024e9c4d4f273749
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup