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

webpack-trace-dep

v2.0.2

Published

Find out why a given file is included in a webpack bundle or a specific chunk

Downloads

14

Readme

webpack-trace-dep

Webpack Dependency Explorer CLI
Trace and visualize module dependencies in your Webpack project—find full dependency trees or show chains from any file A to file B. Supports filtering by chunks, highlights, depth, and can skip async (import()) dependencies.

Features

  • Show dependency trees for any file/module in your bundle.
  • Find chains of dependencies: “How can module X possibly require module Y?”
  • Chunk filtering: Restrict to specific chunks via regex.
  • Depth limiting: Limit tree/chain depth for clarity.
  • Highlights: Colorize specific modules and chunks.
  • Skip async: Optionally ignore async (import()) edges.
  • Flexible substring matching for fuzzy module lookups.

Installation

git clone https://github.com/YOUR_USERNAME/webpack-trace-dep.git
cd webpack-trace-dep
npm install
npm run build

Or run directly with ts-node:

npm install
npx ts-node src/index.ts ...

Usage

Generate Webpack Stats

First, generate your stats file:

webpack --config webpack.config.js --stats > stats.json

Show Dependency Tree

node dist/index.js tree <statsFile> <module> [options]

Example:

node dist/index.js tree build/stats.app.json src/main.ts -d 5

Find Dependency Chains (from A to B)

node dist/index.js find-chain <statsFile> <from> <to> [options]

Example:

node dist/index.js find-chain build/stats.app.json src/foo.ts src/bar.ts -d 10

CLI Options

| Option | Alias | Description | Example | |--------------------|-------|------------------------------------------------------------|--------------------------------| | --chunk | -c | Regex: limit to specific chunk(s) | -c "main" | | --depth | -d | Max depth for tree/chain | -d 6 | | --highlight | -h | Regex: highlight module(s) in tree | -h "utils" | | --highlightChunk | -H | Regex: highlight chunk(s) in tree | -H "vendor" | | --trimTree | -t | Regex: trim leaves matching pattern | -t "polyfill" | | --skipModules | -s | Regex: skip modules from chunks matching this pattern | -s "legacy" | | --showRequest | -i | Show user request for each import (tree only) | -i | | --skipAsync | -a | Skip async (import()) dependencies | -a | | --help | | Show help | |

Examples

Show Tree for a File, Highlight "utils", Depth 4

node dist/index.js tree stats.json src/components/App.tsx -d 4 -h "utils"

Find All Chains from a.js to b.js (skipping async imports, up to depth 12)

node dist/index.js find-chain stats.json src/a.js src/b.js -d 12 -a

Restrict Analysis to "main" Chunk Only

node dist/index.js tree stats.json src/index.js -d 5 -c "main"

Development

  • Written in TypeScript, using yargs for CLI.
  • Edit src/index.ts, then run npm run build to produce the CLI.
  • Works on any Webpack JSON stats file (webpack --stats).

Run with ts-node (for development):

npx ts-node src/index.ts tree stats.json src/main.ts -d 5

Contributing

Issues and PRs are welcome!
Please file a bug if you find a case where dependencies or chains are not found as expected.

License

MIT

Credits

Created by Damian Kaczmarek, inspired by real-world pain exploring deep Webpack dependency graphs.