Compare commits

...

20 Commits

Author SHA1 Message Date
Sebastian McKenzie
612ef79d35 v5.6.4 2015-06-22 20:38:12 +01:00
Sebastian McKenzie
2dfa6ddf36 add 5.6.4 changelog 2015-06-22 20:37:00 +01:00
Sebastian McKenzie
2910d4f82c fix Program can only be replaced with another Program error 2015-06-22 20:36:34 +01:00
Sebastian McKenzie
4b6c954f5e add ParenthesizedExpression node type for plugins to generate 2015-06-22 20:36:12 +01:00
Sebastian McKenzie
b7e23e3410 5.6.3 2015-06-22 11:57:53 +01:00
Sebastian McKenzie
a19f10e124 v5.6.3 2015-06-22 11:56:46 +01:00
Sebastian McKenzie
8e1f134635 fix rest parameter array allocation loop being incorrectly aliased - fixes #1800 2015-06-22 11:54:57 +01:00
Sebastian McKenzie
aa151016f5 5.6.2 2015-06-22 00:10:56 +01:00
Sebastian McKenzie
ce3c6289a2 v5.6.2 2015-06-22 00:08:52 +01:00
Sebastian McKenzie
0364519869 remove unused import 2015-06-22 00:06:43 +01:00
Sebastian McKenzie
58cda35831 log spread element rest parameter as a candidate instead of replacing it in place - fixes #1796 2015-06-22 00:06:03 +01:00
Sebastian McKenzie
ebaa06f4a2 add ensureBlock path method 2015-06-21 23:59:14 +01:00
Sebastian McKenzie
4b0f624fb3 turn method literal keys into assignments in loose mode - fixes #1797 2015-06-21 23:59:06 +01:00
Sebastian McKenzie
aa0f3ac5d0 5.6.1 2015-06-21 00:07:07 +01:00
Sebastian McKenzie
725906a7dc v5.6.1 2015-06-21 00:05:13 +01:00
Sebastian McKenzie
13d5c94b8b update transformation tests 2015-06-21 00:03:29 +01:00
Sebastian McKenzie
85308a1e8c fix super spread in loose mode 2015-06-21 00:01:19 +01:00
Sebastian McKenzie
83bcaba1a5 downgrade to babel 5.5.7 2015-06-21 00:01:11 +01:00
Sebastian McKenzie
185648cb2c 5.6.0 2015-06-20 23:44:46 +01:00
Sebastian McKenzie
be355fc1c6 fix build-runtime script 2015-06-20 23:37:46 +01:00
29 changed files with 188 additions and 39 deletions

View File

@@ -13,6 +13,52 @@ _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.4
* **Internal**
* Add `ParenthesizedExpression` node type.
## 5.6.3
* **Bug Fix**
* Fix rest parameter array allocation loop being incorrectly aliased.
## 5.6.2
* **Bug Fix**
* Fix method key literals not turning into computed member expression in loose mode.
* Elect rest parameters in spread element position as candidates instead of replacing them in place.
## 5.6.0
* **Bug Fix**
* Fix istanbul interop for register hook when registering for non-existence extension.
* Fix super class constructor call differing for no constructor in derived classes.
* Disable module import receiver when in loose mode.
* Fix duplicate filenames when using `babel` CLI when passing multiple matching patterns.
* Register labels as bindings to fix undeclared variable checks.
* **Polish**
* Remove unnecessary string binary expressions when transforming template literals.
* Support module live bindings in arbitary positions not in Program statement position.
* Throw error when attemping to replace a `Program` root node with another node not of type `Program`.
* Optimise rest parameters in spread element position and allocate rest array at the earliest common ancestor of all references.
* Generate original number representation when value was not changed.
* Check for invalid binding identifiers when generating inferred method names.
* Don't terminate CLI when watching files fail compilation on init.
* **New Feature**
* Add new plugin API.
* **Internal**
* Split react displayName addition into a plugin.
* Add check for `JSXMemberExpression` to `t.isReferenced`.
* Move `validation.undeclaredVariableCheck` transformer up.
* Start great core-to-plugin exodus.
* Add `BindingIdentifier` virtual type.
* Hidden class optimisations.
* Array allocation optimisations.
* Update `regenerator`.
* Update `js-tokens`.
* Sync with upstream Acorn.
## 5.5.8
* **Internal**

View File

@@ -1,7 +1,7 @@
{
"name": "babel-core",
"description": "A compiler for writing next generation JavaScript",
"version": "5.6.0",
"version": "5.6.4",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
@@ -77,7 +77,7 @@
"trim-right": "^1.0.0"
},
"devDependencies": {
"babel": "5.5.8",
"babel": "5.5.7",
"browserify": "^9.0.8",
"chai": "^2.2.0",
"eslint": "^0.21.2",

View File

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

View File

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

View File

@@ -75,7 +75,7 @@ writeFile("regenerator/runtime.js", selfContainify(readFile("regenerator/runtime
//
var coreDefinitions = require("../lib/babel/transformation/transformers/other/runtime/definitions");
var coreDefinitions = require("babel-plugin-runtime/lib/definitions");
var paths = ["is-iterable", "get-iterator"];

View File

@@ -24,6 +24,12 @@ export function DoExpression(node, print) {
print.plain(node.body);
}
export function ParenthesizedExpression(node, print) {
this.push("(");
print.plain(node.expression);
this.push(")");
}
export function UpdateExpression(node, print) {
if (node.prefix) {
this.push(node.operator);

View File

@@ -169,7 +169,13 @@ export default class ReplaceSupers {
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superRef, t.identifier("call"));
if (parent.arguments.length === 2 && t.isSpreadElement(parent.arguments[1]) && t.isIdentifier(parent.arguments[1].argument, { name: "arguments" })) {
// special case single arguments spread
parent.arguments[1] = parent.arguments[1].argument;
return t.memberExpression(superRef, t.identifier("apply"));
} else {
return t.memberExpression(superRef, t.identifier("call"));
}
} else {
id = superRef;

View File

@@ -1,9 +1,6 @@
import * as t from "../../../types";
export var visitor = {
ArrowFunctionExpression(node) {
t.ensureBlock(node);
this.ensureBlock();
node.expression = false;
node.type = "FunctionExpression";
node.shadow = true;

View File

@@ -477,7 +477,7 @@ class ClassTransformer {
var classRef = this.classRef;
if (!node.static) classRef = t.memberExpression(classRef, t.identifier("prototype"));
var methodName = t.memberExpression(classRef, node.key, node.computed);
var methodName = t.memberExpression(classRef, node.key, node.computed || t.isLiteral(node.key));
var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
t.inheritsComments(expr, node);

View File

@@ -18,7 +18,7 @@ export var visitor = {
t.variableDeclarator(temp)
]);
t.ensureBlock(node);
this.ensureBlock();
node.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(left, temp)
@@ -48,7 +48,7 @@ export var visitor = {
destructuring.init(pattern, key);
t.ensureBlock(node);
this.ensureBlock();
var block = node.body;
block.body = nodes.concat(block.body);
@@ -84,7 +84,7 @@ export var visitor = {
destructuring.init(pattern, ref);
}
t.ensureBlock(node);
this.ensureBlock();
var block = node.body;
block.body = nodes.concat(block.body);

View File

@@ -17,7 +17,7 @@ export var visitor = {
var block = loop.body;
// ensure that it's a block so we can take all its statements
t.ensureBlock(node);
this.ensureBlock();
// add the value declaration to the new loop body
if (declar) {

View File

@@ -27,7 +27,7 @@ export var visitor = {
if (!hasDefaults(node)) return;
// ensure it's a block, useful for arrow functions
t.ensureBlock(node);
this.ensureBlock();
var state = {
iife: false,

View File

@@ -42,7 +42,8 @@ var memberExpressionOptimisationVisitor = {
if (this.parentPath.isSpreadElement() && state.offset === 0) {
var call = this.parentPath.parentPath;
if (call.isCallExpression() && call.node.arguments.length === 1) {
return state.argumentsNode;
state.candidates.push(this);
return;
}
}
}
@@ -99,7 +100,6 @@ export var visitor = {
}
// check and optimise for extremely common cases
var state = {
references: [],
offset: node.params.length,
@@ -124,7 +124,9 @@ export var visitor = {
if (state.candidates.length) {
for (var candidate of (state.candidates: Array)) {
candidate.replaceWith(argsId);
optimiseMemberExpression(candidate.parent, state.offset);
if (candidate.parentPath.isMemberExpression()) {
optimiseMemberExpression(candidate.parent, state.offset);
}
}
}
return;
@@ -132,6 +134,9 @@ export var visitor = {
state.references = state.references.concat(state.candidates);
}
// deopt shadowed functions as transforms like regenerator may try touch the allocation loop
state.deopted = state.deopted || !!node.shadow;
//
var start = t.literal(node.params.length);
@@ -170,13 +175,13 @@ export var visitor = {
LEN: len
});
if (!state.deopted) {
if (state.deopted) {
loop._blockHoist = node.params.length + 1;
node.body.body.unshift(loop);
} else {
// perform allocation at the lowest common denominator of all references
loop._blockHoist = 1;
this.getEarliestCommonAncestorFrom(state.references).getStatementParent().insertBefore(loop);
return;
}
loop._blockHoist = node.params.length + 1;
node.body.body.unshift(loop);
}
};

View File

@@ -1,7 +1,7 @@
import * as t from "../../../types";
function getSpreadLiteral(spread, scope) {
if (scope.hub.file.isLoose("es6.spread")) {
if (scope.hub.file.isLoose("es6.spread") && !t.isIdentifier(spread.argument, { name: "arguments" })) {
return spread.argument;
} else {
return scope.toArray(spread.argument, true);

View File

@@ -150,7 +150,7 @@ class TailCallTransformer {
//
var body = t.ensureBlock(node).body;
var body = this.path.ensureBlock().body;
for (var i = 0; i < body.length; i++) {
var bodyNode = body[i];

View File

@@ -22,3 +22,11 @@ export function toComputedKey(): Object {
return key;
}
/**
* Description
*/
export function ensureBlock() {
return t.ensureBlock(this.node);
}

View File

@@ -92,14 +92,14 @@ export function replaceWith(replacement, whateverAllowed) {
return;
}
if (this.isProgram() && !t.isProgram(replacement)) {
throw new Error("You can only replace a Program root node with another Program node");
}
// normalise inserting an entire AST
if (t.isProgram(replacement) && !this.isProgram()) {
replacement = replacement.body;
whateverAllowed = true;
} else {
if (this.isProgram()) {
throw new Error("You can only replace a Program root node with another Program node");
}
}
if (Array.isArray(replacement)) {

View File

@@ -71,6 +71,7 @@
"MetaProperty": ["Expression"],
"NewExpression": ["Expression"],
"ObjectExpression": ["Expression"],
"ParenthesizedExpression": ["Expression"],
"SequenceExpression": ["Expression"],
"TaggedTemplateExpression": ["Expression"],
"ThisExpression": ["Expression"],

View File

@@ -46,6 +46,7 @@
"Noop": [],
"ObjectExpression": ["properties"],
"ObjectPattern": ["properties", "typeAnnotation"],
"ParenthesizedExpression": ["expression"],
"Program": ["body"],
"Property": ["key", "value", "decorators"],
"RestElement": ["argument", "typeAnnotation"],

View File

@@ -10,7 +10,7 @@ var Test = (function (_Foo) {
_Foo.call(this);
_Foo.prototype.test.call(this);
_Foo.call.apply(_Foo, [this].concat(babelHelpers.slice.call(arguments)));
_Foo.apply(this, arguments);
_Foo.call.apply(_Foo, [this, "test"].concat(babelHelpers.slice.call(arguments)));
(_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(babelHelpers.slice.call(arguments)));
@@ -36,4 +36,4 @@ var Test = (function (_Foo) {
};
return Test;
})(Foo);
})(Foo);

View File

@@ -0,0 +1,5 @@
class Foo {
"bar"() {
}
}

View File

@@ -0,0 +1,11 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
Foo.prototype["bar"] = function bar() {};
return Foo;
})();

View File

@@ -4,7 +4,7 @@ var BaseController = (function (_Chaplin$Controller) {
function BaseController() {
babelHelpers.classCallCheck(this, BaseController);
_Chaplin$Controller.call.apply(_Chaplin$Controller, [this].concat(babelHelpers.slice.call(arguments)));
_Chaplin$Controller.apply(this, arguments);
}
babelHelpers.inherits(BaseController, _Chaplin$Controller);
@@ -15,9 +15,9 @@ var BaseController2 = (function (_Chaplin$Controller$Another) {
function BaseController2() {
babelHelpers.classCallCheck(this, BaseController2);
_Chaplin$Controller$Another.call.apply(_Chaplin$Controller$Another, [this].concat(babelHelpers.slice.call(arguments)));
_Chaplin$Controller$Another.apply(this, arguments);
}
babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2;
})(Chaplin.Controller.Another);
})(Chaplin.Controller.Another);

View File

@@ -4,9 +4,9 @@ var Test = (function (_Foo) {
function Test() {
babelHelpers.classCallCheck(this, Test);
_Foo.call.apply(_Foo, [this].concat(babelHelpers.slice.call(arguments)));
_Foo.apply(this, arguments);
}
babelHelpers.inherits(Test, _Foo);
return Test;
})(Foo);
})(Foo);

View File

@@ -0,0 +1,7 @@
var fn = async (...rest) => rest;
var fn = async (...rest) => {
if (true) {
rest;
}
};

View File

@@ -0,0 +1,39 @@
"use strict";
var _this = this;
var fn = function fn() {
for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key];
}
return regeneratorRuntime.async(function fn$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
return context$1$0.abrupt("return", rest);
case 1:
case "end":
return context$1$0.stop();
}
}, null, _this);
};
var fn = function fn() {
for (var _len2 = arguments.length, rest = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
rest[_key2] = arguments[_key2];
}
return regeneratorRuntime.async(function fn$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
if (true) {
rest;
}
case 1:
case "end":
return context$1$0.stop();
}
}, null, _this);
};

View File

@@ -0,0 +1,3 @@
{
"stage": 0
}

View File

@@ -13,3 +13,8 @@ function foo(a, ...b) {
function foo(...b) {
foo(1, ...b);
}
function foo(...args){
args.pop()
foo(...args);
}

View File

@@ -23,3 +23,12 @@ function foo() {
foo.apply(undefined, [1].concat(b));
}
function foo() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
args.pop();
foo.apply(undefined, args);
}