{"id":19127,"library":"babel-plugin-pure-calls-annotation","title":"babel-plugin-pure-calls-annotation","description":"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.","status":"active","version":"0.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/morlay/babel-plugin-pure-calls-annotation","tags":["javascript","typescript"],"install":[{"cmd":"npm install babel-plugin-pure-calls-annotation","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-pure-calls-annotation","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-pure-calls-annotation","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin requires Babel core for transformation","package":"@babel/core","optional":false}],"imports":[{"note":"Default import works in ESM; CommonJS require is also supported but discouraged for TypeScript","wrong":"const pureCallsAnnotation = require('babel-plugin-pure-calls-annotation')","symbol":"default","correct":"import pureCallsAnnotation from 'babel-plugin-pure-calls-annotation'"},{"note":"Plugin is used as a Babel plugin, imported as default and passed to plugins array","wrong":"","symbol":"pureCallsAnnotation","correct":"import pureCallsAnnotation from 'babel-plugin-pure-calls-annotation'"},{"note":"Named export does not exist; only default export. Use default import.","wrong":"const { BabelPluginPureCallsAnnotation } = require('babel-plugin-pure-calls-annotation')","symbol":"BabelPluginPureCallsAnnotation","correct":"import BabelPluginPureCallsAnnotation from 'babel-plugin-pure-calls-annotation'"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  plugins: [\n    'babel-plugin-pure-calls-annotation'\n  ]\n};\n\n// Input: const result = compute()\n// Output: const result = /*#__PURE__*/compute()","lang":"javascript","description":"Add the plugin to Babel config to automatically annotate pure call expressions with /*#__PURE__*/ for tree shaking."},"warnings":[{"fix":"Manually verify or use other methods (e.g., /*#__PURE__*/ comments) to ensure purity.","message":"The plugin annotates all eligible call expressions, including those that may have side effects. Use with caution; only include if you are certain the annotated calls are pure.","severity":"gotcha","affected_versions":"*"},{"fix":"If you rely on IIFEs not being annotated, downgrade to <0.4.0 or update your code to handle the change.","message":"BREAKING: Version 0.4.0 changed annotation behavior for IIFEs: previously IIFEs were not annotated; now they are.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Review current tree shaking needs; use terser-webpack-plugin with sideEffects: false as a more maintained alternative.","message":"The plugin may not be actively maintained; last release was in 2021. Consider alternatives like manual annotation or custom Babel plugin for tree shaking.","severity":"deprecated","affected_versions":"*"},{"fix":"Manually add /*#__PURE__*/ to unannotated pure calls or extend the plugin.","message":"Does not annotate call expressions in all positions (e.g., as standalone statements). Only variable declarators, assignment expressions, and call arguments are covered.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install @babel/core --save-dev","cause":"Missing @babel/core as a peer dependency.","error":"SyntaxError: 'babel-plugin-pure-calls-annotation' threw an error: Cannot find module '@babel/core'"},{"fix":"Update Babel to version 7.x or above and ensure the plugin is compatible.","cause":"The plugin expects a Babel AST node with a callee property; corrupted or outdated Babel version may cause this.","error":"TypeError: Cannot read properties of undefined (reading 'callee')"},{"fix":"Use default import: import pureCallsAnnotation from 'babel-plugin-pure-calls-annotation'","cause":"This error occurs if the plugin is imported incorrectly (e.g., using named import instead of default).","error":"Error: Plugin/preset files are not allowed to export objects, only functions."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}