Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e530afd78 | ||
|
|
6c66a82b37 | ||
|
|
737abca3a9 | ||
|
|
9db43ca7a9 | ||
|
|
25b0683316 | ||
|
|
a096f6b1c5 | ||
|
|
e41ab2ab0c | ||
|
|
6a6764fa7b | ||
|
|
a2358d6863 | ||
|
|
612ef79d35 | ||
|
|
2dfa6ddf36 | ||
|
|
2910d4f82c | ||
|
|
4b6c954f5e | ||
|
|
b7e23e3410 | ||
|
|
a19f10e124 | ||
|
|
8e1f134635 | ||
|
|
aa151016f5 |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -13,6 +13,22 @@ _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**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-core",
|
||||
"description": "A compiler for writing next generation JavaScript",
|
||||
"version": "5.6.2",
|
||||
"version": "5.6.5",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
@@ -64,7 +64,7 @@
|
||||
"output-file-sync": "^1.1.0",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"private": "^0.1.6",
|
||||
"regenerator": "0.8.30",
|
||||
"regenerator": "0.8.31",
|
||||
"regexpu": "^1.1.2",
|
||||
"repeating": "^1.1.2",
|
||||
"resolve": "^1.1.6",
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "5.6.1",
|
||||
"version": "5.6.4",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
"repository": "babel/babel",
|
||||
"preferGlobal": true,
|
||||
"dependencies": {
|
||||
"babel-core": "^5.6.1",
|
||||
"babel-core": "^5.6.4",
|
||||
"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.6.1",
|
||||
"version": "5.6.4",
|
||||
"license": "MIT",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -33,13 +33,13 @@ export function ForStatement(node, print) {
|
||||
this.push(";");
|
||||
|
||||
if (node.test) {
|
||||
this.push(" ");
|
||||
this.space();
|
||||
print.plain(node.test);
|
||||
}
|
||||
this.push(";");
|
||||
|
||||
if (node.update) {
|
||||
this.push(" ");
|
||||
this.space();
|
||||
print.plain(node.update);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@ var memberExpressionOptimisationVisitor = {
|
||||
Function(node, parent, scope, state) {
|
||||
// skip over functions as whatever `arguments` we reference inside will refer
|
||||
// to the wrong function
|
||||
var oldNoOptimise = state.noOptimise;
|
||||
state.noOptimise = true;
|
||||
this.traverse(memberExpressionOptimisationVisitor, state);
|
||||
state.noOptimise = false;
|
||||
state.noOptimise = oldNoOptimise;
|
||||
this.skip();
|
||||
},
|
||||
|
||||
@@ -27,7 +28,9 @@ var memberExpressionOptimisationVisitor = {
|
||||
// is this a referenced identifier and is it referencing the rest parameter?
|
||||
if (node.name !== state.name) return;
|
||||
|
||||
if (!state.noOptimise) {
|
||||
if (state.noOptimise) {
|
||||
state.deopted = true;
|
||||
} else {
|
||||
if (this.parentPath.isMemberExpression({ computed: true, object: node })) {
|
||||
// if we know that this member expression is referencing a number then we can safely
|
||||
// optimise it
|
||||
@@ -46,11 +49,7 @@ var memberExpressionOptimisationVisitor = {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.noOptimise) {
|
||||
state.deopted = true;
|
||||
} else {
|
||||
state.references.push(this);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +99,6 @@ export var visitor = {
|
||||
}
|
||||
|
||||
// check and optimise for extremely common cases
|
||||
|
||||
var state = {
|
||||
references: [],
|
||||
offset: node.params.length,
|
||||
@@ -135,6 +133,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);
|
||||
@@ -173,13 +174,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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,9 +61,11 @@ export function _getTypeAnnotation(): ?Object {
|
||||
* Description
|
||||
*/
|
||||
|
||||
export function isBaseType(baseName: string): boolean {
|
||||
var type = this.getTypeAnnotation();
|
||||
export function isBaseType(baseName: string, soft?): boolean {
|
||||
return _isBaseType(baseName, this.getTypeAnnotation(), soft);
|
||||
}
|
||||
|
||||
function _isBaseType(baseName: string, type?, soft?): boolean {
|
||||
if (baseName === "string") {
|
||||
return t.isStringTypeAnnotation(type);
|
||||
} else if (baseName === "number") {
|
||||
@@ -75,7 +77,31 @@ export function isBaseType(baseName: string): boolean {
|
||||
} else if (baseName === "mixed") {
|
||||
return t.isMixedTypeAnnotation(type);
|
||||
} else {
|
||||
throw new Error(`Unknown base type ${baseName}`);
|
||||
if (soft) {
|
||||
return false;
|
||||
} else {
|
||||
throw new Error(`Unknown base type ${baseName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
|
||||
export function couldBeBaseType(name: string): boolean {
|
||||
var type = this.getTypeAnnotation();
|
||||
if (t.isAnyTypeAnnotation(type)) return true;
|
||||
|
||||
if (t.isUnionTypeAnnotation(type)) {
|
||||
for (var type2 of (type.types: Array)) {
|
||||
if (t.isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return _isBaseType(name, type, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ export function ObjectExpression() {
|
||||
|
||||
//
|
||||
|
||||
export function ArrayExpression () {
|
||||
export function ArrayExpression() {
|
||||
return t.genericTypeAnnotation(t.identifier("Array"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
"MetaProperty": ["Expression"],
|
||||
"NewExpression": ["Expression"],
|
||||
"ObjectExpression": ["Expression"],
|
||||
"ParenthesizedExpression": ["Expression"],
|
||||
"SequenceExpression": ["Expression"],
|
||||
"TaggedTemplateExpression": ["Expression"],
|
||||
"ThisExpression": ["Expression"],
|
||||
|
||||
@@ -23,7 +23,7 @@ export function isReferenced(node: Object, parent: Object): boolean {
|
||||
switch (parent.type) {
|
||||
// yes: PARENT[NODE]
|
||||
// yes: NODE.child
|
||||
// no: parent.CHILD
|
||||
// no: parent.NODE
|
||||
case "MemberExpression":
|
||||
case "JSXMemberExpression":
|
||||
if (parent.property === node && parent.computed) {
|
||||
@@ -73,21 +73,17 @@ export function isReferenced(node: Object, parent: Object): boolean {
|
||||
return parent.local === node;
|
||||
}
|
||||
|
||||
// no: import NODE from "foo";
|
||||
case "ImportDefaultSpecifier":
|
||||
return false;
|
||||
|
||||
// no: import * as NODE from "foo";
|
||||
case "ImportNamespaceSpecifier":
|
||||
return false;
|
||||
|
||||
// no: <div NODE="foo" />
|
||||
case "JSXAttribute":
|
||||
return parent.name !== node;
|
||||
|
||||
// no: import NODE from "foo";
|
||||
// no: import * as NODE from "foo";
|
||||
// no: import { NODE as foo } from "foo";
|
||||
// no: import { foo as NODE } from "foo";
|
||||
// no: import NODE from "bar";
|
||||
case "ImportDefaultSpecifier":
|
||||
case "ImportNamespaceSpecifier":
|
||||
case "ImportSpecifier":
|
||||
return false;
|
||||
|
||||
@@ -112,12 +108,16 @@ export function isReferenced(node: Object, parent: Object): boolean {
|
||||
case "RestElement":
|
||||
return false;
|
||||
|
||||
// no: [NODE = foo] = [];
|
||||
// yes: [foo = NODE] = [];
|
||||
// yes: left = NODE;
|
||||
// no: NODE = right;
|
||||
case "AssignmentExpression":
|
||||
case "AssignmentPattern":
|
||||
return parent.right === node;
|
||||
|
||||
// no: [NODE = foo] = [];
|
||||
// no: [foo = NODE] = [];
|
||||
case "AssignmentPattern":
|
||||
return false;
|
||||
|
||||
// no: [NODE] = [];
|
||||
// no: ({ NODE }) = [];
|
||||
case "ObjectPattern":
|
||||
@@ -195,7 +195,7 @@ export function isImmutable(node: Object): boolean {
|
||||
|
||||
if (t.isLiteral(node)) {
|
||||
if (node.regex) {
|
||||
// regexes are mutable
|
||||
// regexs are mutable
|
||||
return false;
|
||||
} else {
|
||||
// immutable!
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"Noop": [],
|
||||
"ObjectExpression": ["properties"],
|
||||
"ObjectPattern": ["properties", "typeAnnotation"],
|
||||
"ParenthesizedExpression": ["expression"],
|
||||
"Program": ["body"],
|
||||
"Property": ["key", "value", "decorators"],
|
||||
"RestElement": ["argument", "typeAnnotation"],
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
var fn = async (...rest) => rest;
|
||||
|
||||
var fn = async (...rest) => {
|
||||
if (true) {
|
||||
rest;
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"stage": 0
|
||||
}
|
||||
@@ -41,3 +41,12 @@ function r(...rest){
|
||||
if (lol) rest;
|
||||
rest;
|
||||
}
|
||||
|
||||
// nested functions
|
||||
function a(...args) {
|
||||
return function() {
|
||||
function b() {}
|
||||
|
||||
console.log("Shouldn't args be from a's scope?", args);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,3 +64,16 @@ function r() {
|
||||
if (lol) rest;
|
||||
rest;
|
||||
}
|
||||
|
||||
// nested functions
|
||||
function a() {
|
||||
for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
||||
args[_key6] = arguments[_key6];
|
||||
}
|
||||
|
||||
return function () {
|
||||
function b() {}
|
||||
|
||||
console.log("Shouldn't args be from a's scope?", args);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user