网页
综合
更新时间 2026-11-13 04:38:23
Getting Started | Rolldown
自动蜘蛛
rolldown.rs
正文约 2827 字
Why Plugin Hook Filter
Automatic Code Splitting
Manual Code Splitting
Inline Common Chunks
Non ESM Output Formats
Dead Code Elimination
Lazy Barrel Optimization
Looking for specific use cases?
For most applications, using Rolldown through Vite is the recommended approach, as it provides a complete development experience with dev server, HMR, and optimized production builds.
For library bundling, check out tsdown.
Prebuilt binaries are distributed for the following platforms (grouped by Node.js v24 platform support tier):
If you are using a platform that a prebuilt binary is not distributed, you have the following options:
To verify Rolldown is installed correctly, run the following in the directory where you installed it:
You can also check out the CLI options and examples with:
Let's create two source JavaScript files:
Then run the following in the command line:
You should see the content written to bundle.js in your current directory. Let's run it to verify it's working:
You should see Hello Rolldown! printed.
To avoid typing the long command, we can move it inside a package.json script:
Now we can run the build with just:
When more options are needed, it is recommended to use a config file for more flexibility. A config file can be written in .js, .cjs, .mjs, .ts, .mts, or .cts formats. Let's create the following config file:
Rolldown supports most of the Rollup config options, with some notable additional features. See the reference for the full list of options.
While exporting a plain object also works, it is recommended to utilize the defineConfig helper method to get options intellisense and auto-completion. This helper is provided purely for the types and returns the options as-is.
Next, in the npm script, we can instruct Rolldown to use the config file with the --config CLI option (-c for short):
You can also specify multiple configurations as an array. The CLI bundles them one after another, in the order they are listed. The build() API bundles an array of configurations concurrently.
Rolldown's plugin API is identical to that of Rollup's, so you can reuse most of the existing Rollup plugins when using Rolldown. That said, Rolldown provides many built-in features that make it unnecessary to use plugins.
Also Rolldown provides some builtin plugins that can be used for some use cases. See Builtin Plugins for more information.
Community plugins that are published to npm are listed in Vite Plugin Registry.
Rolldown provides a JavaScript API that is compatible with Rollup's, which separates input and output options:
Alternatively, you can also use the more concise build API, which accepts the exact same options as the config file export:
The rolldown watcher api is compatible with rollup watch.
Was this page helpful?
© 2025-present VoidZero Inc. and Rolldown contributors.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。