The Svelte 5 compiler, in Rust.
Identical output.
rusvelte is a port of the Svelte 5 compiler and svelte-check to Rust. Every layer is checked against the official JavaScript tools: on four real-world codebases its compiled output is identical to Svelte 5.57.2's.
svelte-check on a 1,982-component appParity with the official compiler
Each number counts compilations whose js.code is exactly the text svelte/compiler 5.57.2 produces with the same options, including .svelte.ts modules (compileModule).
| Corpus | Files | Client | Server |
|---|---|---|---|
| Real-world code | |||
| Windmill frontend | 1,982 | 1,982 | 1,982 |
| Immich web (incl. 45 modules) | 456 | 456 | 456 |
| bits-ui (incl. 58 modules) | 284 | 284 | 284 |
| A private SvelteKit app | 171 | 171 | 171 |
| Svelte's own test suites | |||
| runtime-runes | 1,428 | 1,428 | 1,428 |
| runtime-legacy | 1,658 | 1,658 | 1,590 |
| hydration | 98 | 98 | 98 |
| snapshot | 36 | 36 | 36 |
| css | 188 | 187 | 187 |
| server-side-rendering | 159 | n/a | 153 |
The one css sample left uses a custom cssHash function the test harness can't call yet. Seven Immich modules are excluded because their TypeScript (enums) can't be type-stripped, so the official compiler can't compile them either.
| Other layers | Parity |
|---|---|
| Parser (modern and legacy AST) | 4,567 / 4,567 Svelte test files |
| Compiler warnings and errors | 4,564 / 4,567 Svelte test files; all of Immich and bits-ui; svelte-check's warnings on Windmill |
CSS output and source maps (css, js.map, css.map) | identical on every compilation above |
| JS printer (port of esrap) | identical code and source map mappings on 16,470 JS files |
| svelte2tsx | Windmill 1,982 / 1,982; Svelte tests 4,566 / 4,567 |
| svelte-check-rs diagnostics | identical to svelte-check --tsgo on Windmill (7,922 diagnostics) |
Speed
Same machine, warm runs. Compile times exclude file reading and use one thread; the compiler hasn't been profiled or tuned yet.
On Windmill, most of svelte-check-rs's 9.3 s is the TypeScript 7 type-check itself. In a full vite build, bundling, CSS tooling and preprocessors take most of the time, so whole builds speed up less than the compiler alone; both builds above came out identical to the official ones (apart from SvelteKit's build timestamp). Build times are the median of three alternating runs.
How it's verified
The port follows the official source function by function, and nothing counts as done until it matches.
An oracle for every layer
Node scripts run the official tool over a corpus and record its exact output, options included: ASTs, warnings, generated JS and CSS, TypeScript overlays, diagnostics.
Diff, group, fix
A Rust binary per layer reruns the same inputs, compares the output exactly and groups mismatches by their first differing line, so the biggest gap is always next.
Real code, not just tests
Svelte's own suites cover the edge cases. Windmill, Immich and bits-ui cover what people actually write: legacy components, runes classes, snippets, async.
Variants for coverage
Corpora are recompiled with dev, hmr, custom elements, injected CSS, runes forced on or off and TypeScript, to push the code down every path.
What's there, what's next
Working
- Parser, analysis, warnings and errors
compile(client and server) andcompileModule- CSS output, scoping and pruning
- svelte2tsx and
svelte-check-rs(with TypeScript 7) - Source maps, identical to the official ones
- A drop-in for
svelte/compilerin Vite builds (Node binding)
Not yet
- Testing
vite devwith hot reload - An npm release, then a native Rolldown plugin
- Preprocessors still run in Node
Try it
In a Vite or SvelteKit app on Svelte 5.57.2:
npm install -D @rusveltejs/compiler
NODE_OPTIONS="--import @rusveltejs/compiler/register" vite build
Anything rusvelte doesn't handle (other Svelte versions, some options, components with errors) falls back to the official compiler. RUSVELTE_VERIFY=1 compiles everything both ways and reports any difference.
svelte-check-rs
The project needs TypeScript 7 (@typescript/native-preview or typescript@7), as with svelte-check --tsgo.
cargo build --release --bin svelte-check-rs
cd my-app
/path/to/svelte-check-rs --tsconfig ./tsconfig.json
Options follow svelte-check: --workspace, --output, --threshold, --watch, --incremental, --fail-on-warnings and more. See the README.