vite_plugin_docs_mdz.ts

Vite plugin that pre-parses the markdown-bearing fields of virtual:svelte-docinfo at build time, so the API-docs pages render pre-parsed MdzNode trees instead of calling mdz_parse on every <Mdz> mount in the client.

A docs module page mounts tens–100+ <Mdz> instances (one per declaration doc comment, per @param/@returns description, per @example, per @see), each of which parses its markdown string on hydration *and* on every client-side navigation (the virtual:svelte-docinfo payload is bundled into the client chunk via library.ts's top-level import under prerender + adapter-static). This plugin moves that parse to build time.

It runs as a transform on svelte-docinfo's own resolved virtual module — *not* a separate derived module — so HMR needs no extra wiring: when svelte-docinfo invalidates virtual:svelte-docinfo on a source change, Vite re-runs its load and then this transform with the fresh data.

Sibling, not replace. For each markdown string field (docComment, description, returnDescription, moduleComment) it adds a *Nodes sibling (docCommentNodes: MdzNode[], …); for the string-array fields it adds examplesNodes: MdzNode[][] and seeAlsoNodes: MdzNode[][] (the latter via mdz_from_tsdoc, matching the runtime <Mdz content={mdz_from_tsdoc(ref)}>). The raw strings stay, so nothing that reads them as strings breaks; the trade is payload size (pre-parsed JSON runs ~3–5× the raw string for a typical doc comment, and higher for short one-line fields, where the per-node type/start/end bookkeeping dominates) for client parse CPU. declaration.svelte.ts surfaces the *Nodes fields and DeclarationDetail.svelte passes them to <Mdz nodes={…}>.

Registered after svelte_docinfo() in vite.config.ts.

view source

Declarations
#

vite_plugin_docs_mdz
#

vite_plugin_docs_mdz.ts view source

(): Plugin<any> import {vite_plugin_docs_mdz} from '@fuzdev/fuz_ui/vite_plugin_docs_mdz.js';

Creates the docs-mdz pre-parse plugin. Zero-config; register it *after* svelte_docinfo() so this transform sees the loaded virtual module.

returns

Plugin<any>