Compare commits

...

17 Commits

Author SHA1 Message Date
Sebastian McKenzie
8706754550 v5.4.6 2015-05-21 18:46:22 +01:00
Sebastian McKenzie
c7b507e119 add 5.4.6 changelog 2015-05-21 18:45:31 +01:00
Sebastian McKenzie
221c632c05 deprecate custom module formatters 2015-05-21 18:44:02 +01:00
Sebastian McKenzie
7dbde208ef spec.functionName transformer: hasBinding(name) returns true for built-in globals, so we attempt to rename the binding but it doesn't exist so exits early, add a check that doesn't perform the renaming and instead uses the wrapper - fixes #1598 2015-05-21 18:43:55 +01:00
Sebastian McKenzie
52a2e3e17c return original input if glob returned nothing in babel-cli - fixes #1591 2015-05-21 10:57:37 +01:00
Sebastian McKenzie
fa22d7dca0 5.4.5 2015-05-21 01:52:03 +01:00
Sebastian McKenzie
9fcdebde08 v5.4.5 2015-05-21 01:44:29 +01:00
Sebastian McKenzie
92157161f0 fix prettyCall generation option 2015-05-21 01:43:02 +01:00
Sebastian McKenzie
82b5479436 add 5.4.5 changelog 2015-05-21 01:41:30 +01:00
Sebastian McKenzie
91a037af55 Merge pull request #1590 from Khan/fix_retainLines_with_jsx
tests for retainLines formatting
2015-05-21 01:39:33 +01:00
Kevin Barabash
067fccc2c9 tests for retainLines formatting 2015-05-20 18:36:47 -06:00
Sebastian McKenzie
348c0d2542 handle TCO for calls that exceed the functions parameter count - fixes #1589 2015-05-21 01:21:49 +01:00
Sebastian McKenzie
f2f6bbb02c clean up explosion of module declarations, remove and inherit comments when taking off the declaration - fixes #1583 2015-05-21 01:03:23 +01:00
Sebastian McKenzie
16f7b967b5 ignore CallExpression _prettyCall when retainLines is enabled - fixes #1585 2015-05-21 00:21:18 +01:00
Sebastian McKenzie
270a8be68d add JSXIdentifier as a valid ReferencedIdentifier - fixes #1584 2015-05-21 00:20:53 +01:00
Sebastian McKenzie
82254d9d9b force push space for await/async - fixes #1581 2015-05-20 12:45:04 +01:00
Sebastian McKenzie
759a265fb0 5.4.4 2015-05-20 10:52:28 +01:00
24 changed files with 167 additions and 38 deletions

View File

@@ -13,6 +13,21 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 5.4.6
* **Bug Fix**
* Fix `spec.functionName` transformer incorrectly attempting to rename a binding that doesn't exist as it's a global.
* **Internal**
* Deprecate custom module formatters.
## 5.4.5
* **Bug Fix**
* Add `JSXIdentifier` as a valid `ReferencedIdentifier` visitor virtual type.
* Ignore `CallExpression` `_prettyCall` when the `retainLines` option is enabled.
* Inherit comments to new declaration node when exploding module declarations.
* Fix `es6.tailCall` transformer failing on calls that exceed the max parameters of the function.
## 5.4.4
* **Bug Fix**

View File

@@ -1,7 +1,7 @@
{
"name": "babel-core",
"description": "A compiler for writing next generation JavaScript",
"version": "5.4.4",
"version": "5.4.6",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",

View File

@@ -79,7 +79,9 @@ if (commander.extensions) {
var errors = [];
var filenames = commander.args.reduce(function (globbed, input) {
return globbed.concat(glob.sync(input));
var files = glob.sync(input);
if (!files.length) files = [input];
return globbed.concat(files);
}, []);
each(filenames, function (filename) {

View File

@@ -1,14 +1,14 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "5.4.3",
"version": "5.4.5",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
"repository": "babel/babel",
"preferGlobal": true,
"dependencies": {
"babel-core": "^5.4.3",
"babel-core": "^5.4.5",
"chokidar": "^1.0.0",
"commander": "^2.6.0",
"convert-source-map": "^1.1.0",

View File

@@ -1,7 +1,7 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "5.4.3",
"version": "5.4.5",
"license": "MIT",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

View File

@@ -79,7 +79,9 @@ export function CallExpression(node, print) {
var separator = ",";
if (node._prettyCall) {
var isPrettyCall = node._prettyCall && !this.format.retainLines;
if (isPrettyCall) {
separator += "\n";
this.newline();
this.indent();
@@ -89,7 +91,7 @@ export function CallExpression(node, print) {
print.list(node.arguments, { separator: separator });
if (node._prettyCall) {
if (isPrettyCall) {
this.newline();
this.dedent();
}
@@ -106,7 +108,7 @@ var buildYieldAwait = function (keyword) {
}
if (node.argument) {
this.space();
this.push(" ");
print(node.argument);
}
};

View File

@@ -420,6 +420,10 @@ export default class File {
getModuleFormatter(type: string) {
if (isFunction(type) || !moduleFormatters[type]) {
this.log.deprecate("Custom module formatters are deprecated and will be removed in the next major. Please use Babel plugins instead.");
}
var ModuleFormatter = isFunction(type) ? type : moduleFormatters[type];
if (!ModuleFormatter) {

View File

@@ -20,7 +20,7 @@ var visitor = {
var wrap = function (state, method, id, scope) {
if (state.selfReference) {
if (scope.hasBinding(id.name)) {
if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {
// we can just munge the local binding
scope.rename(id.name);
} else {

View File

@@ -51,7 +51,7 @@ var visitor = {
},
ReferencedIdentifier(node, parent, scope, state) {
if (node.name === "arguments" && !state.isShadowed) {
if (node.name === "arguments" && (!state.isShadowed || node._shadowedFunctionLiteral)) {
state.needsArguments = true;
state.argumentsPaths.push(this);
}
@@ -211,6 +211,7 @@ class TailCallTransformer {
var decl = t.variableDeclarator(this.argumentsId);
if (this.argumentsId) {
decl.init = t.identifier("arguments");
decl.init._shadowedFunctionLiteral = true;
}
topVars.push(decl);
}
@@ -291,7 +292,8 @@ class TailCallTransformer {
}
subTransformCallExpression(node) {
var callee = node.callee, thisBinding, args;
var callee = node.callee;
var thisBinding, args;
if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) {
switch (callee.property.name) {
@@ -301,6 +303,7 @@ class TailCallTransformer {
case "apply":
args = node.arguments[1] || t.identifier("undefined");
this.needsArguments = true;
break;
default:
@@ -334,6 +337,10 @@ class TailCallTransformer {
args = t.arrayExpression(node.arguments);
}
if (t.isArrayExpression(args) && args.elements.length > this.node.params.length) {
this.needsArguments = true;
}
var argumentsId = this.getArgumentsId();
var params = this.getParams();

View File

@@ -7,6 +7,14 @@
import clone from "lodash/lang/clone";
import * as t from "../../../types";
function getDeclar(node) {
var declar = node.declaration;
t.inheritsComments(declar, node);
t.removeComments(node);
declar._ignoreUserWhitespace = true;
return declar;
}
export var metadata = {
group: "builtin-setup"
};
@@ -24,28 +32,28 @@ export function ExportDefaultDeclaration(node, parent, scope) {
var declar = node.declaration;
var getDeclar = function () {
declar._ignoreUserWhitespace = true;
return declar;
};
if (t.isClassDeclaration(declar)) {
// export default class Foo {};
var nodes = [getDeclar(node), node];
node.declaration = declar.id;
return [getDeclar(), node];
return nodes;
} else if (t.isClassExpression(declar)) {
// export default class {};
var temp = scope.generateUidIdentifier("default");
declar = t.variableDeclaration("var", [
node.declaration = t.variableDeclaration("var", [
t.variableDeclarator(temp, declar)
]);
var nodes = [getDeclar(node), node];
node.declaration = temp;
return [getDeclar(), node];
return nodes;
} else if (t.isFunctionDeclaration(declar)) {
// export default function Foo() {}
node._blockHoist = 2;
var nodes = [getDeclar(node), node];
node.declaration = declar.id;
return [getDeclar(), node];
return nodes;
}
}
@@ -58,22 +66,20 @@ export function ExportNamedDeclaration(node, parent, scope) {
var declar = node.declaration;
var getDeclar = function () {
declar._ignoreUserWhitespace = true;
return declar;
};
if (t.isClassDeclaration(declar)) {
// export class Foo {}
node.specifiers = [buildExportSpecifier(declar.id)];
var nodes = [getDeclar(node), node];
node.declaration = null;
return [getDeclar(), node];
return nodes;
} else if (t.isFunctionDeclaration(declar)) {
// export function Foo() {}
node.specifiers = [buildExportSpecifier(declar.id)];
node.declaration = null;
node._blockHoist = 2;
return [getDeclar(), node];
var nodes = [getDeclar(node), node];
node.declaration = null;
return nodes;
} else if (t.isVariableDeclaration(declar)) {
// export var foo = "bar";
var specifiers = [];

View File

@@ -1,14 +1,14 @@
import * as t from "../../types";
export var ReferencedIdentifier = {
type: "Identifier",
types: ["Identifier", "JSXIdentifier"],
checkPath(path, opts) {
return t.isReferencedIdentifier(path.node, path.parent, opts);
}
};
export var Scope = {
type: "Scopable",
types: ["Scopable"],
checkPath(path) {
return t.isScope(path.node, path.parent);
}
@@ -27,7 +27,7 @@ export var BlockScoped = {
};
export var Var = {
type: "VariableDeclaration",
types: ["VariableDeclaration"],
checkPath(path) {
return t.isVar(path.node);
}

View File

@@ -29,19 +29,21 @@ export function explode(visitor, mergeConflicts) {
// wrap all the functions
var fns = visitor[nodeType];
for (var type in fns) {
for (let type in fns) {
fns[type] = wrapCheck(wrapper, fns[type]);
}
// clear it from the visitor
delete visitor[nodeType];
if (wrapper.type) {
// merge the visitor if necessary or just put it back in
if (visitor[wrapper.type]) {
mergePair(visitor[wrapper.type], fns);
} else {
visitor[wrapper.type] = fns;
if (wrapper.types) {
for (let type of (wrapper.types: Array)) {
// merge the visitor if necessary or just put it back in
if (visitor[type]) {
mergePair(visitor[type], fns);
} else {
visitor[type] = fns;
}
}
} else {
mergePair(visitor, fns);

View File

@@ -0,0 +1,4 @@
bar();
// bar
export function foo() {}

View File

@@ -0,0 +1,8 @@
"use strict";
export { foo };
bar();
// bar
function foo() {}

View File

@@ -0,0 +1,4 @@
{
"blacklist": ["es6.modules"],
"noCheckAst": true
}

View File

@@ -0,0 +1,9 @@
var count = (i = 10) => {
if (!i) return;
return count(i - 1);
};
function count2(i = 10) {
if (!i) return;
return count2(i - 1);
}

View File

@@ -0,0 +1,33 @@
"use strict";
var count = function count() {
var _arguments = arguments;
var _again = true;
_function: while (_again) {
i = undefined;
_again = false;
var i = _arguments[0] === undefined ? 10 : _arguments[0];
if (!i) return;
_arguments = [i - 1];
_again = true;
continue _function;
}
};
function count2() {
var _arguments2 = arguments;
var _again2 = true;
_function2: while (_again2) {
i = undefined;
_again2 = false;
var i = _arguments2[0] === undefined ? 10 : _arguments2[0];
if (!i) return;
_arguments2 = [i - 1];
_again2 = true;
continue _function2;
}
}

View File

@@ -0,0 +1 @@
var div = <div>test</div>;

View File

@@ -0,0 +1 @@
var div = React.createElement("div", null, "test");

View File

@@ -0,0 +1,3 @@
{
"retainLines": true
}

View File

@@ -0,0 +1 @@
var div = <div>test</div>;

View File

@@ -0,0 +1,5 @@
var div = React.createElement(
"div",
null,
"test"
);

View File

@@ -0,0 +1,5 @@
var test = {
setInterval: function(fn, ms) {
setInterval(fn, ms);
}
};

View File

@@ -0,0 +1,17 @@
"use strict";
var test = {
setInterval: (function (_setInterval) {
function setInterval(_x, _x2) {
return _setInterval.apply(this, arguments);
}
setInterval.toString = function () {
return _setInterval.toString();
};
return setInterval;
})(function (fn, ms) {
setInterval(fn, ms);
})
};