{"id":22636,"library":"vite-plugin-deadfile","title":"vite-plugin-deadfile","description":"Vite plugin to find unused source files (dead files) in Vite projects. Current stable version 1.4.0, released under MIT license. Uses @swc/core to detect pure type references and handles Vite's dynamic import (glob-import) feature via the isDynamicModuleLive callback. Differentiators: built for Vite ecosystem, supports TypeScript, customizable include/exclude patterns, optional throw-on-found for CI, and output to file. Peer dependency: vite ^4.0.0 || ^5.0.0 || ^6.0.0.","status":"active","version":"1.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/stauren/vite-plugin-deadfile","tags":["javascript","frontend","unused","dead","source","vite","typescript"],"install":[{"cmd":"npm install vite-plugin-deadfile","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-deadfile","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-deadfile","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Vite plugin, requires Vite as peer dependency","package":"vite","optional":false},{"reason":"Used for parsing JavaScript/TypeScript to detect type-only imports","package":"@swc/core","optional":true}],"imports":[{"note":"Default export. Named import deadFile will be undefined. Use default import.","wrong":"import { deadFile } from 'vite-plugin-deadfile'","symbol":"deadFile","correct":"import deadFile from 'vite-plugin-deadfile'"},{"note":"TypeScript type only, not a runtime value.","wrong":"const DeadFileOptions = require('vite-plugin-deadfile').DeadFileOptions","symbol":"DeadFileOptions","correct":"import type { DeadFileOptions } from 'vite-plugin-deadfile'"},{"note":"CommonJS import requires .default access. The package is ESM-first.","wrong":"const deadFile = require('vite-plugin-deadfile')","symbol":"deadFile (CommonJS)","correct":"const deadFile = require('vite-plugin-deadfile').default"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite';\nimport deadFile from 'vite-plugin-deadfile';\n\nexport default defineConfig({\n  plugins: [deadFile({\n    root: 'src',\n    include: ['**/*.{js,ts,jsx,tsx}'],\n    exclude: ['**/*.test.*', '**/*.spec.*'],\n    throwWhenFound: true,\n    output: 'dead-files.txt'\n  })],\n});","lang":"javascript","description":"Shows basic setup: import deadFile, pass options (root, include/exclude patterns, throw on found, output to file)."},"warnings":[{"fix":"Upgrade Vite to 4.x, 5.x, or 6.x.","message":"Plugin does not work with Vite versions before 4.0; peer dependencies only allow ^4.0.0 || ^5.0.0 || ^6.0.0.","severity":"breaking","affected_versions":"<4.0.0"},{"fix":"Set root explicitly (e.g., root: 'src') and use include/exclude patterns.","message":"The default root is '.', which may include node_modules if not excluded. node_modules is excluded by default but other non-source dirs may be included.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Implement isDynamicModuleLive callback to return true for dynamically imported files.","message":"Dynamic imports (glob-import) require manually marking glob-imported files as alive via isDynamicModuleLive callback, otherwise they may be falsely reported as dead.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Install @swc/core as a dev dependency to enable accurate type reference detection.","message":"The plugin uses @swc/core for type detection; if @swc/core is not installed, type-only imports may be incorrectly reported as dead.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"N/A","message":"No deprecation warnings reported for current version.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use default import: import deadFile from 'vite-plugin-deadfile'","cause":"Using named import { deadFile } instead of default import.","error":"TypeError: deadFile is not a function"},{"fix":"Run: npm install @swc/core --save-dev","cause":"@swc/core is an optional peer dependency but not installed.","error":"Cannot find module '@swc/core'"},{"fix":"Set root to a string: deadFile({ root: 'src' })","cause":"Passing root as something other than a string (e.g., array).","error":"Error: `root` must be a string"},{"fix":"Verify root path and include pattern: root must contain source files matching include.","cause":"Root directory is empty or include pattern matches no files.","error":"[vite-plugin-deadfile]  All source files: 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}