Skip to main content

Migrating from madge

madge generates dependency graphs and finds circular dependencies. rev-dep replaces its analysis commands with config-driven checks and fast text-based exploration.

Why migrate​

  • Speed. rev-dep is written in Go and runs in one parallel pass - up to 207x faster than madge on large codebases.
  • Enforceable, not just informational. madge prints info; rev-dep turns the same findings into CI checks that fail the build, and adds unused exports, unused/missing dependencies, module boundaries, and more.

What carries over, what changes​

  • Covered well: circular dependencies, and the "what imports/depends on what" questions.
  • Not replaced - visualization. madge's main feature is rendering a graph image (--image, --dot). rev-dep has no image output; it answers reachability questions as text via the exploratory toolkit. If you rely on the visual graph, keep madge for that and use rev-dep for the checks.

Feature mapping​

madgerev-dep
madge --circularcircular command / circularImportsDetection check
madge --orphans (modules nothing imports)entry-points command
madge --leaves (modules with no deps)- (no equivalent)
madge --depends <module>imported-by / resolve
dead/unreachable filesorphanFilesDetection (more precise - uses real entry points)
madge --image / --dot (visual graph)- (no image output)

Translating your usage​

Ad-hoc madge commands:

madge --circular src
madge --orphans src

become exploratory commands, or a config check for CI:

rev-dep circular
rev-dep entry-points
{
"rules": [
{
"path": ".",
"circularImportsDetection": {
"enabled": true,
"ignoreTypeImports": true,
"algorithm": "SCC"
}
}
]
}
madge optionrev-dep equivalent
--extensions js,tssupported source extensions are built in; see supported file types
--exclude <regexp>graphExclude / ignoreFiles (globs)
--ts-config / --webpack-configrev-dep reads tsconfig.json paths; webpack aliases must be mirrored in tsconfig - see module resolution

Running it​

# madge
npx madge --circular src

# rev-dep (CI gate)
rev-dep config run

rev-dep circular (and config run) exit non-zero when cycles exist, ready for CI.

Next steps​