The Svelte 5 compiler, rewritten in Rust.
Drop-in replacement for svelte/compiler (pinned to svelte@5.55.5) — same JS output, ~30× faster.
⚠️ WIP / canary. Built by a human with heavy AI assistance. Expect bugs, missing edge cases, and breaking changes. Not production-ready — please report what breaks.
compile() / compileModule() API as svelte/compiler.vite-plugin-svelte, so you can try it in a real Vite app today.| Node | ^20.19 || ^22.12 || >=24 |
| Platforms | macOS arm64/x64, Linux x64 glibc. Windows and Linux musl (Alpine) not yet. |
| Peer | [email protected] — Vite plugin falls back to svelte/compiler for unsupported options. |
This is still a work in progress and is not yet at full feature parity with svelte/compiler. Parity target: svelte@5.55.5. Bugs may exist. Please check this list carefully before logging a new issue or assuming an intentional change.
| Feature | Status | Notes |
|---|---|---|
| Svelte 5 syntax | done | Runes, template, bindings, directives, events, special elements, diagnostics, a11y. Byte-exact diff against svelte/compiler. |
| Svelte 4 legacy | in progress | export let, $:, beforeUpdate/afterUpdate, <svelte:component>, auto-mode detection done. <slot> / <svelte:self> still pending. |
| CSS pipeline | done | analyze + transform + codegen |
| TypeScript | done | Script stripping only — no type checking. |
.svelte.js / .svelte.ts modules |
done | — |
| Custom elements | in progress | Basic path works; some option combinations not covered. |
| Compiler options | in progress | Most common options honored; long tail (discloseVersion, etc.) still landing. |
Dev mode (dev: true) |
in progress | Runtime checks and ownership tracking land case-by-case. |
| Source maps | in progress | Partial implementation, not yet verified against reference. |
| Preprocessors | not ready | Not started. |
SSR (generate: 'server') |
not ready | Not started — large chunk of work. |
| HMR | not ready | Not started. |
Definitions:
Full breakdown: ROADMAP.md.
ast option is not supported — passing it throws; the returned ast is always null.sourcemap and outputFilename options are not supported — passing them throws.modernAst: true is accepted but ignored (emits unsupported_option_ignored warning).js.map / css.map are always null (source maps are WIP).dev: true runtime checks land case-by-case — not all ownership / hydration diagnostics are emitted yet.npm i -D @mrwaip/svelte-rs2
import { compile } from '@mrwaip/svelte-rs2/compiler';
const { js } = compile(
`<script>let { name } = $props();</script><h1>hello {name}</h1>`,
{ filename: 'Hello.svelte', generate: 'client' }
);
console.log(js.code);
API mirrors svelte/compiler. Unsupported options (ast, sourcemap, outputFilename) throw; see packages/svelte-rs2/compiler/index.d.ts.
Want to see real input → output? Browse tasks/compiler_tests/cases2/ — each folder has case.svelte (input), case-rust.js (our output) and case-svelte.js (reference). 1100+ cases, byte-diffed.
Use the fork of vite-plugin-svelte — it routes compile / compileModule through @mrwaip/svelte-rs2 automatically, with fallback to svelte/compiler where the Rust side doesn't support an option yet.
npm i -D @mrwaip/vite-plugin-svelte
import { defineConfig } from 'vite';
import { svelte } from '@mrwaip/vite-plugin-svelte';
export default defineConfig({
plugins: [svelte()],
});
Source: https://github.com/MrWaip/vite-plugin-svelte.
Geomean: 30.18× across 24 cases (min 20.14×, max 51.97×). Walltime vs svelte/compiler, measured 2026-05-04 via just bench-compare-walltime. big_v6.svelte is a synthetic stress component (~5.8k LOC); the rest are real-world Svelte files.
| case | rust med | js med | speedup |
|---|---|---|---|
big_v6.svelte (compile, synthetic stress) |
18.39 ms | 955.9 ms | 51.97× |
big_v6.svelte (compile_dev, synthetic stress) |
19.56 ms | 944.7 ms | 48.30× |
module/case_02.svelte.js (real-world) |
0.131 ms | 5.283 ms | 40.37× |
template/case_01.svelte (real-world) |
0.745 ms | 21.65 ms | 29.08× |
snippets/case_01.svelte (real-world) |
1.558 ms | 35.62 ms | 22.86× |
css/case_01.svelte (real-world) |
0.014 ms | 0.290 ms | 20.14× |
Requires Rust, Node, and just (cargo install just or brew install just).
just playground # build wasm + serve playground
just quick-check App.svelte # diff one component against svelte/compiler
just test-compiler # run the 1500+ e2e suite
Standard PRs welcome — no AI required. Day-to-day work uses Claude Code; slash commands live in .claude/commands/ (/status, /port, /audit). Before opening a PR: just test-compiler && just test-diagnostics && just lint must be green.
Bugs and questions: https://github.com/MrWaip/svelte-rs-2/issues.
MIT © Lobkov Constantine