Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3b1fcc79c | ||
|
|
491cb26c1f | ||
|
|
7c3d052714 | ||
|
|
4971d0c7f0 | ||
|
|
eb4922b1ec | ||
|
|
bb26183b44 | ||
|
|
4b066f7f1b | ||
|
|
3cd110a7c9 | ||
|
|
a7f9e035a4 | ||
|
|
146b9e6708 | ||
|
|
0953c48620 | ||
|
|
056b90831d | ||
|
|
8ba276b209 |
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.
|
||||
|
||||
## 4.7.9
|
||||
|
||||
* **Polish**
|
||||
* Allow `inputSourceMap` to be set to `false` to skip the source map inference.
|
||||
* Infer computed literal property names.
|
||||
* **Bug Fix**
|
||||
* Fix nested labeled for-ofs.
|
||||
* Fix block scoping `break` colliding with the parent switch case.
|
||||
* **Internal**
|
||||
* Upgrade `acorn-babel`.
|
||||
|
||||
## 4.7.8
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix computed classes not properly setting symbols.
|
||||
|
||||
## 4.7.7
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "4.7.7",
|
||||
"version": "4.7.9",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
@@ -36,7 +36,7 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn-babel": "0.11.1-37",
|
||||
"acorn-babel": "0.11.1-38",
|
||||
"ast-types": "~0.7.0",
|
||||
"chalk": "^1.0.0",
|
||||
"chokidar": "^0.12.6",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "4.7.6",
|
||||
"version": "4.7.8",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"dependencies": {
|
||||
|
||||
@@ -139,7 +139,7 @@ export default class File {
|
||||
returnUsedHelpers: false,
|
||||
externalHelpers: false,
|
||||
auxilaryComment: "",
|
||||
inputSourceMap: false,
|
||||
inputSourceMap: null,
|
||||
experimental: false,
|
||||
reactCompat: false,
|
||||
playground: false,
|
||||
@@ -280,10 +280,12 @@ export default class File {
|
||||
parseInputSourceMap(code: string) {
|
||||
var opts = this.opts;
|
||||
|
||||
var inputMap = convertSourceMap.fromSource(code);
|
||||
if (inputMap) {
|
||||
opts.inputSourceMap = inputMap.toObject();
|
||||
code = convertSourceMap.removeComments(code);
|
||||
if (opts.inputSourceMap === false) {
|
||||
var inputMap = convertSourceMap.fromSource(code);
|
||||
if (inputMap) {
|
||||
opts.inputSourceMap = inputMap.toObject();
|
||||
code = convertSourceMap.removeComments(code);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
||||
@@ -111,7 +111,7 @@ export function bare(node, parent, scope) {
|
||||
if (node.id) return node;
|
||||
|
||||
var id;
|
||||
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
|
||||
if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
|
||||
// { foo() {} };
|
||||
id = parent.key;
|
||||
} else if (t.isVariableDeclarator(parent)) {
|
||||
@@ -121,9 +121,16 @@ export function bare(node, parent, scope) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (!t.isIdentifier(id)) return node;
|
||||
var name;
|
||||
if (t.isLiteral(id)) {
|
||||
name = id.value;
|
||||
} else if (t.isIdentifier(id)) {
|
||||
name = id.name;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = t.toIdentifier(id.name);
|
||||
name = t.toIdentifier(name);
|
||||
id = t.identifier(name);
|
||||
|
||||
var state = visit(node, name, scope);
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
(function() {
|
||||
function defineProperties(target, rawProps) {
|
||||
var props = {};
|
||||
for (var i = 0; i < rawProps.length; i ++) {
|
||||
var prop = rawProps[i];
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i ++) {
|
||||
var prop = props[i];
|
||||
prop.configurable = true;
|
||||
if (prop.value) prop.writable = true;
|
||||
props[prop.key] = prop;
|
||||
Object.defineProperty(target, prop.key, prop);
|
||||
}
|
||||
Object.defineProperties(target, props);
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
|
||||
@@ -69,8 +69,9 @@ export function Loop(node, parent, scope, file) {
|
||||
t.ensureBlock(node);
|
||||
node.body._letDeclarators = [init];
|
||||
}
|
||||
var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
|
||||
blockScoping.run();
|
||||
|
||||
var blockScoping = new BlockScoping(this, node.body, parent, scope, file);
|
||||
return blockScoping.run();
|
||||
}
|
||||
|
||||
export function BlockStatement(block, parent, scope, file) {
|
||||
@@ -224,17 +225,22 @@ class BlockScoping {
|
||||
* Description
|
||||
*/
|
||||
|
||||
constructor(loopParent?: Object, block: Object, parent: Object, scope: Scope, file: File) {
|
||||
this.loopParent = loopParent;
|
||||
this.parent = parent;
|
||||
this.scope = scope;
|
||||
this.block = block;
|
||||
this.file = file;
|
||||
constructor(loopPath?: TraversalPath, block: Object, parent: Object, scope: Scope, file: File) {
|
||||
this.parent = parent;
|
||||
this.scope = scope;
|
||||
this.block = block;
|
||||
this.file = file;
|
||||
|
||||
this.outsideLetReferences = object();
|
||||
this.hasLetReferences = false;
|
||||
this.letReferences = block._letReferences = object();
|
||||
this.body = [];
|
||||
|
||||
if (loopPath) {
|
||||
this.loopParent = loopPath.parent;
|
||||
this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
|
||||
this.loop = loopPath.node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,6 +265,10 @@ class BlockScoping {
|
||||
} else {
|
||||
this.remap();
|
||||
}
|
||||
|
||||
if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
|
||||
return t.labeledStatement(this.loopLabel, this.loop);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,11 +307,11 @@ class BlockScoping {
|
||||
|
||||
//
|
||||
|
||||
var loopParent = this.loopParent;
|
||||
if (loopParent) {
|
||||
traverseReplace(loopParent.right, loopParent, scope, remaps);
|
||||
traverseReplace(loopParent.test, loopParent, scope, remaps);
|
||||
traverseReplace(loopParent.update, loopParent, scope, remaps);
|
||||
var loop = this.loop;
|
||||
if (loop) {
|
||||
traverseReplace(loop.right, loop, scope, remaps);
|
||||
traverseReplace(loop.test, loop, scope, remaps);
|
||||
traverseReplace(loop.update, loop, scope, remaps);
|
||||
}
|
||||
|
||||
scope.traverse(this.block, replaceVisitor, remaps);
|
||||
@@ -317,7 +327,7 @@ class BlockScoping {
|
||||
var outsideRefs = this.outsideLetReferences;
|
||||
|
||||
// remap loop heads with colliding variables
|
||||
if (this.loopParent) {
|
||||
if (this.loop) {
|
||||
for (var name in outsideRefs) {
|
||||
var id = outsideRefs[name];
|
||||
|
||||
@@ -438,7 +448,7 @@ class BlockScoping {
|
||||
ignoreLabeless: false,
|
||||
innerLabels: [],
|
||||
hasReturn: false,
|
||||
isLoop: !!this.loopParent,
|
||||
isLoop: !!this.loop,
|
||||
map: {}
|
||||
};
|
||||
|
||||
@@ -504,7 +514,7 @@ class BlockScoping {
|
||||
t.variableDeclarator(ret, call)
|
||||
]));
|
||||
|
||||
var loopParent = this.loopParent;
|
||||
var loop = this.loop;
|
||||
var retCheck;
|
||||
var has = this.has;
|
||||
var cases = [];
|
||||
@@ -517,9 +527,8 @@ class BlockScoping {
|
||||
}
|
||||
|
||||
if (has.hasBreakContinue) {
|
||||
if (!loopParent) {
|
||||
throw new Error("Has no loop parent but we're trying to reassign breaks " +
|
||||
"and continues, something is going wrong here.");
|
||||
if (!loop) {
|
||||
throw new Error("Aren't in a loop and we're trying to reassign breaks and continues, something is going wrong here.");
|
||||
}
|
||||
|
||||
for (var key in has.map) {
|
||||
@@ -537,6 +546,14 @@ class BlockScoping {
|
||||
single.consequent[0]
|
||||
)));
|
||||
} else {
|
||||
// #998
|
||||
for (var i = 0; i < cases.length; i++) {
|
||||
var caseConsequent = cases[i].consequent[0];
|
||||
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
|
||||
caseConsequent.label = this.loopLabel ||= this.file.scope.generateUidIdentifier("loop");
|
||||
}
|
||||
}
|
||||
|
||||
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -32,11 +32,8 @@ export function ForOfStatement(node, parent, scope, file) {
|
||||
// todo: find out why this is necessary? #538
|
||||
loop._scopeInfo = node._scopeInfo;
|
||||
|
||||
if (build.replaceParent) {
|
||||
this.parentPath.node = build.node;
|
||||
} else {
|
||||
return build.node;
|
||||
}
|
||||
if (build.replaceParent) this.parentPath.node = build.node;
|
||||
return build.node;
|
||||
}
|
||||
|
||||
var loose = function (node, parent, scope, file) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
(function () {
|
||||
for (var i in nums) {
|
||||
_loop: for (var i in nums) {
|
||||
var _ret = (function (i) {
|
||||
fns.push(function () {
|
||||
return i;
|
||||
@@ -22,7 +22,7 @@
|
||||
continue;
|
||||
|
||||
case "break":
|
||||
break;
|
||||
break _loop;
|
||||
|
||||
default:
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
|
||||
5
test/fixtures/transformation/es6-for-of/nested-label-for-of/actual.js
vendored
Normal file
5
test/fixtures/transformation/es6-for-of/nested-label-for-of/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
b: for (let c of d()) {
|
||||
for (let e of f()) {
|
||||
continue b;
|
||||
}
|
||||
}
|
||||
48
test/fixtures/transformation/es6-for-of/nested-label-for-of/expected.js
vendored
Normal file
48
test/fixtures/transformation/es6-for-of/nested-label-for-of/expected.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
b: for (var _iterator = d()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var c = _step.value;
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = f()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var e = _step2.value;
|
||||
|
||||
continue b;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2["return"]) {
|
||||
_iterator2["return"]();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator["return"]) {
|
||||
_iterator["return"]();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user