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

who-imports

v0.2.1

Published

Export-level dependency graph tool for TypeScript codebases

Readme

who-imports

npm version Downloads Build Status License

Export-level dependency graph tool for TypeScript codebases. Unlike module-level tools (Madge, Skott), this traces dependencies at individual export granularity.

Installation

npm install -g who-imports

Or run directly with npx:

npx who-imports -f ./src -o deps.json

Usage

who-imports -f <folder> [-f <folder>...] [-c <folder>...] -o <output>

Options

| Flag | Description | | ------------------------------ | ------------------------------------------------------------------------------------ | | -f, --folder <path> | Target folder(s) to analyze exports from. Repeatable. | | -c, --consumer <path> | Folder(s) to search for consumers. Defaults to -f. Repeatable. | | -i, --ignore-extension <ext> | File patterns to ignore (e.g., '.test.*'). Quote globs to prevent shell expansion. | | -d, --declarations | Include .d.ts files (excluded by default). | | -o, --output <path> | Output file. Extension determines format (.json or .dot). |

Examples

Analyze exports and consumers within the same folder:

who-imports -f ./src/features/auth -o auth-deps.json

Find consumers of shared types across multiple feature folders:

who-imports \
  -f ./src/shared/types \
  -c ./src/features/payments \
  -c ./src/features/onboarding \
  -o types-consumers.json

Output Formats

JSON

{
  "exports": [
    {
      "module": "primitiveTypes.ts",
      "name": "GroupId",
      "consumerCount": 7,
      "consumers": [
        { "module": "helpers/csv/operations.ts", "via": ["types.ts"] },
        { "module": "spreadsheet/types.ts" }
      ]
    }
  ]
}
  • module: Relative path to file where export is originally defined
  • name: Export name (default for default exports)
  • consumerCount: Number of files importing this export
  • consumers[].module: Consuming file path
  • consumers[].via: Re-export chain if consumer imported through barrel files

DOT (GraphViz)

who-imports -f ./src -o deps.dot
dot -Tsvg deps.dot -o deps.svg  # Render with GraphViz

Features

  • Re-export tracing: Follows re-exports to original source
    • export { X } from './other'
    • export * from './other'
    • import { X } from './other'; export { X }; (import-then-export)
  • Type exports: Includes export type and import type
  • Path resolution: Paths relative to folder (single) or common ancestor (multiple folders)

Programmatic API

Use as a library for custom tooling:

import {
  parseFiles,
  buildExportRegistry,
  findConsumers,
  buildDependencyOutput,
  formatAsJson,
} from 'who-imports';

const { files, basePath } = parseFiles(['./src']);
const registry = buildExportRegistry(files, basePath);
const consumers = findConsumers(files, registry, basePath);
const output = buildDependencyOutput(registry, consumers, files, basePath);

console.log(formatAsJson(output));

Exported Functions

| Function | Description | | ------------------------- | ------------------------------------------------------ | | parseFiles | Load TypeScript files into a ts-morph Project | | addFilesToProject | Add additional files to existing project | | buildExportRegistry | Extract all exports and build re-export map | | resolveExport | Trace an export to its original source | | getAllExportsFromModule | Get all exports from a module (including star exports) | | findConsumers | Find all consumers of exports | | buildDependencyOutput | Build final dependency output structure | | formatAsJson | Format output as JSON | | formatAsDot | Format output as GraphViz DOT |

Exported Types

ExportEntry, ResolvedExport, Consumer, ExportDependencyInfo, DependencyGraphOutput, ExportRegistry, ConsumerMap

How It Works

CLI args
  → parseFiles()           # Load .ts/.tsx files into ts-morph Project
  → buildExportRegistry()  # Extract exports, build re-export map
  → findConsumers()        # Scan imports, trace through re-exports
  → buildDependencyOutput()# Aggregate into final structure
  → formatAsJson/Dot()     # Serialize

Development

git clone https://github.com/yoavsion/who-imports.git
cd who-imports
yarn install
yarn build

Scripts

| Script | Description | | ------------- | ------------------------------- | | yarn build | Compile TypeScript to dist/ | | yarn dev | Run directly via tsx (no build) | | yarn test | Run tests | | yarn lint | Run ESLint | | yarn format | Format with Prettier |

Architecture

src/
├── index.ts        # CLI entry point (commander)
├── api.ts          # Programmatic API exports
├── types.ts        # Shared TypeScript types
├── parser.ts       # ts-morph project initialization, file collection
├── exports.ts      # Export extraction, re-export chain resolution
├── consumers.ts    # Import scanning, consumer mapping
└── output/
    ├── json.ts     # JSON formatter
    └── dot.ts      # GraphViz DOT formatter

Contributing

Issues and PRs welcome on GitHub.

Related Tools

  • ts-morph - TypeScript compiler API wrapper (powers this tool)
  • Madge - Module-level dependency graphs
  • Skott - Module-level dependency analysis

License

MIT