svelte_preprocess_mdz.ts

Svelte preprocessor that compiles static Mdz content to Svelte markup at build time.

Detects Mdz components with static string content props, parses the mdz content, renders each MdzNode to equivalent Svelte markup via mdz_to_svelte, and replaces the Mdz with MdzPrecompiled containing pre-rendered children.

Also handles ternary chains (content={a ? 'x' : b ? 'y' : 'z'}) where all leaf values are statically resolvable strings, emitting {#if a}markup_x{:else if b}markup_y{:else}markup_z{/if} as children of a single MdzPrecompiled.

Truly dynamic content props are left untouched.

Declarations
#

2 declarations

view source

svelte_preprocess_mdz
#

svelte_preprocess_mdz.ts view source

(options?: SveltePreprocessMdzOptions): PreprocessorGroup

Creates a Svelte preprocessor that compiles static Mdz content at build time.

options

Configuration for component/element resolution and file filtering.

default {}

returns

PreprocessorGroup

A Svelte PreprocessorGroup for use in svelte.config.js.

SveltePreprocessMdzOptions
#

svelte_preprocess_mdz.ts view source

SveltePreprocessMdzOptions

exclude

File patterns to exclude.

type Array<string | RegExp>

components

Component import mapping for mdz content. Key: component name as used in mdz (e.g., 'Alert'). Value: import path (e.g., '$lib/Alert.svelte').

If mdz content references a component not in this map, that Mdz usage is skipped (left as runtime).

type Record<string, string>

elements

Allowed HTML elements in mdz content. If mdz content references an element not in this list, that Mdz usage is skipped (left as runtime).

type Array<string>

component_imports

Import sources that resolve to the Mdz component. Used to verify that Mdz in templates refers to fuz_ui's Mdz.svelte.

type Array<string>

compiled_component_import

Import path for the precompiled wrapper component.

type string

on_error

How to handle errors during mdz parsing or rendering.

type 'log' | 'throw'

Depends on
#