Registry / devops / rollup-plugin-unused

rollup-plugin-unused

JSON →
library0.1.1jsnpmunverified

Rollup plugin that identifies source files not imported during a build, helping keep repositories clean. Version 0.1.1 (latest) released 2021-12-30, with low release cadence. Supports customization via extensions, include/exclude globs. Ships TypeScript definitions. Distinct from similar plugins (e.g., rollup-plugin-unused-files) by its minimal configuration and focus on detection rather than removal.

npm install rollup-plugin-unused
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-UNUS
R
rollup-plugin-unused
devopsjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18223 runs
build_error
glibc
node 18223 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.
fix
Place 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.
fix
Use '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.
fix
Use 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
fix
Ensure 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
fix
Use 'import findUnused from 'rollup-plugin-unused'' instead of 'import { findUnused } from ...'
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-unused — npm install rollup-plugin-unused · libregistry