Unplugin is a unified plugin system designed to abstract away the differences between various JavaScript build tools, allowing developers to write a single plugin that works across multiple bundlers. As of its current stable version, `3.0.0`, it supports major tools like Vite, Rollup, Webpack, esbuild, Rspack, Rolldown, Farm, and Bun. The project maintains an active development pace with frequent updates and bug fixes, typically releasing minor versions as features are added and major versions when significant breaking changes or architectural shifts occur, as seen with the recent v3.0.0. Its primary differentiator is eliminating the need to adapt plugin logic for each build tool's specific API, providing a consistent hook-based interface that simplifies cross-bundler compatibility and reduces development overhead for library authors and application builders. It ships with full TypeScript support, ensuring a robust developer experience.
npm install unpluginVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a simple Unplugin using `createUnplugin` and integrate it into a Vite project to add a banner to processed files.
Upgrade your Node.js environment to version `^20.19.0` or `>=22.12.0`.
Migrate your project to use ECMAScript Modules (ESM) with `import` statements. Ensure your `package.json` has `"type": "module"` or uses `.mjs` file extensions for ESM files.
When creating a plugin with `createUnplugin`, you must pass a custom `parser` option to handle AST parsing. For example: `createUnplugin(() => ({ /* ... */ }), { parser: { parse, ... } })` using `acorn` or a compatible parser.Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`) and use `import` statements for `unplugin`.
Upgrade your Node.js runtime to `^20.19.0` or `>=22.12.0` or newer to meet the engine requirements.
Provide a custom parser configuration to `createUnplugin` options. Example: `import * as acorn from 'acorn'; createUnplugin(() => ({ /* ... */ }), { parser: acorn })`.