{"id":22188,"library":"rollup-plugin-pure","title":"rollup-plugin-pure","description":"Rollup/Vite plugin that automatically injects /*#__PURE__*/ annotations before specific function calls and /*@__NO_SIDE_EFFECTS__*/ before function declarations, enabling better tree-shaking for libraries with definition functions like Vue's defineComponent. Current stable version is 0.4.0, actively maintained. Supports regex function names, uses AST-based approach, and handles Rollup's awareness of pure annotations. Key differentiator: automatic annotation injection without manual marks, works with Vite and Rollup 3/4.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/danielroe/rollup-plugin-pure","tags":["javascript","vite","rollup","pure-annotation","typescript"],"install":[{"cmd":"npm install rollup-plugin-pure","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-pure","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-pure","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for Rollup integration","package":"rollup","optional":true}],"imports":[{"note":"Named export; default import is not available.","wrong":"import PluginPure from 'rollup-plugin-pure'","symbol":"PluginPure","correct":"import { PluginPure } from 'rollup-plugin-pure'"},{"note":"CommonJS users should use destructured require; ESM is also supported.","wrong":"const rollupPluginPure = require('rollup-plugin-pure').PluginPure;","symbol":"PluginPure as rollupPluginPure","correct":"import { PluginPure as rollupPluginPure } from 'rollup-plugin-pure'"},{"note":"Type-only import is safe but not required; PluginPure is also a runtime value.","wrong":"import { PluginPure } from 'rollup-plugin-pure'","symbol":"PluginPure type","correct":"import type { PluginPure } from 'rollup-plugin-pure'"}],"quickstart":{"code":"// vite.config.ts\nimport { PluginPure } from 'rollup-plugin-pure';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    PluginPure({\n      functions: ['defineComponent', /^define(Page|Meta)$/],\n      include: [/(?<!im)pure\\.js$/],\n      // exclude: [],\n      // sourcemap: true,\n    }),\n  ],\n});","lang":"typescript","description":"Configures Vite to annotate defineComponent and regex-matched functions as pure, targeting files ending with 'pure.js' except those starting with 'im'."},"warnings":[{"fix":"Update import to correctly use named export PluginPure.","message":"Plugin name changed in v0.3.0 from 'rollup-plugin-pure' to 'PluginPure' export","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"Migrate to new configuration; see changelog for details.","message":"AST-based approach introduced in v0.3.0; old RegExp-based approach removed","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"Check if Rollup's built-in pure detection covers your functions; if not, adjust your configuration.","message":"When Rollup already marks a function as pure, the plugin may not add an annotation, leading to no effect","severity":"gotcha","affected_versions":">=0.4.0"},{"fix":"Upgrade to Rollup 3 or 4.","message":"Support for Rollup <3.0 may be dropped in future versions","severity":"deprecated","affected_versions":"<3.0"},{"fix":"Test patterns in the playground or use more specific include/exclude rules.","message":"Using `include` glob may not match expected files if patterns conflict with `exclude`","severity":"gotcha","affected_versions":">=0.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import { PluginPure } from 'rollup-plugin-pure' instead.","cause":"Default import used instead of named import.","error":"Plugin 'rollup-plugin-pure' does not provide a default export, but a named export 'PluginPure' is available."},{"fix":"Call PluginPure({...}) without new.","cause":"PluginPure is a function (factory), not a class. Calling new PluginPure() fails.","error":"TypeError: PluginPure is not a constructor"},{"fix":"Provide an array of function names or regex patterns in the functions option.","cause":"Missing or empty functions array in configuration.","error":"Error: Must specify at least one function name or regex in 'functions' option"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}