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.
findUnused
✓ import findUnused from 'rollup-plugin-unused'
✗ const findUnused = require('rollup-plugin-unused')
Package exports a single default function. Use ESM import as shown.
findUnused with options
✓ import findUnused from 'rollup-plugin-unused';
findUnused({ extensions: ['.js', '.ts'], include: ['src/**/*.mjs'], exclude: ['src/legacy/*.js'] })
✗ import { findUnused } from 'rollup-plugin-unused'
Options are passed directly to the default export. Named import not supported.
Plugin usage in Rollup config
✓ import findUnused from 'rollup-plugin-unused';
export default { input: 'index.js', plugins: [findUnused()] }
✗ plugins: [require('rollup-plugin-unused')()]
Use ESM import; require() may work but is not official. Plugin must be placed before other plugins.
Demonstrates basic usage detecting unused .js files in src/ directory during a Rollup build.
import findUnused from 'rollup-plugin-unused';
import resolve from '@rollup/plugin-node-resolve';
// rollup.config.js
export default {
input: 'src/index.js',
output: { file: 'dist/bundle.js', format: 'cjs' },
plugins: [
// Must come before any source-loading plugins
findUnused({ extensions: ['.js'] }),
resolve()
]
};
Debug
Known issues
gotchaPlugin must be added before any other plugins that load files (e.g., @rollup/plugin-babel) to correctly detect unused imports.fixPlace findUnused() as the first plugin in the plugins array.
affects: >=0.0.0
gotchaBy default, plugin looks for source files with extension .js in the ./src/ folder. Files with other extensions or in other directories are ignored unless configured.fixUse 'extensions' option for additional file types, 'include' option for a custom glob pattern.
affects: >=0.0.0
gotcha'include' option overrides 'extensions' option. If both are specified, only 'include' is used.fixUse either 'include' or 'extensions', not both, unless you understand the override behavior.
affects: >=0.0.0
deprecatedNo known deprecations for this package.
Errors
Common errors & fixes
Error: Could not resolve entry module (index.js)
rollup.config.js missing input or wrong path
fixEnsure input points to your entry file, e.g., input: 'src/index.js'
TypeError: findUnused is not a function
Using named import instead of default import
fixUse 'import findUnused from 'rollup-plugin-unused'' instead of 'import { findUnused } from ...' Audit
Dependencies
No dependency data recorded yet.