Rspack
Rust-based bundler with a webpack-compatible API that delivers fast cold starts and incremental builds for large applications.
Official Documentation ↗v2.3.1. Check the official docs for the latest API surface.Installation
npm install --save-dev @rspack/corepnpm add -D @rspack/coreMethods
No methods match this filter.
Overview
Rspack is a Rust-based bundler that reuses the webpack configuration and plugin model while providing much faster cold and incremental builds. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.
Core APIs
rspack— Creates a Compiler from a webpack-style configuration object.compiler.run— Executes one compilation and reports stats through the callback.compiler.watch— Enables incremental rebuilds on file changes with a watch handle.
Example
const { rspack } = require('@rspack/core');
const compiler = rspack({
entry: './src/index.js',
output: { path: __dirname + '/dist' },
});
Notes
Most webpack configuration maps directly, but some community loaders have no native equivalent yet. Validate plugin compatibility early when migrating.
Verification
Run one compile and then watch a source edit, confirming incremental rebuild latency is far below a full build.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://rspack.dev/api/javascript-api/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:17.619Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- The JavaScript API is useful in scenarios in which you need to customize the build or development process since all the reporting and error handling must be done manually and webpack only does the compiling part. (https://rspack.dev/api/javascript-api/)
- Those must be handled separately using stats.hasErrors() , which will be covered in detail in the Error Handling section of this guide. (https://rspack.dev/api/javascript-api/)
- The final logging of stats and errors should be done in this callback function. (https://rspack.dev/api/javascript-api/)
FAQ
- Is the Rspack config the same as webpack?
- Rspack implements a largely webpack-compatible configuration and plugin interface, but a few loaders and plugins still need native Rspack equivalents.
- Which built-in plugins ship with @rspack/core?
- Common ones such as HtmlRspackPlugin, DefinePlugin, and CopyRspackPlugin are exported directly from @rspack/core.
- How do I migrate an existing webpack config?
- Swap the webpack import for @rspack/core, then replace unsupported loaders; the CLI and most options map one to one.
Report a problem with this API docOpens a pre-filled issue on GitHub.