A Babel plugin (v0.4.2, stable, low release cadence) that automatically adds /*#__PURE__*/ comments to call expressions in variable declarators, assignment expressions, call arguments, and other expression contexts. This helps bundlers like Webpack identify side-effect-free calls for tree shaking and dead code elimination. Unlike manual annotation, it eliminates human error and ensures consistent coverage across large codebases. Ships TypeScript types and integrates seamlessly into any Babel-based build pipeline.
npm install babel-plugin-pure-calls-annotationVerified import paths — ran on the pinned version, not inferred.
Add the plugin to Babel config to automatically annotate pure call expressions with /*#__PURE__*/ for tree shaking.
Manually verify or use other methods (e.g., /*#__PURE__*/ comments) to ensure purity.
If you rely on IIFEs not being annotated, downgrade to <0.4.0 or update your code to handle the change.
Review current tree shaking needs; use terser-webpack-plugin with sideEffects: false as a more maintained alternative.
Manually add /*#__PURE__*/ to unannotated pure calls or extend the plugin.
npm install @babel/core --save-dev
Update Babel to version 7.x or above and ensure the plugin is compatible.
Use default import: import pureCallsAnnotation from 'babel-plugin-pure-calls-annotation'