{"id":22260,"library":"rollup-plugin-tree-shakeable","title":"rollup-plugin-tree-shakeable","description":"A Rollup plugin (v2.0.0, latest) that automatically adds @__PURE__ annotations to top-level expressions in your JavaScript/TypeScript modules, convincing bundlers like Rollup, esbuild, and webpack that the module is side-effect free and enabling effective tree-shaking. Unlike setting `sideEffects: false` in package.json, which cannot handle function calls at module scope, this plugin annotates each call individually. Requires Node >= 22 and Rollup. Lightweight, zero-config, and actively maintained with few dependencies.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/TomerAberbach/rollup-plugin-tree-shakeable","tags":["javascript","bundle","pure","rollup","rollup-plugin","tree-shaking"],"install":[{"cmd":"npm install rollup-plugin-tree-shakeable","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-tree-shakeable","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-tree-shakeable","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Rollup plugin API is required; plugin won't work without it.","package":"rollup","optional":false}],"imports":[{"note":"Plugin has a default export; CommonJS require() may not work if the package is ESM-only (check your Rollup config). v2.0.0 likely ESM-only.","wrong":"const treeShakeable = require('rollup-plugin-tree-shakeable')","symbol":"default","correct":"import treeShakeable from 'rollup-plugin-tree-shakeable'"},{"note":"The plugin does not export a Plugin type; you need to import it from Rollup itself.","wrong":"import { Plugin } from 'rollup-plugin-tree-shakeable'","symbol":"Plugin","correct":"import type { Plugin } from 'rollup'"},{"note":"treeShakeable is a function that must be called; omitting parentheses will not produce a plugin instance.","wrong":"export default { plugins: [treeShakeable] }","symbol":"application","correct":"import treeShakeable from 'rollup-plugin-tree-shakeable'; export default { plugins: [treeShakeable()] }"}],"quickstart":{"code":"// install: npm i rollup rollup-plugin-tree-shakeable\nimport treeShakeable from 'rollup-plugin-tree-shakeable';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'esm',\n  },\n  plugins: [treeShakeable()],\n};\n\n// src/index.js (before plugin)\nconst withLogging = fn => (...args) => {\n  console.log('start');\n  try { return fn(...args); } finally { console.log('end'); }\n};\nexport const f1 = withLogging(() => 1);\nexport const f2 = withLogging(() => 2);\n\n// After plugin: each top-level call gets @__PURE__\n// export const f1 = /* @__PURE__*/ withLogging(() => 1);\n// export const f2 = /* @__PURE__*/ withLogging(() => 2);","lang":"javascript","description":"Shows basic Rollup config using treeShakeable and demonstrates how top-level function calls get annotated with @__PURE__."},"warnings":[{"fix":"Verify that your module does not have side-effectful top-level expressions that depend on other exports.","message":"Only use if your package is actually tree-shakeable: each export works independently when others are stripped.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Manually add @__PURE__ or refactor code that produces side effects inside functions.","message":"Does NOT handle all cases: side effects inside exported function bodies are not annotated.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to Node 22 or stay on v1.0.3.","message":"v2.0.0 requires Node >= 22; older versions of Node are unsupported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update to latest: npm install rollup-plugin-tree-shakeable@latest","message":"v1.x may not be receiving further updates; upgrade to v2 for ongoing maintenance.","severity":"deprecated","affected_versions":"<2.0.0"}],"env_vars":null,"search_vec":"'22':68 'activ':76 'add':13 'annot':15,62 'automat':12 'bundl':82 'bundler':26 'call':56,64 'cannot':53 'config':74 'convinc':25 'depend':80 'effect':38,42 'enabl':41 'esbuild':29 'express':20 'fals':49 'free':39 'function':55 'handl':54 'individu':65 'javascript':81 'javascript/typescript':23 'latest':10 'level':19 'lightweight':71 'like':27 'maintain':77 'modul':24,34,58 'node':67 'package.json':51 'plugin':3,8,61,87 'pure':14,83 'requir':66 'rollup':2,7,28,70,84,86 'rollup-plugin':85 'rollup-plugin-tree-shak':1 'scope':59 'set':47 'shake':45,90 'shakeabl':5 'side':37 'side-effect':36 'sideeffect':48 'top':18 'top-level':17 'tree':4,44,89 'tree-shak':43,88 'unlik':46 'v2.0.0':9 'webpack':31 'zero':73 'zero-config':72","created_at":"2026-04-27T17:04:14.095308+00:00","updated_at":"2026-04-27T17:04:14.095308+00:00","problems":[{"fix":"Use import syntax or set \"type\": \"module\" in package.json and consume as ES module.","cause":"Package uses ESM; require() is not supported without special configuration.","error":"Require is not defined in ES module scope"},{"fix":"Run npm install rollup-plugin-tree-shakeable --save-dev and ensure import path is correct.","cause":"Plugin not installed or path incorrect.","error":"Cannot find module 'rollup-plugin-tree-shakeable'"},{"fix":"Call treeShakeable() in the plugins array: plugins: [treeShakeable()]","cause":"treeShakeable() returns a plugin object, but treeShakeable alone is the function, not a plugin.","error":"TypeError: treeShakeable is not a plugin function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/TomerAberbach/rollup-plugin-tree-shakeable","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-tree-shakeable","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}