unplugin
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnplugin provides a single Rollup-style plugin API that runs on Vite, Rollup, webpack, esbuild, Rspack, Rolldown, Farm, and Bun. Use these skills when implementing a new unplugin, integrating an existing one, or debugging hook/context behavior across bundlers.
The skill is based on unplugin v3.0.0, generated at 2026-01-30.
Unplugin 提供了一套统一的Rollup风格插件API,可在Vite、Rollup、webpack、esbuild、Rspack、Rolldown、Farm和Bun上运行。在开发新的unplugin、集成现有插件或调试跨构建工具的钩子/上下文行为时,可参考以下技能内容。
本技能基于unplugin v3.0.0版本生成,生成时间为2026年1月30日。
Core References
核心参考
| Topic | Description | Reference |
|---|---|---|
| Overview | What unplugin is, supported bundlers, when to use | core-overview |
| Core API | createUnplugin, factory signature, bundler-specific creators | core-api |
| Hooks and context | Lifecycle hooks, filters, this.parse / emitFile / warn / error | core-hooks-and-context |
| Hook compatibility | Per-bundler support tables for hooks and context | core-hook-compatibility |
| Integration | Installing and registering in Vite, Rollup, webpack, etc. | core-integration |
| 主题 | 描述 | 参考链接 |
|---|---|---|
| Overview | 什么是unplugin、支持的构建工具、适用场景 | core-overview |
| Core API | createUnplugin、工厂函数签名、特定构建工具的创建器 | core-api |
| Hooks and context | 生命周期钩子、过滤器、this.parse / emitFile / warn / error | core-hooks-and-context |
| Hook compatibility | 各构建工具对钩子和上下文的支持表 | core-hook-compatibility |
| Integration | 在Vite、Rollup、webpack等工具中的安装与注册 | core-integration |
Features
功能特性
| Topic | Description | Reference |
|---|---|---|
| Filters | filter option for resolveId, transform, load (performance) | features-filters |
| Nested plugins | Returning an array of plugins from the factory | features-nested-plugins |
| Bundler-specific | meta.framework, escape hatches (vite/webpack/esbuild/…), createXxxPlugin | features-bundler-specific |
| Virtual modules | resolveId + load pattern; filter for load | features-virtual-modules |
| Parsing | setParseImpl, this.parse; when needed (esbuild, webpack, etc.) | features-parsing |
| Output and assets | emitFile (EmittedAsset only), writeBundle (timing only) | features-output-and-assets |
| 主题 | 描述 | 参考链接 |
|---|---|---|
| Filters | resolveId、transform、load的filter选项(性能优化) | features-filters |
| Nested plugins | 从工厂函数返回插件数组 | features-nested-plugins |
| Bundler-specific | meta.framework、兼容方案(vite/webpack/esbuild/…)、createXxxPlugin | features-bundler-specific |
| Virtual modules | resolveId + load模式;load的过滤器 | features-virtual-modules |
| Parsing | setParseImpl、this.parse;适用场景(esbuild、webpack等) | features-parsing |
| Output and assets | emitFile(仅支持EmittedAsset)、writeBundle(仅时序相关) | features-output-and-assets |
Best Practices
最佳实践
| Topic | Description | Reference |
|---|---|---|
| Conventions | unplugin- prefix, keyword, default + subpath exports | best-practices-conventions |
| Diagnostics | this.warn / this.error, UnpluginMessage shape | best-practices-diagnostics |
| Scaffolding | Templates (unplugin-starter), try online, prerequisites | best-practices-scaffolding |
| 主题 | 描述 | 参考链接 |
|---|---|---|
| Conventions | unplugin-前缀、关键词、默认导出与子路径导出 | best-practices-conventions |
| Diagnostics | this.warn / this.error、UnpluginMessage结构 | best-practices-diagnostics |
| Scaffolding | 模板(unplugin-starter)、在线试用、前置要求 | best-practices-scaffolding |