Registry / devops / unplugin-pure

unplugin-pure

JSON →
library0.3.2jsnpmunverified

Automatically inject /* #__PURE__ */ annotations before specified function calls in Rollup, Vite, esbuild, and rspack builds to improve tree-shaking. Current stable version is 0.3.2 with infrequent releases. Supports all major bundlers via unplugin interface, includes TypeScript types, and allows flexible function matching via functions array and include/exclude patterns. Unlike manual annotations, this plugin automates the process for library authors.

npm install unplugin-pure
INSTALL
IMPORT
SIG · UNPLUGIN-PURE
U
unplugin-pure
devopsjavascriptv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PluginPure
import { PluginPure } from 'unplugin-pure'
import { PluginPure } from 'unplugin-pure/vite'
Default export for Vite/Rollup; also works with CommonJS: const { PluginPure } = require('unplugin-pure')
esbuildPure
import { esbuildPure } from 'unplugin-pure'
import esbuildPure from 'unplugin-pure'
Named export for esbuild; do not import as default
unpluginPureFactory
import { unpluginPureFactory } from 'unplugin-pure'
Factory for custom bundler integration; available since v0.1.1

Automatically annotate defineComponent and createApp calls as pure in files matching the include pattern using Vite plugin.

import { defineConfig } from 'vite' import { PluginPure } from 'unplugin-pure' export default defineConfig({ plugins: [ PluginPure({ functions: ['defineComponent', 'createApp'], include: [/(?<!im)pure\.js$/], exclude: ['node_modules'], sourcemap: true, }), ], })
Debug
Known issues
gotchaDefault export named PluginPure, not unpluginPure. Importing unpluginPure will result in undefined.
fix
Use import { PluginPure } from 'unplugin-pure'
affects: >=0.1.0
gotchaThe include option uses RegExp or string patterns, not globs. Misusing glob patterns will silently match nothing.
fix
Use RegExp, e.g., /\.(vue|jsx?)$/ or a string for exact paths.
affects: >=0.1.0
deprecatedrollup-plugin-pure is deprecated; unplugin-pure is its successor.
fix
Migrate to unplugin-pure as described in the README.
affects: >=0.1.0
gotchaWorks only with named function calls; does not handle property access like module.defineComponent.
fix
Wrap in a local const: const defineComp = module.defineComponent; then annotate defineComp.
affects: >=0.1.0
gotchaRollup peer dependency is required even when using Vite or esbuild? Not required if using esbuild or rspack alone; for Vite, Rollup is bundled but peer dep may still be needed.
fix
Ensure rollup is installed when using Vite config.
affects: >=0.1.0
Errors
Common errors & fixes
Uncaught TypeError: PluginPure is not a function
Importing as default when using ESM but named export is required.
fix
Use `import { PluginPure } from 'unplugin-pure'`
Cannot find module 'unplugin-pure' or its corresponding type declarations.
Package not installed or TypeScript not configured to resolve node_modules types.
fix
Run `npm install -D unplugin-pure` and ensure tsconfig.json includes 'moduleResolution': 'node' or 'bundler'.
The requested module 'unplugin-pure' does not provide an export named 'default'
Using default import with ESM when package only has named exports.
fix
Use named import: `import { PluginPure } from 'unplugin-pure'`
RollupError: Could not resolve 'unplugin-pure'
Package not installed or bundler config missing node_modules resolution.
fix
Install the package and ensure bundler can resolve it.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies
rollupoptionalpeer dependency for Rollup >=3 or >=4
Agent activity
6 hits · last 30 days
node
6
Resources
unplugin-pure — npm install unplugin-pure · libregistry