* centralize plugin options * Centralize plugins options - move more options to the top - move validations that depend on options to the top * use isLoose option * Move more validations to the top * Move ref parameter for rewriteModuleStatementsAndPrepareHeader() to the top * fix eslint errors * remove unused parameter * set default systemGlobal value * Revert "Move ref parameter for rewriteModuleStatementsAndPrepareHeader() to the top" This reverts commit b3855302d17fa19d8acb4c8accab3680c8d2710e. * Revert "Move more validations to the top" This reverts commit e5861d8a034ff8f553391f55654f753bcf428a5d. * fix allowMutablePropsOnTags option usage * improve naming * change Contructor definition for sake of consistency * move allowMutablePropsOnTags validation to the top * add missing !
29 lines
773 B
JavaScript
29 lines
773 B
JavaScript
import remapAsyncToGenerator from "babel-helper-remap-async-to-generator";
|
|
import syntaxAsyncFunctions from "babel-plugin-syntax-async-functions";
|
|
|
|
import { addNamed } from "babel-helper-module-imports";
|
|
|
|
export default function({ types: t }, options) {
|
|
const { method, module } = options;
|
|
return {
|
|
inherits: syntaxAsyncFunctions,
|
|
|
|
visitor: {
|
|
Function(path, state) {
|
|
if (!path.node.async || path.node.generator) return;
|
|
|
|
let wrapAsync = state.methodWrapper;
|
|
if (wrapAsync) {
|
|
wrapAsync = t.cloneDeep(wrapAsync);
|
|
} else {
|
|
wrapAsync = state.methodWrapper = addNamed(path, method, module);
|
|
}
|
|
|
|
remapAsyncToGenerator(path, state.file, {
|
|
wrapAsync,
|
|
});
|
|
},
|
|
},
|
|
};
|
|
}
|