{"id":26570,"library":"unplugin-pure","title":"unplugin-pure","description":"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.","status":"active","version":"0.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/justin-schroeder/unplugin-pure","tags":["javascript","vite","unplugin","esbuild","rspack","rollup","pure-annotation","typescript"],"install":[{"cmd":"npm install unplugin-pure","lang":"bash","label":"npm"},{"cmd":"yarn add unplugin-pure","lang":"bash","label":"yarn"},{"cmd":"pnpm add unplugin-pure","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for Rollup >=3 or >=4","package":"rollup","optional":true}],"imports":[{"note":"Default export for Vite/Rollup; also works with CommonJS: const { PluginPure } = require('unplugin-pure')","wrong":"import { PluginPure } from 'unplugin-pure/vite'","symbol":"PluginPure","correct":"import { PluginPure } from 'unplugin-pure'"},{"note":"Named export for esbuild; do not import as default","wrong":"import esbuildPure from 'unplugin-pure'","symbol":"esbuildPure","correct":"import { esbuildPure } from 'unplugin-pure'"},{"note":"Factory for custom bundler integration; available since v0.1.1","wrong":"","symbol":"unpluginPureFactory","correct":"import { unpluginPureFactory } from 'unplugin-pure'"}],"quickstart":{"code":"import { defineConfig } from 'vite'\nimport { PluginPure } from 'unplugin-pure'\n\nexport default defineConfig({\n  plugins: [\n    PluginPure({\n      functions: ['defineComponent', 'createApp'],\n      include: [/(?<!im)pure\\.js$/],\n      exclude: ['node_modules'],\n      sourcemap: true,\n    }),\n  ],\n})","lang":"typescript","description":"Automatically annotate defineComponent and createApp calls as pure in files matching the include pattern using Vite plugin."},"warnings":[{"fix":"Use import { PluginPure } from 'unplugin-pure'","message":"Default export named PluginPure, not unpluginPure. Importing unpluginPure will result in undefined.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use RegExp, e.g., /\\.(vue|jsx?)$/ or a string for exact paths.","message":"The include option uses RegExp or string patterns, not globs. Misusing glob patterns will silently match nothing.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Migrate to unplugin-pure as described in the README.","message":"rollup-plugin-pure is deprecated; unplugin-pure is its successor.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Wrap in a local const: const defineComp = module.defineComponent; then annotate defineComp.","message":"Works only with named function calls; does not handle property access like module.defineComponent.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure rollup is installed when using Vite config.","message":"Rollup 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `import { PluginPure } from 'unplugin-pure'`","cause":"Importing as default when using ESM but named export is required.","error":"Uncaught TypeError: PluginPure is not a function"},{"fix":"Run `npm install -D unplugin-pure` and ensure tsconfig.json includes 'moduleResolution': 'node' or 'bundler'.","cause":"Package not installed or TypeScript not configured to resolve node_modules types.","error":"Cannot find module 'unplugin-pure' or its corresponding type declarations."},{"fix":"Use named import: `import { PluginPure } from 'unplugin-pure'`","cause":"Using default import with ESM when package only has named exports.","error":"The requested module 'unplugin-pure' does not provide an export named 'default'"},{"fix":"Install the package and ensure bundler can resolve it.","cause":"Package not installed or bundler config missing node_modules resolution.","error":"RollupError: Could not resolve 'unplugin-pure'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}