vercel/next.js
next-rspack
Purpose
next-rspack is the adapter that lets users replace webpack with rspack — a webpack-API-compatible bundler written in Rust. The package is small (a hundred-odd lines plus a re-export of rspack core) because rspack mostly drops in where webpack does. Activated by setting NEXT_RSPACK=1.
Source: packages/next-rspack/.
Directory layout
packages/next-rspack/
├── README.md
├── index.js # Plugin / loader registry
├── index.d.ts
├── rspack-core.js # Re-exports @rspack/core under a stable shape
└── package.jsonThe package's job is to translate Next.js's webpack-flavored config into rspack-compatible config and to register the rspack-flavored variants of Next.js-specific webpack plugins.
Activation
NEXT_RSPACK=1 next dev
NEXT_RSPACK=1 next buildThe framework reads process.env.NEXT_RSPACK in packages/next/src/build/index.ts and packages/next/src/server/dev/hot-reloader-rspack.ts to switch the builder. The selection cascade is:
--turbopackflag or default → TurbopackNEXT_RSPACK=1→ rspack--webpackflag → webpack
Plugin compatibility
Some Next.js webpack plugins do not work unmodified on rspack. The adapter:
- Translates plugin shapes that depend on webpack-specific internals.
- Provides rspack-flavored versions of
define-env-plugin, the route-bundle-stats plugin, and the build manifest plugin. - Handles asset module differences (rspack and webpack diverge on a few
module.rulesshapes).
Differences are tracked in the rspack-specific test manifests at test/rspack-build-tests-manifest.json and test/rspack-dev-tests-manifest.json (which together top 1.6 MB of skipped/known-failing test entries — the rspack parity work is ongoing).
CI and releases
rspack support has its own CI lanes and release flow:
.github/workflows/release-next-rspack.yml— publishes rspack-compatible builds.github/workflows/rspack-nextjs-build-integration-tests.ymlandrspack-nextjs-dev-integration-tests.yml— test runs.github/workflows/rspack-update-tests-manifest.yml— refreshes the rspack tests manifest
The rspack/ directory at the repo root holds patched binding crates that adapt the upstream @rspack/core to Next.js's needs.
Hot reloader
packages/next/src/server/dev/hot-reloader-rspack.ts (8.3 KB) is the rspack flavor of the dev hot reloader. It mirrors the structure of hot-reloader-webpack.ts but uses the rspack compiler API.
Key source files
| File | Purpose |
|---|---|
packages/next-rspack/index.js |
Plugin / loader registry |
packages/next-rspack/rspack-core.js |
Re-exports @rspack/core |
packages/next/src/server/dev/hot-reloader-rspack.ts |
Dev hot reloader |
packages/next/src/build/webpack-config.ts |
Shared config used (with branches) for both bundlers |
rspack/ |
Patched rspack binding crates |
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.