Registry / testing / vite-plugin-deadfile

vite-plugin-deadfile

JSON →
library1.4.0jsnpmunverified

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.

npm install vite-plugin-deadfile
INSTALL
IMPORT
SIG · VITE-PLUGIN-DEADFI
V
vite-plugin-deadfile
testingjavascriptv1.4.0
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.

deadFile
import deadFile from 'vite-plugin-deadfile'
import { deadFile } from 'vite-plugin-deadfile'
Default export. Named import deadFile will be undefined. Use default import.
DeadFileOptions
import type { DeadFileOptions } from 'vite-plugin-deadfile'
const DeadFileOptions = require('vite-plugin-deadfile').DeadFileOptions
TypeScript type only, not a runtime value.
deadFile (CommonJS)
const deadFile = require('vite-plugin-deadfile').default
const deadFile = require('vite-plugin-deadfile')
CommonJS import requires .default access. The package is ESM-first.

Shows basic setup: import deadFile, pass options (root, include/exclude patterns, throw on found, output to file).

// vite.config.js import { defineConfig } from 'vite'; import deadFile from 'vite-plugin-deadfile'; export default defineConfig({ plugins: [deadFile({ root: 'src', include: ['**/*.{js,ts,jsx,tsx}'], exclude: ['**/*.test.*', '**/*.spec.*'], throwWhenFound: true, output: 'dead-files.txt' })], });
Debug
Known issues
breakingPlugin does not work with Vite versions before 4.0; peer dependencies only allow ^4.0.0 || ^5.0.0 || ^6.0.0.
fix
Upgrade Vite to 4.x, 5.x, or 6.x.
affects: <4.0.0
gotchaThe 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.
fix
Set root explicitly (e.g., root: 'src') and use include/exclude patterns.
affects: >=0.0.0
gotchaDynamic imports (glob-import) require manually marking glob-imported files as alive via isDynamicModuleLive callback, otherwise they may be falsely reported as dead.
fix
Implement isDynamicModuleLive callback to return true for dynamically imported files.
affects: >=0.0.0
gotchaThe plugin uses @swc/core for type detection; if @swc/core is not installed, type-only imports may be incorrectly reported as dead.
fix
Install @swc/core as a dev dependency to enable accurate type reference detection.
affects: >=0.0.0
deprecatedNo deprecation warnings reported for current version.
fix
N/A
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: deadFile is not a function
Using named import { deadFile } instead of default import.
fix
Use default import: import deadFile from 'vite-plugin-deadfile'
Cannot find module '@swc/core'
@swc/core is an optional peer dependency but not installed.
fix
Run: npm install @swc/core --save-dev
Error: `root` must be a string
Passing root as something other than a string (e.g., array).
fix
Set root to a string: deadFile({ root: 'src' })
[vite-plugin-deadfile] All source files: 0
Root directory is empty or include pattern matches no files.
fix
Verify root path and include pattern: root must contain source files matching include.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
viterequiredVite plugin, requires Vite as peer dependency
@swc/coreoptionalUsed for parsing JavaScript/TypeScript to detect type-only imports
Agent activity
10 hits · last 30 days
node
10
Resources
vite-plugin-deadfile — npm install vite-plugin-deadfile · libregistry