Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13bbfa041d | ||
|
|
c43bbb9bf6 | ||
|
|
1bca59a921 | ||
|
|
f80fdf7359 | ||
|
|
aefd69d31e | ||
|
|
e328031b19 | ||
|
|
571b6a4cd7 | ||
|
|
41cf942391 | ||
|
|
98f28b8e89 | ||
|
|
8f88afc037 | ||
|
|
6359675a4f | ||
|
|
a265c3f25c | ||
|
|
29eb99ee93 | ||
|
|
0c5c1ff989 | ||
|
|
499951123a | ||
|
|
c0fd4c1f9e | ||
|
|
579e6fecee | ||
|
|
bb3665a3b6 | ||
|
|
e6de688234 | ||
|
|
4c233e88ff | ||
|
|
ae2ba0b5a3 | ||
|
|
e34d950793 | ||
|
|
e4083fbbd7 | ||
|
|
59ed7977ef | ||
|
|
dc441e9a8f | ||
|
|
2e21795f57 | ||
|
|
5c988f7fc8 |
16
.travis.yml
16
.travis.yml
@@ -12,3 +12,19 @@ script: "make test-travis"
|
||||
|
||||
notifications:
|
||||
slack: babeljs:5Wy4QX13KVkGy9CnU0rmvgeK
|
||||
|
||||
before_deploy:
|
||||
- make prepublish
|
||||
|
||||
after_deploy:
|
||||
- make publish-cli
|
||||
- make publish-runtime
|
||||
|
||||
deploy:
|
||||
provider: npm
|
||||
email: sebmck@gmail.com
|
||||
api_key:
|
||||
secure: BCS0BJ3gjs/fyAj5GrMIj4ZAs/S3Odr/FaCAGo8+mT1+Ayinq5uQb8n07k+TqLRQC+Bm1nkjUGg97UZwBmE6NkkNA9rJkC4HCzuXkwOUmE1MxActB2Jeo1tbl3VbbcMNVBo8oTckh1oBaXN2ZbvvPaQIXMAC+0oZwaeXT5dTzQc=
|
||||
on:
|
||||
tags: true
|
||||
repo: babel/babel
|
||||
|
||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -13,6 +13,23 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 5.6.12
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix finding parent for top-level shadowed functions.
|
||||
|
||||
## 5.6.11
|
||||
|
||||
** **Internal**
|
||||
* Merge `es6.parameters.rest` and `es6.parameters.default` transformers. See commit [c0fd4c1f9e0b18231f585c4fa793e4cb0e01aed1](https://github.com/babel/babel/commit/c0fd4c1f9e0b18231f585c4fa793e4cb0e01aed1) for more info.
|
||||
|
||||
## 5.6.10
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix faulty internal require check.
|
||||
* **Polish**
|
||||
* Add support for trailing commas in arrow function parameter lists.
|
||||
|
||||
## 5.6.8
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
34
Makefile
34
Makefile
@@ -9,7 +9,7 @@ BROWSERIFY_IGNORE = -i esprima-fb
|
||||
|
||||
export NODE_ENV = test
|
||||
|
||||
.PHONY: clean test test-cov test-clean test-travis test-simple test-all test-browser test-parser publish build bootstrap publish-core publish-runtime build-core watch-core build-core-test clean-core
|
||||
.PHONY: clean test test-cov test-clean test-travis test-simple test-all test-browser test-parser publish build bootstrap publish-core publish-runtime build-core watch-core build-core-test clean-core prepublish
|
||||
|
||||
build-core: clean-core
|
||||
node $(BABEL_CMD) src --out-dir lib --copy-files
|
||||
@@ -81,34 +81,20 @@ test-browser:
|
||||
|
||||
publish: lint
|
||||
git pull --rebase
|
||||
|
||||
make test
|
||||
|
||||
read -p "Version: " version; \
|
||||
npm version $$version --message "v%s"
|
||||
|
||||
make build
|
||||
|
||||
cp dist/browser.js browser.js
|
||||
cp dist/browser.min.js browser.min.js
|
||||
|
||||
cp dist/polyfill.js browser-polyfill.js
|
||||
cp dist/polyfill.min.js browser-polyfill.min.js
|
||||
|
||||
cp dist/external-helpers.js external-helpers.js
|
||||
cp dist/external-helpers.min.js external-helpers.min.js
|
||||
|
||||
node tools/cache-templates
|
||||
test -f templates.json
|
||||
|
||||
npm publish
|
||||
|
||||
git push --follow-tags
|
||||
|
||||
make publish-cli
|
||||
make publish-runtime
|
||||
|
||||
rm -rf templates.json browser.js browser.min.js browser-polyfill.js browser-polyfill.min.js external-helpers.js external-helpers.min.js
|
||||
prepublish: build
|
||||
cp dist/browser.js browser.js
|
||||
cp dist/browser.min.js browser.min.js
|
||||
cp dist/polyfill.js browser-polyfill.js
|
||||
cp dist/polyfill.min.js browser-polyfill.min.js
|
||||
cp dist/external-helpers.js external-helpers.js
|
||||
cp dist/external-helpers.min.js external-helpers.min.js
|
||||
node tools/cache-templates
|
||||
test -f templates.json
|
||||
|
||||
publish-runtime:
|
||||
cd packages; \
|
||||
|
||||
10
README.md
10
README.md
@@ -9,11 +9,17 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
For questions and support please visit the <a href="https://babel-slack.herokuapp.com">slack channel</a> or <a href="http://stackoverflow.com/questions/tagged/babeljs">StackOverflow</a>. The Babel issue tracker is <strong>exclusively</strong> for bug reports and feature requests.
|
||||
<a href="https://travis-ci.org/babel/babel"><img alt="Build Status" src="https://img.shields.io/travis/babel/babel.svg?style=flat"></a>
|
||||
<a href="http://issuestats.com/github/babel/babel"><img alt="Issue Stats" src="http://issuestats.com/github/babel/babel/badge/pr?style=flat"></a>
|
||||
<a href="http://issuestats.com/github/babel/babel"><img alt="Issue Stats" src="http://issuestats.com/github/babel/babel/badge/issue?style=flat"></a>
|
||||
<a href="http://badge.fury.io/js/babel-core"><img alt="npm version" src="https://badge.fury.io/js/babel-core.svg"></a>
|
||||
<a href="https://npmjs.org/package/babel-core"><img alt="Downloads" src="http://img.shields.io/npm/dm/babel-core.svg"></a>
|
||||
</p>
|
||||
|
||||
----
|
||||
|
||||
<p align="center">
|
||||
Issues without instructions to reproduce <strong>will be immediately closed<strong>.
|
||||
For questions and support please visit the <a href="https://babel-slack.herokuapp.com">slack channel</a> or <a href="http://stackoverflow.com/questions/tagged/babeljs">StackOverflow</a>. The Babel issue tracker is <strong>exclusively</strong> for bug reports and feature requests.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"name": "babel-core",
|
||||
"description": "A compiler for writing next generation JavaScript",
|
||||
"version": "5.6.8",
|
||||
"version": "5.6.13",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
"repository": "babel/babel",
|
||||
"main": "lib/babel/api/node.js",
|
||||
"browser": {
|
||||
"./lib/babel/api/register/node.js": "./lib/babel/api/register/browser.js"
|
||||
},
|
||||
@@ -77,7 +76,7 @@
|
||||
"trim-right": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel": "5.6.7",
|
||||
"babel": "5.6.10",
|
||||
"browserify": "^9.0.8",
|
||||
"chai": "^2.2.0",
|
||||
"eslint": "^0.21.2",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require("babel-core");
|
||||
|
||||
var moduleFormatters = require("babel-core/lib/babel/transformation/modules");
|
||||
var pathExists = require("path-exists");
|
||||
var commander = require("commander");
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "5.6.7",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
"repository": "babel/babel",
|
||||
"preferGlobal": true,
|
||||
"dependencies": {
|
||||
"babel-core": "^5.6.7",
|
||||
"babel-core": "^5.6.12",
|
||||
"chokidar": "^1.0.0",
|
||||
"commander": "^2.6.0",
|
||||
"convert-source-map": "^1.1.0",
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "5.6.7",
|
||||
"license": "MIT",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"dependencies": {
|
||||
"core-js": "^0.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,9 +432,18 @@ pp.parseParenAndDistinguishExpression = function(start, isAsync, canBeArrow) {
|
||||
}
|
||||
|
||||
let innerStart = this.markPosition(), exprList = [], first = true
|
||||
let refShorthandDefaultPos = {start: 0}, spreadStart, innerParenStart
|
||||
let refShorthandDefaultPos = {start: 0}, spreadStart, innerParenStart, optionalCommaStart
|
||||
while (this.type !== tt.parenR) {
|
||||
first ? first = false : this.expect(tt.comma)
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
this.expect(tt.comma)
|
||||
if (this.type === tt.parenR && this.options.features["es7.trailingFunctionCommas"]) {
|
||||
optionalCommaStart = this.start
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (this.type === tt.ellipsis) {
|
||||
let spreadNodeStart = this.markPosition()
|
||||
spreadStart = this.start
|
||||
@@ -462,6 +471,7 @@ pp.parseParenAndDistinguishExpression = function(start, isAsync, canBeArrow) {
|
||||
this.unexpected(this.lastTokStart)
|
||||
}
|
||||
}
|
||||
if (optionalCommaStart) this.unexpected(optionalCommaStart)
|
||||
if (spreadStart) this.unexpected(spreadStart)
|
||||
if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start)
|
||||
|
||||
|
||||
@@ -8,5 +8,8 @@
|
||||
"utility.inlineExpressions": "minification.constantFolding",
|
||||
"utility.deadCodeElimination": "minification.deadCodeElimination",
|
||||
"utility.removeConsoleCalls": "minification.removeConsole",
|
||||
"utility.removeDebugger": "minification.removeDebugger"
|
||||
"utility.removeDebugger": "minification.removeDebugger",
|
||||
|
||||
"es6.parameters.rest": "es6.parameters",
|
||||
"es6.parameters.default": "es6.parameters"
|
||||
}
|
||||
|
||||
@@ -70,7 +70,15 @@ export var visitor = {
|
||||
let pattern = node.params[i];
|
||||
if (!t.isPattern(pattern)) continue;
|
||||
|
||||
var ref = node.params[i] = scope.generateUidIdentifier("ref");
|
||||
var ref = scope.generateUidIdentifier("ref");
|
||||
if (t.isAssignmentPattern(pattern)) {
|
||||
var _pattern = pattern;
|
||||
pattern = pattern.left;
|
||||
_pattern.left = ref;
|
||||
} else {
|
||||
node.params[i] = ref;
|
||||
}
|
||||
|
||||
t.inherits(ref, pattern);
|
||||
|
||||
var destructuring = new DestructuringTransformer({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import callDelegate from "../../helpers/call-delegate";
|
||||
import getFunctionArity from "../../helpers/get-function-arity";
|
||||
import * as util from "../../../util";
|
||||
import * as t from "../../../types";
|
||||
import callDelegate from "../../../helpers/call-delegate";
|
||||
import getFunctionArity from "../../../helpers/get-function-arity";
|
||||
import * as util from "../../../../util";
|
||||
import * as t from "../../../../types";
|
||||
|
||||
var hasDefaults = function (node) {
|
||||
for (var i = 0; i < node.params.length; i++) {
|
||||
@@ -38,7 +38,7 @@ export var visitor = {
|
||||
|
||||
//
|
||||
var argsIdentifier = t.identifier("arguments");
|
||||
argsIdentifier._shadowedFunctionLiteral = true;
|
||||
argsIdentifier._shadowedFunctionLiteral = this;
|
||||
|
||||
// push a default parameter definition
|
||||
function pushDefNode(left, right, i) {
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as visitors from "../../../../traversal/visitors";
|
||||
|
||||
import * as def from "./default";
|
||||
import * as rest from "./rest";
|
||||
|
||||
export var metadata = {
|
||||
group: "builtin-advanced"
|
||||
};
|
||||
|
||||
export var visitor = visitors.merge([rest.visitor, def.visitor]);
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as util from "../../../util";
|
||||
import * as t from "../../../types";
|
||||
import * as util from "../../../../util";
|
||||
import * as t from "../../../../types";
|
||||
|
||||
var memberExpressionOptimisationVisitor = {
|
||||
Scope(node, parent, scope, state) {
|
||||
@@ -84,7 +84,7 @@ export var visitor = {
|
||||
var argsId = t.identifier("arguments");
|
||||
|
||||
// otherwise `arguments` will be remapped in arrow functions
|
||||
argsId._shadowedFunctionLiteral = true;
|
||||
argsId._shadowedFunctionLiteral = this;
|
||||
|
||||
// support patterns
|
||||
if (t.isPattern(rest)) {
|
||||
@@ -43,6 +43,10 @@ function build(props, scope) {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
export var metadata = {
|
||||
group: "builtin-advanced"
|
||||
};
|
||||
|
||||
export var visitor = {
|
||||
ArrayExpression(node, parent, scope) {
|
||||
var elements = node.elements;
|
||||
|
||||
@@ -211,7 +211,7 @@ class TailCallTransformer {
|
||||
var decl = t.variableDeclarator(this.argumentsId);
|
||||
if (this.argumentsId) {
|
||||
decl.init = t.identifier("arguments");
|
||||
decl.init._shadowedFunctionLiteral = true;
|
||||
decl.init._shadowedFunctionLiteral = this.path;
|
||||
}
|
||||
topVars.push(decl);
|
||||
}
|
||||
|
||||
@@ -46,9 +46,6 @@ export default {
|
||||
"es6.regex.sticky": require("./es6/regex.sticky"),
|
||||
"es6.regex.unicode": require("./es6/regex.unicode"),
|
||||
"es6.constants": require("./es6/constants"),
|
||||
"es6.parameters.rest": require("./es6/parameters.rest"),
|
||||
"es6.spread": require("./es6/spread"),
|
||||
"es6.parameters.default": require("./es6/parameters.default"),
|
||||
"es7.exportExtensions": require("./es7/export-extensions"),
|
||||
"spec.protoToAssign": require("babel-plugin-proto-to-assign"),
|
||||
"es7.doExpressions": require("./es7/do-expressions"),
|
||||
@@ -57,6 +54,8 @@ export default {
|
||||
"spec.undefinedToVoid": require("babel-plugin-undefined-to-void"),
|
||||
|
||||
//- builtin-advanced
|
||||
"es6.spread": require("./es6/spread"),
|
||||
"es6.parameters": require("./es6/parameters"),
|
||||
"es6.destructuring": require("./es6/destructuring"),
|
||||
"es6.blockScoping": require("./es6/block-scoping"),
|
||||
"es6.spec.blockScoping": require("./es6/spec.block-scoping"),
|
||||
|
||||
@@ -8,7 +8,30 @@ function remap(path, key, create) {
|
||||
// ensure that we're shadowed
|
||||
if (!path.inShadow()) return;
|
||||
|
||||
var fnPath = path.findParent((path) => !path.is("shadow") && (path.isFunction() || path.isProgram()));
|
||||
var shadowFunction = path.node._shadowedFunctionLiteral;
|
||||
var currentFunction;
|
||||
|
||||
var fnPath = path.findParent(function (path) {
|
||||
if (path.isProgram() || path.isFunction()) {
|
||||
// catch current function in case this is the shadowed one and we can ignore it
|
||||
currentFunction = currentFunction || path;
|
||||
}
|
||||
|
||||
if (path.isProgram()) {
|
||||
return true;
|
||||
} else if (path.isFunction()) {
|
||||
if (shadowFunction) {
|
||||
return path === shadowFunction || path.node === shadowFunction.node;
|
||||
} else {
|
||||
return !path.is("shadow");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// no point in realiasing if we're in this function
|
||||
if (fnPath === currentFunction) return;
|
||||
|
||||
var cached = fnPath.getData(key);
|
||||
if (cached) return cached;
|
||||
@@ -28,7 +51,7 @@ export var visitor = {
|
||||
},
|
||||
|
||||
ReferencedIdentifier(node) {
|
||||
if (node.name === "arguments" && !node._shadowedFunctionLiteral) {
|
||||
if (node.name === "arguments") {
|
||||
return remap(this, "arguments", () => t.identifier("arguments"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,8 @@ export function merge(visitors) {
|
||||
var rootVisitor = {};
|
||||
|
||||
for (var visitor of (visitors: Array)) {
|
||||
explode(visitor);
|
||||
|
||||
for (var type in visitor) {
|
||||
var nodeVisitor = rootVisitor[type] = rootVisitor[type] || {};
|
||||
mergePair(nodeVisitor, visitor[type]);
|
||||
|
||||
@@ -3374,6 +3374,49 @@ test("class Foo { bar(a,) { } }", {
|
||||
features: { "es7.trailingFunctionCommas": true }
|
||||
});
|
||||
|
||||
test("(x, y, ) => 1;", {
|
||||
start: 0,
|
||||
body: [{
|
||||
start: 0,
|
||||
expression: {
|
||||
start: 0,
|
||||
id: null,
|
||||
generator: false,
|
||||
expression: true,
|
||||
params: [
|
||||
{
|
||||
start: 1,
|
||||
name: "x",
|
||||
type: "Identifier",
|
||||
end: 2
|
||||
},
|
||||
{
|
||||
start: 4,
|
||||
name: "y",
|
||||
type: "Identifier",
|
||||
end: 5
|
||||
}
|
||||
],
|
||||
body: {
|
||||
start: 12,
|
||||
value: 1,
|
||||
raw: "1",
|
||||
type: "Literal",
|
||||
end: 13
|
||||
},
|
||||
type: "ArrowFunctionExpression",
|
||||
end: 13
|
||||
},
|
||||
type: "ExpressionStatement",
|
||||
end: 14
|
||||
}],
|
||||
type: "Program",
|
||||
end: 14
|
||||
}, {
|
||||
ecmaVersion: 7,
|
||||
features: { "es7.trailingFunctionCommas": true }
|
||||
});
|
||||
|
||||
testFail("log(,);", "Unexpected token (1:4)", {
|
||||
ecmaVersion: 7,
|
||||
features: { "es7.trailingFunctionCommas": true }
|
||||
@@ -3383,3 +3426,8 @@ testFail("function log(,) { }", "Unexpected token (1:13)", {
|
||||
ecmaVersion: 7,
|
||||
features: { "es7.trailingFunctionCommas": true }
|
||||
});
|
||||
|
||||
testFail("('foo',)", "Unexpected token (1:7)", {
|
||||
ecmaVersion: 7,
|
||||
features: { "es7.trailingFunctionCommas": true }
|
||||
});
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
function broken(x, ...foo) {
|
||||
if (true) {
|
||||
class Foo extends Bar { }
|
||||
return hello(...foo)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(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; }
|
||||
|
||||
function broken(x) {
|
||||
for (var _len = arguments.length, foo = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
foo[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (true) {
|
||||
var _ret = (function () {
|
||||
var Foo = (function (_Bar) {
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
|
||||
_get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments);
|
||||
}
|
||||
|
||||
_inherits(Foo, _Bar);
|
||||
|
||||
return Foo;
|
||||
})(Bar);
|
||||
|
||||
return {
|
||||
v: hello.apply(undefined, foo)
|
||||
};
|
||||
})();
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
(x, y, ) => {};
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (x, y) {});
|
||||
Reference in New Issue
Block a user