add @danez's changes

This commit is contained in:
Henry Zhu 2017-03-01 12:54:22 -05:00
parent 2b9c3735fd
commit b363e7b199
6 changed files with 43 additions and 0 deletions

View File

@ -6,6 +6,7 @@ packages/*/node_modules
packages/*/lib
packages/*/dist
packages/*/test/fixtures
packages/*/test/tmp
vendor
_babel.github.io
Gulpfile.js

View File

@ -146,6 +146,23 @@ function plainFunction(path: NodePath, callId: Object) {
]);
declar._blockHoist = true;
if (path.parentPath.isExportDefaultDeclaration()) {
// change the path type so that replaceWith() does not wrap
// the identifier into an expressionStatement
path.parentPath.insertBefore(declar);
path.parentPath.replaceWith(
t.exportNamedDeclaration(null,
[
t.exportSpecifier(
t.identifier(asyncFnId.name),
t.identifier("default")
)
]
)
);
return;
}
path.replaceWith(declar);
} else {
const retFunction = container.body.body[1].argument;

View File

@ -0,0 +1 @@
export default async () => { return await foo(); }

View File

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = babelHelpers.asyncToGenerator(function* () {
return yield foo();
});

View File

@ -0,0 +1 @@
export default async function myFunc() {}

View File

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
let myFunc = (() => {
var _ref = babelHelpers.asyncToGenerator(function* () {});
return function myFunc() {
return _ref.apply(this, arguments);
};
})();
exports.default = myFunc;