Skip to content

插件 API

¥Plugin API

🚧 正在建设中

我们正在努力创建更详细的参考资料。目前,请先参考 Rollup 的插件 API

¥We are working on creating a more detailed reference. For now, please refer to Rollup's Plugin API.

Rolldown 的插件接口几乎完全兼容 Rollup(详细跟踪 此处),因此如果你之前编写过 Rollup 插件,那么你已经知道如何编写 Rolldown 插件了!

¥Rolldown's plugin interface is almost fully compatible with Rollup's (detailed tracking here), so if you have written a Rollup plugin before, you already know how to write a Rolldown plugin!

我们仍在努力为 Rollup 和 Rolldown 的新用户创建更详细的指南。目前,请先参考 Rollup 的插件开发指南

¥We are still working on creating a more detailed guide for users who are new to both Rollup and Rolldown. For now, please first refer to Rollup's plugin development guide.

与 Rollup 的显著差异

¥Notable Differences from Rollup

虽然 Rolldown 的插件接口与 Rollup 的接口基本兼容,但仍有一些重要的行为差异需要注意:

¥While Rolldown's plugin interface is largely compatible with Rollup's, there are some important behavioral differences to be aware of:

输出生成处理

¥Output Generation Handling

在 Rollup 中,所有输出都在单个进程中一起生成。但是,Rolldown 会分别处理每个输出的生成。这意味着如果你有多个输出配置,Rolldown 将独立处理每个输出,这可能会影响某些插件的行为,尤其是那些在整个构建过程中维护状态的插件。

¥In Rollup, all outputs are generated together in a single process. However, Rolldown handles each output generation separately. This means that if you have multiple output configurations, Rolldown will process each output independently, which can affect how certain plugins behave, especially those that maintain state across the entire build process.

与此相关,在 Rolldown 中,outputOptions 钩子在构建钩子之前调用,而 Rollup 则在构建钩子之后调用它们。

¥Related to that, the outputOptions hook is called before the build hooks in Rolldown, whereas Rollup calls them after the build hooks.

内置插件

¥Builtin Plugins

Rolldown 提供了一组用 Rust 实现的内置插件,以实现更高的性能。

¥Rolldown offers a set of built-in plugins, implemented in Rust, to achieve higher performance.