Compile JSX and TSX components to Vue VDOM output Provide the public JSX/TSX-to-VDOM…
- User
Compile JSX and TSX components to Vue VDOM output
Provide the public JSX/TSX-to-VDOM compilation API described in the Interface. It must support render and setup-returned render functions, fragments, components, attributes and spreads, class/style merging, DOM properties, directives, slots, patch flags, dynamic props, and Vue model forms. Invalid input must produce diagnostics rather than malformed render output.
Interface
Type: Function Name: compile_to_dom Path: crates/vize_atelier_jsx/src/dom.rs Input: bump: &Bump, source: &str, lang: JsxLang, options: DomCompileOptions Output: DomOutput Description: Compiles a JSX/TSX module into Vue VDOM render functions using the shared lowering layer and Vize DOM compiler infrastructure. This is the primary entry point for transforming JSX/TSX source into VDOM-compatible render code.
Type: Class Name: DomCompileOptions Path: crates/vize_atelier_jsx/src/dom.rs Public API: DomCompileOptions { hoist_static: bool, cache_handlers: bool, source_map: bool } — all fields default to false. Description: Options controlling JSX/TSX to VDOM compilation with defaults that produce
@vue/babel-plugin-jsx-shaped output (no static hoisting, no handler caching, no source map). Pass an instance tocompile_to_domto customize the compilation behavior.Type: Constant Name: DomComponent.code Path: crates/vize_atelier_jsx/src/dom.rs Value/Type: pub code: String Description: The generated render function code for a single compiled component. This field on
DomComponentcontains the complete VDOM render implementation produced by the codegen pass.Type: Constant Name: DomComponent.component_name Path: crates/vize_atelier_jsx/src/dom.rs Value/Type: pub component_name: Option Description: The resolved enclosing component-function name, if it could be determined from the source. This field on
DomComponentisNonefor anonymous renders.Type: Constant Name: DomComponent.mode Path: crates/vize_atelier_jsx/src/dom.rs Value/Type: pub mode: JsxOutputMode Description: The resolved output mode for the component, defaulting to
JsxOutputMode::Vdomunless overridden by a directive such as"use vue:vapor". This field onDomComponentallows consumers to route the component to the appropriate backend.Type: Constant Name: DomComponent.preamble Path: crates/vize_atelier_jsx/src/dom.rs Value/Type: pub preamble: String Description: The import/preamble section containing runtime helper imports (e.g.,
toDisplayStringfromvue) needed by the generated render code. This field onDomComponentshould be emitted once per module or component as a header.Type: Constant Name: DomOutput.components Path: crates/vize_atelier_jsx/src/dom.rs Value/Type: pub components: Vec Description: The compiled components in source order, one entry per outermost JSX render root. This field on holds the complete list of generated render artifacts returned by .
- Assistant
I’ll inspect the JSX crate and shared lowering/DOM compiler structure first, then implement the public API and run its focused tests plus the relevant workspace checks.
- Assistant
rgisn’t installed in this environment, so I’m switching tofind/grep. I’m now tracing the crate’s existing AST, lowering, and codegen APIs to avoid duplicating compiler logic. - Assistant
The integration point is clear: lower the module once, allocate its semantic analysis alongside the IR, run the existing DOM transform on each root, and use module-mode codegen so each artifact has Vue imports in
preamble. I’m also gating code generation when parsing/lowering fails and converting transform failures back into JSX diagnostics. - Assistant
The API and initial safety tests are in place. The crate is rebuilding with the new compiler dependency; after it finishes I’ll inspect actual generated output for spreads, merging, directives, components, fragments, slots, patch flags, and model forms, then address any lowering/codegen mismatches.
- Assistant
The first generated path passes, but two JSX-specific gaps are visible in the shared IR:
onClickis currently treated as an ordinary bind (so handler caching cannot work), and slot-function/object children retain raw nested JSX. I’m correcting those in lowering so the DOM backend receives actualv-onand slot-template IR rather than emitting JSX inside generated JavaScript. - Assistant
The feature smoke test now covers fragments, class/style arrays, prop spreads, dynamic props and flags, event props, named scoped slots, native/component models, model modifiers, and runtime directives without leaving raw JSX behind. I’m at the cleanup/verification stage now: formatting, full crate tests, and lint/check passes.
- Assistant
One final review caught a fragment-specific issue: nested shorthand fragments were represented as a component named
Fragment, which would resolve at runtime instead of using Vue’s fragment helper. I’m normalizing shorthand fragments to transparent template IR and adding that case to the compilation smoke test before the final check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.