Scripts2026年4月14日·1 分钟阅读

Rolldown — Rust-Powered JavaScript Bundler and the Future of Vite

Rolldown is a Rust-based Rollup-compatible bundler built by the Vite team. It replaces esbuild + Rollup in Vite with a single fast bundler, bringing dramatic speed improvements while keeping the plugin API developers already know.

Introduction

Rolldown is the bundler being built by the Vite team to replace the current esbuild-for-dev + Rollup-for-build split. Written in Rust (using Oxc internals), it offers Rollup plugin compatibility with dramatic speed improvements. When Rolldown ships in Vite stable, builds that take 30s will finish in 2–5s.

With over 13,000 GitHub stars despite being pre-1.0, Rolldown is one of the most anticipated projects in the JS ecosystem. Evan You's team ships it incrementally — you can already use it directly for library builds today.

What Rolldown Does

Rolldown is a module bundler: it takes your source entry points, resolves imports, applies plugins, and emits bundled JavaScript. Unlike esbuild, it supports the full Rollup plugin API — which means the existing Vite plugin ecosystem works as-is. Unlike Rollup, it's written in Rust and uses Oxc for parsing.

Architecture Overview

Entry + Config
    |
[Rolldown Core (Rust)]
  Module Resolver  <-- Rollup-style resolveId hook
  Parser           <-- Oxc (fastest JS parser)
  Transformer      <-- Oxc transformer + user plugins
  Graph Builder    <-- dependency graph
  Scope Hoisting   <-- tree-shake + hoist
  Code Generator
    |
  Output bundle(s)
    |
  Consumers:
  - Vite (integration in progress)
  - Library builders (direct)
  - Rolldown-vite (preview)

Self-Hosting & Configuration

// Library mode with multiple entries + dts
import { defineConfig } from "rolldown";
import dts from "rollup-plugin-dts";

export default defineConfig([
  {
    input: { index: "src/index.ts", cli: "src/cli.ts" },
    output: [
      { dir: "dist", format: "esm", entryFileNames: "[name].mjs" },
      { dir: "dist", format: "cjs", entryFileNames: "[name].cjs" },
    ],
    external: ["node:*"],
    treeshake: true,
  },
  {
    input: "src/index.ts",
    output: { file: "dist/index.d.ts" },
    plugins: [dts()],
  },
]);

Key Features

  • Rollup plugin API compatibility — existing Vite plugins mostly work
  • Rust-native speed — 10–40x faster than Rollup on realistic inputs
  • Oxc-based parsing — fastest JS/TS parser available
  • Multi-entry builds — split chunks and code splitting
  • Tree shaking — more aggressive than Rollup via Rust analyzers
  • Scope hoisting — emit smaller bundles
  • Library + app modes — tuned defaults for each scenario
  • Incremental shipping — already usable for library builds

Comparison with Similar Tools

Feature Rolldown Rollup esbuild Rspack Vite (current)
Language Rust JS Go Rust JS (Rollup+esbuild)
Plugin API Rollup-compatible Rollup esbuild Webpack-compat Rollup + Vite
Speed Very Fast Slow Fastest Very Fast Moderate
Tree shaking Excellent Excellent Basic Good Via Rollup
Intended use Libraries + apps Libraries Dev servers Apps Apps
Stability Pre-1.0 Stable Stable Stable Stable

FAQ

Q: Can I use Rolldown in production today? A: For libraries, yes — many package authors already use it. For applications via Vite, there's a rolldown-vite preview; full stable Vite+Rolldown ships in Vite 6 and beyond.

Q: Will my Vite plugins still work? A: Most yes. Rolldown implements the Rollup plugin API, and the Vite-specific hooks map through. A few esbuild-specific plugins need porting.

Q: Rolldown vs Rspack? A: Rspack is a Rust Webpack. Rolldown is a Rust Rollup. Different plugin ecosystems. Rspack targets existing Webpack users; Rolldown targets Vite/Rollup users.

Q: Rolldown vs esbuild? A: esbuild is faster raw but lacks a real plugin ecosystem. Rolldown trades some raw speed for Rollup-level extensibility.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产