babel-source 5.6.5 → 5.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/babel.js +230 -161
  3. data/lib/babel/source.rb +2 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2MyMDM2NmZiNjMxYzM3MDE4Yzc4ZDE1ZTY0M2M5ZTA5ZDI5Nzc4Mw==
4
+ OTk5MzQzMGY1NTAwZjE0ODc3MjAyZmVkNjc4NDI1ZDVlNjlhNWIzYg==
5
5
  data.tar.gz: !binary |-
6
- OWY1OTI1Y2RmOThkMTliYjlhYjk5MWQ2MDU0NmRmNWZjMmZlYzRkYQ==
6
+ OWFiYTI3MWEwOGY5NGEyYTQ3YzFjNTQwNmI1NGU4ZjdjYmJmYmE3OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjlhZjFkYjJjNDY0NTgyMDdlM2IxODg1YWNjZTQxODUyMDMyNDhlMGQ2MzY2
10
- ODRhYmMxMTczYTNmZGRjOGFkMDE5YWIwZmM3YjllYjQ1NGMzYzU4NmQ0NmEy
11
- OTM5ZDczNDFmM2FlODljMmE5Nzg0OGY3NGFhYjhhODEyNGQyNmE=
9
+ ODljOWQxNWIxMzI2Y2VlNWU5NDc3NDMxNmFhZWQ2OTYzNTU4MGJjNzNmNGQ1
10
+ YWViZDcxMWEzY2VkZmM5ZGEyNjRhMWIwOWYyNjk1ODMxM2QxNTkxOTA5NGEy
11
+ NWEyZGY5ZDQxYTc3YzJmNGYxMmZjNTg0ODIyYjgyZWY4YzQ1YjY=
12
12
  data.tar.gz: !binary |-
13
- ZmIwZGZhMjQyZmIyZWIxNGFlZDUwMzdmM2FjM2NkZjI2ZWNlMGVjNjUyNTNk
14
- YzIyMDU5NzcxZTQxMmQ5MmVmZWMzZTAxNmNiNDAyNDk5ZTAxZmQ2ZTkzZTJj
15
- MTMxNzcyOWRkZGE3NjJkOTljNmVhYjAzOGE0ZjdlM2RjNmVlZDA=
13
+ MGZlZTRhZDllYWM4MWE3MTc2NjVjZjI0NjIyNGFkNTRiMjIyMjNhMGU4NWQ4
14
+ YjI3ZTJmMjNhMjQ2NDI4MWY3ZWQ2Y2ZiMDkyYmRkNDc3Y2U2ZmU4MzY1ZWRj
15
+ MTY2NWM5ODdkNGYzZjE2MTE1MWZlNTMyY2RlMzY1YjQ3OWMxNTI=
data/lib/babel.js CHANGED
@@ -25,6 +25,7 @@ _acornJsxInject2["default"](acorn);
25
25
  },{"./plugins/flow":2,"./src/index":5,"acorn-jsx/inject":177}],2:[function(require,module,exports){
26
26
  "use strict";
27
27
 
28
+ Error.stackTraceLimit = Infinity;
28
29
  var acorn = require("../src/index");
29
30
 
30
31
  var pp = acorn.Parser.prototype;
@@ -68,8 +69,11 @@ pp.flow_parseDeclareFunction = function (node) {
68
69
  typeNode.rest = tmp.rest;
69
70
  this.expect(tt.parenR);
70
71
 
72
+ var oldInType = this.inType;
73
+ this.inType = true;
71
74
  this.expect(tt.colon);
72
75
  typeNode.returnType = this.flow_parseType();
76
+ this.inType = oldInType;
73
77
 
74
78
  typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
75
79
  id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
@@ -379,12 +383,6 @@ pp.flow_parseGenericType = function (start, id) {
379
383
  return this.finishNode(node, "GenericTypeAnnotation");
380
384
  };
381
385
 
382
- pp.flow_parseVoidType = function () {
383
- var node = this.startNode();
384
- this.expect(tt._void);
385
- return this.finishNode(node, "VoidTypeAnnotation");
386
- };
387
-
388
386
  pp.flow_parseTypeofType = function () {
389
387
  var node = this.startNode();
390
388
  this.expect(tt._typeof);
@@ -438,6 +436,9 @@ pp.flow_identToTypeAnnotation = function (start, node, id) {
438
436
  case "any":
439
437
  return this.finishNode(node, "AnyTypeAnnotation");
440
438
 
439
+ case "void":
440
+ return this.finishNode(node, "VoidTypeAnnotation");
441
+
441
442
  case "bool":
442
443
  case "boolean":
443
444
  return this.finishNode(node, "BooleanTypeAnnotation");
@@ -544,14 +545,8 @@ pp.flow_parsePrimaryType = function () {
544
545
  return this.finishNode(node, "StringLiteralTypeAnnotation");
545
546
 
546
547
  default:
547
- if (this.type.keyword) {
548
- switch (this.type.keyword) {
549
- case "void":
550
- return this.flow_parseVoidType();
551
-
552
- case "typeof":
553
- return this.flow_parseTypeofType();
554
- }
548
+ if (this.type.keyword === "typeof") {
549
+ return this.flow_parseTypeofType();
555
550
  }
556
551
  }
557
552
 
@@ -714,6 +709,18 @@ acorn.plugins.flow = function (instance) {
714
709
  };
715
710
  });
716
711
 
712
+ // don't consider `void` to be a keyword as then it'll use the void token type
713
+ // and set startExpr
714
+ instance.extend("isKeyword", function (inner) {
715
+ return function (name) {
716
+ if (this.inType && name === "void") {
717
+ return false;
718
+ } else {
719
+ return inner.call(this, name);
720
+ }
721
+ };
722
+ });
723
+
717
724
  instance.extend("readToken", function (inner) {
718
725
  return function (code) {
719
726
  if (this.inType && (code === 62 || code === 60)) {
@@ -1995,7 +2002,7 @@ var _state = require("./state");
1995
2002
 
1996
2003
  var pp = _state.Parser.prototype;
1997
2004
 
1998
- var STATE_KEYS = ["lastTokStartLoc", "lastTokEndLoc", "lastTokStart", "lastTokEnd", "lineStart", "startLoc", "curLine", "endLoc", "start", "pos", "end", "type", "value", "exprAllowed", "potentialArrowAt", "currLine", "input"];
2005
+ var STATE_KEYS = ["lastTokStartLoc", "lastTokEndLoc", "lastTokStart", "lastTokEnd", "lineStart", "startLoc", "curLine", "endLoc", "start", "pos", "end", "type", "value", "exprAllowed", "potentialArrowAt", "currLine", "input", "inType", "inFunction", "inGenerator", "labels"];
1999
2006
 
2000
2007
  pp.getState = function () {
2001
2008
  var state = {};
@@ -2004,6 +2011,7 @@ pp.getState = function () {
2004
2011
  state[key] = this[key];
2005
2012
  }
2006
2013
  state.context = this.context.slice();
2014
+ state.labels = this.labels.slice();
2007
2015
  return state;
2008
2016
  };
2009
2017
 
@@ -2520,11 +2528,11 @@ var _whitespace = require("./whitespace");
2520
2528
 
2521
2529
  function Parser(options, input, startPos) {
2522
2530
  this.options = options;
2523
- this.loadPlugins(this.options.plugins);
2524
2531
  this.sourceFile = this.options.sourceFile || null;
2525
2532
  this.isKeyword = _identifier.keywords[this.options.ecmaVersion >= 6 ? 6 : 5];
2526
2533
  this.isReservedWord = _identifier.reservedWords[this.options.ecmaVersion];
2527
2534
  this.input = input;
2535
+ this.loadPlugins(this.options.plugins);
2528
2536
 
2529
2537
  // Set up token state
2530
2538
 
@@ -4370,7 +4378,7 @@ kw("case", beforeExpr);
4370
4378
  kw("catch");
4371
4379
  kw("continue");
4372
4380
  kw("debugger");
4373
- kw("default");
4381
+ kw("default", beforeExpr);
4374
4382
  kw("do", { isLoop: true });
4375
4383
  kw("else", beforeExpr);
4376
4384
  kw("finally");
@@ -4771,9 +4779,10 @@ var Buffer = (function () {
4771
4779
  this.space();
4772
4780
  };
4773
4781
 
4774
- Buffer.prototype.space = function space() {
4775
- if (this.format.compact) return;
4776
- if (this.buf && !this.isLast(" ") && !this.isLast("\n")) {
4782
+ Buffer.prototype.space = function space(force) {
4783
+ if (!force && this.format.compact) return;
4784
+
4785
+ if (force || this.buf && !this.isLast(" ") && !this.isLast("\n")) {
4777
4786
  this.push(" ");
4778
4787
  }
4779
4788
  };
@@ -4873,7 +4882,13 @@ var Buffer = (function () {
4873
4882
  };
4874
4883
 
4875
4884
  Buffer.prototype.endsWith = function endsWith(str) {
4876
- return this.buf.slice(-str.length) === str;
4885
+ var buf = arguments[1] === undefined ? this.buf : arguments[1];
4886
+
4887
+ if (str.length === 1) {
4888
+ return buf[buf.length - 1] === str;
4889
+ } else {
4890
+ return buf.slice(-str.length) === str;
4891
+ }
4877
4892
  };
4878
4893
 
4879
4894
  Buffer.prototype.isLast = function isLast(cha) {
@@ -5070,19 +5085,19 @@ var _types = require("../../types");
5070
5085
  var t = _interopRequireWildcard(_types);
5071
5086
 
5072
5087
  function UnaryExpression(node, print) {
5073
- var hasSpace = /[a-z]$/.test(node.operator);
5088
+ var needsSpace = /[a-z]$/.test(node.operator);
5074
5089
  var arg = node.argument;
5075
5090
 
5076
5091
  if (t.isUpdateExpression(arg) || t.isUnaryExpression(arg)) {
5077
- hasSpace = true;
5092
+ needsSpace = true;
5078
5093
  }
5079
5094
 
5080
5095
  if (t.isUnaryExpression(arg) && arg.operator === "!") {
5081
- hasSpace = false;
5096
+ needsSpace = false;
5082
5097
  }
5083
5098
 
5084
5099
  this.push(node.operator);
5085
- if (hasSpace) this.push(" ");
5100
+ if (needsSpace) this.push(" ");
5086
5101
  print.plain(node.argument);
5087
5102
  }
5088
5103
 
@@ -5151,16 +5166,13 @@ function CallExpression(node, print) {
5151
5166
 
5152
5167
  this.push("(");
5153
5168
 
5154
- var separator = ",";
5155
-
5156
- var isPrettyCall = node._prettyCall && !this.format.retainLines;
5169
+ var isPrettyCall = node._prettyCall && !this.format.retainLines && !this.format.compact;
5157
5170
 
5171
+ var separator;
5158
5172
  if (isPrettyCall) {
5159
- separator += "\n";
5173
+ separator = ",\n";
5160
5174
  this.newline();
5161
5175
  this.indent();
5162
- } else {
5163
- separator += " ";
5164
5176
  }
5165
5177
 
5166
5178
  print.list(node.arguments, { separator: separator });
@@ -5212,9 +5224,20 @@ function AssignmentPattern(node, print) {
5212
5224
  function AssignmentExpression(node, print) {
5213
5225
  // todo: add cases where the spaces can be dropped when in compact mode
5214
5226
  print.plain(node.left);
5215
- this.push(" ");
5227
+
5228
+ var spaces = node.operator === "in" || node.operator === "instanceof";
5229
+ this.space(spaces);
5230
+
5216
5231
  this.push(node.operator);
5217
- this.push(" ");
5232
+
5233
+ if (!spaces) {
5234
+ // space is mandatory to avoid outputting <!--
5235
+ // http://javascript.spec.whatwg.org/#comment-syntax
5236
+ spaces = node.operator === "<" && t.isUnaryExpression(node.right, { prefix: true, operator: "!" }) && t.isUnaryExpression(node.right.argument, { prefix: true, operator: "--" });
5237
+ }
5238
+
5239
+ this.space(spaces);
5240
+
5218
5241
  print.plain(node.right);
5219
5242
  }
5220
5243
 
@@ -5687,7 +5710,7 @@ function _method(node, print) {
5687
5710
  }
5688
5711
 
5689
5712
  this._params(value, print);
5690
- this.push(" ");
5713
+ this.space();
5691
5714
  print.plain(value.body);
5692
5715
  }
5693
5716
 
@@ -6107,16 +6130,29 @@ function VariableDeclaration(node, print, parent) {
6107
6130
  }
6108
6131
  }
6109
6132
 
6110
- var sep = ",";
6133
+ //
6134
+ // use a pretty separator when we aren't in compact mode, have initializers and don't have retainLines on
6135
+ // this will format declarations like:
6136
+ //
6137
+ // var foo = "bar", bar = "foo";
6138
+ //
6139
+ // into
6140
+ //
6141
+ // var foo = "bar",
6142
+ // bar = "foo";
6143
+ //
6144
+
6145
+ var sep;
6111
6146
  if (!this.format.compact && !this.format.concise && hasInits && !this.format.retainLines) {
6112
- sep += "\n" + _repeating2["default"](" ", node.kind.length + 1);
6113
- } else {
6114
- sep += " ";
6147
+ sep = ",\n" + _repeating2["default"](" ", node.kind.length + 1);
6115
6148
  }
6116
6149
 
6150
+ //
6151
+
6117
6152
  print.list(node.declarations, { separator: sep });
6118
6153
 
6119
6154
  if (t.isFor(parent)) {
6155
+ // don't give semicolons to these nodes since they'll be inserted in the parent generator
6120
6156
  if (parent.left === node || parent.init === node) return;
6121
6157
  }
6122
6158
 
@@ -6269,7 +6305,7 @@ function ArrayExpression(node, print) {
6269
6305
  // both (all) of the holes.
6270
6306
  this.push(",");
6271
6307
  } else {
6272
- if (i > 0) this.push(" ");
6308
+ if (i > 0) this.space();
6273
6309
  print.plain(elem);
6274
6310
  if (i < len - 1) this.push(",");
6275
6311
  }
@@ -7153,7 +7189,11 @@ var NodePrinter = (function () {
7153
7189
  NodePrinter.prototype.list = function list(items) {
7154
7190
  var opts = arguments[1] === undefined ? {} : arguments[1];
7155
7191
 
7156
- if (opts.separator == null) opts.separator = ", ";
7192
+ if (opts.separator == null) {
7193
+ opts.separator = ",";
7194
+ if (!this.generator.format.compact) opts.separator += " ";
7195
+ }
7196
+
7157
7197
  return this.join(items, opts);
7158
7198
  };
7159
7199
 
@@ -18522,6 +18562,7 @@ function unshiftContext(context) {
18522
18562
  */
18523
18563
 
18524
18564
  function setup(parentPath, container, listKey, key) {
18565
+ this.inList = !!listKey;
18525
18566
  this.listKey = listKey;
18526
18567
  this.parentKey = listKey || key;
18527
18568
  this.container = container;
@@ -19059,6 +19100,7 @@ var NodePath = (function () {
19059
19100
  this.context = null;
19060
19101
  this.container = null;
19061
19102
  this.listKey = null;
19103
+ this.inList = false;
19062
19104
  this.parentKey = null;
19063
19105
  this.key = null;
19064
19106
  this.node = null;
@@ -28681,143 +28723,145 @@ exports["default"] = function (_ref) {
28681
28723
  return node;
28682
28724
  }
28683
28725
 
28684
- return new Plugin("dead-code-elimination", {
28685
- metadata: {
28686
- group: "builtin-pre",
28687
- experimental: true
28688
- },
28726
+ var visitor = {
28727
+ ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope) {
28728
+ var binding = scope.getBinding(node.name);
28729
+ if (!binding || binding.references > 1 || !binding.constant) return;
28730
+ if (binding.kind === "param" || binding.kind === "module") return;
28689
28731
 
28690
- visitor: {
28691
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope) {
28692
- var binding = scope.getBinding(node.name);
28693
- if (!binding || binding.references > 1 || !binding.constant) return;
28694
- if (binding.kind === "param" || binding.kind === "module") return;
28695
-
28696
- var replacement = binding.path.node;
28697
- if (t.isVariableDeclarator(replacement)) {
28698
- replacement = replacement.init;
28699
- }
28700
- if (!replacement) return;
28732
+ var replacement = binding.path.node;
28733
+ if (t.isVariableDeclarator(replacement)) {
28734
+ replacement = replacement.init;
28735
+ }
28736
+ if (!replacement) return;
28701
28737
 
28702
- // ensure it's a "pure" type
28703
- if (!scope.isPure(replacement, true)) return;
28738
+ // ensure it's a "pure" type
28739
+ if (!scope.isPure(replacement, true)) return;
28704
28740
 
28705
- if (t.isClass(replacement) || t.isFunction(replacement)) {
28706
- // don't change this if it's in a different scope, this can be bad
28707
- // for performance since it may be inside a loop or deeply nested in
28708
- // hot code
28709
- if (binding.path.scope.parent !== scope) return;
28710
- }
28741
+ if (t.isClass(replacement) || t.isFunction(replacement)) {
28742
+ // don't change this if it's in a different scope, this can be bad
28743
+ // for performance since it may be inside a loop or deeply nested in
28744
+ // hot code
28745
+ if (binding.path.scope.parent !== scope) return;
28746
+ }
28711
28747
 
28712
- if (this.findParent(function (path) {
28713
- return path.node === replacement;
28714
- })) {
28715
- return;
28716
- }
28748
+ if (this.findParent(function (path) {
28749
+ return path.node === replacement;
28750
+ })) {
28751
+ return;
28752
+ }
28717
28753
 
28718
- t.toExpression(replacement);
28719
- scope.removeBinding(node.name);
28720
- binding.path.dangerouslyRemove();
28721
- return replacement;
28722
- },
28754
+ t.toExpression(replacement);
28755
+ scope.removeBinding(node.name);
28756
+ binding.path.dangerouslyRemove();
28757
+ return replacement;
28758
+ },
28723
28759
 
28724
- "ClassDeclaration|FunctionDeclaration": function ClassDeclarationFunctionDeclaration(node, parent, scope) {
28725
- var binding = scope.getBinding(node.id.name);
28726
- if (binding && !binding.referenced) {
28727
- this.dangerouslyRemove();
28728
- }
28729
- },
28760
+ "ClassDeclaration|FunctionDeclaration": function ClassDeclarationFunctionDeclaration(node, parent, scope) {
28761
+ var binding = scope.getBinding(node.id.name);
28762
+ if (binding && !binding.referenced) {
28763
+ this.dangerouslyRemove();
28764
+ }
28765
+ },
28730
28766
 
28731
- VariableDeclarator: function VariableDeclarator(node, parent, scope) {
28732
- if (!t.isIdentifier(node.id) || !scope.isPure(node.init, true)) return;
28733
- visitor["ClassDeclaration|FunctionDeclaration"].apply(this, arguments);
28734
- },
28767
+ VariableDeclarator: function VariableDeclarator(node, parent, scope) {
28768
+ if (!t.isIdentifier(node.id) || !scope.isPure(node.init, true)) return;
28769
+ visitor["ClassDeclaration|FunctionDeclaration"].apply(this, arguments);
28770
+ },
28735
28771
 
28736
- ConditionalExpression: function ConditionalExpression(node) {
28737
- var evaluateTest = this.get("test").evaluateTruthy();
28738
- if (evaluateTest === true) {
28739
- return node.consequent;
28740
- } else if (evaluateTest === false) {
28741
- return node.alternate;
28742
- }
28743
- },
28772
+ ConditionalExpression: function ConditionalExpression(node) {
28773
+ var evaluateTest = this.get("test").evaluateTruthy();
28774
+ if (evaluateTest === true) {
28775
+ return node.consequent;
28776
+ } else if (evaluateTest === false) {
28777
+ return node.alternate;
28778
+ }
28779
+ },
28744
28780
 
28745
- BlockStatement: function BlockStatement() {
28746
- var paths = this.get("body");
28781
+ BlockStatement: function BlockStatement() {
28782
+ var paths = this.get("body");
28747
28783
 
28748
- var purge = false;
28784
+ var purge = false;
28749
28785
 
28750
- for (var i = 0; i < paths.length; i++) {
28751
- var path = paths[i];
28786
+ for (var i = 0; i < paths.length; i++) {
28787
+ var path = paths[i];
28752
28788
 
28753
- if (!purge && path.isCompletionStatement()) {
28754
- purge = true;
28755
- continue;
28756
- }
28789
+ if (!purge && path.isCompletionStatement()) {
28790
+ purge = true;
28791
+ continue;
28792
+ }
28757
28793
 
28758
- if (purge && !path.isFunctionDeclaration()) {
28759
- path.dangerouslyRemove();
28760
- }
28794
+ if (purge && !path.isFunctionDeclaration()) {
28795
+ path.dangerouslyRemove();
28761
28796
  }
28762
- },
28797
+ }
28798
+ },
28763
28799
 
28764
- IfStatement: {
28765
- exit: function exit(node) {
28766
- var consequent = node.consequent;
28767
- var alternate = node.alternate;
28768
- var test = node.test;
28800
+ IfStatement: {
28801
+ exit: function exit(node) {
28802
+ var consequent = node.consequent;
28803
+ var alternate = node.alternate;
28804
+ var test = node.test;
28769
28805
 
28770
- var evaluateTest = this.get("test").evaluateTruthy();
28806
+ var evaluateTest = this.get("test").evaluateTruthy();
28771
28807
 
28772
- // we can check if a test will be truthy 100% and if so then we can inline
28773
- // the consequent and completely ignore the alternate
28774
- //
28775
- // if (true) { foo; } -> { foo; }
28776
- // if ("foo") { foo; } -> { foo; }
28777
- //
28808
+ // we can check if a test will be truthy 100% and if so then we can inline
28809
+ // the consequent and completely ignore the alternate
28810
+ //
28811
+ // if (true) { foo; } -> { foo; }
28812
+ // if ("foo") { foo; } -> { foo; }
28813
+ //
28778
28814
 
28779
- if (evaluateTest === true) {
28780
- return toStatements(consequent);
28781
- }
28815
+ if (evaluateTest === true) {
28816
+ return toStatements(consequent);
28817
+ }
28782
28818
 
28783
- // we can check if a test will be falsy 100% and if so we can inline the
28784
- // alternate if there is one and completely remove the consequent
28785
- //
28786
- // if ("") { bar; } else { foo; } -> { foo; }
28787
- // if ("") { bar; } ->
28788
- //
28819
+ // we can check if a test will be falsy 100% and if so we can inline the
28820
+ // alternate if there is one and completely remove the consequent
28821
+ //
28822
+ // if ("") { bar; } else { foo; } -> { foo; }
28823
+ // if ("") { bar; } ->
28824
+ //
28789
28825
 
28790
- if (evaluateTest === false) {
28791
- if (alternate) {
28792
- return toStatements(alternate);
28793
- } else {
28794
- return this.dangerouslyRemove();
28795
- }
28826
+ if (evaluateTest === false) {
28827
+ if (alternate) {
28828
+ return toStatements(alternate);
28829
+ } else {
28830
+ return this.dangerouslyRemove();
28796
28831
  }
28832
+ }
28797
28833
 
28798
- // remove alternate blocks that are empty
28799
- //
28800
- // if (foo) { foo; } else {} -> if (foo) { foo; }
28801
- //
28834
+ // remove alternate blocks that are empty
28835
+ //
28836
+ // if (foo) { foo; } else {} -> if (foo) { foo; }
28837
+ //
28802
28838
 
28803
- if (t.isBlockStatement(alternate) && !alternate.body.length) {
28804
- alternate = node.alternate = null;
28805
- }
28839
+ if (t.isBlockStatement(alternate) && !alternate.body.length) {
28840
+ alternate = node.alternate = null;
28841
+ }
28806
28842
 
28807
- // if the consequent block is empty turn alternate blocks into a consequent
28808
- // and flip the test
28809
- //
28810
- // if (foo) {} else { bar; } -> if (!foo) { bar; }
28811
- //
28843
+ // if the consequent block is empty turn alternate blocks into a consequent
28844
+ // and flip the test
28845
+ //
28846
+ // if (foo) {} else { bar; } -> if (!foo) { bar; }
28847
+ //
28812
28848
 
28813
- if (t.isBlockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
28814
- node.consequent = node.alternate;
28815
- node.alternate = null;
28816
- node.test = t.unaryExpression("!", test, true);
28817
- }
28849
+ if (t.isBlockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
28850
+ node.consequent = node.alternate;
28851
+ node.alternate = null;
28852
+ node.test = t.unaryExpression("!", test, true);
28818
28853
  }
28819
28854
  }
28820
28855
  }
28856
+ };
28857
+
28858
+ return new Plugin("dead-code-elimination", {
28859
+ metadata: {
28860
+ group: "builtin-pre",
28861
+ experimental: true
28862
+ },
28863
+
28864
+ visitor: visitor
28821
28865
  });
28822
28866
  };
28823
28867
 
@@ -53551,12 +53595,17 @@ var defaults = {
53551
53595
  // If you want esprima not to throw exceptions when it encounters
53552
53596
  // non-fatal errors, keep this option true.
53553
53597
  tolerant: true,
53554
-
53598
+
53555
53599
  // If you want to override the quotes used in string literals, specify
53556
- // either "single", "double", or "auto" here ("auto" will select the one
53600
+ // either "single", "double", or "auto" here ("auto" will select the one
53557
53601
  // which results in the shorter literal)
53558
53602
  // Otherwise, the input marks will be preserved
53559
53603
  quote: null,
53604
+
53605
+ // If you want to print trailing commas in object literals,
53606
+ // array expressions, functions calls and function definitions pass true
53607
+ // for this option.
53608
+ trailingComma: false,
53560
53609
  }, hasOwn = defaults.hasOwnProperty;
53561
53610
 
53562
53611
  // Copy options and fill in default values.
@@ -53582,6 +53631,7 @@ exports.normalize = function(options) {
53582
53631
  range: get("range"),
53583
53632
  tolerant: get("tolerant"),
53584
53633
  quote: get("quote"),
53634
+ trailingComma: get("trailingComma"),
53585
53635
  };
53586
53636
  };
53587
53637
 
@@ -54684,7 +54734,6 @@ function genericPrintNoParens(path, options, print) {
54684
54734
  fields.forEach(function(field) {
54685
54735
  path.map(function(childPath) {
54686
54736
  var i = childPath.getName();
54687
- var prop = childPath.getValue();
54688
54737
  var lines = print(childPath);
54689
54738
 
54690
54739
  if (!oneLine) {
@@ -54706,6 +54755,8 @@ function genericPrintNoParens(path, options, print) {
54706
54755
  allowBreak = !multiLine;
54707
54756
  } else if (len !== 1 && isTypeAnnotation) {
54708
54757
  parts.push(separator);
54758
+ } else if (options.trailingComma) {
54759
+ parts.push(separator);
54709
54760
  }
54710
54761
  }, field);
54711
54762
  });
@@ -54740,8 +54791,12 @@ function genericPrintNoParens(path, options, print) {
54740
54791
  case "ArrayExpression":
54741
54792
  case "ArrayPattern":
54742
54793
  var elems = n.elements,
54743
- len = elems.length,
54744
- parts = ["["];
54794
+ len = elems.length;
54795
+
54796
+ var printed = path.map(print, "elements");
54797
+ var joined = fromString(", ").join(printed);
54798
+ var oneLine = joined.getLineLength(1) <= options.wrapColumn;
54799
+ var parts = [oneLine ? "[" : "[\n"];
54745
54800
 
54746
54801
  path.each(function(elemPath) {
54747
54802
  var i = elemPath.getName();
@@ -54754,11 +54809,18 @@ function genericPrintNoParens(path, options, print) {
54754
54809
  // both (all) of the holes.
54755
54810
  parts.push(",");
54756
54811
  } else {
54757
- if (i > 0)
54758
- parts.push(" ");
54759
- parts.push(print(elemPath));
54760
- if (i < len - 1)
54812
+ var lines = printed[i];
54813
+ if (oneLine) {
54814
+ if (i > 0)
54815
+ parts.push(" ");
54816
+ } else {
54817
+ lines = lines.indent(options.tabWidth);
54818
+ }
54819
+ parts.push(lines);
54820
+ if (i < len - 1 || (!oneLine && options.trailingComma))
54761
54821
  parts.push(",");
54822
+ if (!oneLine)
54823
+ parts.push("\n");
54762
54824
  }
54763
54825
  }, "elements");
54764
54826
 
@@ -55654,7 +55716,11 @@ function printArgumentsList(path, options, print) {
55654
55716
  var joined = fromString(", ").join(printed);
55655
55717
  if (joined.getLineLength(1) > options.wrapColumn) {
55656
55718
  joined = fromString(",\n").join(printed);
55657
- return concat(["(\n", joined.indent(options.tabWidth), "\n)"]);
55719
+ return concat([
55720
+ "(\n",
55721
+ joined.indent(options.tabWidth),
55722
+ options.trailingComma ? ",\n)" : "\n)"
55723
+ ]);
55658
55724
  }
55659
55725
 
55660
55726
  return concat(["(", joined, ")"]);
@@ -55684,6 +55750,9 @@ function printFunctionParams(path, options, print) {
55684
55750
  if (joined.length > 1 ||
55685
55751
  joined.getLineLength(1) > options.wrapColumn) {
55686
55752
  joined = fromString(",\n").join(printed);
55753
+ if (options.trailingComma && !fun.rest) {
55754
+ joined = concat([joined, ",\n"]);
55755
+ }
55687
55756
  return concat(["\n", joined.indent(options.tabWidth)]);
55688
55757
  }
55689
55758
 
@@ -62923,7 +62992,7 @@ module.exports = function (str) {
62923
62992
  module.exports={
62924
62993
  "name": "babel-core",
62925
62994
  "description": "A compiler for writing next generation JavaScript",
62926
- "version": "5.6.5",
62995
+ "version": "5.6.6",
62927
62996
  "author": "Sebastian McKenzie <sebmck@gmail.com>",
62928
62997
  "homepage": "https://babeljs.io/",
62929
62998
  "license": "MIT",
@@ -62953,7 +63022,7 @@ module.exports={
62953
63022
  "acorn-jsx": "^1.0.0",
62954
63023
  "ast-types": "~0.7.0",
62955
63024
  "babel-plugin-constant-folding": "^1.0.1",
62956
- "babel-plugin-dead-code-elimination": "^1.0.1",
63025
+ "babel-plugin-dead-code-elimination": "^1.0.2",
62957
63026
  "babel-plugin-eval": "^1.0.1",
62958
63027
  "babel-plugin-inline-environment-variables": "^1.0.1",
62959
63028
  "babel-plugin-jscript": "^1.0.1",
data/lib/babel/source.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Babel
2
2
  module Source
3
- VERSION = "5.6.5"
4
- DATE = Time.at(1435150074)
3
+ VERSION = "5.6.6"
4
+ DATE = Time.at(1435184864)
5
5
  PATH = File.expand_path("../..", __FILE__)
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babel-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.5
4
+ version: 5.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian McKenzie