npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rsvelte/compiler

v0.10.10

Published

A high-performance Rust implementation of the Svelte compiler

Downloads

7,604

Readme

@rsvelte/compiler

A high-performance Rust implementation of the Svelte 5 compiler, shipped as WebAssembly. Part of the rsvelte project — a port of the official Svelte compiler to Rust, aiming for byte-identical output and a large speedup over the JavaScript compiler.

The whole compile pipeline — parse, analyze, transform — for client, SSR and hydration, with output that matches the official compiler across the in-scope test suite.

⚠️ Early stage. The API surface is stabilising. Output is verified byte-for-byte against the official compiler across the in-scope Svelte test suite, but treat this as experimental for production use.

Install

npm install @rsvelte/compiler
# pnpm add @rsvelte/compiler
# yarn add @rsvelte/compiler

The package is a wasm-pack (--target web) module — the WebAssembly binary ships with the package, so it runs anywhere WebAssembly does (modern browsers, Node.js, Deno, Bun) with no native binaries and no optionalDependencies.

If you need the raw .wasm bytes yourself (for example to drive the synchronous initSync on Node), import them from the stable @rsvelte/compiler/wasm subpath rather than the internal artifact filename:

import { createRequire } from 'node:module';
import { readFileSync } from 'node:fs';
import { initSync } from '@rsvelte/compiler';

const require = createRequire(import.meta.url);
const bytes = readFileSync(require.resolve('@rsvelte/compiler/wasm'));
initSync({ module: bytes });

@rsvelte/compiler/wasm is the supported path for the wasm binary and stays stable across releases; the on-disk filename is an internal build detail and may change.

Usage

import init, {
  parse_svelte,
  compile,
  compile_client,
  compile_server,
  version,
} from '@rsvelte/compiler';

// Initialise the WebAssembly module once before calling any export.
await init();

const source = `<h1>Hello {name}</h1>`;

// Compile for the client.
const client = compile_client(source, 'App');
console.log(client.js);  // generated JavaScript
console.log(client.css); // scoped styles

// Compile for SSR.
const server = compile_server(source, 'App');

// Parse to the Svelte AST (JSON string, same shape the official parser produces).
const ast = JSON.parse(parse_svelte(source).ast);

console.log(version()); // the rsvelte compiler version

Full compile options

compile(source, options) accepts the full compile-options object, including the function forms Svelte's own compile supports. It returns the result as a JSON string ({ js, css, warnings, metadata }); the callbacks are input-only.

const result = JSON.parse(
  compile(source, {
    filename: 'App.svelte',
    generate: 'client',
    // `customElement` / `css` / `runes` also accept `({ filename }) => value`.
    css: 'injected',
    // Filter compiler warnings (applied by the compiler).
    warningFilter: (w) => !w.code.startsWith('a11y'),
    // A constant scope hash, or a dynamic `cssHash({ hash, css, name, filename })`.
    cssHash: ({ hash, css }) => `x-${hash(css)}`,
  }),
);
console.log(result.js.code, result.warnings);

Why it is fast

  • Written in Rust with a memory-efficient AST (u32 spans, compact strings) and direct phase-to-phase AST passing — no re-parsing between phases.
  • Thread-safe, parallel parsing via rayon.
  • Designed for integration into the oxc ecosystem.

Related packages

License

MIT


Maintainers: @rsvelte/compiler is published from the wasm-pack output in the repo-root pkg/ directory, not from this directory. See PUBLISHING.md for how the version anchor and README overlay work.