Compare commits

...

12 Commits

Author SHA1 Message Date
Sebastian McKenzie
e8c672bf4f v5.6.7 2015-06-25 04:17:52 +01:00
Sebastian McKenzie
7083ac61ff remove test.js 2015-06-25 04:16:06 +01:00
Sebastian McKenzie
d256809120 Merge branch 'master' of github.com:babel/babel
# Conflicts:
#	src/babel/traversal/path/replacement.js
2015-06-25 04:12:13 +01:00
Sebastian McKenzie
26a19f82d2 add 5.6.7 changelog 2015-06-25 04:11:40 +01:00
Sebastian McKenzie
128d3b5c91 add missing computed loose test - ref #1820 2015-06-25 04:11:32 +01:00
Sebastian McKenzie
c1a080d0ca supress duplicate deprecation messages 2015-06-25 04:11:13 +01:00
Sebastian McKenzie
0b1ce6c9a4 always coerce leading computed property initialisers into the init object - fixes #1820 2015-06-25 04:10:56 +01:00
Sebastian McKenzie
a6f04055c0 fix block scoping transformer 2015-06-25 04:10:32 +01:00
Sebastian McKenzie
c3219e8b88 deprecate returning source strings from visitor methods 2015-06-25 03:51:25 +01:00
Sebastian McKenzie
a35c863341 deprecate returning source strings from visitor methods 2015-06-25 03:50:10 +01:00
Sebastian McKenzie
6f862a4c45 actually push for left declaration to the returned block scoping body - fixes #1819 2015-06-25 03:48:29 +01:00
Sebastian McKenzie
cf38210fd2 5.6.6 2015-06-24 23:28:44 +01:00
13 changed files with 79 additions and 33 deletions

View File

@@ -13,6 +13,15 @@ _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.7
* **Bug Fix**
* Fix hoisting of `ForXStatement` `left` `var`s when inserting a block scoping IIFE.
* **Polish**
* Combine all leading computed property initialisers into the root object in loose mode.
* **Internal**
* Deprecate returning of replacement strings from visitor methods.
## 5.6.6
* **Bug Fix**

View File

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

View File

@@ -1,14 +1,14 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "5.6.5",
"version": "5.6.6",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
"repository": "babel/babel",
"preferGlobal": true,
"dependencies": {
"babel-core": "^5.6.5",
"babel-core": "^5.6.6",
"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.6.5",
"version": "5.6.6",
"license": "MIT",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

View File

@@ -4,6 +4,8 @@ import buildDebug from "debug/node";
var verboseDebug = buildDebug("babel:verbose");
var generalDebug = buildDebug("babel");
var seenDeprecatedMessages = [];
export default class Logger {
constructor(file: File, filename: string) {
this.filename = filename;
@@ -25,9 +27,17 @@ export default class Logger {
}
deprecate(msg) {
if (!this.file.opts.suppressDeprecationMessages) {
console.error(this._buildMessage(msg));
}
if (this.file.opts.suppressDeprecationMessages) return;
msg = this._buildMessage(msg);
// already seen this message
if (seenDeprecatedMessages.indexOf(msg) >= 0) return;
// make sure we don't see it again
seenDeprecatedMessages.push(msg);
console.error(msg);
}
verbose(msg: string) {

View File

@@ -162,6 +162,7 @@ var hoistVarDeclarationsVisitor = {
} else if (this.isFor()) {
if (isVar(node.left, node)) {
node.left = node.left.declarations[0].id;
self.pushDeclar(node.left);
}
} else if (isVar(node, parent)) {
return self.pushDeclar(node).map(t.expressionStatement);

View File

@@ -1,8 +1,8 @@
import * as t from "../../../types";
function loose(node, body, objId) {
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
for (var prop of (node.properties: Array)) {
if (!prop) continue;
body.push(t.expressionStatement(
t.assignmentExpression(
@@ -15,32 +15,18 @@ function loose(node, body, objId) {
}
function spec(node, body, objId, initProps, file) {
var props = node.properties;
// add all non-computed properties and `__proto__` properties to the initializer
var broken = false;
for (let i = 0; i < props.length; i++) {
let prop = props[i];
if (prop.computed) {
broken = true;
}
if (prop.kind !== "init" || !broken || t.isLiteral(t.toComputedKey(prop, prop.key), { value: "__proto__" })) {
initProps.push(prop);
props[i] = null;
}
}
// add a simple assignment for all Symbol member expressions due to symbol polyfill limitations
// otherwise use Object.defineProperty
for (let i = 0; i < props.length; i++) {
let prop = props[i];
for (let prop of (node.properties: Array)) {
if (!prop) continue;
// this wont work with Object.defineProperty
if (t.isLiteral(t.toComputedKey(prop), { value: "__proto__" })) {
initProps.push(prop);
continue;
}
let key = prop.key;
if (t.isIdentifier(key) && !prop.computed) {
key = t.literal(key.name);
@@ -68,14 +54,33 @@ export var visitor = {
exit(node, parent, scope, file) {
var hasComputed = false;
for (var prop of (node.properties: Array)) {
for (let prop of (node.properties: Array)) {
hasComputed = t.isProperty(prop, { computed: true, kind: "init" });
if (hasComputed) break;
}
if (!hasComputed) return;
// put all getters/setters into the first object expression as well as all initialisers up
// to the first computed property
var initProps = [];
var stopInits = false;
for (var i = 0; i < node.properties.length; i++) {
let prop = node.properties[i];
if (prop.computed) {
stopInits = true;
}
if (prop.kind !== "init" || !stopInits) {
initProps.push(prop);
node.properties[i] = null;
}
}
//
var objId = scope.generateUidIdentifierBasedOnNode(parent);
//

View File

@@ -112,6 +112,13 @@ export function replaceWith(replacement, whateverAllowed) {
if (typeof replacement === "string") {
if (whateverAllowed) {
this.hub.file.log.deprecate("Returning a string from a visitor method will be removed in the future. String " +
"building is NOT a substitute for AST generation. String building leads to " +
"terrible performance due to the additional parsing overhead and will lead to " +
"extremely brittle transformers. For those extreme cases where you're dealing " +
"with strings from a foreign source you may continue to use " +
"`path.replaceWithSourceString(code)`. Please don't abuse this. Bad plugins " +
"hurt the ecosystem.");
return this.replaceWithSourceString(replacement);
} else {
throw new Error("Don't use `path.replaceWith()` with a string, use `path.replaceWithSourceString()`");

View File

@@ -0,0 +1,4 @@
var obj = {
foo: "bar",
[bar]: "foo"
};

View File

@@ -0,0 +1,7 @@
"use strict";
var _obj;
var obj = (_obj = {
foo: "bar"
}, _obj[bar] = "foo", _obj);

View File

@@ -1,3 +1,4 @@
{
"blacklist": ["es5.properties.mutators"],
"loose": ["es6.properties.computed"]
}

View File

@@ -1,4 +1,4 @@
var obj = {
first: "first",
["second"]: "second",
[second]: "second",
};

View File

@@ -2,4 +2,6 @@
var _obj;
var obj = (_obj = {}, _obj.first = "first", _obj["second"] = "second", _obj);
var obj = (_obj = {
first: "first"
}, _obj[second] = "second", _obj);