diff --git a/lib/babel/generation/buffer.js b/lib/babel/generation/buffer.js index 67ea4fdc63..a061718d16 100644 --- a/lib/babel/generation/buffer.js +++ b/lib/babel/generation/buffer.js @@ -86,7 +86,7 @@ Buffer.prototype.newline = function (i, removeLast) { if (isNumber(i)) { i = Math.min(2, i); - if (this.endsWith("{\n")) i--; + if (this.endsWith("{\n") || this.endsWith(":\n")) i--; if (i <= 0) return; while (i > 0) { diff --git a/lib/babel/generation/generators/statements.js b/lib/babel/generation/generators/statements.js index f9a75d656e..fe0cf18e71 100644 --- a/lib/babel/generation/generators/statements.js +++ b/lib/babel/generation/generators/statements.js @@ -149,6 +149,7 @@ exports.SwitchStatement = function (node, print) { this.space(); this.push("{"); print.sequence(node.cases, { indent: true }); + this.removeLast("\n"); this.push("}"); }; @@ -161,8 +162,10 @@ exports.SwitchCase = function (node, print) { this.push("default:"); } - this.newline(); - print.sequence(node.consequent, { indent: true }); + if (node.consequent.length) { + this.newline(); + print.sequence(node.consequent, { indent: true }); + } }; exports.DebuggerStatement = function () { diff --git a/lib/babel/generation/node/whitespace.js b/lib/babel/generation/node/whitespace.js index e0362d5144..ae09727259 100644 --- a/lib/babel/generation/node/whitespace.js +++ b/lib/babel/generation/node/whitespace.js @@ -5,23 +5,51 @@ var each = require("lodash/collection/each"); var map = require("lodash/collection/map"); var t = require("../../types"); -var shouldWhitespace = function (node) { - if (t.isFunction(node)) { - return true; - } else if (t.isAssignmentExpression(node)) { - return shouldWhitespace(node.right); - } else if (t.isBinary(node)) { - return shouldWhitespace(node.left) || shouldWhitespace(node.right); +var crawl = function (node, state) { + state = state || {}; + + if (t.isMemberExpression(node)) { + crawl(node.object, state); + if (node.computed) crawl(node.property, state); + } else if (t.isBinary(node) || t.isAssignmentExpression(node)) { + crawl(node.left, state); + crawl(node.right, state); + } else if (t.isCallExpression(node)) { + state.hasCall = true; + crawl(node.callee, state); + } else if (t.isFunction(node)) { + state.hasFunction = true; + } else if (t.isIdentifier(node)) { + state.hasHelper = state.hasHelper || isHelper(node.callee); } - return false; + return state; +}; + +var isHelper = function (node) { + if (t.isMemberExpression(node)) { + return isHelper(node.object) || isHelper(node.property); + } else if (t.isIdentifier(node)) { + return node.name === "require" || node.name[0] === "_"; + } else if (t.isCallExpression(node)) { + return isHelper(node.callee); + } else if (t.isBinary(node) || t.isAssignmentExpression(node)) { + return (t.isIdentifier(node.left) && isHelper(node.left)) || isHelper(node.right); + } else { + return false; + } +}; + +var isType = function (node) { + return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node); }; exports.nodes = { AssignmentExpression: function (node) { - if (shouldWhitespace(node.right)) { + var state = crawl(node.right); + if ((state.hasCall && state.hasHelper) || state.hasFunction) { return { - before: true, + before: state.hasFunction, after: true }; } @@ -52,7 +80,7 @@ exports.nodes = { }, CallExpression: function (node) { - if (t.isFunction(node.callee)) { + if (t.isFunction(node.callee) || isHelper(node)) { return { before: true, after: true @@ -63,14 +91,29 @@ exports.nodes = { VariableDeclaration: function (node) { for (var i = 0; i < node.declarations.length; i++) { var declar = node.declarations[i]; - var init = declar.init; - if (!t.isIdentifier(init) && shouldWhitespace(init)) { + + var enabled = isHelper(declar.id) && !isType(declar.init); + if (!enabled) { + var state = crawl(declar.init); + enabled = (isHelper(declar.init) && state.hasCall) || state.hasFunction; + } + + if (enabled) { return { before: true, after: true }; } } + }, + + IfStatement: function (node) { + if (t.isBlockStatement(node.consequent)) { + return { + before: true, + after: true + }; + } } }; @@ -103,8 +146,7 @@ each({ Loop: true, LabeledStatement: true, SwitchStatement: true, - TryStatement: true, - IfStatement: true + TryStatement: true }, function (amounts, type) { if (isBoolean(amounts)) { amounts = { after: amounts, before: amounts }; diff --git a/test/fixtures/generation/comments/2-space-multi-comment-with-space/expected.js b/test/fixtures/generation/comments/2-space-multi-comment-with-space/expected.js index aa61a9c8fe..ae61df36f1 100644 --- a/test/fixtures/generation/comments/2-space-multi-comment-with-space/expected.js +++ b/test/fixtures/generation/comments/2-space-multi-comment-with-space/expected.js @@ -1,10 +1,7 @@ function test() { - - /* * this is comment */ - var i = 20; } diff --git a/test/fixtures/generation/comments/simple-a-lot-of-line-comment/expected.js b/test/fixtures/generation/comments/simple-a-lot-of-line-comment/expected.js index 9dc22c7c8a..47869b2606 100644 --- a/test/fixtures/generation/comments/simple-a-lot-of-line-comment/expected.js +++ b/test/fixtures/generation/comments/simple-a-lot-of-line-comment/expected.js @@ -20,11 +20,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - function test() {} - - // Copyright (C) 2012 Yusuke Suzuki // // Redistribution and use in source and binary forms, with or without diff --git a/test/fixtures/transformation/es6-arrow-functions/arguments/expected.js b/test/fixtures/transformation/es6-arrow-functions/arguments/expected.js index 99d0d2a083..05f7b209cf 100644 --- a/test/fixtures/transformation/es6-arrow-functions/arguments/expected.js +++ b/test/fixtures/transformation/es6-arrow-functions/arguments/expected.js @@ -2,6 +2,7 @@ function one() { var _arguments = arguments; + var inner = function () { return _arguments; }; @@ -11,12 +12,14 @@ one(1, 2); function two() { var _arguments = arguments; + var inner = function () { return _arguments; }; var another = function another() { var _arguments2 = arguments; + var inner2 = function () { return _arguments2; }; @@ -28,6 +31,7 @@ two(1, 2); function three() { var _arguments = arguments; + var fn = function () { return _arguments[0] + "bar"; }; @@ -37,6 +41,7 @@ three("foo"); function four() { var _arguments = arguments; + var fn = function () { return _arguments[0].foo + "bar"; }; diff --git a/test/fixtures/transformation/es6-arrow-functions/default-parameters/expected.js b/test/fixtures/transformation/es6-arrow-functions/default-parameters/expected.js index 19d93a94d6..f857152487 100644 --- a/test/fixtures/transformation/es6-arrow-functions/default-parameters/expected.js +++ b/test/fixtures/transformation/es6-arrow-functions/default-parameters/expected.js @@ -2,6 +2,7 @@ var some = function () { var count = arguments[0] === undefined ? "30" : arguments[0]; + console.log("count", count); }; diff --git a/test/fixtures/transformation/es6-arrow-functions/nested/expected.js b/test/fixtures/transformation/es6-arrow-functions/nested/expected.js index 1e6a139baa..81937d4cb6 100644 --- a/test/fixtures/transformation/es6-arrow-functions/nested/expected.js +++ b/test/fixtures/transformation/es6-arrow-functions/nested/expected.js @@ -3,6 +3,7 @@ module.exports = { init: function init() { var _this = this; + return new Promise(function (resolve, reject) { MongoClient.connect(config.mongodb, function (err, db) { if (err) { diff --git a/test/fixtures/transformation/es6-arrow-functions/this/expected.js b/test/fixtures/transformation/es6-arrow-functions/this/expected.js index 358e3710a3..0a976c0686 100644 --- a/test/fixtures/transformation/es6-arrow-functions/this/expected.js +++ b/test/fixtures/transformation/es6-arrow-functions/this/expected.js @@ -2,6 +2,7 @@ function b() { var _this = this; + var t = function (x) { return _this.x + x; }; diff --git a/test/fixtures/transformation/es6-block-scoping/hoisting/expected.js b/test/fixtures/transformation/es6-block-scoping/hoisting/expected.js index a868d5a90b..341a1f61a0 100644 --- a/test/fixtures/transformation/es6-block-scoping/hoisting/expected.js +++ b/test/fixtures/transformation/es6-block-scoping/hoisting/expected.js @@ -2,9 +2,11 @@ for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var x; + (function () { var i = _step.value; x = 5; + fns.push(function () { return i * x; }); diff --git a/test/fixtures/transformation/es6-classes-loose/accessing-super-class/expected.js b/test/fixtures/transformation/es6-classes-loose/accessing-super-class/expected.js index 0af6c4445f..a02029f0be 100644 --- a/test/fixtures/transformation/es6-classes-loose/accessing-super-class/expected.js +++ b/test/fixtures/transformation/es6-classes-loose/accessing-super-class/expected.js @@ -1,6 +1,7 @@ "use strict"; var _slice = Array.prototype.slice; + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; @@ -8,6 +9,7 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instance var Test = (function (Foo) { function Test() { var _Foo$prototype$test, _Foo$prototype$test2; + _classCallCheck(this, Test); woops["super"].test(); @@ -25,6 +27,7 @@ var Test = (function (Foo) { Test.prototype.test = function test() { var _Foo$prototype$test, _Foo$prototype$test2; + Foo.prototype.test.call(this); (_Foo$prototype$test = Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments))); (_Foo$prototype$test2 = Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments))); @@ -32,10 +35,11 @@ var Test = (function (Foo) { Test.foo = function foo() { var _Foo$foo, _Foo$foo2; + Foo.foo.call(this); (_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments))); (_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments))); }; return Test; -})(Foo); \ No newline at end of file +})(Foo); diff --git a/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js b/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js index a8f74b0cb7..ab0c291252 100644 --- a/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js +++ b/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js @@ -1,6 +1,7 @@ "use strict"; var _slice = Array.prototype.slice; + var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; @@ -12,6 +13,7 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instance var Test = (function (Foo) { function Test() { var _get2, _get3; + _classCallCheck(this, Test); woops["super"].test(); @@ -31,6 +33,7 @@ var Test = (function (Foo) { foo: { value: function foo() { var _get2; + _get(Object.getPrototypeOf(Test), "foo", this).call(this); _get(Object.getPrototypeOf(Test), "foo", this).apply(this, arguments); (_get2 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get2, [this, "test"].concat(_slice.call(arguments))); @@ -42,6 +45,7 @@ var Test = (function (Foo) { test: { value: function test() { var _get2; + _get(Object.getPrototypeOf(Test.prototype), "test", this).call(this); _get(Object.getPrototypeOf(Test.prototype), "test", this).apply(this, arguments); (_get2 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get2, [this, "test"].concat(_slice.call(arguments))); @@ -52,4 +56,4 @@ var Test = (function (Foo) { }); return Test; -})(Foo); \ No newline at end of file +})(Foo); diff --git a/test/fixtures/transformation/es6-constants/destructuring/expected.js b/test/fixtures/transformation/es6-constants/destructuring/expected.js index 567fea8be6..aa1d464e48 100644 --- a/test/fixtures/transformation/es6-constants/destructuring/expected.js +++ b/test/fixtures/transformation/es6-constants/destructuring/expected.js @@ -1,18 +1,12 @@ "use strict"; -var _ref = [1, 2]; - -var a = _ref[0]; -var b = _ref[1]; -var _ref2 = [3, 4]; - -var c = _ref2[0]; -var d = _ref2[1]; -var _ref3 = { e: 5, f: 6 }; - -var e = _ref3.e; -var f = _ref3.f; -var _ref4 = { a: 7, b: 8 }; - -var g = _ref4.a; -var h = _ref4.b; +var a = 1; +var b = 2; +var c = 3; +var d = 4; +var _ref = { e: 5, f: 6 }; +var e = _ref.e; +var f = _ref.f; +var _ref2 = { a: 7, b: 8 }; +var g = _ref2.a; +var h = _ref2.b; diff --git a/test/fixtures/transformation/es6-destructuring/array-unpack-optimisation/expected.js b/test/fixtures/transformation/es6-destructuring/array-unpack-optimisation/expected.js index 56c5ed526b..559122ae23 100644 --- a/test/fixtures/transformation/es6-destructuring/array-unpack-optimisation/expected.js +++ b/test/fixtures/transformation/es6-destructuring/array-unpack-optimisation/expected.js @@ -16,8 +16,11 @@ var b = _ref2[1]; var _ref3 = [1, 2, 3]; var a = _ref3[0]; var b = _ref3[1]; + var items = _ref3.slice(2); + var _ref4 = [1, 2, 3]; var a = _ref4[0]; var b = _ref4[1]; + var items = _ref4.slice(2); diff --git a/test/fixtures/transformation/es6-destructuring/array/expected.js b/test/fixtures/transformation/es6-destructuring/array/expected.js index 1c128a89f2..9a7872ed23 100644 --- a/test/fixtures/transformation/es6-destructuring/array/expected.js +++ b/test/fixtures/transformation/es6-destructuring/array/expected.js @@ -1,14 +1,7 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; - -var _ref = ["hello", [", ", "junk"], ["world"]]; - -var a = _ref[0]; -var _ref$1 = _slicedToArray(_ref[1], 1); - -var b = _ref$1[0]; -var _ref$2 = _slicedToArray(_ref[2], 1); - -var c = _ref$2[0]; -var d = _ref[3]; +var a = "hello"; +var _ref = [", ", "junk"]; +var b = _ref[0]; +var c = "world"; +var d; diff --git a/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js b/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js index 07ada2afa8..fc9e842f53 100644 --- a/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js +++ b/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js @@ -1,6 +1,7 @@ "use strict"; var _temp, _temp2; + var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; console.log((_temp = [123], _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp)); diff --git a/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js b/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js index 71ca802c0b..02e5751c6a 100644 --- a/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js +++ b/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js @@ -8,4 +8,5 @@ var _ref2 = _slicedToArray(_ref, 2); a = _ref2[0]; b = _ref2[1]; + ; diff --git a/test/fixtures/transformation/es6-destructuring/empty/expected.js b/test/fixtures/transformation/es6-destructuring/empty/expected.js index 2dfc21dee2..7f96ccd8e3 100644 --- a/test/fixtures/transformation/es6-destructuring/empty/expected.js +++ b/test/fixtures/transformation/es6-destructuring/empty/expected.js @@ -3,11 +3,12 @@ var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; var _ref = ["foo", "hello", [", ", "junk"], ["world"]]; - var a = _ref[1]; + var _ref$2 = _slicedToArray(_ref[2], 1); var b = _ref$2[0]; + var _ref$3 = _slicedToArray(_ref[3], 1); var c = _ref$3[0]; diff --git a/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js b/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js index 8f78f9f6f2..e4e278732b 100644 --- a/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js +++ b/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js @@ -5,9 +5,11 @@ var _objectWithoutProperties = function (obj, keys) { var target = {}; for (var var x = _objectWithoutProperties(z, []); var x = z.x; + var y = _objectWithoutProperties(z, ["x"]); (function (_ref) { var x = _ref.x; + var y = _objectWithoutProperties(_ref, ["x"]); -}); \ No newline at end of file +}); diff --git a/test/fixtures/transformation/es6-destructuring/for-in/expected.js b/test/fixtures/transformation/es6-destructuring/for-in/expected.js index c320f40d12..64d9b33e42 100644 --- a/test/fixtures/transformation/es6-destructuring/for-in/expected.js +++ b/test/fixtures/transformation/es6-destructuring/for-in/expected.js @@ -7,5 +7,6 @@ for (var _ref in obj) { var name = _ref2[0]; var value = _ref2[1]; + print("Name: " + name + ", Value: " + value); } diff --git a/test/fixtures/transformation/es6-destructuring/known-array/expected.js b/test/fixtures/transformation/es6-destructuring/known-array/expected.js index 13b2f5def6..5ff98bb88f 100644 --- a/test/fixtures/transformation/es6-destructuring/known-array/expected.js +++ b/test/fixtures/transformation/es6-destructuring/known-array/expected.js @@ -5,4 +5,5 @@ var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr var _z = _toArray(z); var x = _z[0]; + var y = _z.slice(1); diff --git a/test/fixtures/transformation/es6-destructuring/member-expression/expected.js b/test/fixtures/transformation/es6-destructuring/member-expression/expected.js index 2deb4b752d..b5f3f8d67c 100644 --- a/test/fixtures/transformation/es6-destructuring/member-expression/expected.js +++ b/test/fixtures/transformation/es6-destructuring/member-expression/expected.js @@ -8,4 +8,5 @@ var _ref2 = _slicedToArray(_ref, 2); foo.foo = _ref2[0]; foo.bar = _ref2[1]; + ; diff --git a/test/fixtures/transformation/es6-destructuring/mixed/expected.js b/test/fixtures/transformation/es6-destructuring/mixed/expected.js index 6e97718460..aff44e464d 100644 --- a/test/fixtures/transformation/es6-destructuring/mixed/expected.js +++ b/test/fixtures/transformation/es6-destructuring/mixed/expected.js @@ -6,6 +6,7 @@ var _rect$topLeft = _slicedToArray(rect.topLeft, 2); var x1 = _rect$topLeft[0]; var y1 = _rect$topLeft[1]; + var _rect$bottomRight = _slicedToArray(rect.bottomRight, 2); var x2 = _rect$bottomRight[0]; diff --git a/test/fixtures/transformation/es6-destructuring/parameters/expected.js b/test/fixtures/transformation/es6-destructuring/parameters/expected.js index c61ec13955..1f93fcdafa 100644 --- a/test/fixtures/transformation/es6-destructuring/parameters/expected.js +++ b/test/fixtures/transformation/es6-destructuring/parameters/expected.js @@ -14,6 +14,7 @@ function somethingAdvanced(_ref) { function unpackObject(_ref) { var title = _ref.title; var author = _ref.author; + return title + " " + author; } @@ -25,11 +26,13 @@ var unpackArray = function unpackArray(_ref, _ref3) { var a = _ref2[0]; var b = _ref2[1]; var c = _ref2[2]; + var _ref32 = _slicedToArray(_ref3, 3); var x = _ref32[0]; var y = _ref32[1]; var z = _ref32[2]; + return a + b + c; }; diff --git a/test/fixtures/transformation/es6-destructuring/spread/expected.js b/test/fixtures/transformation/es6-destructuring/spread/expected.js index 41a784e5f2..ae05dd65fd 100644 --- a/test/fixtures/transformation/es6-destructuring/spread/expected.js +++ b/test/fixtures/transformation/es6-destructuring/spread/expected.js @@ -7,6 +7,7 @@ var isSorted = function (_ref) { var x = _ref2[0]; var y = _ref2[1]; + var wow = _ref2.slice(2); if (!zs.length) return true; diff --git a/test/fixtures/transformation/es6-for-of-loose/let/expected.js b/test/fixtures/transformation/es6-for-of-loose/let/expected.js index 7bca26b4c8..24b278f864 100644 --- a/test/fixtures/transformation/es6-for-of-loose/let/expected.js +++ b/test/fixtures/transformation/es6-for-of-loose/let/expected.js @@ -2,6 +2,7 @@ for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { var _ref; + if (_isArray) { if (_i >= _iterator.length) break; _ref = _iterator[_i++]; @@ -10,5 +11,6 @@ for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator if (_i.done) break; _ref = _i.value; } + var i = _ref; -} \ No newline at end of file +} diff --git a/test/fixtures/transformation/es6-for-of-loose/multiple/expected.js b/test/fixtures/transformation/es6-for-of-loose/multiple/expected.js index cf5042aacc..f3a251f396 100644 --- a/test/fixtures/transformation/es6-for-of-loose/multiple/expected.js +++ b/test/fixtures/transformation/es6-for-of-loose/multiple/expected.js @@ -2,6 +2,7 @@ for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { var _ref; + if (_isArray) { if (_i >= _iterator.length) break; _ref = _iterator[_i++]; @@ -10,11 +11,13 @@ for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator if (_i.done) break; _ref = _i.value; } + var i = _ref; } for (var _iterator2 = numbers, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { var _ref2; + if (_isArray2) { if (_i2 >= _iterator2.length) break; _ref2 = _iterator2[_i2++]; @@ -23,5 +26,6 @@ for (var _iterator2 = numbers, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _ if (_i2.done) break; _ref2 = _i2.value; } + var i = _ref2; -} \ No newline at end of file +} diff --git a/test/fixtures/transformation/es6-for-of-loose/var/expected.js b/test/fixtures/transformation/es6-for-of-loose/var/expected.js index 7bca26b4c8..24b278f864 100644 --- a/test/fixtures/transformation/es6-for-of-loose/var/expected.js +++ b/test/fixtures/transformation/es6-for-of-loose/var/expected.js @@ -2,6 +2,7 @@ for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { var _ref; + if (_isArray) { if (_i >= _iterator.length) break; _ref = _iterator[_i++]; @@ -10,5 +11,6 @@ for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator if (_i.done) break; _ref = _i.value; } + var i = _ref; -} \ No newline at end of file +} diff --git a/test/fixtures/transformation/es6-modules-amd/exports-default/expected.js b/test/fixtures/transformation/es6-modules-amd/exports-default/expected.js index f67a1d2731..2c5794f860 100644 --- a/test/fixtures/transformation/es6-modules-amd/exports-default/expected.js +++ b/test/fixtures/transformation/es6-modules-amd/exports-default/expected.js @@ -8,6 +8,7 @@ define(["exports", "module"], function (exports, module) { module.exports = {}; module.exports = []; module.exports = foo; + module.exports = function () {}; var _default = function _default() { @@ -16,9 +17,10 @@ define(["exports", "module"], function (exports, module) { module.exports = _default; function foo() {} + var Foo = function Foo() { _classCallCheck(this, Foo); }; module.exports = Foo; -}); \ No newline at end of file +}); diff --git a/test/fixtures/transformation/es6-modules-amd/exports-variable/expected.js b/test/fixtures/transformation/es6-modules-amd/exports-variable/expected.js index 04bcc7cdb6..e0b5ef829f 100644 --- a/test/fixtures/transformation/es6-modules-amd/exports-variable/expected.js +++ b/test/fixtures/transformation/es6-modules-amd/exports-variable/expected.js @@ -13,6 +13,7 @@ define(["exports"], function (exports) { var foo5 = exports.foo5 = undefined; var foo6 = exports.foo6 = 3; function foo7() {} + var foo8 = exports.foo8 = function foo8() { _classCallCheck(this, foo8); }; diff --git a/test/fixtures/transformation/es6-modules-amd/get-module-name-option/actual.js b/test/fixtures/transformation/es6-modules-amd/get-module-name-option/actual.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/transformation/es6-modules-amd/get-module-name-option/expected.js b/test/fixtures/transformation/es6-modules-amd/get-module-name-option/expected.js new file mode 100644 index 0000000000..f0e566fff4 --- /dev/null +++ b/test/fixtures/transformation/es6-modules-amd/get-module-name-option/expected.js @@ -0,0 +1,3 @@ +define("my custom module name", ["exports"], function (exports) { + "use strict"; +}); diff --git a/test/fixtures/transformation/es6-modules-amd/get-module-name-option/options.js b/test/fixtures/transformation/es6-modules-amd/get-module-name-option/options.js new file mode 100644 index 0000000000..e9f2b038d2 --- /dev/null +++ b/test/fixtures/transformation/es6-modules-amd/get-module-name-option/options.js @@ -0,0 +1,5 @@ +exports.getModuleName = function () { + return "my custom module name"; +}; + +exports.moduleIds = true; diff --git a/test/fixtures/transformation/es6-modules-common/exports-default/expected.js b/test/fixtures/transformation/es6-modules-common/exports-default/expected.js index f23a52e713..91b0193462 100644 --- a/test/fixtures/transformation/es6-modules-common/exports-default/expected.js +++ b/test/fixtures/transformation/es6-modules-common/exports-default/expected.js @@ -7,6 +7,7 @@ module.exports = 42; module.exports = {}; module.exports = []; module.exports = foo; + module.exports = function () {}; var _default = function _default() { @@ -15,8 +16,9 @@ var _default = function _default() { module.exports = _default; function foo() {} + var Foo = function Foo() { _classCallCheck(this, Foo); }; -module.exports = Foo; \ No newline at end of file +module.exports = Foo; diff --git a/test/fixtures/transformation/es6-modules-common/exports-variable/expected.js b/test/fixtures/transformation/es6-modules-common/exports-variable/expected.js index cb2657cfde..a6a2bed9d2 100644 --- a/test/fixtures/transformation/es6-modules-common/exports-variable/expected.js +++ b/test/fixtures/transformation/es6-modules-common/exports-variable/expected.js @@ -12,6 +12,7 @@ var foo4 = exports.foo4 = 2; var foo5 = exports.foo5 = undefined; var foo6 = exports.foo6 = 3; function foo7() {} + var foo8 = exports.foo8 = function foo8() { _classCallCheck(this, foo8); }; diff --git a/test/fixtures/transformation/es6-modules-common/hoist-function-exports/expected.js b/test/fixtures/transformation/es6-modules-common/hoist-function-exports/expected.js index 1a175b6def..32243d1a56 100644 --- a/test/fixtures/transformation/es6-modules-common/hoist-function-exports/expected.js +++ b/test/fixtures/transformation/es6-modules-common/hoist-function-exports/expected.js @@ -1,7 +1,9 @@ "use strict"; exports.nextOdd = nextOdd; + var isEven = require("./evens").isEven; + function nextOdd(n) { return isEven(n) ? n + 1 : n + 2; } @@ -13,4 +15,4 @@ var isOdd = exports.isOdd = (function (isEven) { })(isEven); Object.defineProperty(exports, "__esModule", { value: true -}); \ No newline at end of file +}); diff --git a/test/fixtures/transformation/es6-modules-common/overview/expected.js b/test/fixtures/transformation/es6-modules-common/overview/expected.js index 10ac16f17e..ecc04745a8 100644 --- a/test/fixtures/transformation/es6-modules-common/overview/expected.js +++ b/test/fixtures/transformation/es6-modules-common/overview/expected.js @@ -15,9 +15,11 @@ var foo = _interopRequire(require("foo2")); var foo2 = _interopRequireWildcard(require("foo3")); var bar = require("foo4").bar; + var bar2 = require("foo5").foo; + exports.test = test; var test = exports.test = 5; Object.defineProperty(exports, "__esModule", { value: true -}); \ No newline at end of file +}); diff --git a/test/fixtures/transformation/es6-modules-ignore/exports-default/expected.js b/test/fixtures/transformation/es6-modules-ignore/exports-default/expected.js index ea2cae4338..27cd0177e0 100644 --- a/test/fixtures/transformation/es6-modules-ignore/exports-default/expected.js +++ b/test/fixtures/transformation/es6-modules-ignore/exports-default/expected.js @@ -7,6 +7,7 @@ var _default = function _default() { }; function foo() {} + var Foo = function Foo() { _classCallCheck(this, Foo); -}; \ No newline at end of file +}; diff --git a/test/fixtures/transformation/es6-modules-system/exports-default/expected.js b/test/fixtures/transformation/es6-modules-system/exports-default/expected.js index 116c8ce6b6..93fa08a649 100644 --- a/test/fixtures/transformation/es6-modules-system/exports-default/expected.js +++ b/test/fixtures/transformation/es6-modules-system/exports-default/expected.js @@ -2,6 +2,7 @@ System.register([], function (_export) { "use strict"; var _classCallCheck, _default, Foo; + _export("default", foo); function foo() {} @@ -33,4 +34,4 @@ System.register([], function (_export) { _export("default", Foo); } }; -}); \ No newline at end of file +}); diff --git a/test/fixtures/transformation/es6-modules-system/exports-generator/expected.js b/test/fixtures/transformation/es6-modules-system/exports-generator/expected.js index fd897196b1..ea08012703 100644 --- a/test/fixtures/transformation/es6-modules-system/exports-generator/expected.js +++ b/test/fixtures/transformation/es6-modules-system/exports-generator/expected.js @@ -7,6 +7,7 @@ System.register([], function (_export) { case 0: context$1$0.next = 2; return 1; + case 2: case "end": return context$1$0.stop(); diff --git a/test/fixtures/transformation/es6-modules-system/exports-variable/expected.js b/test/fixtures/transformation/es6-modules-system/exports-variable/expected.js index 969d94b8dc..2b6c6efd54 100644 --- a/test/fixtures/transformation/es6-modules-system/exports-variable/expected.js +++ b/test/fixtures/transformation/es6-modules-system/exports-variable/expected.js @@ -2,6 +2,7 @@ System.register([], function (_export) { "use strict"; var _classCallCheck, foo, foo2, foo3, foo4, foo5, foo6, foo8; + _export("foo7", foo7); function foo7() {} @@ -19,6 +20,7 @@ System.register([], function (_export) { foo8 = _export("foo8", function foo8() { _classCallCheck(this, foo8); }); + _export("foo3", foo3 = 5); } }; diff --git a/test/fixtures/transformation/es6-modules-system/get-module-name-option/actual.js b/test/fixtures/transformation/es6-modules-system/get-module-name-option/actual.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/transformation/es6-modules-system/get-module-name-option/expected.js b/test/fixtures/transformation/es6-modules-system/get-module-name-option/expected.js new file mode 100644 index 0000000000..0def1f9524 --- /dev/null +++ b/test/fixtures/transformation/es6-modules-system/get-module-name-option/expected.js @@ -0,0 +1,8 @@ +System.register("my custom module name", [], function (_export) { + "use strict"; + + return { + setters: [], + execute: function () {} + }; +}); diff --git a/test/fixtures/transformation/es6-modules-system/get-module-name-option/options.js b/test/fixtures/transformation/es6-modules-system/get-module-name-option/options.js new file mode 100644 index 0000000000..e9f2b038d2 --- /dev/null +++ b/test/fixtures/transformation/es6-modules-system/get-module-name-option/options.js @@ -0,0 +1,5 @@ +exports.getModuleName = function () { + return "my custom module name"; +}; + +exports.moduleIds = true; diff --git a/test/fixtures/transformation/es6-modules-system/hoist-function-exports/expected.js b/test/fixtures/transformation/es6-modules-system/hoist-function-exports/expected.js index fd752cdebf..609ee753d4 100644 --- a/test/fixtures/transformation/es6-modules-system/hoist-function-exports/expected.js +++ b/test/fixtures/transformation/es6-modules-system/hoist-function-exports/expected.js @@ -2,6 +2,7 @@ System.register(["./evens"], function (_export) { "use strict"; var isEven, p, isOdd; + _export("nextOdd", nextOdd); function nextOdd(n) { diff --git a/test/fixtures/transformation/es6-modules-system/overview/expected.js b/test/fixtures/transformation/es6-modules-system/overview/expected.js index 538640f07d..1114e6a2da 100644 --- a/test/fixtures/transformation/es6-modules-system/overview/expected.js +++ b/test/fixtures/transformation/es6-modules-system/overview/expected.js @@ -13,6 +13,7 @@ System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export) { _export("test", test); test2 = _export("test2", 5); + _export("default", test); } }; diff --git a/test/fixtures/transformation/es6-modules-system/remap/expected.js b/test/fixtures/transformation/es6-modules-system/remap/expected.js index b4d66336c9..fa88c07f53 100644 --- a/test/fixtures/transformation/es6-modules-system/remap/expected.js +++ b/test/fixtures/transformation/es6-modules-system/remap/expected.js @@ -6,6 +6,7 @@ System.register([], function (_export) { setters: [], execute: function () { test = _export("test", 2); + _export("test", test = 5); _export("test", test += 1); diff --git a/test/fixtures/transformation/es6-modules-umd/exports-default/expected.js b/test/fixtures/transformation/es6-modules-umd/exports-default/expected.js index 8470debb5a..287f0ec11d 100644 --- a/test/fixtures/transformation/es6-modules-umd/exports-default/expected.js +++ b/test/fixtures/transformation/es6-modules-umd/exports-default/expected.js @@ -14,6 +14,7 @@ module.exports = {}; module.exports = []; module.exports = foo; + module.exports = function () {}; var _default = function _default() { @@ -22,9 +23,10 @@ module.exports = _default; function foo() {} + var Foo = function Foo() { _classCallCheck(this, Foo); }; module.exports = Foo; -}); \ No newline at end of file +}); diff --git a/test/fixtures/transformation/es6-modules-umd/exports-variable/expected.js b/test/fixtures/transformation/es6-modules-umd/exports-variable/expected.js index 55c06d85b3..97a29f5fb3 100644 --- a/test/fixtures/transformation/es6-modules-umd/exports-variable/expected.js +++ b/test/fixtures/transformation/es6-modules-umd/exports-variable/expected.js @@ -19,6 +19,7 @@ var foo5 = exports.foo5 = undefined; var foo6 = exports.foo6 = 3; function foo7() {} + var foo8 = exports.foo8 = function foo8() { _classCallCheck(this, foo8); }; diff --git a/test/fixtures/transformation/es6-modules-umd/get-module-name-option/actual.js b/test/fixtures/transformation/es6-modules-umd/get-module-name-option/actual.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/transformation/es6-modules-umd/get-module-name-option/expected.js b/test/fixtures/transformation/es6-modules-umd/get-module-name-option/expected.js new file mode 100644 index 0000000000..db14ef8bc3 --- /dev/null +++ b/test/fixtures/transformation/es6-modules-umd/get-module-name-option/expected.js @@ -0,0 +1,9 @@ +(function (factory) { + if (typeof define === "function" && define.amd) { + define("my custom module name", ["exports"], factory); + } else if (typeof exports !== "undefined") { + factory(exports); + } +})(function (exports) { + "use strict"; +}); diff --git a/test/fixtures/transformation/es6-modules-umd/get-module-name-option/options.js b/test/fixtures/transformation/es6-modules-umd/get-module-name-option/options.js new file mode 100644 index 0000000000..e9f2b038d2 --- /dev/null +++ b/test/fixtures/transformation/es6-modules-umd/get-module-name-option/options.js @@ -0,0 +1,5 @@ +exports.getModuleName = function () { + return "my custom module name"; +}; + +exports.moduleIds = true; diff --git a/test/fixtures/transformation/es6-modules-umd/overview/expected.js b/test/fixtures/transformation/es6-modules-umd/overview/expected.js index 8f0262a8ee..9d39fbaa49 100644 --- a/test/fixtures/transformation/es6-modules-umd/overview/expected.js +++ b/test/fixtures/transformation/es6-modules-umd/overview/expected.js @@ -21,4 +21,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); -}); \ No newline at end of file +}); diff --git a/test/fixtures/transformation/es6-parameters.default/multiple/expected.js b/test/fixtures/transformation/es6-parameters.default/multiple/expected.js index af684c28f7..b894cb32cd 100644 --- a/test/fixtures/transformation/es6-parameters.default/multiple/expected.js +++ b/test/fixtures/transformation/es6-parameters.default/multiple/expected.js @@ -1,12 +1,14 @@ "use strict"; -var t = function () { +var t = function t() { var t = arguments[0] === undefined ? "foo" : arguments[0]; var f = arguments[1] === undefined ? 5 : arguments[1]; + return t + " bar " + f; }; -var a = function (t) { +var a = function a(t) { var f = arguments[1] === undefined ? 5 : arguments[1]; + return t + " bar " + f; }; diff --git a/test/fixtures/transformation/es6-parameters.default/single/expected.js b/test/fixtures/transformation/es6-parameters.default/single/expected.js index f953c7a0a9..fb12b54cf5 100644 --- a/test/fixtures/transformation/es6-parameters.default/single/expected.js +++ b/test/fixtures/transformation/es6-parameters.default/single/expected.js @@ -1,6 +1,7 @@ "use strict"; -var t = function () { +var t = function t() { var t = arguments[0] === undefined ? "foo" : arguments[0]; + return t + " bar"; }; diff --git a/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js b/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js index 821f0dfae6..b3f2634c07 100644 --- a/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js +++ b/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js @@ -5,7 +5,6 @@ var foo = function foo() { _ref[_key] = arguments[_key]; } - var _ref2 = _ref; - var a = _ref2[0]; - var b = _ref2[1]; + var a = _ref[0]; + var b = _ref[1]; }; diff --git a/test/fixtures/transformation/es6-properties.computed-loose/argument/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/argument/expected.js index 8a544ec30e..3731ff5791 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/argument/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/argument/expected.js @@ -2,7 +2,6 @@ foo((function () { var _foo = {}; - _foo[bar] = "foobar"; return _foo; -})()); \ No newline at end of file +})()); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/assignment/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/assignment/expected.js index 2b1f23d706..190325c4da 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/assignment/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/assignment/expected.js @@ -2,7 +2,6 @@ foo = (function () { var _foo = {}; - _foo[bar] = "foobar"; return _foo; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/ignore-symbol/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/ignore-symbol/expected.js index 852e2b4e6c..96612ae7ad 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/ignore-symbol/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/ignore-symbol/expected.js @@ -2,7 +2,6 @@ var foo = (function () { var _foo = {}; - _foo[Symbol.iterator] = "foobar"; return _foo; })(); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/method/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/method/expected.js index da3d3d08e2..fd5025bbd1 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/method/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/method/expected.js @@ -8,4 +8,4 @@ var obj = (function () { }; return _obj; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/mixed/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/mixed/expected.js index 7728ebd72c..a31474e280 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/mixed/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/mixed/expected.js @@ -2,10 +2,9 @@ var obj = (function () { var _obj = {}; - _obj["x" + foo] = "heh"; _obj["y" + bar] = "noo"; _obj.foo = "foo"; _obj.bar = "bar"; return _obj; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/multiple/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/multiple/expected.js index fb1c4ceb31..d1d1e8b1d1 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/multiple/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/multiple/expected.js @@ -2,8 +2,7 @@ var obj = (function () { var _obj = {}; - _obj["x" + foo] = "heh"; _obj["y" + bar] = "noo"; return _obj; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/single/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/single/expected.js index 627faff494..774b07f4d4 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/single/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/single/expected.js @@ -2,7 +2,6 @@ var obj = (function () { var _obj = {}; - _obj["x" + foo] = "heh"; return _obj; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js index 72554a9599..fc7d1bd4c7 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js @@ -2,7 +2,6 @@ var obj = (function () { var _obj = {}; - _obj["x" + foo.bar] = "heh"; return _obj; })(); diff --git a/test/fixtures/transformation/es6-properties.computed-loose/two/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/two/expected.js index 42ef0c1e64..523a93dcb7 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/two/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/two/expected.js @@ -2,7 +2,6 @@ var obj = (function () { var _obj = {}; - _obj.first = "first"; _obj.second = "second"; return _obj; diff --git a/test/fixtures/transformation/es6-properties.computed-loose/variable/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/variable/expected.js index 6f691f0fd6..656ac58d4c 100644 --- a/test/fixtures/transformation/es6-properties.computed-loose/variable/expected.js +++ b/test/fixtures/transformation/es6-properties.computed-loose/variable/expected.js @@ -2,7 +2,6 @@ var foo = (function () { var _foo = {}; - _foo[bar] = "foobar"; return _foo; })(); diff --git a/test/fixtures/transformation/es6-properties.computed/ignore-symbol/expected.js b/test/fixtures/transformation/es6-properties.computed/ignore-symbol/expected.js index 852e2b4e6c..96612ae7ad 100644 --- a/test/fixtures/transformation/es6-properties.computed/ignore-symbol/expected.js +++ b/test/fixtures/transformation/es6-properties.computed/ignore-symbol/expected.js @@ -2,7 +2,6 @@ var foo = (function () { var _foo = {}; - _foo[Symbol.iterator] = "foobar"; return _foo; })(); diff --git a/test/fixtures/transformation/es6-properties.shorthand/method-self-reference/expected.js b/test/fixtures/transformation/es6-properties.shorthand/method-self-reference/expected.js index de924da268..556770fa0e 100644 --- a/test/fixtures/transformation/es6-properties.shorthand/method-self-reference/expected.js +++ b/test/fixtures/transformation/es6-properties.shorthand/method-self-reference/expected.js @@ -1,19 +1,15 @@ "use strict"; var bar = { - foo: (function (_foo) { - var _fooWrapper = function foo() { - return _foo.apply(this, arguments); - }; + foo: (function () { + function _getOuter() { + return foo; + } - _fooWrapper.toString = function () { - return _foo.toString(); + return function foo() { + console.log(_getOuter()); }; - - return _fooWrapper; - })(function () { - console.log(foo); - }) + })() }; var bar = { @@ -25,17 +21,13 @@ var bar = { var foobar = 123; var foobar2 = { - foobar: (function (_foobar) { - var _foobarWrapper = function foobar() { - return _foobar.apply(this, arguments); - }; + foobar: (function () { + function _getOuter() { + return foobar; + } - _foobarWrapper.toString = function () { - return _foobar.toString(); + return function foobar() { + console.log(_getOuter()); }; - - return _foobarWrapper; - })(function () { - console.log(foobar); - }) + })() }; diff --git a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js index 1be56b7551..2acacbf97d 100644 --- a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js @@ -1,6 +1,7 @@ "use strict"; var _obj; + var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }; (_obj = obj)[method].apply(_obj, [foo, bar].concat(_toConsumableArray(args))); diff --git a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js index 1ec66fdeab..90d4042576 100644 --- a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js @@ -1,6 +1,7 @@ "use strict"; var _obj; + var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }; (_obj = obj)[method].apply(_obj, _toConsumableArray(args)); diff --git a/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js b/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js index a45e8ae7d5..8918047bf1 100644 --- a/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js @@ -1,6 +1,7 @@ "use strict"; var _foob, _foob$test; + var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }; (_foob = foob).add.apply(_foob, [foo, bar].concat(_toConsumableArray(numbers))); diff --git a/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js b/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js index 0a0755cc0d..68e7049991 100644 --- a/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js @@ -1,6 +1,7 @@ "use strict"; var _foob, _foob$test; + var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }; (_foob = foob).add.apply(_foob, _toConsumableArray(numbers)); diff --git a/test/fixtures/transformation/es6-tail-call/call-apply/actual.js b/test/fixtures/transformation/es6-tail-call/call-apply/actual.js index 2bb42c6c81..9aefdea5cc 100755 --- a/test/fixtures/transformation/es6-tail-call/call-apply/actual.js +++ b/test/fixtures/transformation/es6-tail-call/call-apply/actual.js @@ -3,5 +3,6 @@ console.log(this, arguments); return "foo"; } + return Math.random() > 0.5 ? f.call(this, n - 1) : f.apply(this, [n - 1]); })(1e6) === "foo"; diff --git a/test/fixtures/transformation/es6-tail-call/call-apply/expected.js b/test/fixtures/transformation/es6-tail-call/call-apply/expected.js index 22251dcdfc..e4f1e2f6b3 100755 --- a/test/fixtures/transformation/es6-tail-call/call-apply/expected.js +++ b/test/fixtures/transformation/es6-tail-call/call-apply/expected.js @@ -3,12 +3,15 @@ (function f(_x) { var _this = this, _arguments = arguments; + _function: while (true) { var n = _x; + if (n <= 0) { console.log(_this, _arguments); return "foo"; } + if (Math.random() > 0.5) { _arguments = [_x = n - 1]; continue _function; diff --git a/test/fixtures/transformation/es6-tail-call/expressions/expected.js b/test/fixtures/transformation/es6-tail-call/expressions/expected.js index 9182bf49e7..1c86593dbf 100755 --- a/test/fixtures/transformation/es6-tail-call/expressions/expected.js +++ b/test/fixtures/transformation/es6-tail-call/expressions/expected.js @@ -2,6 +2,7 @@ (function f(_x) { var _left; + _function: while (true) { var n = _x; if (n <= 0) { @@ -12,9 +13,11 @@ if (!(_left = getTrueValue())) { return _left; } + if (_left = getFalseValue()) { return _left; } + _x = n - 1; continue _function; }return; diff --git a/test/fixtures/transformation/es6-tail-call/factorial/expected.js b/test/fixtures/transformation/es6-tail-call/factorial/expected.js index 7345ac60cf..61ec9282e0 100644 --- a/test/fixtures/transformation/es6-tail-call/factorial/expected.js +++ b/test/fixtures/transformation/es6-tail-call/factorial/expected.js @@ -1,16 +1,17 @@ -"use strict"; - -function fact(_x2) { - var _arguments = arguments; - _function: while (true) { - var n = _x2; - acc = undefined; - var acc = _arguments[1] === undefined ? 1 : _arguments[1]; - if (n > 1) { - _arguments = [_x2 = n - 1, acc * n]; - continue _function; - } else { - return acc; - }return; - } -} +"use strict"; + +function fact(_x2) { + var _arguments = arguments; + + _function: while (true) { + var n = _x2; + acc = undefined; + var acc = _arguments[1] === undefined ? 1 : _arguments[1]; + if (n > 1) { + _arguments = [_x2 = n - 1, acc * n]; + continue _function; + } else { + return acc; + }return; + } +} diff --git a/test/fixtures/transformation/es6-tail-call/recursion/expected.js b/test/fixtures/transformation/es6-tail-call/recursion/expected.js index 9126477265..6a33e19173 100755 --- a/test/fixtures/transformation/es6-tail-call/recursion/expected.js +++ b/test/fixtures/transformation/es6-tail-call/recursion/expected.js @@ -2,12 +2,14 @@ (function f(_x2) { var _arguments = arguments; + _function: while (true) { var g = function g() {}; var n = _x2; m = local1 = local2 = local3 = undefined; var m = _arguments[1] === undefined ? getDefaultValue() : _arguments[1]; + // `m` should be `getDefaultValue()` after first pass if (n <= 0) { return "foo"; diff --git a/test/fixtures/transformation/es6-tail-call/try-catch/actual.js b/test/fixtures/transformation/es6-tail-call/try-catch/actual.js index 0a6be74326..654f4ce709 100755 --- a/test/fixtures/transformation/es6-tail-call/try-catch/actual.js +++ b/test/fixtures/transformation/es6-tail-call/try-catch/actual.js @@ -2,6 +2,7 @@ if (n <= 0) { return "foo"; } + try { return f(n - 1); } catch (e) {} @@ -11,6 +12,7 @@ if (n <= 0) { return "foo"; } + try { throw new Error(); } catch (e) { @@ -22,6 +24,7 @@ if (n <= 0) { return "foo"; } + try { throw new Error(); } catch (e) { @@ -33,6 +36,7 @@ if (n <= 0) { return "foo"; } + try {} finally { return f(n - 1); } diff --git a/test/fixtures/transformation/es6-tail-call/try-catch/expected.js b/test/fixtures/transformation/es6-tail-call/try-catch/expected.js index fa1f502af2..d911002438 100755 --- a/test/fixtures/transformation/es6-tail-call/try-catch/expected.js +++ b/test/fixtures/transformation/es6-tail-call/try-catch/expected.js @@ -4,6 +4,7 @@ if (n <= 0) { return "foo"; } + try { return f(n - 1); } catch (e) {} @@ -12,9 +13,11 @@ (function f(_x) { _function: while (true) { var n = _x; + if (n <= 0) { return "foo"; } + try { throw new Error(); } catch (e) { @@ -29,6 +32,7 @@ if (n <= 0) { return "foo"; } + try { throw new Error(); } catch (e) { @@ -39,9 +43,11 @@ (function f(_x) { _function: while (true) { var n = _x; + if (n <= 0) { return "foo"; } + try {} finally { _x = n - 1; continue _function; diff --git a/test/fixtures/transformation/es7-abstract-references/call/expected.js b/test/fixtures/transformation/es7-abstract-references/call/expected.js index 4a2d6e1482..55bdecc949 100644 --- a/test/fixtures/transformation/es7-abstract-references/call/expected.js +++ b/test/fixtures/transformation/es7-abstract-references/call/expected.js @@ -1,6 +1,7 @@ "use strict"; var _foo, _foo2; + _foo = foo, bar[Symbol.referenceGet](_foo).call(_foo); _foo2 = foo, bar[Symbol.referenceGet](_foo2).call(_foo2, "arg"); diff --git a/test/fixtures/transformation/es7-abstract-references/private/expected.js b/test/fixtures/transformation/es7-abstract-references/private/expected.js index 08e3dde5f8..ad0c2b95c7 100644 --- a/test/fixtures/transformation/es7-abstract-references/private/expected.js +++ b/test/fixtures/transformation/es7-abstract-references/private/expected.js @@ -5,10 +5,12 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instance var A = new WeakMap(); var B = new WeakMap(), C = new WeakMap(); + var D = (function () { var F = new WeakMap(), G = new WeakMap(); var E = new WeakMap(); + function D() { _classCallCheck(this, D); } @@ -20,9 +22,10 @@ var H = (function () { var J = new WeakMap(), K = new WeakMap(); var I = new WeakMap(); + function H() { _classCallCheck(this, H); } return H; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es7-comprehensions/arguments/expected.js b/test/fixtures/transformation/es7-comprehensions/arguments/expected.js index 39115d87d3..55b06801b2 100644 --- a/test/fixtures/transformation/es7-comprehensions/arguments/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/arguments/expected.js @@ -2,11 +2,13 @@ function add() { var _arguments = arguments; + return (function () { var _ref = []; for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; + _ref.push(i * _arguments[0]); } diff --git a/test/fixtures/transformation/es7-comprehensions/array-expression-single-if/expected.js b/test/fixtures/transformation/es7-comprehensions/array-expression-single-if/expected.js index 0f3f625138..40fd64916f 100644 --- a/test/fixtures/transformation/es7-comprehensions/array-expression-single-if/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/array-expression-single-if/expected.js @@ -5,6 +5,7 @@ var arr = (function () { for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; + if (i > 1) { _arr.push(i * i); } diff --git a/test/fixtures/transformation/es7-comprehensions/array-expression-single/expected.js b/test/fixtures/transformation/es7-comprehensions/array-expression-single/expected.js index c3ae8d9432..fe30ac0289 100644 --- a/test/fixtures/transformation/es7-comprehensions/array-expression-single/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/array-expression-single/expected.js @@ -5,6 +5,7 @@ var arr = (function () { for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; + _arr.push(i * i); } diff --git a/test/fixtures/transformation/es7-comprehensions/array-multiple-if/expected.js b/test/fixtures/transformation/es7-comprehensions/array-multiple-if/expected.js index 6b486b45f5..39ea4c3311 100644 --- a/test/fixtures/transformation/es7-comprehensions/array-multiple-if/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/array-multiple-if/expected.js @@ -5,8 +5,10 @@ var seattlers = (function () { for (var _iterator = countries[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var customers = _step.value; + for (var _iterator2 = customers[Symbol.iterator](), _step2; !(_step2 = _iterator2.next()).done;) { var c = _step2.value; + if (c.city == "Seattle") { _seattlers.push({ name: c.name, age: c.age }); } diff --git a/test/fixtures/transformation/es7-comprehensions/array-multiple/expected.js b/test/fixtures/transformation/es7-comprehensions/array-multiple/expected.js index 05f2c6e76d..87291a575d 100644 --- a/test/fixtures/transformation/es7-comprehensions/array-multiple/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/array-multiple/expected.js @@ -5,8 +5,10 @@ var arr = (function () { for (var _iterator = "abcdefgh".split("")[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var x = _step.value; + for (var _iterator2 = "12345678".split("")[Symbol.iterator](), _step2; !(_step2 = _iterator2.next()).done;) { var y = _step2.value; + _arr.push(x + y); } } diff --git a/test/fixtures/transformation/es7-comprehensions/array-single-if/expected.js b/test/fixtures/transformation/es7-comprehensions/array-single-if/expected.js index 6e95f9cadc..33b4263716 100644 --- a/test/fixtures/transformation/es7-comprehensions/array-single-if/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/array-single-if/expected.js @@ -5,6 +5,7 @@ var arr = (function () { for (var _iterator = nums[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; + if (i > 1) { _arr.push(i * i); } diff --git a/test/fixtures/transformation/es7-comprehensions/array-single/expected.js b/test/fixtures/transformation/es7-comprehensions/array-single/expected.js index 88e01e350a..b0bfaeeee9 100644 --- a/test/fixtures/transformation/es7-comprehensions/array-single/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/array-single/expected.js @@ -5,6 +5,7 @@ var arr = (function () { for (var _iterator = nums[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; + _arr.push(i * i); } diff --git a/test/fixtures/transformation/es7-comprehensions/array-this/expected.js b/test/fixtures/transformation/es7-comprehensions/array-this/expected.js index 5645b53dcc..a03db14f50 100644 --- a/test/fixtures/transformation/es7-comprehensions/array-this/expected.js +++ b/test/fixtures/transformation/es7-comprehensions/array-this/expected.js @@ -2,11 +2,13 @@ function add() { var _this = this; + return (function () { var _ref = []; for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; + _ref.push(i * _this.multiplier); } diff --git a/test/fixtures/transformation/es7-exponentian-operator/assignment/expected.js b/test/fixtures/transformation/es7-exponentian-operator/assignment/expected.js index cd3678c7fe..771217952d 100644 --- a/test/fixtures/transformation/es7-exponentian-operator/assignment/expected.js +++ b/test/fixtures/transformation/es7-exponentian-operator/assignment/expected.js @@ -1,4 +1,5 @@ "use strict"; num = Math.pow(num, 2); + ; diff --git a/test/fixtures/transformation/playground/method-binding/expected.js b/test/fixtures/transformation/playground/method-binding/expected.js index 135ef9247d..6f76e45d89 100644 --- a/test/fixtures/transformation/playground/method-binding/expected.js +++ b/test/fixtures/transformation/playground/method-binding/expected.js @@ -1,6 +1,7 @@ "use strict"; var _obj, _obj2, _obj$foo, _obj$foo2, _obj$foo3, _args, _args2, _args3; + var fn = (_obj = obj, _obj.method.bind(_obj)); var fn = (_obj2 = obj, _obj2.method.bind(_obj2, "foob")); var fn = (_obj$foo = obj[foo], _obj$foo.method.bind(_obj$foo)); diff --git a/test/fixtures/transformation/react/arrow-functions/expected.js b/test/fixtures/transformation/react/arrow-functions/expected.js index 0b69bab154..62f1a66163 100644 --- a/test/fixtures/transformation/react/arrow-functions/expected.js +++ b/test/fixtures/transformation/react/arrow-functions/expected.js @@ -1,5 +1,6 @@ var foo = function foo() { var _this = this; + return function () { return React.createElement(_this, null); }; @@ -7,6 +8,7 @@ var foo = function foo() { var bar = function bar() { var _this = this; + return function () { return React.createElement(_this.foo, null); }; diff --git a/test/fixtures/transformation/react/display-name-assignment-expression/expected.js b/test/fixtures/transformation/react/display-name-assignment-expression/expected.js index 12fa356793..4a98b832ac 100644 --- a/test/fixtures/transformation/react/display-name-assignment-expression/expected.js +++ b/test/fixtures/transformation/react/display-name-assignment-expression/expected.js @@ -1,6 +1,7 @@ var Component; Component = React.createClass({ displayName: "Component", + render: function render() { return null; } diff --git a/test/fixtures/transformation/react/display-name-export-default/expected.js b/test/fixtures/transformation/react/display-name-export-default/expected.js index b97066d1e2..991968ff6c 100644 --- a/test/fixtures/transformation/react/display-name-export-default/expected.js +++ b/test/fixtures/transformation/react/display-name-export-default/expected.js @@ -1,5 +1,6 @@ module.exports = React.createClass({ displayName: "actual", + render: function render() { return null; } diff --git a/test/fixtures/transformation/react/display-name-object-declaration/expected.js b/test/fixtures/transformation/react/display-name-object-declaration/expected.js index e6565826f5..9d7948f677 100644 --- a/test/fixtures/transformation/react/display-name-object-declaration/expected.js +++ b/test/fixtures/transformation/react/display-name-object-declaration/expected.js @@ -1,6 +1,7 @@ exports = { Component: React.createClass({ displayName: "Component", + render: function render() { return null; } diff --git a/test/fixtures/transformation/react/display-name-property-assignment/expected.js b/test/fixtures/transformation/react/display-name-property-assignment/expected.js index e08bf5d35d..0e2b4ecec9 100644 --- a/test/fixtures/transformation/react/display-name-property-assignment/expected.js +++ b/test/fixtures/transformation/react/display-name-property-assignment/expected.js @@ -1,5 +1,6 @@ exports.Component = React.createClass({ displayName: "Component", + render: function render() { return null; } diff --git a/test/fixtures/transformation/react/display-name-variable-declaration/expected.js b/test/fixtures/transformation/react/display-name-variable-declaration/expected.js index d6393b0105..961056a9e2 100644 --- a/test/fixtures/transformation/react/display-name-variable-declaration/expected.js +++ b/test/fixtures/transformation/react/display-name-variable-declaration/expected.js @@ -1,5 +1,6 @@ var Component = React.createClass({ displayName: "Component", + render: function render() { return null; } diff --git a/test/fixtures/transformation/self-contained/aliased-constructors/expected.js b/test/fixtures/transformation/self-contained/aliased-constructors/expected.js index f00771d316..71a45ff0b9 100644 --- a/test/fixtures/transformation/self-contained/aliased-constructors/expected.js +++ b/test/fixtures/transformation/self-contained/aliased-constructors/expected.js @@ -1,6 +1,7 @@ "use strict"; var _core = require("babel-runtime/core-js")["default"]; + obj.constructor === Object; obj.constructor === _core.Promise; diff --git a/test/fixtures/transformation/self-contained/es6-for-of/expected.js b/test/fixtures/transformation/self-contained/es6-for-of/expected.js index 29a0778685..328ac648d8 100644 --- a/test/fixtures/transformation/self-contained/es6-for-of/expected.js +++ b/test/fixtures/transformation/self-contained/es6-for-of/expected.js @@ -1,6 +1,7 @@ "use strict"; var _core = require("babel-runtime/core-js")["default"]; + for (var _iterator = _core.$for.getIterator(arr), _step; !(_step = _iterator.next()).done;) { var i = _step.value; } diff --git a/test/fixtures/transformation/self-contained/es7-array-comprehensions/expected.js b/test/fixtures/transformation/self-contained/es7-array-comprehensions/expected.js index db2347aee3..f75b32e72d 100644 --- a/test/fixtures/transformation/self-contained/es7-array-comprehensions/expected.js +++ b/test/fixtures/transformation/self-contained/es7-array-comprehensions/expected.js @@ -1,11 +1,13 @@ "use strict"; var _core = require("babel-runtime/core-js")["default"]; + var arr = (function () { var _arr = []; for (var _iterator = _core.$for.getIterator(nums), _step; !(_step = _iterator.next()).done;) { var i = _step.value; + _arr.push(i * i); } diff --git a/test/fixtures/transformation/self-contained/full/expected.js b/test/fixtures/transformation/self-contained/full/expected.js index 40529f7d09..76c62631aa 100644 --- a/test/fixtures/transformation/self-contained/full/expected.js +++ b/test/fixtures/transformation/self-contained/full/expected.js @@ -1,14 +1,18 @@ "use strict"; var _core = require("babel-runtime/core-js")["default"]; + var _regeneratorRuntime = require("babel-runtime/regenerator")["default"]; + var _babelHelpers = require("babel-runtime/helpers")["default"]; + var giveWord = _regeneratorRuntime.mark(function giveWord() { return _regeneratorRuntime.wrap(function giveWord$(context$1$0) { while (1) switch (context$1$0.prev = context$1$0.next) { case 0: context$1$0.next = 2; return myWord; + case 2: case "end": return context$1$0.stop(); @@ -17,6 +21,7 @@ var giveWord = _regeneratorRuntime.mark(function giveWord() { }); exports.giveWord = giveWord; + var _someModule = require("someModule"); var foo = _babelHelpers.interopRequire(_someModule); diff --git a/test/fixtures/transformation/self-contained/modules-amd/expected.js b/test/fixtures/transformation/self-contained/modules-amd/expected.js index a7826ee065..9543e99b18 100644 --- a/test/fixtures/transformation/self-contained/modules-amd/expected.js +++ b/test/fixtures/transformation/self-contained/modules-amd/expected.js @@ -2,5 +2,6 @@ define(["exports", "foo", "babel-runtime/helpers"], function (exports, _foo, _ba "use strict"; var _babelHelpers = _babelRuntimeHelpers["default"]; + var foo = _babelHelpers.interopRequire(_foo); }); diff --git a/test/fixtures/transformation/self-contained/modules-common/expected.js b/test/fixtures/transformation/self-contained/modules-common/expected.js index 5909c60160..3554ee2668 100644 --- a/test/fixtures/transformation/self-contained/modules-common/expected.js +++ b/test/fixtures/transformation/self-contained/modules-common/expected.js @@ -1,4 +1,5 @@ "use strict"; var _babelHelpers = require("babel-runtime/helpers")["default"]; + var foo = _babelHelpers.interopRequire(require("foo")); diff --git a/test/fixtures/transformation/self-contained/modules-system/expected.js b/test/fixtures/transformation/self-contained/modules-system/expected.js index c876067c45..8bbdcb08a7 100644 --- a/test/fixtures/transformation/self-contained/modules-system/expected.js +++ b/test/fixtures/transformation/self-contained/modules-system/expected.js @@ -2,6 +2,7 @@ System.register(["babel-runtime/helpers"], function (_export) { "use strict"; var _babelHelpers; + return { setters: [function (_babelRuntimeHelpers) { _babelHelpers = _babelRuntimeHelpers["default"]; diff --git a/test/fixtures/transformation/self-contained/modules-umd/expected.js b/test/fixtures/transformation/self-contained/modules-umd/expected.js index f99576af2f..9808628579 100644 --- a/test/fixtures/transformation/self-contained/modules-umd/expected.js +++ b/test/fixtures/transformation/self-contained/modules-umd/expected.js @@ -8,5 +8,6 @@ "use strict"; var _babelHelpers = _babelRuntimeHelpers["default"]; + var foo = _babelHelpers.interopRequire(_foo); }); diff --git a/test/fixtures/transformation/self-contained/regenerator-runtime/expected.js b/test/fixtures/transformation/self-contained/regenerator-runtime/expected.js index 4c76fc466a..e9871b174e 100644 --- a/test/fixtures/transformation/self-contained/regenerator-runtime/expected.js +++ b/test/fixtures/transformation/self-contained/regenerator-runtime/expected.js @@ -1,6 +1,7 @@ "use strict"; var _regeneratorRuntime = require("babel-runtime/regenerator")["default"]; + void _regeneratorRuntime.mark(function callee$0$0() { return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) { while (1) switch (context$1$0.prev = context$1$0.next) { diff --git a/test/fixtures/transformation/self-contained/symbol-iterator-in/expected.js b/test/fixtures/transformation/self-contained/symbol-iterator-in/expected.js index e71041cfad..c533610e7f 100644 --- a/test/fixtures/transformation/self-contained/symbol-iterator-in/expected.js +++ b/test/fixtures/transformation/self-contained/symbol-iterator-in/expected.js @@ -1,4 +1,5 @@ "use strict"; var _core = require("babel-runtime/core-js")["default"]; + _core.$for.isIterable(Object(arr)); diff --git a/test/fixtures/transformation/spec-proto-to-assign/assignment-expression/expected.js b/test/fixtures/transformation/spec-proto-to-assign/assignment-expression/expected.js index 08369913d8..c562f1f1e7 100644 --- a/test/fixtures/transformation/spec-proto-to-assign/assignment-expression/expected.js +++ b/test/fixtures/transformation/spec-proto-to-assign/assignment-expression/expected.js @@ -1,10 +1,11 @@ "use strict"; var _foo, _foo$bar, _foo$bar2; + var _defaults = function (obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }; console.log((_foo = foo, _defaults(_foo, bar), _foo)); console.log((_foo$bar = foo[bar], _defaults(_foo$bar, bar), _foo$bar)); -console.log((_foo$bar2 = foo[bar()], _defaults(_foo$bar2, bar), _foo$bar2)); \ No newline at end of file +console.log((_foo$bar2 = foo[bar()], _defaults(_foo$bar2, bar), _foo$bar2));