UNPKG

unplugin-ast

Version:

Manipulate the AST to transform your code.

25 lines (22 loc) 662 B
import { isCallOf, isTaggedFunctionCallOf } from "ast-kit"; import { toArray } from "@antfu/utils"; //#region src/core/transformers/remove-wrapper-function.ts function RemoveWrapperFunction(functionNames) { return { onNode: (node) => isCallOf(node, toArray(functionNames)) || isTaggedFunctionCallOf(node, toArray(functionNames)), transform(node) { if (node.type === "TaggedTemplateExpression") return node.quasi; return node.arguments[0]; } }; } //#endregion //#region src/core/transformers/remove-node.ts function RemoveNode(onNode) { return { onNode, transform: () => false }; } //#endregion export { RemoveNode, RemoveWrapperFunction };