Skip to main content

Overview

The rev-dep imported-by command finds and lists all files in the project that directly import the specified file. This is also known as finding “reverse dependencies” or “dependents.” This is useful for understanding the impact of changes to a particular file. It answers the question: “What breaks if I change or delete this file?”

Usage

rev-dep imported-by [flags]

Flags

--condition-names
string[]
List of conditions for package.json imports resolution (e.g. node, imports, default)
-n, --count
boolean
Only display the count of importing files
-c, --cwd
string
default:"$PWD"
Working directory for the command
-f, --file
string
required
Target file to find importers for
--follow-monorepo-packages
string[]
Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
--list-imports
boolean
List the import identifiers used by each file
--package-json
string
default:"./package.json"
Path to package.json
--tsconfig-json
string
default:"./tsconfig.json"
Path to tsconfig.json
-v, --verbose
boolean
Show warnings and verbose output
-h, --help
boolean
Help for imported-by command

Examples

Find files importing a utility

rev-dep imported-by --file src/utils/helpers.ts

Count importers

rev-dep imported-by --file src/utils/helpers.ts --count
Quickly see how widely used a file is.

Show what’s being imported

rev-dep imported-by --file src/utils/helpers.ts --list-imports
This shows not just which files import the target, but also which specific exports they use:
src/components/Button.tsx
  - formatDate
  - calculateSum

src/pages/Dashboard.tsx
  - formatDate

Check imports across monorepo

rev-dep imported-by --file packages/shared/src/utils.ts --follow-monorepo-packages

Use custom paths

rev-dep imported-by --file src/utils/helpers.ts --cwd ./packages/app --tsconfig-json ./tsconfig.build.json

Use Cases

Before modifying a shared utility, see which files depend on it to assess the impact.
Check if a file has any importers before removing it. If the count is 0, it’s likely safe to delete.
When splitting or restructuring code, understand which files need to be updated.
Use --list-imports to see which exports are actually being used, helping identify unused code.

Tips

If imported-by returns 0 results, the file is an entry point (nothing imports it). Use the entry-points command to verify.
Combine with resolve to understand the full dependency chain, not just direct importers.
  • resolve - Trace complete dependency paths between files
  • files - List all files in an entry point’s dependency tree
  • entry-points - Find files that aren’t imported by anything

Build docs developers (and LLMs) love