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