Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8706754550 | ||
|
|
c7b507e119 | ||
|
|
221c632c05 | ||
|
|
7dbde208ef | ||
|
|
52a2e3e17c | ||
|
|
fa22d7dca0 | ||
|
|
9fcdebde08 | ||
|
|
92157161f0 | ||
|
|
82b5479436 | ||
|
|
91a037af55 | ||
|
|
067fccc2c9 | ||
|
|
348c0d2542 | ||
|
|
f2f6bbb02c | ||
|
|
16f7b967b5 | ||
|
|
270a8be68d | ||
|
|
82254d9d9b | ||
|
|
759a265fb0 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -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**
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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>",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
bar();
|
||||
|
||||
// bar
|
||||
export function foo() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
export { foo };
|
||||
bar();
|
||||
|
||||
// bar
|
||||
|
||||
function foo() {}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"blacklist": ["es6.modules"],
|
||||
"noCheckAst": true
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
var div = <div>test</div>;
|
||||
@@ -0,0 +1 @@
|
||||
var div = React.createElement("div", null, "test");
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"retainLines": true
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
var div = <div>test</div>;
|
||||
@@ -0,0 +1,5 @@
|
||||
var div = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"test"
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
var test = {
|
||||
setInterval: function(fn, ms) {
|
||||
setInterval(fn, ms);
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
})
|
||||
};
|
||||
Reference in New Issue
Block a user