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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # rollup changelog
2
2
 
3
+ ## 0.58.2
4
+ *2018-04-23*
5
+ * Fix rendering of certain statically resolvable if statements ([#2146](https://github.com/rollup/rollup/pull/2146))
6
+
3
7
  ## 0.58.1
4
8
  *2018-04-18*
5
9
  * Fix comment detection ([#2129](https://github.com/rollup/rollup/pull/2129))
package/bin/rollup CHANGED
@@ -252,7 +252,7 @@ function isNumber (x) {
252
252
 
253
253
  var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-v, --version Show version number\n-h, --help Show this help message\n-c, --config Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-w, --watch Watch files in bundle and rebuild on changes\n-i, --input Input (alternative to <entry file>)\n-o, --file <output> Output (if absent, prints to stdout)\n-f, --format [es] Type of output (amd, cjs, es, iife, umd)\n-e, --external Comma-separate list of module IDs to exclude\n-g, --globals Comma-separate list of `module ID:Global` pairs\n Any module IDs defined here are added to external\n-n, --name Name for UMD export\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-l, --legacy Support IE8\n--amd.id ID for AMD module (default is anonymous)\n--amd.define Function to use in place of `define`\n--no-strict Don't emit a `\"use strict\";` in the generated modules.\n--no-indent Don't indent result\n--environment <values> Settings passed to config file (see example)\n--no-conflict Generate a noConflict method for UMD globals\n--no-treeshake Disable tree-shaking\n--silent Don't print warnings\n--intro Content to insert at top of bundle (inside wrapper)\n--outro Content to insert at end of bundle (inside wrapper)\n--banner Content to insert at top of bundle (outside wrapper)\n--footer Content to insert at end of bundle (outside wrapper)\n--no-interop Do not include interop block\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
254
254
 
255
- var version = "0.58.1";
255
+ var version = "0.58.2";
256
256
 
257
257
  var modules = {};
258
258
 
@@ -1777,10 +1777,6 @@ function supportsColor(stream) {
1777
1777
  }
1778
1778
 
1779
1779
  if (stream && !stream.isTTY && forceColor !== true) {
1780
- // VS code debugger doesn't have isTTY set
1781
- if (env.VSCODE_PID) {
1782
- return 1;
1783
- }
1784
1780
  return 0;
1785
1781
  }
1786
1782
 
@@ -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
@@ -14863,49 +14863,62 @@
14863
14863
  return _super !== null && _super.apply(this, arguments) || this;
14864
14864
  }
14865
14865
  ConditionalExpression.prototype.forEachReturnExpressionWhenCalledAtPath = function (path, callOptions, callback, options) {
14866
- if (this.hasUnknownTestValue) {
14866
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14867
+ if (testValue === UNKNOWN_VALUE || testValue) {
14867
14868
  this.consequent.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
14868
- this.alternate.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
14869
14869
  }
14870
- else {
14871
- this.forEachRelevantBranch(function (node) {
14872
- return node.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
14873
- });
14870
+ if (testValue === UNKNOWN_VALUE || !testValue) {
14871
+ this.alternate.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
14874
14872
  }
14875
14873
  };
14876
14874
  ConditionalExpression.prototype.getValue = function () {
14877
- var testValue = this.test.getValue();
14875
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14878
14876
  if (testValue === UNKNOWN_VALUE)
14879
14877
  return UNKNOWN_VALUE;
14880
14878
  return testValue ? this.consequent.getValue() : this.alternate.getValue();
14881
14879
  };
14882
14880
  ConditionalExpression.prototype.hasEffects = function (options) {
14883
- return (this.test.hasEffects(options) ||
14884
- (this.hasUnknownTestValue
14885
- ? this.consequent.hasEffects(options) || this.alternate.hasEffects(options)
14886
- : this.someRelevantBranch(function (node) { return node.hasEffects(options); })));
14881
+ if (this.test.hasEffects(options))
14882
+ return true;
14883
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14884
+ if (testValue === UNKNOWN_VALUE) {
14885
+ return this.consequent.hasEffects(options) || this.alternate.hasEffects(options);
14886
+ }
14887
+ return testValue ? this.consequent.hasEffects(options) : this.alternate.hasEffects(options);
14887
14888
  };
14888
14889
  ConditionalExpression.prototype.hasEffectsWhenAccessedAtPath = function (path, options) {
14889
- return (path.length > 0 &&
14890
- (this.hasUnknownTestValue
14891
- ? this.consequent.hasEffectsWhenAccessedAtPath(path, options) ||
14892
- this.alternate.hasEffectsWhenAccessedAtPath(path, options)
14893
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAccessedAtPath(path, options); })));
14890
+ if (path.length === 0)
14891
+ return false;
14892
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14893
+ if (testValue === UNKNOWN_VALUE) {
14894
+ return (this.consequent.hasEffectsWhenAccessedAtPath(path, options) ||
14895
+ this.alternate.hasEffectsWhenAccessedAtPath(path, options));
14896
+ }
14897
+ return testValue
14898
+ ? this.consequent.hasEffectsWhenAccessedAtPath(path, options)
14899
+ : this.alternate.hasEffectsWhenAccessedAtPath(path, options);
14894
14900
  };
14895
14901
  ConditionalExpression.prototype.hasEffectsWhenAssignedAtPath = function (path, options) {
14896
- return (path.length === 0 ||
14897
- (this.hasUnknownTestValue
14898
- ? this.consequent.hasEffectsWhenAssignedAtPath(path, options) ||
14899
- this.alternate.hasEffectsWhenAssignedAtPath(path, options)
14900
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAssignedAtPath(path, options); })));
14902
+ if (path.length === 0)
14903
+ return true;
14904
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14905
+ if (testValue === UNKNOWN_VALUE) {
14906
+ return (this.consequent.hasEffectsWhenAssignedAtPath(path, options) ||
14907
+ this.alternate.hasEffectsWhenAssignedAtPath(path, options));
14908
+ }
14909
+ return testValue
14910
+ ? this.consequent.hasEffectsWhenAssignedAtPath(path, options)
14911
+ : this.alternate.hasEffectsWhenAssignedAtPath(path, options);
14901
14912
  };
14902
14913
  ConditionalExpression.prototype.hasEffectsWhenCalledAtPath = function (path, callOptions, options) {
14903
- return this.hasUnknownTestValue
14904
- ? this.consequent.hasEffectsWhenCalledAtPath(path, callOptions, options) ||
14905
- this.alternate.hasEffectsWhenCalledAtPath(path, callOptions, options)
14906
- : this.someRelevantBranch(function (node) {
14907
- return node.hasEffectsWhenCalledAtPath(path, callOptions, options);
14908
- });
14914
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14915
+ if (testValue === UNKNOWN_VALUE) {
14916
+ return (this.consequent.hasEffectsWhenCalledAtPath(path, callOptions, options) ||
14917
+ this.alternate.hasEffectsWhenCalledAtPath(path, callOptions, options));
14918
+ }
14919
+ return testValue
14920
+ ? this.consequent.hasEffectsWhenCalledAtPath(path, callOptions, options)
14921
+ : this.alternate.hasEffectsWhenCalledAtPath(path, callOptions, options);
14909
14922
  };
14910
14923
  ConditionalExpression.prototype.initialise = function () {
14911
14924
  this.included = false;
@@ -14913,7 +14926,7 @@
14913
14926
  };
14914
14927
  ConditionalExpression.prototype.include = function () {
14915
14928
  this.included = true;
14916
- var testValue = this.test.getValue();
14929
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14917
14930
  if (testValue === UNKNOWN_VALUE || this.test.shouldBeIncluded()) {
14918
14931
  this.test.include();
14919
14932
  this.consequent.include();
@@ -14928,61 +14941,50 @@
14928
14941
  };
14929
14942
  ConditionalExpression.prototype.reassignPath = function (path, options) {
14930
14943
  if (path.length > 0) {
14931
- if (this.hasUnknownTestValue) {
14944
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14945
+ if (testValue === UNKNOWN_VALUE || testValue) {
14932
14946
  this.consequent.reassignPath(path, options);
14933
- this.alternate.reassignPath(path, options);
14934
14947
  }
14935
- else {
14936
- this.forEachRelevantBranch(function (node) { return node.reassignPath(path, options); });
14948
+ if (testValue === UNKNOWN_VALUE || !testValue) {
14949
+ this.alternate.reassignPath(path, options);
14937
14950
  }
14938
14951
  }
14939
14952
  };
14940
14953
  ConditionalExpression.prototype.render = function (code, options, _a) {
14941
14954
  var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent;
14942
- if (!this.context.treeshake || this.test.included) {
14943
- _super.prototype.render.call(this, code, options);
14944
- }
14945
- else {
14946
- var branchToRetain = this.consequent.included ? this.consequent : this.alternate;
14947
- code.remove(this.start, branchToRetain.start);
14948
- code.remove(branchToRetain.end, this.end);
14949
- branchToRetain.render(code, options, {
14955
+ if (!this.test.included) {
14956
+ var singleRetainedBranch = this.consequent.included ? this.consequent : this.alternate;
14957
+ code.remove(this.start, singleRetainedBranch.start);
14958
+ code.remove(singleRetainedBranch.end, this.end);
14959
+ singleRetainedBranch.render(code, options, {
14950
14960
  renderedParentType: renderedParentType || this.parent.type,
14951
14961
  isCalleeOfRenderedParent: renderedParentType
14952
14962
  ? isCalleeOfRenderedParent
14953
14963
  : this.parent.callee === this
14954
14964
  });
14955
14965
  }
14966
+ else {
14967
+ _super.prototype.render.call(this, code, options);
14968
+ }
14956
14969
  };
14957
14970
  ConditionalExpression.prototype.someReturnExpressionWhenCalledAtPath = function (path, callOptions, predicateFunction, options) {
14958
- return this.hasUnknownTestValue
14959
- ? this.consequent.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options) ||
14960
- this.alternate.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options)
14961
- : this.someRelevantBranch(function (node) {
14962
- return node.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options);
14963
- });
14964
- };
14965
- ConditionalExpression.prototype.forEachRelevantBranch = function (callback) {
14966
- var testValue = this.test.getValue();
14971
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
14967
14972
  if (testValue === UNKNOWN_VALUE) {
14968
- this.hasUnknownTestValue = true;
14969
- callback(this.consequent);
14970
- callback(this.alternate);
14971
- }
14972
- else if (testValue) {
14973
- callback(this.consequent);
14974
- }
14975
- else {
14976
- callback(this.alternate);
14973
+ return (this.consequent.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options) ||
14974
+ this.alternate.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options));
14977
14975
  }
14976
+ return testValue
14977
+ ? this.consequent.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options)
14978
+ : this.alternate.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options);
14978
14979
  };
14979
- ConditionalExpression.prototype.someRelevantBranch = function (predicateFunction) {
14980
- var testValue = this.test.getValue();
14981
- if (testValue === UNKNOWN_VALUE) {
14980
+ ConditionalExpression.prototype.getTestValue = function () {
14981
+ if (this.hasUnknownTestValue)
14982
+ return UNKNOWN_VALUE;
14983
+ var value = this.test.getValue();
14984
+ if (value === UNKNOWN_VALUE) {
14982
14985
  this.hasUnknownTestValue = true;
14983
- return predicateFunction(this.consequent) || predicateFunction(this.alternate);
14984
14986
  }
14985
- return testValue ? predicateFunction(this.consequent) : predicateFunction(this.alternate);
14987
+ return value;
14986
14988
  };
14987
14989
  return ConditionalExpression;
14988
14990
  }(NodeBase));
@@ -15190,27 +15192,28 @@
15190
15192
  return _super !== null && _super.apply(this, arguments) || this;
15191
15193
  }
15192
15194
  IfStatement.prototype.hasEffects = function (options) {
15193
- return (this.test.hasEffects(options) ||
15194
- (this.hasUnknownTestValue
15195
- ? this.consequent.hasEffects(options) ||
15196
- (this.alternate !== null && this.alternate.hasEffects(options))
15197
- : this.someRelevantBranch(function (node) { return node.hasEffects(options); })));
15195
+ if (this.test.hasEffects(options))
15196
+ return true;
15197
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
15198
+ if (testValue === UNKNOWN_VALUE) {
15199
+ return (this.consequent.hasEffects(options) ||
15200
+ (this.alternate !== null && this.alternate.hasEffects(options)));
15201
+ }
15202
+ return testValue
15203
+ ? this.consequent.hasEffects(options)
15204
+ : this.alternate !== null && this.alternate.hasEffects(options);
15198
15205
  };
15199
15206
  IfStatement.prototype.include = function () {
15200
15207
  this.included = true;
15201
- var testValue = this.test.getValue();
15208
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.getTestValue();
15202
15209
  if (testValue === UNKNOWN_VALUE || this.test.shouldBeIncluded()) {
15203
15210
  this.test.include();
15204
15211
  }
15205
- if (testValue === UNKNOWN_VALUE) {
15212
+ if ((testValue === UNKNOWN_VALUE || testValue) && this.consequent.shouldBeIncluded()) {
15206
15213
  this.consequent.include();
15207
- if (this.alternate !== null)
15208
- this.alternate.include();
15209
15214
  }
15210
- else if (testValue) {
15211
- this.consequent.include();
15212
- }
15213
- else if (this.alternate !== null) {
15215
+ if (this.alternate !== null &&
15216
+ ((testValue === UNKNOWN_VALUE || !testValue) && this.alternate.shouldBeIncluded())) {
15214
15217
  this.alternate.include();
15215
15218
  }
15216
15219
  };
@@ -15219,30 +15222,46 @@
15219
15222
  this.hasUnknownTestValue = false;
15220
15223
  };
15221
15224
  IfStatement.prototype.render = function (code, options) {
15222
- var testValue = this.test.getValue();
15223
- if (!this.context.treeshake ||
15224
- this.test.included ||
15225
- (testValue ? this.alternate !== null && this.alternate.included : this.consequent.included)) {
15226
- _super.prototype.render.call(this, code, options);
15225
+ // Note that unknown test values are always included
15226
+ var testValue = this.hasUnknownTestValue ? UNKNOWN_VALUE : this.test.getValue();
15227
+ if (!this.test.included &&
15228
+ (testValue ? this.alternate === null || !this.alternate.included : !this.consequent.included)) {
15229
+ var singleRetainedBranch = testValue ? this.consequent : this.alternate;
15230
+ code.remove(this.start, singleRetainedBranch.start);
15231
+ code.remove(singleRetainedBranch.end, this.end);
15232
+ singleRetainedBranch.render(code, options);
15227
15233
  }
15228
15234
  else {
15229
- // if test is not included, it is impossible that alternate===null even though it is the retained branch
15230
- var branchToRetain = testValue ? this.consequent : this.alternate;
15231
- code.remove(this.start, branchToRetain.start);
15232
- code.remove(branchToRetain.end, this.end);
15233
- branchToRetain.render(code, options);
15235
+ if (this.test.included) {
15236
+ this.test.render(code, options);
15237
+ }
15238
+ else {
15239
+ code.overwrite(this.test.start, this.test.end, testValue ? 'true' : 'false');
15240
+ }
15241
+ if (this.consequent.included) {
15242
+ this.consequent.render(code, options);
15243
+ }
15244
+ else {
15245
+ code.overwrite(this.consequent.start, this.consequent.end, ';');
15246
+ }
15247
+ if (this.alternate !== null) {
15248
+ if (this.alternate.included) {
15249
+ this.alternate.render(code, options);
15250
+ }
15251
+ else {
15252
+ code.remove(this.consequent.end, this.alternate.end);
15253
+ }
15254
+ }
15234
15255
  }
15235
15256
  };
15236
- IfStatement.prototype.someRelevantBranch = function (predicateFunction) {
15237
- var testValue = this.test.getValue();
15238
- if (testValue === UNKNOWN_VALUE) {
15257
+ IfStatement.prototype.getTestValue = function () {
15258
+ if (this.hasUnknownTestValue)
15259
+ return UNKNOWN_VALUE;
15260
+ var value = this.test.getValue();
15261
+ if (value === UNKNOWN_VALUE) {
15239
15262
  this.hasUnknownTestValue = true;
15240
- return (predicateFunction(this.consequent) ||
15241
- (this.alternate !== null && predicateFunction(this.alternate)));
15242
15263
  }
15243
- return testValue
15244
- ? predicateFunction(this.consequent)
15245
- : this.alternate !== null && predicateFunction(this.alternate);
15264
+ return value;
15246
15265
  };
15247
15266
  return IfStatement;
15248
15267
  }(NodeBase));
@@ -15366,125 +15385,133 @@
15366
15385
  return _super !== null && _super.apply(this, arguments) || this;
15367
15386
  }
15368
15387
  LogicalExpression.prototype.forEachReturnExpressionWhenCalledAtPath = function (path, callOptions, callback, options) {
15369
- if (this.hasUnknownLeftValue) {
15388
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15389
+ if (leftValue === UNKNOWN_VALUE) {
15370
15390
  this.left.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
15371
15391
  this.right.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
15372
15392
  }
15393
+ else if (leftValue === (this.operator === '||')) {
15394
+ this.left.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
15395
+ }
15373
15396
  else {
15374
- this.forEachRelevantBranch(function (node) {
15375
- return node.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
15376
- });
15397
+ this.right.forEachReturnExpressionWhenCalledAtPath(path, callOptions, callback, options);
15377
15398
  }
15378
15399
  };
15379
15400
  LogicalExpression.prototype.getValue = function () {
15380
- var leftValue = this.left.getValue();
15401
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15381
15402
  if (leftValue === UNKNOWN_VALUE)
15382
15403
  return UNKNOWN_VALUE;
15383
- if (!leftValue === (this.operator === '&&'))
15404
+ if (leftValue === (this.operator === '||'))
15384
15405
  return leftValue;
15385
15406
  return this.right.getValue();
15386
15407
  };
15387
15408
  LogicalExpression.prototype.hasEffects = function (options) {
15388
15409
  if (this.left.hasEffects(options))
15389
15410
  return true;
15390
- var leftValue = this.left.getValue();
15391
- return ((leftValue === UNKNOWN_VALUE || !leftValue === (this.operator === '||')) &&
15411
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15412
+ return ((leftValue === UNKNOWN_VALUE || leftValue === (this.operator === '&&')) &&
15392
15413
  this.right.hasEffects(options));
15393
15414
  };
15394
15415
  LogicalExpression.prototype.hasEffectsWhenAccessedAtPath = function (path, options) {
15395
- return (path.length > 0 &&
15396
- (this.hasUnknownLeftValue
15397
- ? this.left.hasEffectsWhenAccessedAtPath(path, options) ||
15398
- this.right.hasEffectsWhenAccessedAtPath(path, options)
15399
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAccessedAtPath(path, options); })));
15416
+ if (path.length === 0)
15417
+ return false;
15418
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15419
+ if (leftValue === UNKNOWN_VALUE) {
15420
+ return (this.left.hasEffectsWhenAccessedAtPath(path, options) ||
15421
+ this.right.hasEffectsWhenAccessedAtPath(path, options));
15422
+ }
15423
+ return leftValue === (this.operator === '||')
15424
+ ? this.left.hasEffectsWhenAccessedAtPath(path, options)
15425
+ : this.right.hasEffectsWhenAccessedAtPath(path, options);
15400
15426
  };
15401
15427
  LogicalExpression.prototype.hasEffectsWhenAssignedAtPath = function (path, options) {
15402
- return (path.length === 0 ||
15403
- (this.hasUnknownLeftValue
15404
- ? this.left.hasEffectsWhenAssignedAtPath(path, options) ||
15405
- this.right.hasEffectsWhenAssignedAtPath(path, options)
15406
- : this.someRelevantBranch(function (node) { return node.hasEffectsWhenAssignedAtPath(path, options); })));
15428
+ if (path.length === 0)
15429
+ return true;
15430
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15431
+ if (leftValue === UNKNOWN_VALUE) {
15432
+ return (this.left.hasEffectsWhenAssignedAtPath(path, options) ||
15433
+ this.right.hasEffectsWhenAssignedAtPath(path, options));
15434
+ }
15435
+ return leftValue === (this.operator === '||')
15436
+ ? this.left.hasEffectsWhenAssignedAtPath(path, options)
15437
+ : this.right.hasEffectsWhenAssignedAtPath(path, options);
15407
15438
  };
15408
15439
  LogicalExpression.prototype.hasEffectsWhenCalledAtPath = function (path, callOptions, options) {
15409
- return this.hasUnknownLeftValue
15410
- ? this.left.hasEffectsWhenCalledAtPath(path, callOptions, options) ||
15411
- this.right.hasEffectsWhenCalledAtPath(path, callOptions, options)
15412
- : this.someRelevantBranch(function (node) {
15413
- return node.hasEffectsWhenCalledAtPath(path, callOptions, options);
15414
- });
15440
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15441
+ if (leftValue === UNKNOWN_VALUE) {
15442
+ return (this.left.hasEffectsWhenCalledAtPath(path, callOptions, options) ||
15443
+ this.right.hasEffectsWhenCalledAtPath(path, callOptions, options));
15444
+ }
15445
+ return leftValue === (this.operator === '||')
15446
+ ? this.left.hasEffectsWhenCalledAtPath(path, callOptions, options)
15447
+ : this.right.hasEffectsWhenCalledAtPath(path, callOptions, options);
15415
15448
  };
15416
15449
  LogicalExpression.prototype.include = function () {
15417
15450
  this.included = true;
15418
- var leftValue = this.left.getValue();
15451
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15419
15452
  if (leftValue === UNKNOWN_VALUE ||
15420
- !leftValue === (this.operator === '&&') ||
15421
- this.left.shouldBeIncluded())
15453
+ leftValue === (this.operator === '||') ||
15454
+ this.left.shouldBeIncluded()) {
15422
15455
  this.left.include();
15423
- if (leftValue === UNKNOWN_VALUE || !leftValue === (this.operator === '||'))
15456
+ }
15457
+ if (leftValue === UNKNOWN_VALUE || leftValue === (this.operator === '&&')) {
15424
15458
  this.right.include();
15459
+ }
15425
15460
  };
15426
15461
  LogicalExpression.prototype.initialise = function () {
15462
+ this.included = false;
15427
15463
  this.hasUnknownLeftValue = false;
15428
15464
  };
15429
15465
  LogicalExpression.prototype.reassignPath = function (path, options) {
15430
15466
  if (path.length > 0) {
15431
- if (this.hasUnknownLeftValue) {
15467
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15468
+ if (leftValue === UNKNOWN_VALUE) {
15432
15469
  this.left.reassignPath(path, options);
15433
15470
  this.right.reassignPath(path, options);
15434
15471
  }
15472
+ else if (leftValue === (this.operator === '||')) {
15473
+ this.left.reassignPath(path, options);
15474
+ }
15435
15475
  else {
15436
- this.forEachRelevantBranch(function (node) { return node.reassignPath(path, options); });
15476
+ this.right.reassignPath(path, options);
15437
15477
  }
15438
15478
  }
15439
15479
  };
15440
15480
  LogicalExpression.prototype.render = function (code, options, _a) {
15441
15481
  var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent;
15442
- if (!this.context.treeshake || (this.left.included && this.right.included)) {
15443
- _super.prototype.render.call(this, code, options);
15444
- }
15445
- else {
15446
- var branchToRetain = this.left.included ? this.left : this.right;
15447
- code.remove(this.start, branchToRetain.start);
15448
- code.remove(branchToRetain.end, this.end);
15449
- branchToRetain.render(code, options, {
15482
+ if (!this.left.included || !this.right.included) {
15483
+ var singleRetainedBranch = this.left.included ? this.left : this.right;
15484
+ code.remove(this.start, singleRetainedBranch.start);
15485
+ code.remove(singleRetainedBranch.end, this.end);
15486
+ singleRetainedBranch.render(code, options, {
15450
15487
  renderedParentType: renderedParentType || this.parent.type,
15451
15488
  isCalleeOfRenderedParent: renderedParentType
15452
15489
  ? isCalleeOfRenderedParent
15453
15490
  : this.parent.callee === this
15454
15491
  });
15455
15492
  }
15493
+ else {
15494
+ _super.prototype.render.call(this, code, options);
15495
+ }
15456
15496
  };
15457
15497
  LogicalExpression.prototype.someReturnExpressionWhenCalledAtPath = function (path, callOptions, predicateFunction, options) {
15458
- return this.hasUnknownLeftValue
15459
- ? this.left.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options) ||
15460
- this.right.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options)
15461
- : this.someRelevantBranch(function (node) {
15462
- return node.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options);
15463
- });
15464
- };
15465
- LogicalExpression.prototype.forEachRelevantBranch = function (callback) {
15466
- var leftValue = this.left.getValue();
15498
+ var leftValue = this.hasUnknownLeftValue ? UNKNOWN_VALUE : this.getLeftValue();
15467
15499
  if (leftValue === UNKNOWN_VALUE) {
15468
- this.hasUnknownLeftValue = true;
15469
- callback(this.left);
15470
- callback(this.right);
15471
- }
15472
- else if (!leftValue === (this.operator === '&&')) {
15473
- callback(this.left);
15474
- }
15475
- else {
15476
- callback(this.right);
15500
+ return (this.left.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options) ||
15501
+ this.right.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options));
15477
15502
  }
15503
+ return leftValue === (this.operator === '||')
15504
+ ? this.left.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options)
15505
+ : this.right.someReturnExpressionWhenCalledAtPath(path, callOptions, predicateFunction, options);
15478
15506
  };
15479
- LogicalExpression.prototype.someRelevantBranch = function (predicateFunction) {
15480
- var leftValue = this.left.getValue();
15481
- if (leftValue === UNKNOWN_VALUE) {
15507
+ LogicalExpression.prototype.getLeftValue = function () {
15508
+ if (this.hasUnknownLeftValue)
15509
+ return UNKNOWN_VALUE;
15510
+ var value = this.left.getValue();
15511
+ if (value === UNKNOWN_VALUE) {
15482
15512
  this.hasUnknownLeftValue = true;
15483
- return predicateFunction(this.left) || predicateFunction(this.right);
15484
15513
  }
15485
- return !leftValue === (this.operator === '&&')
15486
- ? predicateFunction(this.left)
15487
- : predicateFunction(this.right);
15514
+ return value;
15488
15515
  };
15489
15516
  return LogicalExpression;
15490
15517
  }(NodeBase));
@@ -16053,38 +16080,33 @@
16053
16080
  };
16054
16081
  SequenceExpression.prototype.render = function (code, options, _a) {
16055
16082
  var _b = _a === void 0 ? BLANK : _a, renderedParentType = _b.renderedParentType, isCalleeOfRenderedParent = _b.isCalleeOfRenderedParent;
16056
- if (!this.context.treeshake) {
16057
- _super.prototype.render.call(this, code, options);
16058
- }
16059
- else {
16060
- var firstStart = 0, lastEnd = void 0, includedNodes = 0;
16061
- for (var _i = 0, _c = getCommaSeparatedNodesWithBoundaries(this.expressions, code, this.start, this.end); _i < _c.length; _i++) {
16062
- var _d = _c[_i], node = _d.node, start = _d.start, end = _d.end;
16063
- if (!node.included) {
16064
- code.remove(start, end);
16065
- continue;
16066
- }
16067
- includedNodes++;
16068
- if (firstStart === 0)
16069
- firstStart = start;
16070
- lastEnd = end;
16071
- if (node === this.expressions[this.expressions.length - 1] && includedNodes === 1) {
16072
- node.render(code, options, {
16073
- renderedParentType: renderedParentType || this.parent.type,
16074
- isCalleeOfRenderedParent: renderedParentType
16075
- ? isCalleeOfRenderedParent
16076
- : this.parent.callee === this
16077
- });
16078
- }
16079
- else {
16080
- node.render(code, options);
16081
- }
16083
+ var firstStart = 0, lastEnd, includedNodes = 0;
16084
+ for (var _i = 0, _c = getCommaSeparatedNodesWithBoundaries(this.expressions, code, this.start, this.end); _i < _c.length; _i++) {
16085
+ var _d = _c[_i], node = _d.node, start = _d.start, end = _d.end;
16086
+ if (!node.included) {
16087
+ code.remove(start, end);
16088
+ continue;
16082
16089
  }
16083
- // Round brackets are part of the actual parent and should be re-added in case the parent changed
16084
- if (includedNodes > 1 && renderedParentType) {
16085
- code.prependRight(firstStart, '(');
16086
- code.appendLeft(lastEnd, ')');
16090
+ includedNodes++;
16091
+ if (firstStart === 0)
16092
+ firstStart = start;
16093
+ lastEnd = end;
16094
+ if (node === this.expressions[this.expressions.length - 1] && includedNodes === 1) {
16095
+ node.render(code, options, {
16096
+ renderedParentType: renderedParentType || this.parent.type,
16097
+ isCalleeOfRenderedParent: renderedParentType
16098
+ ? isCalleeOfRenderedParent
16099
+ : this.parent.callee === this
16100
+ });
16087
16101
  }
16102
+ else {
16103
+ node.render(code, options);
16104
+ }
16105
+ }
16106
+ // Round brackets are part of the actual parent and should be re-added in case the parent changed
16107
+ if (includedNodes > 1 && renderedParentType) {
16108
+ code.prependRight(firstStart, '(');
16109
+ code.appendLeft(lastEnd, ')');
16088
16110
  }
16089
16111
  };
16090
16112
  return SequenceExpression;
@@ -21241,7 +21263,7 @@
21241
21263
  return outputOptions;
21242
21264
  }
21243
21265
 
21244
- var version$1 = "0.58.1";
21266
+ var version$1 = "0.58.2";
21245
21267
 
21246
21268
  exports.rollup = rollup;
21247
21269
  exports.VERSION = version$1;