unplugin

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Unplugin 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

核心参考

TopicDescriptionReference
OverviewWhat unplugin is, supported bundlers, when to usecore-overview
Core APIcreateUnplugin, factory signature, bundler-specific creatorscore-api
Hooks and contextLifecycle hooks, filters, this.parse / emitFile / warn / errorcore-hooks-and-context
Hook compatibilityPer-bundler support tables for hooks and contextcore-hook-compatibility
IntegrationInstalling and registering in Vite, Rollup, webpack, etc.core-integration
主题描述参考链接
Overview什么是unplugin、支持的构建工具、适用场景core-overview
Core APIcreateUnplugin、工厂函数签名、特定构建工具的创建器core-api
Hooks and context生命周期钩子、过滤器、this.parse / emitFile / warn / errorcore-hooks-and-context
Hook compatibility各构建工具对钩子和上下文的支持表core-hook-compatibility
Integration在Vite、Rollup、webpack等工具中的安装与注册core-integration

Features

功能特性

TopicDescriptionReference
Filtersfilter option for resolveId, transform, load (performance)features-filters
Nested pluginsReturning an array of plugins from the factoryfeatures-nested-plugins
Bundler-specificmeta.framework, escape hatches (vite/webpack/esbuild/…), createXxxPluginfeatures-bundler-specific
Virtual modulesresolveId + load pattern; filter for loadfeatures-virtual-modules
ParsingsetParseImpl, this.parse; when needed (esbuild, webpack, etc.)features-parsing
Output and assetsemitFile (EmittedAsset only), writeBundle (timing only)features-output-and-assets
主题描述参考链接
FiltersresolveId、transform、load的filter选项(性能优化)features-filters
Nested plugins从工厂函数返回插件数组features-nested-plugins
Bundler-specificmeta.framework、兼容方案(vite/webpack/esbuild/…)、createXxxPluginfeatures-bundler-specific
Virtual modulesresolveId + load模式;load的过滤器features-virtual-modules
ParsingsetParseImpl、this.parse;适用场景(esbuild、webpack等)features-parsing
Output and assetsemitFile(仅支持EmittedAsset)、writeBundle(仅时序相关)features-output-and-assets

Best Practices

最佳实践

TopicDescriptionReference
Conventionsunplugin- prefix, keyword, default + subpath exportsbest-practices-conventions
Diagnosticsthis.warn / this.error, UnpluginMessage shapebest-practices-diagnostics
ScaffoldingTemplates (unplugin-starter), try online, prerequisitesbest-practices-scaffolding
主题描述参考链接
Conventionsunplugin-前缀、关键词、默认导出与子路径导出best-practices-conventions
Diagnosticsthis.warn / this.error、UnpluginMessage结构best-practices-diagnostics
Scaffolding模板(unplugin-starter)、在线试用、前置要求best-practices-scaffolding