Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8c672bf4f | ||
|
|
7083ac61ff | ||
|
|
d256809120 | ||
|
|
26a19f82d2 | ||
|
|
128d3b5c91 | ||
|
|
c1a080d0ca | ||
|
|
0b1ce6c9a4 | ||
|
|
a6f04055c0 | ||
|
|
c3219e8b88 | ||
|
|
a35c863341 | ||
|
|
6f862a4c45 | ||
|
|
cf38210fd2 |
@@ -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**
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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>",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
//
|
||||
|
||||
@@ -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()`");
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
var obj = {
|
||||
foo: "bar",
|
||||
[bar]: "foo"
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _obj;
|
||||
|
||||
var obj = (_obj = {
|
||||
foo: "bar"
|
||||
}, _obj[bar] = "foo", _obj);
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"blacklist": ["es5.properties.mutators"],
|
||||
"loose": ["es6.properties.computed"]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var obj = {
|
||||
first: "first",
|
||||
["second"]: "second",
|
||||
[second]: "second",
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user