Registry /
devops / rollup-plugin-tree-shakeable
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import treeShakeable from 'rollup-plugin-tree-shakeable'
✗ const treeShakeable = require('rollup-plugin-tree-shakeable')
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.
Plugin
✓ import type { Plugin } from 'rollup'
✗ import { Plugin } from 'rollup-plugin-tree-shakeable'
The plugin does not export a Plugin type; you need to import it from Rollup itself.
application
✓ import treeShakeable from 'rollup-plugin-tree-shakeable'; export default { plugins: [treeShakeable()] }
✗ export default { plugins: [treeShakeable] }
treeShakeable is a function that must be called; omitting parentheses will not produce a plugin instance.
Shows basic Rollup config using treeShakeable and demonstrates how top-level function calls get annotated with @__PURE__.
// install: npm i rollup rollup-plugin-tree-shakeable
import treeShakeable from 'rollup-plugin-tree-shakeable';
export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'esm',
},
plugins: [treeShakeable()],
};
// src/index.js (before plugin)
const withLogging = fn => (...args) => {
console.log('start');
try { return fn(...args); } finally { console.log('end'); }
};
export const f1 = withLogging(() => 1);
export const f2 = withLogging(() => 2);
// After plugin: each top-level call gets @__PURE__
// export const f1 = /* @__PURE__*/ withLogging(() => 1);
// export const f2 = /* @__PURE__*/ withLogging(() => 2);
Errors
Common errors & fixes
Require is not defined in ES module scope
Package uses ESM; require() is not supported without special configuration.
fixUse import syntax or set "type": "module" in package.json and consume as ES module.
Cannot find module 'rollup-plugin-tree-shakeable'
Plugin not installed or path incorrect.
fixRun npm install rollup-plugin-tree-shakeable --save-dev and ensure import path is correct.
TypeError: treeShakeable is not a plugin function
treeShakeable() returns a plugin object, but treeShakeable alone is the function, not a plugin.
fixCall treeShakeable() in the plugins array: plugins: [treeShakeable()]
Audit
Dependencies
rolluprequiredRollup plugin API is required; plugin won't work without it.