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

svelte-bun

v0.10.0

Published

Svelte for Bun.build and Bun's dev server.

Readme

svelte-bun

Svelte for Bun.build and Bun's dev server.

svelte-bun compiles Svelte 5 components and rune modules for Bun's dev server and Bun.build, from one line of bunfig, and Svelte 3 and 4 components too. It reads svelte.config.js, so your preprocessors and compiler options work as they do under Vite, and it handles the cases where Bun's dev server breaks a Svelte app. When Svelte rejects a file, the build fails with the file and Svelte's message.

| On Bun 1.4.6, Svelte 5.59.1 | bun-plugin-svelte 0.0.6 | svelte-bun | | :------------------------------------------------------ | :--------------------------------------------------------------- | :----------- | | <svelte:head> in the dev server | undefined is not an object (evaluating '$.document.title = …') | ✓ | | a library's svelte export condition | Could not resolve: "fake-lib" | ✓ | | @import "./card.css" in a component in a subdirectory | Could not resolve: "./card.css" | ✓ | | preprocessors and svelte.config.js | ✗ | ✓ | | a custom renderer, in bun run and bun test | ✗ can't pass experimental.customRenderer | ✓ | | a minimal app, minify: true, production | 21.2 kB gzip | 18.7 kB gzip |

Quick start

bun add -d svelte-bun svelte
# bunfig.toml
[serve.static]
plugins = ["svelte-bun"]
bun index.html

Bun's dev server serves index.html, compiling each .svelte file it reaches, with hot updates. It keeps each compile in node_modules/.cache/svelte-bun, so the next start reads it rather than compiling again. Options come from svelte.config.js, since bunfig can't pass any:

// svelte.config.js
import { optimizeImports } from "carbon-preprocess-svelte";

export default {
  preprocess: [optimizeImports()],
  compilerOptions: { runes: true },
};

In bun run and bun test, a preload compiles the .svelte files Bun's runtime imports, with the same config, for the client in a test file with a DOM and for the server in one marked @vitest-environment node:

# bunfig.toml
preload = ["svelte-bun/register"]

The preload reads and writes the same cache, so under bun test --isolate a component compiles once, not once per test file that imports it. An entry is keyed by the component's source, its compiler options, svelte.config.*, tsconfig.json and the lockfile, so an edit misses rather than reading a stale entry, and one unread for 7 days is removed; a preprocessor that reads other files names them in cacheKey. svelteBun: { cache: false } in svelte.config.js turns it off; onwarn there takes each warning as it does under Vite. A project with no svelte.config.js sets the cache, and compiler options for the files a glob matches, under [svelte-bun] in bunfig.toml.

From code

A production build, and a server build for prerendering:

// build.ts
import { svelte } from "svelte-bun";

await Bun.build({
  entrypoints: ["index.html"],
  outdir: "dist",
  minify: true,
  plugins: [svelte({ production: true })],
});

await Bun.build({
  entrypoints: ["src/ssr.ts"],
  outdir: "dist/server",
  target: "bun",
  plugins: [svelte({ production: true, side: "server" })],
});

production drops Svelte's development checks and the dev-only code in its runtime; it defaults to NODE_ENV === "production". A host with its own bundler compiles files through svelte-bun/compile instead.

Docs

  • Options: every option, svelte.config.js, Svelte 3 and 4, custom renderers, and the preload
  • Compile API: compileFile() and scanImports(), for another host
  • Recipes: prerendering, hydrating, build-time data, CSS types
  • Compared: what differs from bun-plugin-svelte, and how it was measured

These docs ship in the package, at node_modules/svelte-bun/docs/.