@loadable/babel-plugin
Version:
Babel plugin for loadable (required for SSR).
25 lines (21 loc) • 481 B
JavaScript
;
exports.__esModule = true;
exports.default = requireAsyncProperty;
function requireAsyncProperty({
types: t
}) {
function getFunc(funcPath) {
if (funcPath.isObjectMethod()) {
const {
params,
body,
async
} = funcPath.node;
return t.arrowFunctionExpression(params, body, async);
}
return funcPath.node;
}
return ({
funcPath
}) => t.objectProperty(t.identifier('importAsync'), getFunc(funcPath));
}