Merge branch 'master' of github.com:babel/babel
This commit is contained in:
commit
acbeda8182
@ -143,7 +143,7 @@ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
* The `Literal` node type has been unoverloaded and split into `BooleanLiteral`, `RegExpLiteral`, `NumericLiteral`, `StringLiteral` and `NullLiteral`.
|
||||
* The `SpreadProperty` (from `object-rest-spread`) node type has been split into `RestProperty` (for `ObjectPattern`) and `SpreadProperty` (for `ObjectExpression`)
|
||||
* Remove `module.exports` export interop for CommonJS module formatter.
|
||||
* `externalHelpers` option has been moved into the plugin `babel-plugin-external-helper-2`.
|
||||
* `externalHelpers` option has been moved into the plugin `babel-plugin-external-helpers-2`.
|
||||
* **New Feature**
|
||||
* Add plugin options.
|
||||
* Add callable class constructor.
|
||||
|
||||
4
Makefile
4
Makefile
@ -31,10 +31,12 @@ test-clean:
|
||||
rm -rf packages/*/test/tmp
|
||||
rm -rf packages/*/test-fixtures.json
|
||||
|
||||
test: lint
|
||||
test-only:
|
||||
./scripts/test.sh
|
||||
make test-clean
|
||||
|
||||
test: lint test-only
|
||||
|
||||
test-cov: clean
|
||||
BABEL_ENV=test; \
|
||||
gulp build
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
"regenerator": "0.8.35",
|
||||
"shebang-regex": "^1.0.0",
|
||||
"slash": "^1.0.0",
|
||||
"source-map": "^0.4.0",
|
||||
"source-map": "^0.5.0",
|
||||
"source-map-support": "^0.2.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -107,8 +107,8 @@ function run(task, done) {
|
||||
}
|
||||
};
|
||||
|
||||
var fn = new Function("require", "done", "exports", execCode);
|
||||
fn.call(global, fakeRequire, chai.assert, {}, done);
|
||||
var fn = new Function("require", "assert", "exports", "done", "transform", execCode);
|
||||
fn.call(global, fakeRequire, chai.assert, {}, done, transform);
|
||||
} catch (err) {
|
||||
err.message = exec.loc + ": " + err.message;
|
||||
err.message += codeFrame(execCode);
|
||||
|
||||
37
packages/babel-core/test/fixtures/plugins/regression-2772/exec.js
vendored
Normal file
37
packages/babel-core/test/fixtures/plugins/regression-2772/exec.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
var code = `
|
||||
(function() {
|
||||
function foo(b){
|
||||
b === "lol";
|
||||
foo(b);
|
||||
}
|
||||
})();
|
||||
`;
|
||||
|
||||
transform(code, {
|
||||
plugins: [
|
||||
function (b) {
|
||||
var t = b.types;
|
||||
return {
|
||||
visitor: {
|
||||
// Replace block statements with a new node without changing anything
|
||||
BlockStatement: function(path) {
|
||||
if (path.node.seen) {
|
||||
return;
|
||||
}
|
||||
var node = t.blockStatement(path.node.body);
|
||||
node.seen = true;
|
||||
path.replaceWith(node);
|
||||
},
|
||||
// do type inference
|
||||
BinaryExpression: function(path) {
|
||||
var left = path.get("left");
|
||||
var right = path.get("right");
|
||||
left.baseTypeStrictlyMatches(right);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
],
|
||||
compact: true,
|
||||
comments: false,
|
||||
}).code;
|
||||
6
packages/babel-core/test/fixtures/transformation/async-to-generator/object-method/actual.js
vendored
Normal file
6
packages/babel-core/test/fixtures/transformation/async-to-generator/object-method/actual.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
let obj = {
|
||||
a: 123,
|
||||
async foo(bar) {
|
||||
return await baz(bar);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
let obj = {
|
||||
a: 123,
|
||||
foo(bar) {
|
||||
return babelHelpers.asyncToGenerator(function* () {
|
||||
return yield baz(bar);
|
||||
})();
|
||||
}
|
||||
};
|
||||
1
packages/babel-core/test/fixtures/transformation/es6.classes/export-super-class/actual.js
vendored
Normal file
1
packages/babel-core/test/fixtures/transformation/es6.classes/export-super-class/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
export default class extends A {}
|
||||
12
packages/babel-core/test/fixtures/transformation/es6.classes/export-super-class/expected.js
vendored
Normal file
12
packages/babel-core/test/fixtures/transformation/es6.classes/export-super-class/expected.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
var _class = (function (_A) {
|
||||
babelHelpers.inherits(_class, _A);
|
||||
|
||||
function _class() {
|
||||
babelHelpers.classCallCheck(this, _class);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments));
|
||||
}
|
||||
|
||||
return _class;
|
||||
})(A);
|
||||
|
||||
export default _class;
|
||||
@ -0,0 +1,5 @@
|
||||
export default function (number) {
|
||||
if (!isNaN(number)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
export default function (number) {
|
||||
if (!isNaN(number)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
3
packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/options.json
vendored
Normal file
3
packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-es2015-typeof-symbol"]
|
||||
}
|
||||
1
packages/babel-core/test/plugins.js
Normal file
1
packages/babel-core/test/plugins.js
Normal file
@ -0,0 +1 @@
|
||||
require("./_transformation-helper").run("plugins");
|
||||
@ -18,7 +18,7 @@
|
||||
"is-integer": "^1.0.4",
|
||||
"lodash": "^3.10.1",
|
||||
"repeating": "^1.1.3",
|
||||
"source-map": "^0.4.4",
|
||||
"source-map": "^0.5.0",
|
||||
"trim-right": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -24,7 +24,7 @@ let awaitVisitor = {
|
||||
}
|
||||
};
|
||||
|
||||
function classMethod(path: NodePath, callId: Object) {
|
||||
function classOrObjectMethod(path: NodePath, callId: Object) {
|
||||
let node = path.node;
|
||||
let body = node.body;
|
||||
|
||||
@ -99,8 +99,8 @@ export default function (path: NodePath, callId: Object) {
|
||||
|
||||
path.traverse(awaitVisitor);
|
||||
|
||||
if (path.isClassMethod()) {
|
||||
return classMethod(path, callId);
|
||||
if (path.isClassMethod() || path.isObjectMethod()) {
|
||||
return classOrObjectMethod(path, callId);
|
||||
} else {
|
||||
return plainFunction(path, callId);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ export function get(key: string, ...args): string {
|
||||
|
||||
// replace $0 placeholders with args
|
||||
return msg.replace(/\$(\d+)/g, function (str, i) {
|
||||
return args[--i];
|
||||
return args[i - 1];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -8,13 +8,15 @@ export default function ({ types: t }) {
|
||||
ClassDeclaration(path) {
|
||||
let { node } = path;
|
||||
|
||||
let ref = node.id || path.scope.generateUidIdentifier("class");
|
||||
|
||||
if (path.parentPath.isExportDefaultDeclaration()) {
|
||||
path = path.parentPath;
|
||||
path.insertAfter(t.exportDefaultDeclaration(node.id));
|
||||
path.insertAfter(t.exportDefaultDeclaration(ref));
|
||||
}
|
||||
|
||||
path.replaceWith(t.variableDeclaration("let", [
|
||||
t.variableDeclarator(node.id, t.toExpression(node))
|
||||
t.variableDeclarator(ref, t.toExpression(node))
|
||||
]));
|
||||
},
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ export default function ({ types: t }) {
|
||||
UnaryExpression(path) {
|
||||
let { node, parent } = path;
|
||||
if (node[IGNORE]) return;
|
||||
if (path.find(path => !!path.node._generated)) return;
|
||||
if (path.find(path => path.node && !!path.node._generated)) return;
|
||||
|
||||
if (path.parentPath.isBinaryExpression() && t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0) {
|
||||
// optimise `typeof foo === "string"` since we can determine that they'll never need to handle symbols
|
||||
|
||||
@ -146,6 +146,10 @@ function getOuterFnExpr(funPath) {
|
||||
var node = funPath.node;
|
||||
t.assertFunction(node);
|
||||
|
||||
if (!node.id) {
|
||||
node.id = funPath.scope.parent.generateUidIdentifier("callee");
|
||||
}
|
||||
|
||||
if (node.generator && // Non-generator functions don't need to be marked.
|
||||
t.isFunctionDeclaration(node)) {
|
||||
var pp = funPath.findParent(function (path) {
|
||||
@ -171,9 +175,7 @@ function getOuterFnExpr(funPath) {
|
||||
);
|
||||
}
|
||||
|
||||
return node.id || (
|
||||
node.id = funPath.scope.parent.generateUidIdentifier("callee")
|
||||
);
|
||||
return node.id;
|
||||
}
|
||||
|
||||
function getRuntimeMarkDecl(blockPath) {
|
||||
|
||||
@ -12,6 +12,6 @@ node $BROWSERIFY_CMD lib/index.js \
|
||||
--plugin derequire/plugin \
|
||||
>dist/polyfill.js
|
||||
node $UGLIFY_CMD dist/polyfill.js \
|
||||
--compress warnings=false \
|
||||
--mangle \
|
||||
--compress keep_fnames,keep_fargs,warnings=false \
|
||||
--mangle keep_fnames \
|
||||
>dist/polyfill.min.js
|
||||
|
||||
@ -4,5 +4,6 @@ module.exports = {
|
||||
require("babel-plugin-transform-flow-strip-types"),
|
||||
require("babel-plugin-syntax-flow"),
|
||||
require("babel-plugin-syntax-jsx"),
|
||||
require("babel-plugin-transform-react-display-name"),
|
||||
]
|
||||
};
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
"dependencies": {
|
||||
"babel-plugin-syntax-flow": "^6.0.14",
|
||||
"babel-plugin-syntax-jsx": "^6.0.14",
|
||||
"babel-plugin-transform-react-jsx": "^6.0.14",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.0.14"
|
||||
"babel-plugin-transform-flow-strip-types": "^6.0.14",
|
||||
"babel-plugin-transform-react-display-name": "^6.0.14",
|
||||
"babel-plugin-transform-react-jsx": "^6.0.14"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user