rollup 0.58.1 → 0.58.2

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,6 +1,6 @@
1
1
  /*
2
- Rollup.js v0.58.1
3
- Wed, 18 Apr 2018 18:21:56 GMT - commit ce3801d3fe33c957c607ebd75e3d8ef3f39af13b
2
+ Rollup.js v0.58.2
3
+ Mon, 23 Apr 2018 15:25:53 GMT - commit d21b9359fe1b8845abb5801dbce27a16f3a67aed
4
4
 
5
5
 
6
6
  https://github.com/rollup/rollup
@@ -14836,49 +14836,62 @@ var ConditionalExpression = /** @class */ (function (_super) {
14836
14836
  return _super !== null && _super.apply(this, arguments) || this;
14837
14837
  }
14838
14838
  ConditionalExpression.prototype.forEachReturnExpressionWhenCalledAtPath = function (path$$1, callOptions, callback, options) {
14839
- if (this.hasUnknownTestValue) {
14839
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14840
+ if (testValue === UNKNOWN_VALUE || testValue) {
14840
14841
  this.consequent.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
14841
- this.alternate.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
14842
14842
  }
14843
- else {
14844
- this.forEachRelevantBranch(function (node) {
14845
- return node.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
14846
- });
14843
+ if (testValue === UNKNOWN_VALUE || !testValue) {
14844
+ this.alternate.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
14847
14845
  }
14848
14846
  };
14849
14847
  ConditionalExpression.prototype.getValue = function () {
14850
- var testValue = this.test.getValue();
14848
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14851
14849
  if (testValue === UNKNOWN_VALUE)
14852
14850
  return UNKNOWN_VALUE;
14853
14851
  return testValue ? this.consequent.getValue() : this.alternate.getValue();
14854
14852
  };
14855
14853
  ConditionalExpression.prototype.hasEffects = function (options) {
14856
- return (this.test.hasEffects(options) ||
14857
- (this.hasUnknownTestValue
14858
- ? this.consequent.hasEffects(options) || this.alternate.hasEffects(options)
14859
- : this.someRelevantBranch(function (node) { return node.hasEffects(options); })));
14854
+ if (this.test.hasEffects(options))
14855
+ return true;
14856
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14857
+ if (testValue === UNKNOWN_VALUE) {
14858
+ return this.consequent.hasEffects(options) || this.alternate.hasEffects(options);
14859
+ }
14860
+ return testValue ? this.consequent.hasEffects(options) : this.alternate.hasEffects(options);
14860
14861
  };
14861
14862
  ConditionalExpression.prototype.hasEffectsWhenAccessedAtPath = function (path$$1, options) {
14862
- return (path$$1.length > 0 &&
14863
- (this.hasUnknownTestValue
14864
- ? this.consequent.hasEffectsWhenAccessedAtPath(path$$1, options) ||
14865
- this.alternate.hasEffectsWhenAccessedAtPath(path$$1, options)
14866
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAccessedAtPath(path$$1, options); })));
14863
+ if (path$$1.length === 0)
14864
+ return false;
14865
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14866
+ if (testValue === UNKNOWN_VALUE) {
14867
+ return (this.consequent.hasEffectsWhenAccessedAtPath(path$$1, options) ||
14868
+ this.alternate.hasEffectsWhenAccessedAtPath(path$$1, options));
14869
+ }
14870
+ return testValue
14871
+ ? this.consequent.hasEffectsWhenAccessedAtPath(path$$1, options)
14872
+ : this.alternate.hasEffectsWhenAccessedAtPath(path$$1, options);
14867
14873
  };
14868
14874
  ConditionalExpression.prototype.hasEffectsWhenAssignedAtPath = function (path$$1, options) {
14869
- return (path$$1.length === 0 ||
14870
- (this.hasUnknownTestValue
14871
- ? this.consequent.hasEffectsWhenAssignedAtPath(path$$1, options) ||
14872
- this.alternate.hasEffectsWhenAssignedAtPath(path$$1, options)
14873
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAssignedAtPath(path$$1, options); })));
14875
+ if (path$$1.length === 0)
14876
+ return true;
14877
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14878
+ if (testValue === UNKNOWN_VALUE) {
14879
+ return (this.consequent.hasEffectsWhenAssignedAtPath(path$$1, options) ||
14880
+ this.alternate.hasEffectsWhenAssignedAtPath(path$$1, options));
14881
+ }
14882
+ return testValue
14883
+ ? this.consequent.hasEffectsWhenAssignedAtPath(path$$1, options)
14884
+ : this.alternate.hasEffectsWhenAssignedAtPath(path$$1, options);
14874
14885
  };
14875
14886
  ConditionalExpression.prototype.hasEffectsWhenCalledAtPath = function (path$$1, callOptions, options) {
14876
- return this.hasUnknownTestValue
14877
- ? this.consequent.hasEffectsWhenCalledAtPath(path$$1, callOptions, options) ||
14878
- this.alternate.hasEffectsWhenCalledAtPath(path$$1, callOptions, options)
14879
- : this.someRelevantBranch(function (node) {
14880
- return node.hasEffectsWhenCalledAtPath(path$$1, callOptions, options);
14881
- });
14887
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14888
+ if (testValue === UNKNOWN_VALUE) {
14889
+ return (this.consequent.hasEffectsWhenCalledAtPath(path$$1, callOptions, options) ||
14890
+ this.alternate.hasEffectsWhenCalledAtPath(path$$1, callOptions, options));
14891
+ }
14892
+ return testValue
14893
+ ? this.consequent.hasEffectsWhenCalledAtPath(path$$1, callOptions, options)
14894
+ : this.alternate.hasEffectsWhenCalledAtPath(path$$1, callOptions, options);
14882
14895
  };
14883
14896
  ConditionalExpression.prototype.initialise = function () {
14884
14897
  this.included = false;
@@ -14886,7 +14899,7 @@ var ConditionalExpression = /** @class */ (function (_super) {
14886
14899
  };
14887
14900
  ConditionalExpression.prototype.include = function () {
14888
14901
  this.included = true;
14889
- var testValue = this.test.getValue();
14902
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14890
14903
  if (testValue === UNKNOWN_VALUE || this.test.shouldBeIncluded()) {
14891
14904
  this.test.include();
14892
14905
  this.consequent.include();
@@ -14901,61 +14914,50 @@ var ConditionalExpression = /** @class */ (function (_super) {
14901
14914
  };
14902
14915
  ConditionalExpression.prototype.reassignPath = function (path$$1, options) {
14903
14916
  if (path$$1.length > 0) {
14904
- if (this.hasUnknownTestValue) {
14917
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14918
+ if (testValue === UNKNOWN_VALUE || testValue) {
14905
14919
  this.consequent.reassignPath(path$$1, options);
14906
- this.alternate.reassignPath(path$$1, options);
14907
14920
  }
14908
- else {
14909
- this.forEachRelevantBranch(function (node) { return node.reassignPath(path$$1, options); });
14921
+ if (testValue === UNKNOWN_VALUE || !testValue) {
14922
+ this.alternate.reassignPath(path$$1, options);
14910
14923
  }
14911
14924
  }
14912
14925
  };
14913
14926
  ConditionalExpression.prototype.render = function (code, options, _a) {
14914
14927
  var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent;
14915
- if (!this.context.treeshake || this.test.included) {
14916
- _super.prototype.render.call(this, code, options);
14917
- }
14918
- else {
14919
- var branchToRetain = this.consequent.included ? this.consequent : this.alternate;
14920
- code.remove(this.start, branchToRetain.start);
14921
- code.remove(branchToRetain.end, this.end);
14922
- branchToRetain.render(code, options, {
14928
+ if (!this.test.included) {
14929
+ var singleRetainedBranch = this.consequent.included ? this.consequent : this.alternate;
14930
+ code.remove(this.start, singleRetainedBranch.start);
14931
+ code.remove(singleRetainedBranch.end, this.end);
14932
+ singleRetainedBranch.render(code, options, {
14923
14933
  renderedParentType: renderedParentType || this.parent.type,
14924
14934
  isCalleeOfRenderedParent: renderedParentType
14925
14935
  ? isCalleeOfRenderedParent
14926
14936
  : this.parent.callee === this
14927
14937
  });
14928
14938
  }
14939
+ else {
14940
+ _super.prototype.render.call(this, code, options);
14941
+ }
14929
14942
  };
14930
14943
  ConditionalExpression.prototype.someReturnExpressionWhenCalledAtPath = function (path$$1, callOptions, predicateFunction, options) {
14931
- return this.hasUnknownTestValue
14932
- ? this.consequent.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options) ||
14933
- this.alternate.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options)
14934
- : this.someRelevantBranch(function (node) {
14935
- return node.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options);
14936
- });
14937
- };
14938
- ConditionalExpression.prototype.forEachRelevantBranch = function (callback) {
14939
- var testValue = this.test.getValue();
14944
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14940
14945
  if (testValue === UNKNOWN_VALUE) {
14941
- this.hasUnknownTestValue = true;
14942
- callback(this.consequent);
14943
- callback(this.alternate);
14944
- }
14945
- else if (testValue) {
14946
- callback(this.consequent);
14947
- }
14948
- else {
14949
- callback(this.alternate);
14946
+ return (this.consequent.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options) ||
14947
+ this.alternate.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options));
14950
14948
  }
14949
+ return testValue
14950
+ ? this.consequent.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options)
14951
+ : this.alternate.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options);
14951
14952
  };
14952
- ConditionalExpression.prototype.someRelevantBranch = function (predicateFunction) {
14953
- var testValue = this.test.getValue();
14954
- if (testValue === UNKNOWN_VALUE) {
14953
+ ConditionalExpression.prototype.getTestValue = function () {
14954
+ if (this.hasUnknownTestValue)
14955
+ return UNKNOWN_VALUE;
14956
+ var value = this.test.getValue();
14957
+ if (value === UNKNOWN_VALUE) {
14955
14958
  this.hasUnknownTestValue = true;
14956
- return predicateFunction(this.consequent) || predicateFunction(this.alternate);
14957
14959
  }
14958
- return testValue ? predicateFunction(this.consequent) : predicateFunction(this.alternate);
14960
+ return value;
14959
14961
  };
14960
14962
  return ConditionalExpression;
14961
14963
  }(NodeBase));
@@ -15163,27 +15165,28 @@ var IfStatement = /** @class */ (function (_super) {
15163
15165
  return _super !== null && _super.apply(this, arguments) || this;
15164
15166
  }
15165
15167
  IfStatement.prototype.hasEffects = function (options) {
15166
- return (this.test.hasEffects(options) ||
15167
- (this.hasUnknownTestValue
15168
- ? this.consequent.hasEffects(options) ||
15169
- (this.alternate !== null && this.alternate.hasEffects(options))
15170
- : this.someRelevantBranch(function (node) { return node.hasEffects(options); })));
15168
+ if (this.test.hasEffects(options))
15169
+ return true;
15170
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
15171
+ if (testValue === UNKNOWN_VALUE) {
15172
+ return (this.consequent.hasEffects(options) ||
15173
+ (this.alternate !== null && this.alternate.hasEffects(options)));
15174
+ }
15175
+ return testValue
15176
+ ? this.consequent.hasEffects(options)
15177
+ : this.alternate !== null && this.alternate.hasEffects(options);
15171
15178
  };
15172
15179
  IfStatement.prototype.include = function () {
15173
15180
  this.included = true;
15174
- var testValue = this.test.getValue();
15181
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
15175
15182
  if (testValue === UNKNOWN_VALUE || this.test.shouldBeIncluded()) {
15176
15183
  this.test.include();
15177
15184
  }
15178
- if (testValue === UNKNOWN_VALUE) {
15185
+ if ((testValue === UNKNOWN_VALUE || testValue) && this.consequent.shouldBeIncluded()) {
15179
15186
  this.consequent.include();
15180
- if (this.alternate !== null)
15181
- this.alternate.include();
15182
15187
  }
15183
- else if (testValue) {
15184
- this.consequent.include();
15185
- }
15186
- else if (this.alternate !== null) {
15188
+ if (this.alternate !== null &&
15189
+ ((testValue === UNKNOWN_VALUE || !testValue) && this.alternate.shouldBeIncluded())) {
15187
15190
  this.alternate.include();
15188
15191
  }
15189
15192
  };
@@ -15192,30 +15195,46 @@ var IfStatement = /** @class */ (function (_super) {
15192
15195
  this.hasUnknownTestValue = false;
15193
15196
  };
15194
15197
  IfStatement.prototype.render = function (code, options) {
15195
- var testValue = this.test.getValue();
15196
- if (!this.context.treeshake ||
15197
- this.test.included ||
15198
- (testValue ? this.alternate !== null && this.alternate.included : this.consequent.included)) {
15199
- _super.prototype.render.call(this, code, options);
15198
+ // Note that unknown test values are always included
15199
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.test.getValue();
15200
+ if (!this.test.included &&
15201
+ (testValue ? this.alternate === null || !this.alternate.included : !this.consequent.included)) {
15202
+ var singleRetainedBranch = testValue ? this.consequent : this.alternate;
15203
+ code.remove(this.start, singleRetainedBranch.start);
15204
+ code.remove(singleRetainedBranch.end, this.end);
15205
+ singleRetainedBranch.render(code, options);
15200
15206
  }
15201
15207
  else {
15202
- // if test is not included, it is impossible that alternate===null even though it is the retained branch
15203
- var branchToRetain = testValue ? this.consequent : this.alternate;
15204
- code.remove(this.start, branchToRetain.start);
15205
- code.remove(branchToRetain.end, this.end);
15206
- branchToRetain.render(code, options);
15208
+ if (this.test.included) {
15209
+ this.test.render(code, options);
15210
+ }
15211
+ else {
15212
+ code.overwrite(this.test.start, this.test.end, testValue ? 'true' : 'false');
15213
+ }
15214
+ if (this.consequent.included) {
15215
+ this.consequent.render(code, options);
15216
+ }
15217
+ else {
15218
+ code.overwrite(this.consequent.start, this.consequent.end, ';');
15219
+ }
15220
+ if (this.alternate !== null) {
15221
+ if (this.alternate.included) {
15222
+ this.alternate.render(code, options);
15223
+ }
15224
+ else {
15225
+ code.remove(this.consequent.end, this.alternate.end);
15226
+ }
15227
+ }
15207
15228
  }
15208
15229
  };
15209
- IfStatement.prototype.someRelevantBranch = function (predicateFunction) {
15210
- var testValue = this.test.getValue();
15211
- if (testValue === UNKNOWN_VALUE) {
15230
+ IfStatement.prototype.getTestValue = function () {
15231
+ if (this.hasUnknownTestValue)
15232
+ return UNKNOWN_VALUE;
15233
+ var value = this.test.getValue();
15234
+ if (value === UNKNOWN_VALUE) {
15212
15235
  this.hasUnknownTestValue = true;
15213
- return (predicateFunction(this.consequent) ||
15214
- (this.alternate !== null && predicateFunction(this.alternate)));
15215
15236
  }
15216
- return testValue
15217
- ? predicateFunction(this.consequent)
15218
- : this.alternate !== null && predicateFunction(this.alternate);
15237
+ return value;
15219
15238
  };
15220
15239
  return IfStatement;
15221
15240
  }(NodeBase));
@@ -15339,125 +15358,133 @@ var LogicalExpression = /** @class */ (function (_super) {
15339
15358
  return _super !== null && _super.apply(this, arguments) || this;
15340
15359
  }
15341
15360
  LogicalExpression.prototype.forEachReturnExpressionWhenCalledAtPath = function (path$$1, callOptions, callback, options) {
15342
- if (this.hasUnknownLeftValue) {
15361
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15362
+ if (leftValue === UNKNOWN_VALUE) {
15343
15363
  this.left.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
15344
15364
  this.right.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
15345
15365
  }
15366
+ else if (leftValue === (this.operator === '||')) {
15367
+ this.left.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
15368
+ }
15346
15369
  else {
15347
- this.forEachRelevantBranch(function (node) {
15348
- return node.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
15349
- });
15370
+ this.right.forEachReturnExpressionWhenCalledAtPath(path$$1, callOptions, callback, options);
15350
15371
  }
15351
15372
  };
15352
15373
  LogicalExpression.prototype.getValue = function () {
15353
- var leftValue = this.left.getValue();
15374
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15354
15375
  if (leftValue === UNKNOWN_VALUE)
15355
15376
  return UNKNOWN_VALUE;
15356
- if (!leftValue === (this.operator === '&&'))
15377
+ if (leftValue === (this.operator === '||'))
15357
15378
  return leftValue;
15358
15379
  return this.right.getValue();
15359
15380
  };
15360
15381
  LogicalExpression.prototype.hasEffects = function (options) {
15361
15382
  if (this.left.hasEffects(options))
15362
15383
  return true;
15363
- var leftValue = this.left.getValue();
15364
- return ((leftValue === UNKNOWN_VALUE || !leftValue === (this.operator === '||')) &&
15384
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15385
+ return ((leftValue === UNKNOWN_VALUE || leftValue === (this.operator === '&&')) &&
15365
15386
  this.right.hasEffects(options));
15366
15387
  };
15367
15388
  LogicalExpression.prototype.hasEffectsWhenAccessedAtPath = function (path$$1, options) {
15368
- return (path$$1.length > 0 &&
15369
- (this.hasUnknownLeftValue
15370
- ? this.left.hasEffectsWhenAccessedAtPath(path$$1, options) ||
15371
- this.right.hasEffectsWhenAccessedAtPath(path$$1, options)
15372
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAccessedAtPath(path$$1, options); })));
15389
+ if (path$$1.length === 0)
15390
+ return false;
15391
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15392
+ if (leftValue === UNKNOWN_VALUE) {
15393
+ return (this.left.hasEffectsWhenAccessedAtPath(path$$1, options) ||
15394
+ this.right.hasEffectsWhenAccessedAtPath(path$$1, options));
15395
+ }
15396
+ return leftValue === (this.operator === '||')
15397
+ ? this.left.hasEffectsWhenAccessedAtPath(path$$1, options)
15398
+ : this.right.hasEffectsWhenAccessedAtPath(path$$1, options);
15373
15399
  };
15374
15400
  LogicalExpression.prototype.hasEffectsWhenAssignedAtPath = function (path$$1, options) {
15375
- return (path$$1.length === 0 ||
15376
- (this.hasUnknownLeftValue
15377
- ? this.left.hasEffectsWhenAssignedAtPath(path$$1, options) ||
15378
- this.right.hasEffectsWhenAssignedAtPath(path$$1, options)
15379
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAssignedAtPath(path$$1, options); })));
15401
+ if (path$$1.length === 0)
15402
+ return true;
15403
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15404
+ if (leftValue === UNKNOWN_VALUE) {
15405
+ return (this.left.hasEffectsWhenAssignedAtPath(path$$1, options) ||
15406
+ this.right.hasEffectsWhenAssignedAtPath(path$$1, options));
15407
+ }
15408
+ return leftValue === (this.operator === '||')
15409
+ ? this.left.hasEffectsWhenAssignedAtPath(path$$1, options)
15410
+ : this.right.hasEffectsWhenAssignedAtPath(path$$1, options);
15380
15411
  };
15381
15412
  LogicalExpression.prototype.hasEffectsWhenCalledAtPath = function (path$$1, callOptions, options) {
15382
- return this.hasUnknownLeftValue
15383
- ? this.left.hasEffectsWhenCalledAtPath(path$$1, callOptions, options) ||
15384
- this.right.hasEffectsWhenCalledAtPath(path$$1, callOptions, options)
15385
- : this.someRelevantBranch(function (node) {
15386
- return node.hasEffectsWhenCalledAtPath(path$$1, callOptions, options);
15387
- });
15413
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15414
+ if (leftValue === UNKNOWN_VALUE) {
15415
+ return (this.left.hasEffectsWhenCalledAtPath(path$$1, callOptions, options) ||
15416
+ this.right.hasEffectsWhenCalledAtPath(path$$1, callOptions, options));
15417
+ }
15418
+ return leftValue === (this.operator === '||')
15419
+ ? this.left.hasEffectsWhenCalledAtPath(path$$1, callOptions, options)
15420
+ : this.right.hasEffectsWhenCalledAtPath(path$$1, callOptions, options);
15388
15421
  };
15389
15422
  LogicalExpression.prototype.include = function () {
15390
15423
  this.included = true;
15391
- var leftValue = this.left.getValue();
15424
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15392
15425
  if (leftValue === UNKNOWN_VALUE ||
15393
- !leftValue === (this.operator === '&&') ||
15394
- this.left.shouldBeIncluded())
15426
+ leftValue === (this.operator === '||') ||
15427
+ this.left.shouldBeIncluded()) {
15395
15428
  this.left.include();
15396
- if (leftValue === UNKNOWN_VALUE || !leftValue === (this.operator === '||'))
15429
+ }
15430
+ if (leftValue === UNKNOWN_VALUE || leftValue === (this.operator === '&&')) {
15397
15431
  this.right.include();
15432
+ }
15398
15433
  };
15399
15434
  LogicalExpression.prototype.initialise = function () {
15435
+ this.included = false;
15400
15436
  this.hasUnknownLeftValue = false;
15401
15437
  };
15402
15438
  LogicalExpression.prototype.reassignPath = function (path$$1, options) {
15403
15439
  if (path$$1.length > 0) {
15404
- if (this.hasUnknownLeftValue) {
15440
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15441
+ if (leftValue === UNKNOWN_VALUE) {
15405
15442
  this.left.reassignPath(path$$1, options);
15406
15443
  this.right.reassignPath(path$$1, options);
15407
15444
  }
15445
+ else if (leftValue === (this.operator === '||')) {
15446
+ this.left.reassignPath(path$$1, options);
15447
+ }
15408
15448
  else {
15409
- this.forEachRelevantBranch(function (node) { return node.reassignPath(path$$1, options); });
15449
+ this.right.reassignPath(path$$1, options);
15410
15450
  }
15411
15451
  }
15412
15452
  };
15413
15453
  LogicalExpression.prototype.render = function (code, options, _a) {
15414
15454
  var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent;
15415
- if (!this.context.treeshake || (this.left.included && this.right.included)) {
15416
- _super.prototype.render.call(this, code, options);
15417
- }
15418
- else {
15419
- var branchToRetain = this.left.included ? this.left : this.right;
15420
- code.remove(this.start, branchToRetain.start);
15421
- code.remove(branchToRetain.end, this.end);
15422
- branchToRetain.render(code, options, {
15455
+ if (!this.left.included || !this.right.included) {
15456
+ var singleRetainedBranch = this.left.included ? this.left : this.right;
15457
+ code.remove(this.start, singleRetainedBranch.start);
15458
+ code.remove(singleRetainedBranch.end, this.end);
15459
+ singleRetainedBranch.render(code, options, {
15423
15460
  renderedParentType: renderedParentType || this.parent.type,
15424
15461
  isCalleeOfRenderedParent: renderedParentType
15425
15462
  ? isCalleeOfRenderedParent
15426
15463
  : this.parent.callee === this
15427
15464
  });
15428
15465
  }
15466
+ else {
15467
+ _super.prototype.render.call(this, code, options);
15468
+ }
15429
15469
  };
15430
15470
  LogicalExpression.prototype.someReturnExpressionWhenCalledAtPath = function (path$$1, callOptions, predicateFunction, options) {
15431
- return this.hasUnknownLeftValue
15432
- ? this.left.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options) ||
15433
- this.right.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options)
15434
- : this.someRelevantBranch(function (node) {
15435
- return node.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options);
15436
- });
15437
- };
15438
- LogicalExpression.prototype.forEachRelevantBranch = function (callback) {
15439
- var leftValue = this.left.getValue();
15471
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15440
15472
  if (leftValue === UNKNOWN_VALUE) {
15441
- this.hasUnknownLeftValue = true;
15442
- callback(this.left);
15443
- callback(this.right);
15444
- }
15445
- else if (!leftValue === (this.operator === '&&')) {
15446
- callback(this.left);
15447
- }
15448
- else {
15449
- callback(this.right);
15473
+ return (this.left.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options) ||
15474
+ this.right.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options));
15450
15475
  }
15476
+ return leftValue === (this.operator === '||')
15477
+ ? this.left.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options)
15478
+ : this.right.someReturnExpressionWhenCalledAtPath(path$$1, callOptions, predicateFunction, options);
15451
15479
  };
15452
- LogicalExpression.prototype.someRelevantBranch = function (predicateFunction) {
15453
- var leftValue = this.left.getValue();
15454
- if (leftValue === UNKNOWN_VALUE) {
15480
+ LogicalExpression.prototype.getLeftValue = function () {
15481
+ if (this.hasUnknownLeftValue)
15482
+ return UNKNOWN_VALUE;
15483
+ var value = this.left.getValue();
15484
+ if (value === UNKNOWN_VALUE) {
15455
15485
  this.hasUnknownLeftValue = true;
15456
- return predicateFunction(this.left) || predicateFunction(this.right);
15457
15486
  }
15458
- return !leftValue === (this.operator === '&&')
15459
- ? predicateFunction(this.left)
15460
- : predicateFunction(this.right);
15487
+ return value;
15461
15488
  };
15462
15489
  return LogicalExpression;
15463
15490
  }(NodeBase));
@@ -16026,38 +16053,33 @@ var SequenceExpression = /** @class */ (function (_super) {
16026
16053
  };
16027
16054
  SequenceExpression.prototype.render = function (code, options, _a) {
16028
16055
  var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent;
16029
- if (!this.context.treeshake) {
16030
- _super.prototype.render.call(this, code, options);
16031
- }
16032
- else {
16033
- var firstStart = 0, lastEnd = void 0, includedNodes = 0;
16034
- for (var _i = 0, _c = getCommaSeparatedNodesWithBoundaries(this.expressions, code, this.start, this.end); _i < _c.length; _i++) {
16035
- var _d = _c[_i], node = _d.node, start = _d.start, end = _d.end;
16036
- if (!node.included) {
16037
- code.remove(start, end);
16038
- continue;
16039
- }
16040
- includedNodes++;
16041
- if (firstStart === 0)
16042
- firstStart = start;
16043
- lastEnd = end;
16044
- if (node === this.expressions[this.expressions.length - 1] && includedNodes === 1) {
16045
- node.render(code, options, {
16046
- renderedParentType: renderedParentType || this.parent.type,
16047
- isCalleeOfRenderedParent: renderedParentType
16048
- ? isCalleeOfRenderedParent
16049
- : this.parent.callee === this
16050
- });
16051
- }
16052
- else {
16053
- node.render(code, options);
16054
- }
16056
+ var firstStart = 0, lastEnd, includedNodes = 0;
16057
+ for (var _i = 0, _c = getCommaSeparatedNodesWithBoundaries(this.expressions, code, this.start, this.end); _i < _c.length; _i++) {
16058
+ var _d = _c[_i], node = _d.node, start = _d.start, end = _d.end;
16059
+ if (!node.included) {
16060
+ code.remove(start, end);
16061
+ continue;
16055
16062
  }
16056
- // Round brackets are part of the actual parent and should be re-added in case the parent changed
16057
- if (includedNodes > 1 && renderedParentType) {
16058
- code.prependRight(firstStart, '(');
16059
- code.appendLeft(lastEnd, ')');
16063
+ includedNodes++;
16064
+ if (firstStart === 0)
16065
+ firstStart = start;
16066
+ lastEnd = end;
16067
+ if (node === this.expressions[this.expressions.length - 1] && includedNodes === 1) {
16068
+ node.render(code, options, {
16069
+ renderedParentType: renderedParentType || this.parent.type,
16070
+ isCalleeOfRenderedParent: renderedParentType
16071
+ ? isCalleeOfRenderedParent
16072
+ : this.parent.callee === this
16073
+ });
16060
16074
  }
16075
+ else {
16076
+ node.render(code, options);
16077
+ }
16078
+ }
16079
+ // Round brackets are part of the actual parent and should be re-added in case the parent changed
16080
+ if (includedNodes > 1 && renderedParentType) {
16081
+ code.prependRight(firstStart, '(');
16082
+ code.appendLeft(lastEnd, ')');
16061
16083
  }
16062
16084
  };
16063
16085
  return SequenceExpression;
@@ -25299,7 +25321,7 @@ function watch(configs) {
25299
25321
  return new Watcher(configs);
25300
25322
  }
25301
25323
 
25302
- var version$1 = "0.58.1";
25324
+ var version$1 = "0.58.2";
25303
25325
 
25304
25326
  /// <reference path="../typings/package.json.d.ts" />
25305
25327
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "0.58.1",
3
+ "version": "0.58.2",
4
4
  "description": "Next-generation ES6 module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/rollup.es.js",