npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tomi_tom/depgraph

v0.4.0

Published

Visualiseur de graphe de dépendances interactif et 100% local pour projets JS/TS, avec détection actionnable des dépendances circulaires. Zéro Graphviz, zéro dépendance runtime.

Readme

DepGraph

Interactive, 100% local dependency graph for JS/TS projects, with actionable circular-dependency detection. No Graphviz, no runtime dependencies.

A single command produces a standalone HTML file (force-directed graph, folder view, search, click-to-highlight cycles) and prints the exact cycle chains in the terminal, classified runtime vs type-only, with the cheapest edge to break suggested for each real cycle.

Usage

No install needed — run it with npx:

npx @tomi_tom/depgraph <dir> -o graph.html
# then open graph.html in your browser

Or install it globally:

npm install -g @tomi_tom/depgraph
depgraph <dir> -o graph.html

Options

-o, --out <file>       output HTML file (default: depgraph.html)
    --json             also write the graph as JSON (<out>.json)
    --dot              also write Graphviz DOT (<out>.dot)
    --forbid "a -> b"  forbid imports from a to b (repeatable, globs * and **)
    --fail-type-cycles exit non-zero even when cycles are type-only
-h, --help             show help

Exit codes (CI-ready)

0  clean — type-only cycles are tolerated by default (they vanish at compile time)
1  usage / IO error
2  runtime circular dependencies
3  forbidden dependencies (--forbid violations)

Features

  • Runtime vs type-only cycles. DepGraph knows the difference between a cycle that can break your app at runtime and one made only of import type edges (which TypeScript erases at compile time). Only runtime cycles fail the build — no more red CI for harmless type cycles.
  • Cheapest break suggested. Every runtime cycle comes with the edge that is cheapest to cut (fewest imported bindings): invert it, extract shared code, or switch it to import type.
  • Architecture rules. --forbid "src/ui -> src/db" (repeatable, globs * and **) turns the graph into a CI guardrail against forbidden layer crossings — violations are listed in the terminal and clickable in the HTML.
  • Folder view. One toggle aggregates the graph by directory (edge thickness = number of imports) — the architecture at a glance on large codebases. Files are color-coded by folder, with a legend.
  • Impact analysis. Click any file → ⌁ impact highlights everything it transitively touches: dependents upstream (orange) and dependencies downstream (cyan). Your blast radius before a refactor.
  • Circular dependencies surfaced as closed import chains, clickable to highlight (type-only edges are dashed, runtime cycle nodes have a red ring).
  • TypeScript path aliases resolved from tsconfig.json (paths + baseUrl), plus the NodeNext .js.ts convention — works even when run from a subfolder.
  • Interactive HTML: hover tooltips, detail panel with clickable imports/importers, search (/), "show cycles only" toggle, zoom/pan, pinnable nodes (double-click / shift-drag).
  • Live layout controls: real-time physics sliders (repulsion, cable length, elasticity, gravity, damping, node size, edge opacity) + shape presets (Balanced / Compact / Spread / Tree).
  • Calm & efficient: the force layout freezes once it settles (no CPU spinning) and wakes on interaction; respects prefers-reduced-motion.
  • One-click PNG export straight from the browser — no Graphviz, unlike madge/dependency-cruiser.
  • Insights in the terminal: most-imported file, orphan files (no imports in/out).

Example

$ npx @tomi_tom/depgraph src --forbid "src/components -> src/utils"
✓ 18 files · 28 imports analyzed (tsconfig aliases resolved)
⚠ 3 circular dependency(ies) detected (2 runtime · 1 type-only):
   ⤷ [runtime] src/api/client.ts → src/api/endpoints.ts → src/api/client.ts
     ✂ cheapest break: src/api/client.ts → src/api/endpoints.ts (1 binding) — invert it, or extract shared code / use "import type"
   ⤷ [type-only] src/models/post.ts → src/models/user.ts → src/models/post.ts
   ⤷ [runtime] src/lib/a.ts → src/lib/b.ts → src/lib/c.ts → src/lib/a.ts
     ✂ cheapest break: src/lib/a.ts → src/lib/b.ts (1 binding) — invert it, or extract shared code / use "import type"
   ℹ type-only cycles vanish at compile time (no runtime risk) — they don't fail the build (use --fail-type-cycles to change that)
✗ 2 forbidden dependency(ies):
   ⤷ src/components/button.ts → src/utils/format.ts  (rule: src/components -> src/utils)
→ depgraph.html

Why

Existing tools require Graphviz for the visuals (madge, dependency-cruiser), leave cycles as a "wall of paths" that is hard to act on, and treat every cycle the same. DepGraph shows each cycle as a closed import chain (A → B → C → A), tells you whether it can actually hurt you at runtime, and points at the cheapest edge to cut.

Limitations

Resolves relative imports (./, ../), the NodeNext .js.ts convention, and TS path aliases (tsconfig.json paths + baseUrl). Not yet supported: monorepo project references / workspace packages, and dynamic/computed import paths. UTF-8 source; symlinks are ignored.

Development

git clone https://github.com/Tomi-Tom/depgraph
cd depgraph
npm install          # builds dist/ automatically (prepare script)
npm test             # 59 tests (Vitest)
node dist/cli.js sample-project -o graph.html   # demo (2 runtime cycles + 1 type-only)

License

MIT