import { bench, describe } from 'vitest' import { mdxParse } from './parse.js' import { MdastToJsx } from './safe-mdx.js' let longMdxContent = await fetch( 'https://raw.githubusercontent.com/colinhacks/zod/0a49fa39348b7c72b19ddedc3b0f879bd395304b/packages/docs/content/packages/v3.mdx', ).then((x) => x.text()) function Callout({ children }: { children: any }) { return (
{children}
) } const mdast = mdxParse(longMdxContent) describe('safe-mdx performance benchmarks', () => { bench('MdastToJsx class processing (long MDX)', () => { const visitor = new MdastToJsx({ markdown: longMdxContent, mdast, components: { Callout }, }) visitor.run() const errors = visitor.errors // export interface SafeMdxError { // message: string // line?: number // schemaPath?: string // } }) bench('MdastToJsx with noop createElement (long MDX)', () => { const noopCreateElement = () => null const visitor = new MdastToJsx({ markdown: longMdxContent, mdast, components: { Callout }, createElement: noopCreateElement, }) visitor.run() }) })