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 holds the complete list of generated render artifacts returned by .
- Assistant
I’ll first inspect the workspace and the JSX crate to understand the existing parser/lowering/compiler infrastructure and identify whether
dom.rsis missing or incomplete. Then I’ll implement the API using existing conventions and run the most focused tests plus broader crate checks. - Assistant
The JSX crate currently has only parsing, root discovery, and shared lowering; no DOM entry point exists. I’ll inspect its public types and lowered IR, then locate the Vue DOM code generator in sibling crates so the new API delegates rather than reimplementing semantics.
- Assistant
The shared IR feeds
vize_atelier_corecodegen, whilevize_atelier_domlikely applies DOM-specific transforms first. I’ll inspect its compile pipeline, option mapping, and result formatting, as well as the current JSX lowering tests to see the exact IR conventions for JSX-only constructs. - Assistant
I need the transform function’s ownership/signature because lowered roots are already parsed, and compiler diagnostics must be converted into
JsxDiagnostic. I’ll inspect the omitted pipeline and diagnostic definitions before designing the adapter. - Assistant
The DOM crate’s pipeline confirms that DOM compilation after parsing is exactly core transform + core codegen; DOM-specific behavior is already integrated in those transforms. The JSX adapter should therefore: lower once, transform each mutable root with module/prefix-identifiers settings suitable for JSX, pass Croquis binding metadata, generate code, and preserve each root’s metadata. I’ll inspect option defaults, error spans, and root codegen shape to choose settings and safely suppress output when transforms report errors.
- Assistant
The codegen module mode produces the desired imported-helper/render-function shape. One nuance is setup-returned JSX: generated identifiers should use Croquis metadata (
$setup.foo) and component names should support self-reference, so each root needs its own codegen options but can share analysis. I’ll locate the actual split option/error modules and then implement the public module and dependency changes. - Assistant
vize_atelier_corereexports its AST/options/errors fromvize_reliefrather than owning files. I’ll inspect those definitions and then patch. - Assistant
I found the canonical definitions; I’ll now read only the relevant fields and proceed with implementation.
- Assistant
I’ll implement
dom.rswith conservative error gating: parse/lowering errors return diagnostics and no generated components, preventing malformed output. Transform diagnostics are mapped with source locations and likewise suppress that component’s code. Recoverable compiler diagnostics become warnings. Options will default exactly as requested and map to module-mode codegen, TypeScript awareness, shared bindings, hoisting, handler caching, and source maps. - Assistant
The special
createeditor command does not accept shell heredoc content, so it created an empty file; the API implementation itself was not written. I’ll write the intended source using a standard shell heredoc, format it, and rerun the crate check. - Assistant
Croquis and compiler binding metadata are intentionally separate representations. The transform already receives Croquis directly for semantic analysis; codegen still needs the relief representation. I’ll find the established conversion used by SFC compilation and reuse it rather than introducing an incomplete mapping.
- Assistant
The binding types are shared, so conversion is lossless; the SFC crate has a dedicated helper that likely performs the map-key conversion. I’ll inspect it and either expose/reuse equivalent local logic without adding an SFC dependency cycle.
- Assistant
I’ll add a small private lossless conversion matching the SFC compiler. This preserves imported components, refs, props aliases, and setup/function bindings consistently for transform and codegen.
- Assistant
The crate now compiles. Next I’ll run all existing JSX integration tests to ensure adding the backend and dependency does not alter lowering behavior. Then I’ll use a temporary example (removed afterward) to exercise the new API across elements, components/spreads/classes/styles/events, fragments, directives/model, TSX, modes, and invalid syntax, inspecting actual generated output and diagnostics.
- Assistant
All 91 existing unit/integration/doc tests pass. I’ll now create a temporary example harness with assertions on generated helper imports, patch flags/dynamic props, spread/class/style merging, component/slot handling, v-model, mode/name metadata, TS stripping, and invalid-input gating. This is not a repository test and will be deleted after execution.
- Assistant
The smoke harness passed all targeted assertions. Before finalizing, I’ll inspect the actual diff and run Clippy on the crate. I’ll also remove the temporary example as required, verify no unintended lockfile/test changes, and consider API/docs consistency.
- Assistant
Clippy passes cleanly. One semantic point warrants validation: Babel JSX output normally references an imported/local component directly, whereas template compilation may call
resolveComponent. Croquis marks module bindings and has anis_script_setupflag that controls this behavior. I’ll inspect JSX analysis setup and generated component output to ensure local components are emitted correctly, since this affects the “components” requirement and plugin-shaped defaults. - Assistant
JSX analysis deliberately uses the script-setup analyzer, which should mark direct module bindings appropriately. I’ll confirm that application sets the flag and inspect component binding resolution for member expressions and imports; if sound, no adjustment is needed.
- Assistant
The semantic analyzer does mark JSX modules as script setup, and codegen resolves local/member components through the converted metadata, so imported components are not incorrectly runtime-resolved. The lockfile change is the expected new core dependency only.
I’ll perform a broader workspace check to detect feature-unification or dependency-cycle issues, then review formatting/status and submit if clean.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.