babel-source 5.0.6 → 5.0.7

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 +75 -65
  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
- NzEwNDY1YWQ5N2I0ZjM5Y2QwNjg0MjQwY2RjNWQyZGZkY2Q5YjJlMw==
4
+ YjRlYzhkN2I3N2YxY2NmZmY2ZWI0ZmQxNjRjODU2OTFhOTVlYWVjOQ==
5
5
  data.tar.gz: !binary |-
6
- MGU5YjcyMmNmM2NlMmI3YzAzNGFhYTU3MDNjYzAxZmVlNWZhZjlhZQ==
6
+ OGFlM2QxYmVkOTMyZWQxYzIzMmIzMGUyZTExMGRlYzczM2QyODVkMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODBjNjk3NDcwODdkZjZhMmFkZDY4YjNhOWMxMTg3YmQ5Mzc2Nzg1NGRkYThh
10
- ZThjNGU1Mjc3NTQzY2Y4MGI1N2E2MzVjNTgyMWUwZTM2OTc4NmRjMzEyZDAx
11
- NTgxYjY5MzYxZGMzNWY3Y2YwYWIzZjEzNTI5M2VmYTY5YjU0MDM=
9
+ MjljNTQwZjY4MjJmZDRlM2RkYWE2ZmNlZTY1ZGVhNTAyNDhhMzI0MGQ4YzBj
10
+ MDRiMWZjMzg1ZGMxNDBiYThiMjUwMTlmNTdjZDJhYjk3NDc5YTlmY2UzMDkz
11
+ ZGJhNDU4N2VhNWIyZmRkYWYxNTkzYjYzODBlYzdjOGY4OGRkNGY=
12
12
  data.tar.gz: !binary |-
13
- M2QxYjY2NTUxZWFlZTk3MTg3NzVjMTgzZGVkMmY1ZWI2NTI3YTgzOGFmNDkz
14
- NjdlMTI3ZjUyOThmMDYwYzdmNzcwMjUxZDI3MDY3Y2U5MWU3ZGM4ZGY0OGZi
15
- MTA4ZGFiMzE5MzU3NDI4N2JlZjBhZWQ5ZWEzOGU2MWE3Njk2NGY=
13
+ YWM4ZWY1M2RjYTAzM2E4YzZjMmNkYjNmOGUwNGViN2M2ZTBmYjBkNWY0NDNi
14
+ OTFhZGI4Y2MxODA3NzcyYjJhZGViODlmZGYzN2EzNmEzYTU5MzE2YjVkZmNm
15
+ MWIxZTU4MGU4YTYyODBhYmYxYmUzYjI1MzhlZDU1OWE0YTBmYzg=
data/lib/babel.js CHANGED
@@ -8590,23 +8590,7 @@ var File = (function () {
8590
8590
 
8591
8591
  File.prototype.shouldIgnore = function shouldIgnore() {
8592
8592
  var opts = this.opts;
8593
-
8594
- var filename = opts.filename;
8595
- var ignore = opts.ignore;
8596
- var only = opts.only;
8597
-
8598
- if (only.length) {
8599
- for (var i = 0; i < only.length; i++) {
8600
- if (only[i].test(filename)) return false;
8601
- }
8602
- return true;
8603
- } else if (ignore.length) {
8604
- for (var i = 0; i < ignore.length; i++) {
8605
- if (ignore[i].test(filename)) return true;
8606
- }
8607
- }
8608
-
8609
- return false;
8593
+ return util.shouldIgnore(opts.filename, opts.ignore, opts.only);
8610
8594
  };
8611
8595
 
8612
8596
  File.prototype.parse = (function (_parse) {
@@ -10435,7 +10419,6 @@ var importsVisitor = {
10435
10419
  enter: function enter(node, parent, scope, formatter) {
10436
10420
  formatter.hasLocalImports = true;
10437
10421
  extend(formatter.localImports, this.getBindingIdentifiers());
10438
- formatter.bumpImportOccurences(node);
10439
10422
  }
10440
10423
  }
10441
10424
  };
@@ -10443,7 +10426,7 @@ var importsVisitor = {
10443
10426
  var exportsVisitor = traverse.explode({
10444
10427
  ExportDeclaration: {
10445
10428
  enter: function enter(node, parent, scope, formatter) {
10446
- formatter.hasLocalImports = true;
10429
+ formatter.hasLocalExports = true;
10447
10430
 
10448
10431
  var declar = this.get("declaration");
10449
10432
  if (declar.isStatement()) {
@@ -10470,10 +10453,6 @@ var exportsVisitor = traverse.explode({
10470
10453
  formatter.hasNonDefaultExports = true;
10471
10454
  }
10472
10455
  }
10473
-
10474
- if (node.source) {
10475
- formatter.bumpImportOccurences(node);
10476
- }
10477
10456
  }
10478
10457
  }
10479
10458
  });
@@ -10493,7 +10472,6 @@ var DefaultFormatter = (function () {
10493
10472
  this.hasLocalExports = false;
10494
10473
  this.hasLocalImports = false;
10495
10474
 
10496
- this.localImportOccurences = object();
10497
10475
  this.localExports = object();
10498
10476
  this.localImports = object();
10499
10477
 
@@ -10509,18 +10487,6 @@ var DefaultFormatter = (function () {
10509
10487
  return (t.isExportDefaultDeclaration(node) || t.isSpecifierDefault(node)) && !this.noInteropRequireExport && !this.hasNonDefaultExports;
10510
10488
  };
10511
10489
 
10512
- DefaultFormatter.prototype.bumpImportOccurences = function bumpImportOccurences(node) {
10513
- var source = node.source.value;
10514
- var occurs = this.localImportOccurences;
10515
- var _occurs = occurs;
10516
- var _source = source;
10517
- if (!_occurs[_source]) _occurs[_source] = 0;
10518
-
10519
- if (node.specifiers) {
10520
- occurs[source] += node.specifiers.length;
10521
- }
10522
- };
10523
-
10524
10490
  DefaultFormatter.prototype.getLocalExports = function getLocalExports() {
10525
10491
  this.file.path.traverse(exportsVisitor, this);
10526
10492
  };
@@ -10530,7 +10496,7 @@ var DefaultFormatter = (function () {
10530
10496
  };
10531
10497
 
10532
10498
  DefaultFormatter.prototype.remapAssignments = function remapAssignments() {
10533
- if (this.hasLocalImports) {
10499
+ if (this.hasLocalExports || this.hasLocalImports) {
10534
10500
  this.file.path.traverse(remapVisitor, this);
10535
10501
  }
10536
10502
  };
@@ -10781,8 +10747,6 @@ var t = _interopRequireWildcard(require("../../types"));
10781
10747
 
10782
10748
  var AMDFormatter = (function (_DefaultFormatter) {
10783
10749
  function AMDFormatter() {
10784
- this.init = CommonFormatter.prototype.init;
10785
-
10786
10750
  _classCallCheck(this, AMDFormatter);
10787
10751
 
10788
10752
  if (_DefaultFormatter != null) {
@@ -10792,6 +10756,10 @@ var AMDFormatter = (function (_DefaultFormatter) {
10792
10756
 
10793
10757
  _inherits(AMDFormatter, _DefaultFormatter);
10794
10758
 
10759
+ AMDFormatter.prototype.init = function init() {
10760
+ CommonFormatter.prototype._init.call(this, this.hasNonDefaultExports);
10761
+ };
10762
+
10795
10763
  AMDFormatter.prototype.buildDependencyLiterals = function buildDependencyLiterals() {
10796
10764
  var names = [];
10797
10765
  for (var name in this.ids) {
@@ -10880,16 +10848,35 @@ var AMDFormatter = (function (_DefaultFormatter) {
10880
10848
  this.internalRemap[specifier.local.name] = ref;
10881
10849
  };
10882
10850
 
10883
- AMDFormatter.prototype.exportSpecifier = function exportSpecifier() {
10884
- CommonFormatter.prototype.exportSpecifier.apply(this, arguments);
10851
+ AMDFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
10852
+ if (this.doDefaultExportInterop(specifier)) {
10853
+ nodes.push(util.template("exports-default-assign", {
10854
+ VALUE: specifier.local
10855
+ }, true));
10856
+ } else {
10857
+ CommonFormatter.prototype.exportSpecifier.apply(this, arguments);
10858
+ }
10885
10859
  };
10886
10860
 
10887
- AMDFormatter.prototype.exportDeclaration = function exportDeclaration(node) {
10861
+ AMDFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
10888
10862
  if (this.doDefaultExportInterop(node)) {
10889
10863
  this.passModuleArg = true;
10864
+
10865
+ var declar = node.declaration;
10866
+ var assign = util.template("exports-default-assign", {
10867
+ VALUE: this._pushStatement(declar, nodes)
10868
+ }, true);
10869
+
10870
+ if (t.isFunctionDeclaration(declar)) {
10871
+ // we can hoist this assignment to the top of the file
10872
+ assign._blockHoist = 3;
10873
+ }
10874
+
10875
+ nodes.push(assign);
10876
+ return;
10890
10877
  }
10891
10878
 
10892
- CommonFormatter.prototype.exportDeclaration.apply(this, arguments);
10879
+ DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);
10893
10880
  };
10894
10881
 
10895
10882
  return AMDFormatter;
@@ -10939,13 +10926,17 @@ var CommonJSFormatter = (function (_DefaultFormatter) {
10939
10926
  _inherits(CommonJSFormatter, _DefaultFormatter);
10940
10927
 
10941
10928
  CommonJSFormatter.prototype.init = function init() {
10929
+ this._init(this.hasLocalExports);
10930
+ };
10931
+
10932
+ CommonJSFormatter.prototype._init = function _init(conditional) {
10942
10933
  var file = this.file;
10943
10934
  var scope = file.scope;
10944
10935
 
10945
10936
  scope.rename("module");
10946
10937
  scope.rename("exports");
10947
10938
 
10948
- if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
10939
+ if (!this.noInteropRequireImport && conditional) {
10949
10940
  var templateName = "exports-module-declaration";
10950
10941
  if (this.file.isLoose("es6.modules")) templateName += "-loose";
10951
10942
  var declar = util.template(templateName, true);
@@ -10954,6 +10945,14 @@ var CommonJSFormatter = (function (_DefaultFormatter) {
10954
10945
  }
10955
10946
  };
10956
10947
 
10948
+ CommonJSFormatter.prototype.transform = function transform(program) {
10949
+ DefaultFormatter.prototype.transform.apply(this, arguments);
10950
+
10951
+ if (this.hasDefaultOnlyExport) {
10952
+ program.body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("module"), t.identifier("exports")), t.memberExpression(t.identifier("exports"), t.identifier("default")))));
10953
+ }
10954
+ };
10955
+
10957
10956
  CommonJSFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
10958
10957
  var variableName = specifier.local;
10959
10958
 
@@ -10967,7 +10966,11 @@ var CommonJSFormatter = (function (_DefaultFormatter) {
10967
10966
  if (this.noInteropRequireImport) {
10968
10967
  this.internalRemap[variableName.name] = t.memberExpression(ref, t.identifier("default"));
10969
10968
  } else if (!includes(this.file.dynamicImported, node)) {
10970
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, t.callExpression(this.file.addHelper("interop-require"), [ref]))]));
10969
+ var uid = this.scope.generateUidBasedOnNode(node, "import");
10970
+
10971
+ nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]))]));
10972
+
10973
+ this.internalRemap[variableName.name] = t.memberExpression(uid, t.identifier("default"));
10971
10974
  }
10972
10975
  }
10973
10976
  } else {
@@ -10994,29 +10997,15 @@ var CommonJSFormatter = (function (_DefaultFormatter) {
10994
10997
 
10995
10998
  CommonJSFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
10996
10999
  if (this.doDefaultExportInterop(specifier)) {
10997
- nodes.push(util.template("exports-default-assign", {
10998
- VALUE: specifier.local
10999
- }, true));
11000
- return;
11001
- } else {
11002
- DefaultFormatter.prototype.exportSpecifier.apply(this, arguments);
11000
+ this.hasDefaultOnlyExport = true;
11003
11001
  }
11002
+
11003
+ DefaultFormatter.prototype.exportSpecifier.apply(this, arguments);
11004
11004
  };
11005
11005
 
11006
11006
  CommonJSFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
11007
11007
  if (this.doDefaultExportInterop(node)) {
11008
- var declar = node.declaration;
11009
- var assign = util.template("exports-default-assign", {
11010
- VALUE: this._pushStatement(declar, nodes)
11011
- }, true);
11012
-
11013
- if (t.isFunctionDeclaration(declar)) {
11014
- // we can hoist this assignment to the top of the file
11015
- assign._blockHoist = 3;
11016
- }
11017
-
11018
- nodes.push(assign);
11019
- return;
11008
+ this.hasDefaultOnlyExport = true;
11020
11009
  }
11021
11010
 
11022
11011
  DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);
@@ -17993,6 +17982,9 @@ var TraversalPath = (function () {
17993
17982
  var binding = this.scope.getBinding(this.node.name);
17994
17983
  if (!binding || !binding.constant) return;
17995
17984
 
17985
+ // todo: take into consideration infinite recursion #1149
17986
+ return;
17987
+
17996
17988
  if (binding.path === this) {
17997
17989
  return this;
17998
17990
  } else {
@@ -20386,6 +20378,7 @@ exports.list = list;
20386
20378
  exports.regexify = regexify;
20387
20379
  exports.arrayify = arrayify;
20388
20380
  exports.booleanify = booleanify;
20381
+ exports.shouldIgnore = shouldIgnore;
20389
20382
 
20390
20383
  //
20391
20384
 
@@ -20475,8 +20468,10 @@ function list(val) {
20475
20468
  return [];
20476
20469
  } else if (Array.isArray(val)) {
20477
20470
  return val;
20478
- } else {
20471
+ } else if (typeof val === "string") {
20479
20472
  return val.split(",");
20473
+ } else {
20474
+ return [val];
20480
20475
  }
20481
20476
  }
20482
20477
 
@@ -20507,6 +20502,21 @@ function booleanify(val) {
20507
20502
  return val;
20508
20503
  }
20509
20504
 
20505
+ function shouldIgnore(filename, ignore, only) {
20506
+ if (only.length) {
20507
+ for (var i = 0; i < only.length; i++) {
20508
+ if (only[i].test(filename)) return false;
20509
+ }
20510
+ return true;
20511
+ } else if (ignore.length) {
20512
+ for (var i = 0; i < ignore.length; i++) {
20513
+ if (ignore[i].test(filename)) return true;
20514
+ }
20515
+ }
20516
+
20517
+ return false;
20518
+ }
20519
+
20510
20520
  var templateVisitor = {
20511
20521
  enter: function enter(node, parent, scope, nodes) {
20512
20522
  if (t.isExpressionStatement(node)) {
@@ -49731,7 +49741,7 @@ module.exports = function (str) {
49731
49741
  module.exports={
49732
49742
  "name": "babel-core",
49733
49743
  "description": "Turn ES6 code into readable vanilla ES5 with source maps",
49734
- "version": "5.0.6",
49744
+ "version": "5.0.7",
49735
49745
  "author": "Sebastian McKenzie <sebmck@gmail.com>",
49736
49746
  "homepage": "https://babeljs.io/",
49737
49747
  "repository": "babel/babel",
data/lib/babel/source.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Babel
2
2
  module Source
3
- VERSION = "5.0.6"
4
- DATE = Time.at(1428063223)
3
+ VERSION = "5.0.7"
4
+ DATE = Time.at(1428083371)
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.0.6
4
+ version: 5.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian McKenzie