import type { Root } from 'mdast' export function DemoMdxPlugin() { return transformer function transformer(tree: Root, file: any) { const children = tree.children const addImports: string[] = [] children.forEach((child: any) => { if ((child.type as string) === 'jsx') { const regexp = /` } } }) children.unshift( ...addImports.map((importStr) => { return { type: 'import', value: importStr, } as any }) ) } }