Skip to main content
Rev-dep provides a comprehensive CLI toolkit that helps you debug issues with dependencies between files, understand transitive relations, and fix problems in your codebase.

Identify Where a File is Used

Find all entry points that implicitly require a specific file, along with resolution paths.
rev-dep resolve --file path/to/file.ts
This command shows you the complete dependency chain from entry points to the target file, helping you understand the impact of changes.

Check If a File is Used

Quickly see how many entry points depend on a file without showing the full paths.
rev-dep resolve --file path/to/file.ts --compact-summary
Example output:
Found 3 entry points that depend on src/utils/helper.ts

Identify Dead Files

Discover files that are not imported by any other file and may be safe to delete.

Basic Usage

rev-dep entry-points
This lists all entry points in your project. Files that are entry points but don’t produce meaningful output might be dead files.

Exclude Known Entry Points

For more accurate results, exclude framework entry points and known valid entry points:
# Exclude Next.js pages router entry points, scripts, and test files
rev-dep entry-points --result-exclude "pages/**","scripts/**","**/*.test.*"
Always review the list before deleting files. Some entry points (like config files or scripts) may be legitimate even if they’re not imported.

List All Files Imported by an Entry Point

See the complete dependency tree for a specific entry point.
rev-dep files --entry-point path/to/file.ts
This is useful for:
  • Identifying heavy components
  • Finding unintended dependencies
  • Understanding bundle size contributors

Count Only

Get just the number of dependencies:
rev-dep files --entry-point path/to/file.ts --count

Reduce Unnecessary Imports

Follow this workflow to optimize your entry point’s dependencies:
1

List all files imported

rev-dep files --entry-point path/to/entry.ts
2

Identify suspicious files

Look for files that shouldn’t be in this dependency tree (e.g., heavy libraries, unrelated modules)
3

Trace why they are included

rev-dep resolve --file path/to/suspect --entry-points path/to/entry.ts --all
The --all flag shows all possible dependency paths, helping you find the import chain to break.
This technique is particularly effective for reducing bundle sizes and removing accidental dependencies.

Detect Circular Dependencies

Find all circular dependency chains in your project.
rev-dep circular

Ignore Type Imports

Circular dependencies in TypeScript type imports are usually harmless:
rev-dep circular --ignore-type-imports

With Monorepo Support

rev-dep circular --follow-monorepo-packages

Find Unused Node Modules

Discover dependencies declared in package.json but never imported in your code.
rev-dep node-modules unused

Exclude Specific Modules

# Exclude type definitions from the check
rev-dep node-modules unused --exclude-modules=@types/*

Count Only

rev-dep node-modules unused --count

Performance Tip

Rev-dep can analyze a 500k+ LoC project for unused modules in around 287ms - up to 22x faster than alternatives.

Find Missing Node Modules

Identify packages imported in your code but not declared in package.json.
rev-dep node-modules missing

Group by Module

rev-dep node-modules missing --group-by-module

Group by File

rev-dep node-modules missing --group-by-file

Check node_modules Space Usage

Analyze disk space usage by your node_modules directories.
rev-dep node-modules dirs-size
This command:
  • Calculates cumulative file sizes in node_modules directories
  • Shows size for the current directory and subdirectories
  • Helps identify space optimization opportunities
Sizes shown are actual file sizes rather than disk space usage (which may differ due to disk block allocation).

Advanced Resolution Techniques

Find All Paths Between Files

Show every possible dependency path from an entry point to a target file:
rev-dep resolve --file path/to/target.ts --entry-points path/to/entry.ts --all

Check Direct Importers

See only files that directly import a specific file:
rev-dep imported-by --file src/utils/helpers.ts
With import identifiers:
rev-dep imported-by --file src/utils/helpers.ts --list-imports

Exclude Files from Analysis

rev-dep resolve --file src/utils.ts --graph-exclude "**/*.test.*","**/*.spec.*"

Count Lines of Code

Get an accurate count of effective lines of code, excluding comments and blank lines:
rev-dep lines-of-code

List Source Files

Recursively list all files in the current working directory with filtering:
# List only TypeScript files, excluding tests
rev-dep list-cwd-files --include='*.ts' --exclude='*.test.ts'

Count Files Only

rev-dep list-cwd-files --count

Combining Commands for Powerful Workflows

# 1. Find all utility files
rev-dep list-cwd-files --include='src/utils/**'

# 2. Check each one
rev-dep resolve --file src/utils/old-helper.ts --compact-summary
These exploratory commands complement the config-based checks, giving you both automated governance and manual investigation capabilities.

Build docs developers (and LLMs) love