{"id":22274,"library":"rollup-plugin-unused","title":"rollup-plugin-unused","description":"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.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/ls-age/devtools","tags":["javascript","rollup-plugin","unused","files","import","module","typescript"],"install":[{"cmd":"npm install rollup-plugin-unused","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-unused","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-unused","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exports a single default function. Use ESM import as shown.","wrong":"const findUnused = require('rollup-plugin-unused')","symbol":"findUnused","correct":"import findUnused from 'rollup-plugin-unused'"},{"note":"Options are passed directly to the default export. Named import not supported.","wrong":"import { findUnused } from 'rollup-plugin-unused'","symbol":"findUnused with options","correct":"import findUnused from 'rollup-plugin-unused';\nfindUnused({ extensions: ['.js', '.ts'], include: ['src/**/*.mjs'], exclude: ['src/legacy/*.js'] })"},{"note":"Use ESM import; require() may work but is not official. Plugin must be placed before other plugins.","wrong":"plugins: [require('rollup-plugin-unused')()]","symbol":"Plugin usage in Rollup config","correct":"import findUnused from 'rollup-plugin-unused';\nexport default { input: 'index.js', plugins: [findUnused()] }"}],"quickstart":{"code":"import findUnused from 'rollup-plugin-unused';\nimport resolve from '@rollup/plugin-node-resolve';\n\n// rollup.config.js\nexport default {\n  input: 'src/index.js',\n  output: { file: 'dist/bundle.js', format: 'cjs' },\n  plugins: [\n    // Must come before any source-loading plugins\n    findUnused({ extensions: ['.js'] }),\n    resolve()\n  ]\n};","lang":"typescript","description":"Demonstrates basic usage detecting unused .js files in src/ directory during a Rollup build."},"warnings":[{"fix":"Place findUnused() as the first plugin in the plugins array.","message":"Plugin must be added before any other plugins that load files (e.g., @rollup/plugin-babel) to correctly detect unused imports.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'extensions' option for additional file types, 'include' option for a custom glob pattern.","message":"By 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use either 'include' or 'extensions', not both, unless you understand the override behavior.","message":"'include' option overrides 'extensions' option. If both are specified, only 'include' is used.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"","message":"No known deprecations for this package.","severity":"deprecated","affected_versions":""}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure input points to your entry file, e.g., input: 'src/index.js'","cause":"rollup.config.js missing input or wrong path","error":"Error: Could not resolve entry module (index.js)"},{"fix":"Use 'import findUnused from 'rollup-plugin-unused'' instead of 'import { findUnused } from ...'","cause":"Using named import instead of default import","error":"TypeError: findUnused is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}