2018-01-29 22:59:06 +01:00

29 lines
598 B
JavaScript

import { types as t } from "@babel/core";
export default function() {
return {
visitor: {
FunctionExpression: {
exit(path) {
const { node } = path;
if (!node.id) return;
path.replaceWith(
t.callExpression(
t.functionExpression(
null,
[],
t.blockStatement([
t.toStatement(node),
t.returnStatement(t.cloneNode(node.id)),
]),
),
[],
),
);
},
},
},
};
}