{"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.","language":"javascript","status":"active","last_verified":"Mon Apr 27","install":{"commands":["npm install rollup-plugin-tree-shakeable"],"cli":null},"imports":["import treeShakeable from 'rollup-plugin-tree-shakeable'","import type { Plugin } from 'rollup'","import treeShakeable from 'rollup-plugin-tree-shakeable'; export default { plugins: [treeShakeable()] }"],"auth":{"required":false,"env_vars":[]},"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__.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}