ISSUE DESCRIPTION Compile JSX and TSX components to Vue VDOM output Provide the public…
- User
ISSUE DESCRIPTION
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
DomOutputholds the complete list of generated render artifacts returned bycompile_to_dom.Type: Constant Name: DomOutput.diagnostics Path: crates/vize_atelier_jsx/src/dom.rs Value/Type: pub diagnostics: Vec Description: Parse, lowering, and transform diagnostics produced during compilation. This field on
DomOutputshould be inspected before using the generated code; usehas_errors()to check for error-severity diagnostics.Type: Function Name: has_errors Path: crates/vize_atelier_jsx/src/dom.rs Input: (&self) Output: bool Description: Returns
trueif any error-severity diagnostic was produced during compilation. Call this onDomOutputbefore using the generated components to ensure compilation succeeded without errors.ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /vize, current file: none) bash-$
Assistant
Now let's look at the lower module and RootNode structure in vize_relief, plus how vize_atelier_dom's transform/codegen consume RootNode, to understand what's needed to bridge JSX lowered roots into DOM codegen.
Assistant
Now let's check codegen
generate_with_sectionsandCodegenResult, and CompilerError vs JsxDiagnostic mapping.Assistant
Good,
codegen::generateandcodegen::generate_with_sectionsare exported. Let's checktransformmodule's public exports similarly, and checkBindingMetadataclone-ability and structure.Assistant
Now let's add vize_atelier_dom as a dependency to vize_atelier_jsx crate and write a scratch test to validate the pipeline before finalizing dom.rs.
Assistant
Now let's create the actual
dom.rsfile.Assistant
Now register the module in
lib.rsand export the public items.Assistant
Now let's build and run tests.
Assistant
Compiles cleanly. Now let's run the tests I wrote in dom.rs.
Assistant
All tests pass. Let's scroll up to see the full summary including unit tests and other test binaries.
Assistant
All green (32 lib tests including my 12 new dom tests, plus all integration tests). Now let's check other affected crates in the workspace (vize_atelier_dom, vize_atelier_core) and do a full workspace build check since we added new dependencies.
Assistant
Full workspace builds successfully. Now let's check for clippy warnings on the new file since the repo seems clippy-conscious.
Assistant
Clean. Let's re-run the tests to confirm everything still passes after the signature change, then check clippy/tests for dependent crates too.
Assistant
Good — confirmed pre-existing test-only clippy issues unrelated to my change; the library targets are clean. Now let's run the full workspace test suite to make sure nothing else broke.
Assistant
Confirmed: this test fails even on a clean checkout without any of my changes — it's a pre-existing failure unrelated to this issue. Let's restore my changes.
Assistant
Good, changes restored. Now let's run the rest of the workspace test suite (excluding the known pre-existing failure) to make sure everything else passes.
Assistant
All these failures are pre-existing (environment/pkl/snapshot related, likely missing external tool dependencies like MoonBit/pkl in this sandbox), identical with and without my changes. My changes introduce no new test failures. Let's do a final review of the diff and file contents.
Assistant
Now let's view the final
dom.rsfile in full to review it once more.Assistant
Let's fix this doc link ambiguity warning to keep the build fully clean.
Assistant
Clean now. Let's do a final full re-run of the crate's test suite plus clippy to confirm everything's still good after this doc tweak.
Assistant
Let's apply
cargo fmtto fix formatting.Assistant
Everything passes and formatting is clean. Let's take a final look at the complete diff summary before submitting.
Assistant
This all looks correct and minimal. Let's do one more full workspace build + test pass to be fully sure, then finalize.
Assistant
All green. Now let's go through the checklist explicitly.
Checklist review
- If an error was reported in the issue description, I have successfully reproduced it.
This issue is a feature request (implement
compile_to_dom), not a bug report with a reproducible error. There was no pre-existing error to reproduce; instead I explored the codebase to understand the existing lowering layer (lower_source) and the DOM template compiler infrastructure (vize_atelier_dom) that this new API needed to bridge. I validated my understanding with scratch tests before writing the real implementation.
- If an error was reported in the issue description, I have successfully reproduced it.
This issue is a feature request (implement
Assistant
I've completed the implementation. Let me provide a summary before submitting.
Summary
I implemented
compile_to_domincrates/vize_atelier_jsx/src/dom.rs, which bridges the existing backend-neutral JSX/TSX lowering layer (lower_source) with Vize's DOM compiler infrastructure (vize_atelier_dom'stransform+codegenpipeline).Key design decisions discovered through investigation:
- Reuse, don't reimplement: Since JSX lowering already produces the same shared
RootNode/ElementNodeIR that Vue SFC templates use, I feed lowered roots directly intovize_atelier_dom::transform::transform+vize_atelier_dom::codegen::generate, skipping the DOM parser entirely. This gets class/style merging, DOM properties, directives (v-if,v-for,v-model,v-show, custom directives), patch flags, and dynamic props "for free" from the shared engine. - Component resolution: JSX component tags are real JS identifiers (imports/consts), not runtime-registered strings. I convert Croquis's binding metadata into the DOM compiler's
BindingMetadataand compile withinline: true, so known bindings (e.g. an importedFoo) codegen as the raw identifier (createBlock(Foo, ...)) instead ofresolveComponent("Foo"); unresolved tags still fall back safely. - Slot/template reclassification: The shared lowering layer only distinguishes Element vs Component, so I added a small pre-transform pass mirroring the real parser's classification, giving
<slot>and<template v-slot:x>their correct element types. - Defaults:
DomCompileOptions(hoist_static/cache_handlers/source_map, all defaultfalse) plusCodegenMode::Modulefor ESM-styleimport {...} from "vue"preambles, matching@vue/babel-plugin-jsx-shaped output. - Diagnostics over malformed output: lowering-level errors bail out with diagnostics only (no components); per-root transform errors are surfaced as diagnostics without blocking other roots.
I verified the approach extensively with throwaway scripts (removed before submitting) covering elements, fragments, components (imported/unresolved), slots, named
v-slottemplates,v-model, class/style/spread merging, and vapor-mode tagging — all validated via 12 inline unit tests indom.rs. Full workspace build/tests/clippy/fmt/doc all pass, with pre-existing unrelated failures confirmed viagit stashcomparison against the clean checkout.- Reuse, don't reimplement: Since JSX lowering already produces the same shared
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →