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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dependensia

v0.0.7

Published

Analyze a TypeScript/JavaScript project's dependencies and generates a dependency graph using TypeScript APIs

Downloads

52

Readme

dependensia

codecov Ask DeepWiki

A static analysis tool designed to examine TypeScript and JavaScript projects and produce dependency graphs,using TypeScript APIs.

Key Features

  • Dependency Graph Generation: Analyze TypeScript/JavaScript projects to map file dependencies.
  • Circular Dependency Detection: Implements depth-first search (DFS) algorithms to identify cycles in the dependency graph, helping developers locate problematic import patterns.
  • Topological Sorting: Files are ordered according to their dependency relationships, enabling build systems and bundlers to process files in the correct sequence.
  • Leaf & Mutual Dependencies: Find files with no local imports and mutual (two-way) dependencies.
  • NPM & Node Built-in Detection: List external and built-in module usage.

Use

Installation

Install dependensia as a development dependency in your project:

npm i -D dependensia

Basic Usage

ES Modules

import dependensia from "dependensia";

const entry = "src/index.ts";
const analysis = await dependensia(entry);

// Get topologically sorted files
const sorted = analysis.sort();

// Check for circular dependencies
const circular = analysis.circular();

// Find mutual dependencies
const mutual = analysis.mutual();

CommonJS

const dependensia = require("dependensia");

const entry = "src/index.js";
dependensia(entry).then((analysis) => {
  console.log("Circular dependencies:", analysis.circular());
  console.log("NPM dependencies:", analysis.npm());
});

API

dependensia(entry:string)

Dependensia Interface Overview

The Dependensia interface defines 12 methods that provide access to different aspects of the dependency analysis.

Method Categories

Structural Analysis Methods

These methods provide insights into the structural properties of the dependency graph, including ordering, cycles, and relationship patterns.

| Method | Return Type | Purpose | | --------------- | -------------------------- | -------------------------------- | | sort() | string[] | Topological sort of dependencies | | circular() | CircularDependency[] | Detected circular dependencies | | mutual() | string[][] | Bidirectional dependency pairs | | leaf() | string[] | Files with no local imports | | chain() | Record<string, string[]> | Complete dependency chains | | entryToLeaf() | string[][] | Paths from entry to leaf files |

Query Methods

These methods provide access to the raw dependency data and allow querying specific relationships.

| Method | Return Type | Purpose | | ------------------------- | -------------------------- | ------------------------------- | | deps() | Record<string, string[]> | Raw dependency graph | | dependents(file:string) | string[] | Files that depend on given file | | npm() | string[] | External NPM dependencies | | node() | string[] | Node.js built-in modules |

Visualization and Metadata Methods

These methods provide formatted output and analysis metadata.

| Method | Return Type | Purpose | | ------------- | ----------- | ---------------------------- | | textGraph() | string | Text representation of graph | | warn() | string[] | Analysis warnings |

Contributing

Contributions are welcome for bug fixes, features, documentation, and code quality improvements.

See detail in CONTRIBUTING.md

License

Apache-2.0 © Pho Thin Mg