Rust + Oxc + direct DOM
Preact authoring.
Compiler-level work.
This page was rendered to HTML, hydrated, and made interactive by the compiler itself. No VDOM runtime ships in the browser bundle.
Server HTML ready · hydration pending
Live compiled component
3 rowsKeyed rows, direct updates
Compiler x-ray
Authored TSX becomes direct DOM work
Both panes come from this build. The right side is the Rust compiler's emitted JavaScript—not a hand-written approximation.
Inputdemo/src/App.tsx
188 linesimport { signal, useComputed, useSignalEffect } from "@preact/signals";
import { useState } from "preact/hooks";
import { StatCard } from "./StatCard.tsx";
export function App(props) {
const [count, setCount] = useState(0);
const rows = signal(props.rows);
const selected = signal(props.rows[0].id);
const showFullOutput = signal(false);
const rowCount = useComputed(() => rows.value.length);
const compiledOutput = useComputed(() =>
showFullOutput.value ? props.compiled.full : props.compiled.excerpt
);
const outputLabel = useComputed(() =>
showFullOutput.value ? "Show focused excerpts" : "Show full emitted module"
);
useSignalEffect(() => {
props.onCommit(rowCount.value);
});
return (
<main className="showcase">
<section className="hero">
<div className="eyebrow">Rust + Oxc + direct DOM</div>
<h1>Preact authoring.<br />Compiler-level work.</h1>
<p className="lede">
This page was rendered to HTML, hydrated, and made interactive by the
compiler itself. No VDOM runtime ships in the browser bundle.
</p>
<div className="hero-actions">
<button id="increment" className="primary" onClick={() => setCount(count + 1)}>
Hook updates: {count}
</button>
<span id="hydration-result" className="runtime-status">
Server HTML ready · hydration pending
</span>
</div>
</section>
<section className="stats" aria-label="Verified project statistics">
<StatCard
value={props.stats.upstream}
label="upstream cases"
detail="independently compiled"
/>
<StatCard
value={props.stats.compatibility}
label="attributed behaviors"
detail="exact pinned titles"
/>
<StatCard
value={props.stats.bundle}
label="browser bundle"
detail="Brotli compressed"
/>
<StatCard
value={props.stats.hydration}
label="hydration model"
detail="shared template shape"
/>
</section>
<section className="demo-grid">
<article className="interactive-panel">
<div className="section-heading">
<div>
<span className="section-kicker">Live compiled component</span>
<h2>Keyed rows, direct updates</h2>
</div>
<strong className="row-count">{rowCount.value} rows</strong>
</div>
<div className="toolbar">
<button
id="add-row"
onClick={() =>
rows.value = rows.value.concat({
id: props.nextId(),
label: `Compiled row ${rows.value.length + 1}`
})
}
>
Add row
</button>
<button
id="rotate-rows"
onClick={() =>
rows.value = rows.value.length > 1
? rows.value.slice(1).concat(rows.value[0])
: rows.value
}
>
Rotate identity
</button>
</div>
<ul id="compiled-rows" className="compiled-rows">
{rows.value.map(row => (
<li
key={row.id}
data-id={row.id}
className={selected.value === row.id ? "selected" : ""}
>
<button
className="row-select"
onClick={() => selected.value = row.id}
>
<span>{row.label}</span>
<small>key {row.id}</small>
</button>
<button
className="row-remove"
aria-label={`Remove ${row.label}`}
onClick={() =>
rows.value = rows.value.filter(item => item.id !== row.id)
}
>
×
</button>
</li>
))}
</ul>
</article>
<aside className="proof-panel">
<span className="section-kicker">What this proves</span>
<h2>One authored component, three real paths</h2>
<ol>
<li><strong>Compile</strong><span>Oxc lowers TSX into direct DOM instructions.</span></li>
<li><strong>Render</strong><span>The same create path emits the server HTML you loaded.</span></li>
<li><strong>Hydrate</strong><span>Existing nodes are claimed before exact bindings attach.</span></li>
</ol>
<div className="target-row">
<span>Targets</span>
<code>{props.stats.targets}</code>
</div>
</aside>
</section>
<section className="compiler-panel">
<div className="compiler-heading">
<div>
<span className="section-kicker">Compiler x-ray</span>
<h2>Authored TSX becomes direct DOM work</h2>
</div>
<p>
Both panes come from this build. The right side is the Rust compiler's
emitted JavaScript—not a hand-written approximation.
</p>
</div>
<div className="compiler-flow">
<article className="code-card">
<header>
<div>
<span>Input</span>
<strong>demo/src/App.tsx</strong>
</div>
<small>{props.sourceLines} lines</small>
</header>
<pre><code>{props.source}</code></pre>
</article>
<div className="compile-arrow" aria-hidden="true">→</div>
<article className="code-card emitted-code">
<header>
<div>
<span>Rust / Oxc output</span>
<strong>App.compiled.mjs</strong>
</div>
<small>{props.compiled.lines} lines · {props.compiled.bytes}</small>
</header>
<pre id="compiled-output"><code>{compiledOutput.value}</code></pre>
<button
id="toggle-compiled-output"
className="output-toggle"
onClick={() => showFullOutput.value = !showFullOutput.value}
>
{outputLabel.value}
</button>
</article>
</div>
</section>
</main>
);
}
Rust / Oxc outputApp.compiled.mjs
1003 lines · 45,777 B// Generated by preact_compiler_lab. Do not edit by hand.
import { createRuntime, own as $own } from "preact-compiler-lab:runtime";
import { bindKeyedAttribute as $bindKeyedAttribute } from "preact-compiler-lab:runtime/keyed-attributes";
import { createComponent as $factory_StatCard, componentMetadata as $metadata_StatCard } from "./StatCard.compiled.mjs";
// … source-location table omitted from this focused view …
function $createRoot($ctx, props, $n = 0) {
return $ctx.renderPhase(() => {
const {useState,signal,computed,effect,batch,useComputed,useSignalEffect}=$ctx;
const $state_count = useState(0);
let count = $state_count.value;
const setCount = value => { const $next_count = typeof value === "function" ? value($state_count.value) : value; $ctx.setState($state_count, $next_count, v=>count=v); };
const rows = signal(props.rows);
const selected = signal(props.rows[0].id);
const showFullOutput = signal(false);
const rowCount = useComputed(() => rows.value.length);
const compiledOutput = useComputed(() =>
showFullOutput.value ? props.compiled.full : props.compiled.excerpt
);
const outputLabel = useComputed(() =>
showFullOutput.value ? "Show focused excerpts" : "Show full emitted module"
);
useSignalEffect(() => {
props.onCommit(rowCount.value);
});
return () => {
const $el0 = $rt.element("main", $n);
$el0.setAttribute("class", "showcase");
const $el1 = $rt.element("section", $n);
$el1.setAttribute("class", "hero");
const $el2 = $rt.element("div", $n);
$el2.setAttribute("class", "eyebrow");
const $text3 = $rt.text("Rust + Oxc + direct DOM");
$el2.appendChild($text3);
$el1.appendChild($el2);
const $el4 = $rt.element("h1", $n);
const $text5 = $rt.text("Preact authoring.");
$el4.appendChild($text5);
const $el6 = $rt.element("br", $n);
$el4.appendChild($el6);
const $text7 = $rt.text("Compiler-level work.");
$el4.appendChild($text7);
$el1.appendChild($el4);
const $el8 = $rt.element("p", $n);
$el8.setAttribute("class", "lede");
const $text9 = $rt.text("This page was rendered to HTML, hydrated, and made interactive by the compiler itself. No VDOM runtime ships in the browser bundle.");
$el8.appendChild($text9);
$el1.appendChild($el8);
const $el10 = $rt.element("div", $n);
// … direct instructions for the remaining static sections …
const $map46 = $rt.map($ctx, () => (rows.value), (row, $index, $ctx, $item47, $key) => {
const $el49 = $rt.element("li", $n);
$keyed48($ctx, $el49, $key);
const $el50 = $rt.element("button", $n);
$el50.setAttribute("class", "row-select");
$rt.bindEvent($ctx, $el50, "onClick", (() => selected.value = $item47.value.id));
const $el51 = $rt.element("span", $n);
const $text52 = $rt.text("");
$el51.appendChild($text52);
$el50.appendChild($el51);
const $el53 = $rt.element("small", $n);
const $text54 = $rt.text("key ");
$el53.appendChild($text54);
const $text55 = $rt.text("");
$el53.appendChild($text55);
$el50.appendChild($el53);
$el49.appendChild($el50);
const $el56 = $rt.element("button", $n);
$el56.setAttribute("class", "row-remove");
$rt.boundAttr($ctx, $el56, "aria-label", () => (`Remove ${row.label}`));
$rt.bindEvent($ctx, $el56, "onClick", (() =>
rows.value = rows.value.filter(item => item.id !== row.id)));
const $text57 = $rt.text("×");
$el56.appendChild($text57);
$el49.appendChild($el56);
let $value58, $value59, $value60;
$ctx.observe(() => {
let $error, $next;
if ($value58 !== $ctx) try {
$next = $rt.value($item47.value.id);
if ($next !== $value58) { $value58 = $next; $rt.setAttr($el49, "data-id", $next); }
} catch ($caught) { $value58 = $ctx; $error ??= $caught; }
if ($value59 !== $ctx) try {
$next = $rt.textValue($item47.value.label);
if ($next !== $value59) { $value59 = $next; if ($text52.data !== $next) $text52.data = $next; }
// … remaining keyed-row bindings omitted …
export function createApp(host = document, { hydratable = true } = {}) {
const $module = $createModule(host);
const $rt = $module.runtime;
return {
render(container, props = {}) {
const $ctx = $rt.createContext(props, true, hydratable);
const $value = $own($ctx, () => $module.create($ctx, props, $rt.ns(container)));
container.textContent = "";
const $root = $rt.mount(container, $value);
$own($ctx, () => $ctx.commit());
return { root: $root, dispose: () => $ctx.dispose() };
},
renderToString(props = {}) {
const $container = host.createElement("div");
const $ctx = $rt.createContext(props, false);
try {
const $value = $module.create($ctx, props);
$rt.mount($container, $value);
// … renderToString() and hydrate() share the generated template shape …