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

OptionAliasDescription
--packages <name>-pScope analysis to specific packages (repeatable)
--ignore-iGlob patterns to exclude from scanning (repeatable)
--verbose-vPrint 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

  1. Detects the monorepo workspace layout
  2. Scans all TypeScript and JavaScript files in each package
  3. Parses exported symbols from each file using oxc-parser
  4. Parses imported symbols from each file
  5. Builds an export dependency graph across package boundaries
  6. 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.