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.
npm install rollup-plugin-pureVerified import paths — ran on the pinned version, not inferred.
Configures Vite to annotate defineComponent and regex-matched functions as pure, targeting files ending with 'pure.js' except those starting with 'im'.
Update import to correctly use named export PluginPure.
Migrate to new configuration; see changelog for details.
Check if Rollup's built-in pure detection covers your functions; if not, adjust your configuration.
Upgrade to Rollup 3 or 4.
Test patterns in the playground or use more specific include/exclude rules.
Use import { PluginPure } from 'rollup-plugin-pure' instead.Call PluginPure({...}) without new.Provide an array of function names or regex patterns in the functions option.