rollup 0.66.5 → 0.66.6

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 v0.66.5
4
- Tue, 09 Oct 2018 05:29:31 GMT - commit e5d9f3e08694d94e363ba6b45315a41890caf76b
3
+ Rollup.js v0.66.6
4
+ Wed, 10 Oct 2018 14:49:51 GMT - commit aa68a8cd6d363681ec1df60df63e05f6b53c4277
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -2688,36 +2688,36 @@ var ExportDefaultVariable = /** @class */ (function (_super) {
2688
2688
  function ExportDefaultVariable(name, exportDefaultDeclaration, deoptimizationTracker) {
2689
2689
  var _this = _super.call(this, name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, deoptimizationTracker) || this;
2690
2690
  // Not initialised during construction
2691
- _this.original = null;
2692
- _this.hasId =
2693
- (exportDefaultDeclaration.declaration.type === FunctionDeclaration ||
2694
- exportDefaultDeclaration.declaration.type === ClassDeclaration) &&
2695
- !!exportDefaultDeclaration.declaration.id;
2691
+ _this.originalId = null;
2692
+ var declaration = exportDefaultDeclaration.declaration;
2693
+ if ((declaration.type === FunctionDeclaration ||
2694
+ declaration.type === ClassDeclaration) &&
2695
+ declaration.id) {
2696
+ _this.hasId = true;
2697
+ _this.originalId = declaration.id;
2698
+ }
2699
+ else if (declaration.type === Identifier) {
2700
+ _this.originalId = declaration;
2701
+ }
2696
2702
  return _this;
2697
2703
  }
2698
2704
  ExportDefaultVariable.prototype.addReference = function (identifier) {
2699
2705
  if (!this.hasId) {
2700
2706
  this.name = identifier.name;
2701
- if (this.original !== null) {
2702
- this.original.addReference(identifier);
2703
- }
2704
2707
  }
2705
2708
  };
2706
2709
  ExportDefaultVariable.prototype.getName = function (reset) {
2707
2710
  if (!reset && this.safeName)
2708
2711
  return this.safeName;
2709
- if (this.original !== null && !this.original.isReassigned)
2710
- return this.original.getName();
2712
+ if (this.referencesOriginal())
2713
+ return this.originalId.variable.getName();
2711
2714
  return this.name;
2712
2715
  };
2713
2716
  ExportDefaultVariable.prototype.referencesOriginal = function () {
2714
- return this.original && !this.original.isReassigned;
2717
+ return this.originalId && (this.hasId || !this.originalId.variable.isReassigned);
2715
2718
  };
2716
2719
  ExportDefaultVariable.prototype.getOriginalVariableName = function () {
2717
- return this.original && this.original.getName();
2718
- };
2719
- ExportDefaultVariable.prototype.setOriginalVariable = function (original) {
2720
- this.original = original;
2720
+ return (this.originalId && this.originalId.name) || null;
2721
2721
  };
2722
2722
  return ExportDefaultVariable;
2723
2723
  }(LocalVariable));
@@ -9622,151 +9622,6 @@ var FunctionDeclaration$1 = /** @class */ (function (_super) {
9622
9622
  return FunctionDeclaration$$1;
9623
9623
  }(FunctionNode));
9624
9624
 
9625
- function isReference(node, parent) {
9626
- if (node.type === 'MemberExpression') {
9627
- return !node.computed && isReference(node.object, node);
9628
- }
9629
- if (node.type === 'Identifier') {
9630
- // the only time we could have an identifier node without a parent is
9631
- // if it's the entire body of a function without a block statement –
9632
- // i.e. an arrow function expression like `a => a`
9633
- if (!parent)
9634
- return true;
9635
- // TODO is this right?
9636
- if (parent.type === 'MemberExpression' || parent.type === 'MethodDefinition') {
9637
- return parent.computed || node === parent.object;
9638
- }
9639
- // disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
9640
- if (parent.type === 'Property')
9641
- return parent.computed || node === parent.value;
9642
- // disregard the `bar` in `export { foo as bar }`
9643
- if (parent.type === 'ExportSpecifier' && node !== parent.local)
9644
- return false;
9645
- return true;
9646
- }
9647
- return false;
9648
- }
9649
-
9650
- function isIdentifier(node) {
9651
- return node.type === Identifier;
9652
- }
9653
- var Identifier$1 = /** @class */ (function (_super) {
9654
- __extends(Identifier$$1, _super);
9655
- function Identifier$$1() {
9656
- return _super !== null && _super.apply(this, arguments) || this;
9657
- }
9658
- Identifier$$1.prototype.bind = function () {
9659
- if (this.bound)
9660
- return;
9661
- this.bound = true;
9662
- if (this.variable === null && isReference(this, this.parent)) {
9663
- this.variable = this.scope.findVariable(this.name);
9664
- this.variable.addReference(this);
9665
- }
9666
- if (this.variable !== null &&
9667
- this.variable.isLocal &&
9668
- this.variable.additionalInitializers !== null) {
9669
- this.variable.consolidateInitializers();
9670
- }
9671
- };
9672
- Identifier$$1.prototype.declare = function (kind, init) {
9673
- switch (kind) {
9674
- case 'var':
9675
- case 'function':
9676
- this.variable = this.scope.addDeclaration(this, this.context.deoptimizationTracker, init, true);
9677
- break;
9678
- case 'let':
9679
- case 'const':
9680
- case 'class':
9681
- this.variable = this.scope.addDeclaration(this, this.context.deoptimizationTracker, init, false);
9682
- break;
9683
- case 'parameter':
9684
- this.variable = this.scope.addParameterDeclaration(this);
9685
- break;
9686
- default:
9687
- throw new Error("Unexpected identifier kind " + kind + ".");
9688
- }
9689
- };
9690
- Identifier$$1.prototype.getLiteralValueAtPath = function (path$$1, recursionTracker, origin) {
9691
- if (this.variable !== null) {
9692
- return this.variable.getLiteralValueAtPath(path$$1, recursionTracker, origin);
9693
- }
9694
- return UNKNOWN_VALUE;
9695
- };
9696
- Identifier$$1.prototype.getReturnExpressionWhenCalledAtPath = function (path$$1, recursionTracker, origin) {
9697
- if (this.variable !== null) {
9698
- return this.variable.getReturnExpressionWhenCalledAtPath(path$$1, recursionTracker, origin);
9699
- }
9700
- return UNKNOWN_EXPRESSION;
9701
- };
9702
- Identifier$$1.prototype.hasEffectsWhenAccessedAtPath = function (path$$1, options) {
9703
- return this.variable && this.variable.hasEffectsWhenAccessedAtPath(path$$1, options);
9704
- };
9705
- Identifier$$1.prototype.hasEffectsWhenAssignedAtPath = function (path$$1, options) {
9706
- return !this.variable || this.variable.hasEffectsWhenAssignedAtPath(path$$1, options);
9707
- };
9708
- Identifier$$1.prototype.hasEffectsWhenCalledAtPath = function (path$$1, callOptions, options) {
9709
- return !this.variable || this.variable.hasEffectsWhenCalledAtPath(path$$1, callOptions, options);
9710
- };
9711
- Identifier$$1.prototype.include = function () {
9712
- if (!this.included) {
9713
- this.included = true;
9714
- if (this.variable !== null && !this.variable.included) {
9715
- this.variable.include();
9716
- this.context.requestTreeshakingPass();
9717
- }
9718
- }
9719
- };
9720
- Identifier$$1.prototype.initialise = function () {
9721
- this.included = false;
9722
- this.bound = false;
9723
- // To avoid later shape mutations
9724
- if (!this.variable) {
9725
- this.variable = null;
9726
- }
9727
- };
9728
- Identifier$$1.prototype.deoptimizePath = function (path$$1) {
9729
- if (!this.bound)
9730
- this.bind();
9731
- if (this.variable !== null) {
9732
- if (path$$1.length === 0 &&
9733
- this.name in this.context.imports &&
9734
- !this.scope.contains(this.name)) {
9735
- this.disallowImportReassignment();
9736
- }
9737
- this.variable.deoptimizePath(path$$1);
9738
- }
9739
- };
9740
- Identifier$$1.prototype.render = function (code, _options, _a) {
9741
- var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent, isShorthandProperty = _b.isShorthandProperty;
9742
- if (this.variable) {
9743
- var name = this.variable.getName();
9744
- if (name !== this.name) {
9745
- code.overwrite(this.start, this.end, name, {
9746
- storeName: true,
9747
- contentOnly: true
9748
- });
9749
- if (isShorthandProperty) {
9750
- code.prependRight(this.start, this.name + ": ");
9751
- }
9752
- }
9753
- // In strict mode, any variable named "eval" must be the actual "eval" function
9754
- if (name === 'eval' &&
9755
- renderedParentType === CallExpression &&
9756
- isCalleeOfRenderedParent) {
9757
- code.appendRight(this.start, '0, ');
9758
- }
9759
- }
9760
- };
9761
- Identifier$$1.prototype.disallowImportReassignment = function () {
9762
- this.context.error({
9763
- code: 'ILLEGAL_REASSIGNMENT',
9764
- message: "Illegal reassignment to import '" + this.name + "'"
9765
- }, this.start);
9766
- };
9767
- return Identifier$$1;
9768
- }(NodeBase));
9769
-
9770
9625
  var WHITESPACE = /\s/;
9771
9626
  // The header ends at the first non-white-space after "default"
9772
9627
  function getDeclarationStart(code, start) {
@@ -9794,16 +9649,6 @@ var ExportDefaultDeclaration$1 = /** @class */ (function (_super) {
9794
9649
  function ExportDefaultDeclaration$$1() {
9795
9650
  return _super !== null && _super.apply(this, arguments) || this;
9796
9651
  }
9797
- ExportDefaultDeclaration$$1.prototype.bind = function () {
9798
- _super.prototype.bind.call(this);
9799
- if (this.declarationName &&
9800
- // Do not set it for Class and FunctionExpressions otherwise they get treeshaken away
9801
- (isFunctionDeclaration(this.declaration) ||
9802
- isClassDeclaration(this.declaration) ||
9803
- isIdentifier(this.declaration))) {
9804
- this.variable.setOriginalVariable(this.scope.findVariable(this.declarationName));
9805
- }
9806
- };
9807
9652
  ExportDefaultDeclaration$$1.prototype.initialise = function () {
9808
9653
  this.included = false;
9809
9654
  this.declarationName =
@@ -10225,6 +10070,151 @@ var ImmutableEntityPathTracker = /** @class */ (function () {
10225
10070
  }());
10226
10071
  var EMPTY_IMMUTABLE_TRACKER = new ImmutableEntityPathTracker();
10227
10072
 
10073
+ function isReference(node, parent) {
10074
+ if (node.type === 'MemberExpression') {
10075
+ return !node.computed && isReference(node.object, node);
10076
+ }
10077
+ if (node.type === 'Identifier') {
10078
+ // the only time we could have an identifier node without a parent is
10079
+ // if it's the entire body of a function without a block statement –
10080
+ // i.e. an arrow function expression like `a => a`
10081
+ if (!parent)
10082
+ return true;
10083
+ // TODO is this right?
10084
+ if (parent.type === 'MemberExpression' || parent.type === 'MethodDefinition') {
10085
+ return parent.computed || node === parent.object;
10086
+ }
10087
+ // disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
10088
+ if (parent.type === 'Property')
10089
+ return parent.computed || node === parent.value;
10090
+ // disregard the `bar` in `export { foo as bar }`
10091
+ if (parent.type === 'ExportSpecifier' && node !== parent.local)
10092
+ return false;
10093
+ return true;
10094
+ }
10095
+ return false;
10096
+ }
10097
+
10098
+ function isIdentifier(node) {
10099
+ return node.type === Identifier;
10100
+ }
10101
+ var Identifier$1 = /** @class */ (function (_super) {
10102
+ __extends(Identifier$$1, _super);
10103
+ function Identifier$$1() {
10104
+ return _super !== null && _super.apply(this, arguments) || this;
10105
+ }
10106
+ Identifier$$1.prototype.bind = function () {
10107
+ if (this.bound)
10108
+ return;
10109
+ this.bound = true;
10110
+ if (this.variable === null && isReference(this, this.parent)) {
10111
+ this.variable = this.scope.findVariable(this.name);
10112
+ this.variable.addReference(this);
10113
+ }
10114
+ if (this.variable !== null &&
10115
+ this.variable.isLocal &&
10116
+ this.variable.additionalInitializers !== null) {
10117
+ this.variable.consolidateInitializers();
10118
+ }
10119
+ };
10120
+ Identifier$$1.prototype.declare = function (kind, init) {
10121
+ switch (kind) {
10122
+ case 'var':
10123
+ case 'function':
10124
+ this.variable = this.scope.addDeclaration(this, this.context.deoptimizationTracker, init, true);
10125
+ break;
10126
+ case 'let':
10127
+ case 'const':
10128
+ case 'class':
10129
+ this.variable = this.scope.addDeclaration(this, this.context.deoptimizationTracker, init, false);
10130
+ break;
10131
+ case 'parameter':
10132
+ this.variable = this.scope.addParameterDeclaration(this);
10133
+ break;
10134
+ default:
10135
+ throw new Error("Unexpected identifier kind " + kind + ".");
10136
+ }
10137
+ };
10138
+ Identifier$$1.prototype.getLiteralValueAtPath = function (path$$1, recursionTracker, origin) {
10139
+ if (this.variable !== null) {
10140
+ return this.variable.getLiteralValueAtPath(path$$1, recursionTracker, origin);
10141
+ }
10142
+ return UNKNOWN_VALUE;
10143
+ };
10144
+ Identifier$$1.prototype.getReturnExpressionWhenCalledAtPath = function (path$$1, recursionTracker, origin) {
10145
+ if (this.variable !== null) {
10146
+ return this.variable.getReturnExpressionWhenCalledAtPath(path$$1, recursionTracker, origin);
10147
+ }
10148
+ return UNKNOWN_EXPRESSION;
10149
+ };
10150
+ Identifier$$1.prototype.hasEffectsWhenAccessedAtPath = function (path$$1, options) {
10151
+ return this.variable && this.variable.hasEffectsWhenAccessedAtPath(path$$1, options);
10152
+ };
10153
+ Identifier$$1.prototype.hasEffectsWhenAssignedAtPath = function (path$$1, options) {
10154
+ return !this.variable || this.variable.hasEffectsWhenAssignedAtPath(path$$1, options);
10155
+ };
10156
+ Identifier$$1.prototype.hasEffectsWhenCalledAtPath = function (path$$1, callOptions, options) {
10157
+ return !this.variable || this.variable.hasEffectsWhenCalledAtPath(path$$1, callOptions, options);
10158
+ };
10159
+ Identifier$$1.prototype.include = function () {
10160
+ if (!this.included) {
10161
+ this.included = true;
10162
+ if (this.variable !== null && !this.variable.included) {
10163
+ this.variable.include();
10164
+ this.context.requestTreeshakingPass();
10165
+ }
10166
+ }
10167
+ };
10168
+ Identifier$$1.prototype.initialise = function () {
10169
+ this.included = false;
10170
+ this.bound = false;
10171
+ // To avoid later shape mutations
10172
+ if (!this.variable) {
10173
+ this.variable = null;
10174
+ }
10175
+ };
10176
+ Identifier$$1.prototype.deoptimizePath = function (path$$1) {
10177
+ if (!this.bound)
10178
+ this.bind();
10179
+ if (this.variable !== null) {
10180
+ if (path$$1.length === 0 &&
10181
+ this.name in this.context.imports &&
10182
+ !this.scope.contains(this.name)) {
10183
+ this.disallowImportReassignment();
10184
+ }
10185
+ this.variable.deoptimizePath(path$$1);
10186
+ }
10187
+ };
10188
+ Identifier$$1.prototype.render = function (code, _options, _a) {
10189
+ var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent, isShorthandProperty = _b.isShorthandProperty;
10190
+ if (this.variable) {
10191
+ var name = this.variable.getName();
10192
+ if (name !== this.name) {
10193
+ code.overwrite(this.start, this.end, name, {
10194
+ storeName: true,
10195
+ contentOnly: true
10196
+ });
10197
+ if (isShorthandProperty) {
10198
+ code.prependRight(this.start, this.name + ": ");
10199
+ }
10200
+ }
10201
+ // In strict mode, any variable named "eval" must be the actual "eval" function
10202
+ if (name === 'eval' &&
10203
+ renderedParentType === CallExpression &&
10204
+ isCalleeOfRenderedParent) {
10205
+ code.appendRight(this.start, '0, ');
10206
+ }
10207
+ }
10208
+ };
10209
+ Identifier$$1.prototype.disallowImportReassignment = function () {
10210
+ this.context.error({
10211
+ code: 'ILLEGAL_REASSIGNMENT',
10212
+ message: "Illegal reassignment to import '" + this.name + "'"
10213
+ }, this.start);
10214
+ };
10215
+ return Identifier$$1;
10216
+ }(NodeBase));
10217
+
10228
10218
  var CallExpression$1 = /** @class */ (function (_super) {
10229
10219
  __extends(CallExpression, _super);
10230
10220
  function CallExpression() {
@@ -13186,9 +13176,6 @@ var Module = /** @class */ (function () {
13186
13176
  // export default function foo () {}
13187
13177
  // export default foo;
13188
13178
  // export default 42;
13189
- var identifier = (node.declaration.id &&
13190
- node.declaration.id.name) ||
13191
- node.declaration.name;
13192
13179
  if (this.exports.default) {
13193
13180
  this.error({
13194
13181
  code: 'DUPLICATE_EXPORT',
@@ -13197,7 +13184,7 @@ var Module = /** @class */ (function () {
13197
13184
  }
13198
13185
  this.exports.default = {
13199
13186
  localName: 'default',
13200
- identifier: identifier,
13187
+ identifier: node.variable.getOriginalVariableName(),
13201
13188
  node: node
13202
13189
  };
13203
13190
  }
@@ -20627,7 +20614,7 @@ function Uint8ArrayEqual(bufferA, bufferB) {
20627
20614
  return true;
20628
20615
  }
20629
20616
 
20630
- var version$1 = "0.66.5";
20617
+ var version$1 = "0.66.6";
20631
20618
 
20632
20619
  function mkdirpath(path$$1) {
20633
20620
  var dir = path.dirname(path$$1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "0.66.5",
3
+ "version": "0.66.6",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/rollup.es.js",