Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb19649af8 | ||
|
|
692262df1b | ||
|
|
067047da34 | ||
|
|
1c5d169b1e | ||
|
|
3f82b4ec72 | ||
|
|
9c6e632021 | ||
|
|
45553f1fb7 | ||
|
|
f228edbb84 | ||
|
|
64e657e53d | ||
|
|
17e65cc772 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -13,6 +13,16 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 4.3.0
|
||||
|
||||
* **Breaking Change**
|
||||
* Remove `commonStandard` module formatter and make it the default behaviour of all the strict module formatters.
|
||||
|
||||
## 4.2.1
|
||||
|
||||
* **Polish**
|
||||
* Add auxiliary comment to let scoping closure flow control.
|
||||
|
||||
## 4.2.0
|
||||
|
||||
* **Polish**
|
||||
|
||||
@@ -60,7 +60,8 @@ File.helpers = [
|
||||
"object-destructuring-empty",
|
||||
"temporal-undefined",
|
||||
"temporal-assert-defined",
|
||||
"tail-call"
|
||||
"tail-call",
|
||||
"self-global"
|
||||
];
|
||||
|
||||
File.validOptions = [
|
||||
|
||||
@@ -4,6 +4,7 @@ var util = require("../../util");
|
||||
|
||||
module.exports = function (Parent) {
|
||||
var Constructor = function () {
|
||||
this.noInteropRequireImport = true;
|
||||
this.noInteropRequireExport = true;
|
||||
Parent.apply(this, arguments);
|
||||
};
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = CommonStandardFormatter;
|
||||
|
||||
var CommonStrictFormatter = require("./common-strict");
|
||||
var util = require("../../util");
|
||||
|
||||
function CommonStandardFormatter() {
|
||||
this.noInteropRequireImport = true;
|
||||
CommonStrictFormatter.apply(this, arguments);
|
||||
}
|
||||
|
||||
util.inherits(CommonStandardFormatter, CommonStrictFormatter);
|
||||
@@ -1,11 +1,10 @@
|
||||
module.exports = {
|
||||
commonStandard: require("./common-standard"),
|
||||
commonStrict: require("./common-strict"),
|
||||
amdStrict: require("./amd-strict"),
|
||||
umdStrict: require("./umd-strict"),
|
||||
common: require("./common"),
|
||||
system: require("./system"),
|
||||
ignore: require("./ignore"),
|
||||
amd: require("./amd"),
|
||||
umd: require("./umd")
|
||||
commonStrict: require("./common-strict"),
|
||||
amdStrict: require("./amd-strict"),
|
||||
umdStrict: require("./umd-strict"),
|
||||
common: require("./common"),
|
||||
system: require("./system"),
|
||||
ignore: require("./ignore"),
|
||||
amd: require("./amd"),
|
||||
umd: require("./umd")
|
||||
};
|
||||
|
||||
7
lib/babel/transformation/templates/named-func.js
Normal file
7
lib/babel/transformation/templates/named-func.js
Normal file
@@ -0,0 +1,7 @@
|
||||
(function () {
|
||||
function GET_OUTER_ID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
return FUNCTION;
|
||||
})()
|
||||
@@ -546,14 +546,16 @@ BlockScoping.prototype.buildHas = function (ret, call) {
|
||||
|
||||
if (cases.length === 1) {
|
||||
var single = cases[0];
|
||||
body.push(t.ifStatement(
|
||||
body.push(this.file.attachAuxiliaryComment(t.ifStatement(
|
||||
t.binaryExpression("===", ret, single.test),
|
||||
single.consequent[0]
|
||||
));
|
||||
)));
|
||||
} else {
|
||||
body.push(t.switchStatement(ret, cases));
|
||||
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
|
||||
}
|
||||
} else {
|
||||
if (has.hasReturn) body.push(retCheck);
|
||||
if (has.hasReturn) {
|
||||
body.push(this.file.attachAuxiliaryComment(retCheck));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -91,6 +91,7 @@ module.exports = {
|
||||
|
||||
"spec.typeofSymbol": require("./spec/typeof-symbol"),
|
||||
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
|
||||
"spec.functionName": require("./spec/function-name"),
|
||||
|
||||
_moduleFormatter: require("./internal/module-formatter"),
|
||||
|
||||
|
||||
53
lib/babel/transformation/transformers/spec/function-name.js
Normal file
53
lib/babel/transformation/transformers/spec/function-name.js
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
|
||||
var propertyFunctionVisitor = {
|
||||
enter: function (node, parent, scope, state) {
|
||||
if (t.isReferencedIdentifier(node, parent, { name: state.name }) && scope.getBindingIdentifier(node.name) === state.binding) {
|
||||
return state.getOuter();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.FunctionExpression = function (node, parent, scope, file) {
|
||||
if (node.id) return;
|
||||
var id;
|
||||
if (t.isProperty(parent)) {
|
||||
id = parent.key;
|
||||
} else if (t.isVariableDeclarator(parent)) {
|
||||
id = parent.id;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
var binding = scope.getBindingIdentifier(id.name);
|
||||
var outerId, selfGlobalId;
|
||||
scope.traverse(node, propertyFunctionVisitor, {
|
||||
name: id.name,
|
||||
binding: binding,
|
||||
|
||||
getOuter: function () {
|
||||
if (!binding) {
|
||||
return t.memberExpression(
|
||||
selfGlobalId || (selfGlobalId = file.addHelper("self-global")),
|
||||
id
|
||||
);
|
||||
}
|
||||
return t.callExpression(
|
||||
outerId || (outerId = scope.generateUidIdentifier("getOuter")),
|
||||
[]
|
||||
);
|
||||
}
|
||||
});
|
||||
node.id = id;
|
||||
if (outerId) {
|
||||
return util.template("named-func", {
|
||||
GET_OUTER_ID: outerId,
|
||||
ID: id,
|
||||
FUNCTION: node
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.optional = true;
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "4.2.0",
|
||||
"version": "4.3.0",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "4.1.1",
|
||||
"version": "4.2.1",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"modules": "commonStandard"
|
||||
}
|
||||
3
test/fixtures/transformation/es6-modules-common-strict/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common-strict/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"modules": "commonStrict"
|
||||
}
|
||||
27
test/fixtures/transformation/spec-function-name/actual.js
vendored
Normal file
27
test/fixtures/transformation/spec-function-name/actual.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var obj = {
|
||||
f: function () {
|
||||
(function f() {
|
||||
console.log(f);
|
||||
})();
|
||||
},
|
||||
|
||||
g: function () {
|
||||
console.log(g);
|
||||
},
|
||||
|
||||
h: function () {
|
||||
console.log(h);
|
||||
},
|
||||
|
||||
m: function () {
|
||||
doSmth();
|
||||
}
|
||||
};
|
||||
|
||||
var f = function () {
|
||||
console.log(f, g);
|
||||
};
|
||||
|
||||
var g = function () {
|
||||
doSmth();
|
||||
};
|
||||
42
test/fixtures/transformation/spec-function-name/expected.js
vendored
Normal file
42
test/fixtures/transformation/spec-function-name/expected.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
var _selfGlobal = typeof global === "undefined" ? self : global;
|
||||
var obj = {
|
||||
f: function f() {
|
||||
(function f() {
|
||||
console.log(f);
|
||||
})();
|
||||
},
|
||||
|
||||
g: (function () {
|
||||
function _getOuter() {
|
||||
return g;
|
||||
}
|
||||
|
||||
return function g() {
|
||||
console.log(_getOuter());
|
||||
};
|
||||
})(),
|
||||
|
||||
h: function h() {
|
||||
console.log(_selfGlobal.h);
|
||||
},
|
||||
|
||||
m: function m() {
|
||||
doSmth();
|
||||
}
|
||||
};
|
||||
|
||||
var f = (function () {
|
||||
function _getOuter() {
|
||||
return f;
|
||||
}
|
||||
|
||||
return function f() {
|
||||
console.log(_getOuter(), g);
|
||||
};
|
||||
})();
|
||||
|
||||
var g = function g() {
|
||||
doSmth();
|
||||
};
|
||||
3
test/fixtures/transformation/spec-function-name/options.json
vendored
Normal file
3
test/fixtures/transformation/spec-function-name/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"whitelist": ["spec.functionName"]
|
||||
}
|
||||
Reference in New Issue
Block a user