CLI to find unused exports across monorepo package boundaries
@wolfcola/dead-export-finder
A CLI tool that scans a monorepo to find exports that are never imported by any other package. Useful for identifying dead code that can be safely removed.
Installation
npm install -D @wolfcola/dead-export-finder
CLI Usage
npx dead-export-finder [options]
Run from the monorepo root. The tool auto-detects workspace packages from pnpm-workspace.yaml or package.json workspaces.
Options
| Option | Alias | Description |
|---|---|---|
--packages <name> | -p | Scope analysis to specific packages (repeatable) |
--ignore | -i | Glob patterns to exclude from scanning (repeatable) |
--verbose | -v | Print timing, file counts, and parse warnings |
Examples
# Scan all packages in the monorepo
npx dead-export-finder
# Scope to specific packages
npx dead-export-finder -p @wolfcola/devtools-core -p @wolfcola/devtools-types
# Ignore test files
npx dead-export-finder -i "**/*.test.ts" -i "**/*.spec.ts"
# Verbose output with timing
npx dead-export-finder --verbose
How It Works
- Detects the monorepo workspace layout
- Scans all TypeScript and JavaScript files in each package
- Parses exported symbols from each file using
oxc-parser - Parses imported symbols from each file
- Builds an export dependency graph across package boundaries
- Reports exports that are not imported anywhere
The tool handles parse errors gracefully, emitting warnings instead of failing. The exit code is 1 if any dead exports are found, making it suitable for CI gates.
CI Integration
{
"scripts": {
"check:dead-exports": "dead-export-finder"
}
}
This tool analyzes cross-package imports only. Exports used within the same package are not flagged.