rusvelte
Experimental · not affiliated with the Svelte team

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.

5,786 / 5,786real-world compilations identical to the official compiler's (client and server)
3.8× – 5.9×faster compile than the official compiler, single-threaded
7.9×faster full svelte-check on a 1,982-component app

Parity 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).

CorpusFilesClientServer
Real-world code
Windmill frontend1,9821,9821,982
Immich web (incl. 45 modules)456456456
bits-ui (incl. 58 modules)284284284
A private SvelteKit app171171171
Svelte's own test suites
runtime-runes1,4281,4281,428
runtime-legacy1,6581,6581,590
hydration989898
snapshot363636
css188187187
server-side-rendering159n/a153

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 layersParity
Parser (modern and legacy AST)4,567 / 4,567 Svelte test files
Compiler warnings and errors4,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
svelte2tsxWindmill 1,982 / 1,982; Svelte tests 4,566 / 4,567
svelte-check-rs diagnosticsidentical 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.

Official (Node)rusvelte
Production vite build, Windmill69.9 s → 54.8 s
Production vite build, a 171-component SvelteKit app7.5 s → 4.5 s
Compile Windmill, client (1,982 components)6.0 s → 1.6 s
Compile Windmill, server5.1 s → 0.87 s
Full svelte-check, Windmill73.5 s → 9.3 s
Print Windmill's compiled JS (esrap)4.3 s → 0.6 s

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) and compileModule
  • 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/compiler in Vite builds (Node binding)

Not yet

  • Testing vite dev with 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.