webpack-bundle-analyzer

Turns webpack build stats into an interactive, zoomable treemap so you can see exactly what's bloating every bundle.

Tool
npm
v5.4.0
12,657 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
72 /100 Good
Development Activity 72
Maintenance 52
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 80
Code Quality 85
Innovation 88
Learning Curve 70

webpack-bundle-analyzer is a webpack plugin and companion CLI utility that renders the contents of your webpack output as an interactive, zoomable treemap. Rather than trusting webpack’s raw stats output, it parses the actual emitted bundle files (when given the output directory) to compute real per-module sizes, and reports them across four different measures at once: stat size (pre-minification), parsed size (post-minification), and gzip/Brotli/Zstandard compressed size — so you can tell the difference between a module that looks huge in source and one that’s actually costing you bytes over the wire.

It runs in three modes: server starts a local HTTP server with a live-updating report (pushed over WebSocket on every rebuild), static writes a single self-contained HTML report you can archive or attach to a CI artifact, and json dumps the same chart data as raw JSON for custom tooling. The CLI path works directly against a webpack --json stats file when you don’t want to touch the build config at all. The treemap itself is searchable, supports per-chunk filtering via a sidebar and right-click context menu, and distinguishes initial vs. lazy-loaded chunks per entrypoint — making it the de facto way developers in the webpack ecosystem answer “why is my bundle this big.”

What You Get

  • An interactive, zoomable treemap UI (built with Preact, MobX, and the FoamTree treemap library) rendered either in a live local server or as a static HTML file you can share
  • Real per-module size measurements across five metrics — stat, parsed, gzip, Brotli, and Zstandard — computed by actually parsing the emitted bundle source, not just trusting webpack’s stats file
  • A CLI utility (webpack-bundle-analyzer <stats.json>) that works entirely from a webpack stats file, with no plugin wiring required
  • Live-updating reports over WebSocket in server mode, so the treemap refreshes automatically on every rebuild during development
  • Chunk-level filtering via a sidebar and right-click context menu, plus visibility into which chunks are part of each entrypoint’s initial load vs. lazily loaded later

Common Use Cases

  • Diagnosing why a production bundle suddenly grew after adding a new dependency
  • Finding accidentally duplicated or unexpectedly large third-party modules bundled into client code
  • Auditing initial-load JS per entrypoint to cut time-to-interactive on a marketing or app shell page
  • Generating a static bundle report as a CI artifact to track size regressions over time
  • Verifying that code-splitting and lazy-loading configuration actually moved modules out of the initial chunk

Under The Hood

Architecture

The plugin entry point (BundleAnalyzerPlugin) hooks into compiler.hooks.done (falling back to the legacy compiler.plugin('done') API for webpack 4) and, on each build, dispatches to one of three action paths keyed off analyzerMode: starting a live server, writing a static HTML report, or emitting a json dump — all funneled through viewer.js. That module resolves report options and calls into analyzer.js, the core data-processing layer, which normalizes webpack’s stats shape (including edge cases like data hiding in a children array), builds a per-asset module tree via a Folder/Module/ContentModule/ConcatenatedModule class hierarchy under src/tree/, and augments each module with a real parsed size by statically parsing the emitted bundle source. In server mode, sirv serves static UI assets while a ws WebSocket channel pushes updated chart data to the browser on every rebuild; static mode instead renders the same chart data into a single self-contained HTML file via template.js. A separate Preact + MobX single-page app under client/ (its own store.js MobX store, Treemap.jsx wrapping the third-party FoamTree charting library, plus Sidebar/Search/ContextMenu components) consumes that chart data — giving a clean pipeline from webpack hook through stats normalization, module-tree construction, and size computation to a shared UI regardless of output mode.

Tech Stack

The analyzer half runs on plain Node.js (>=20.9) with a deliberately small dependency set: @discoveryjs/json-ext for streaming/chunked parsing of large stats files, acorn/acorn-walk for statically parsing bundled JS to recover real module boundaries, commander for the CLI, sirv for static file serving, ws for the WebSocket push channel, and picocolors for console output. The client is a separate Preact 10 + MobX 6 single-page app built with its own webpack.config.js (babel-loader, css-loader, postcss-loader/autoprefixer, cssnano for production CSS), rendering its treemap through the commercially-licensed @carrotsearch/foamtree library. The src/ build itself goes through Babel (@babel/preset-env/preset-react, class-properties and runtime plugins), tests run on Jest 30 with Puppeteer for dev-server/browser-driven cases, and releases are managed with Changesets.

Code Quality

The repo carries an extensive fixture-driven test suite: alongside unit tests for the plugin, viewer/server, and stats-parsing utilities, test/stats/ holds dozens of real webpack-stats fixtures covering edge cases — missing chunks, invalid dynamic imports, worker-loader output, multiple entrypoints, module concatenation, special characters in filenames — so regressions in stats-shape handling get caught directly rather than through incidental coverage. Error handling favors explicit, leveled logging over hard failures: viewer.js catches analyzer errors and reports them through a Logger instead of crashing the host webpack build, and bundle-asset parse failures are caught per-asset with a distinguishing message (ENOENT vs. a generic parse error) so one bad asset doesn’t sink the whole report. The codebase is plain JavaScript annotated throughout with JSDoc types and validated in strict mode via tsc --noEmit (checkJs), giving real type safety without a separate TypeScript build step, and both ESLint (eslint-config-webpack) and Prettier are enforced through dedicated lint/format scripts backed by GitHub Actions CI.

API Design The public surface is intentionally minimal on both entry points: new BundleAnalyzerPlugin(opts) needs zero arguments to do something useful out of the box (defaulting to server mode with auto-open enabled), and the CLI mirrors the same option set one-for-one so switching between plugin config and command-line flags requires no re-learning. Every option is documented with a JSDoc typedef, giving IDE hover/autocomplete without hand-authored .d.ts files, and defaults are chosen so a first run is genuinely a single line of config. There’s effectively no required setup, no external service, and no auth to get a working report — the main friction point is understanding the size-metric vocabulary (stat/parsed/gzip/Brotli/Zstandard), which the README documents at length.

Used by 26 apps in this directory

TypeScript
47%
AGPL 3.0

Grafana

Analytics · Monitoring

77,469

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript 47%
Go 47%
Updated 6 days ago
Go
62%
Apache 2.0

Harness Open Source

Code Editors · Developer Tools · Devops

38,684

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
90
Repo Health
79
Technical
64
Dependency
Built with
Go 62%
TypeScript 33%
Updated 1 weeks ago
TypeScript
62%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,978

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 62%
Svelte 34%
Updated 1 weeks ago
TypeScript
73%
Apache 2.0

Jitsi Meet

Collaboration · Team Chat · Video Conferencing

30,130

Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.

View details
96
Repo Health
85
Technical
67
Dependency
Built with
TypeScript 73%
Lua 11%
JavaScript 10%
Updated 1 weeks ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,338

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated 6 days ago
Clojure
71%
AGPL 3.0

Logseq

Knowledge Management · Note Taking

45,349

A privacy-first, open-source knowledge graph platform combining Markdown, Org-mode, bidirectional linking, and local-first storage for building your second brain.

View details
92
Repo Health
82
Technical
65
Dependency
Built with
Clojure 71%
OCaml 12%
Updated 1 weeks ago
Clojure
57%
Other

Metabase

Analytics

49,827

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
62
Dependency
Built with
Clojure 57%
TypeScript 38%
Updated 6 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
26%
AGPL 3.0

Omnivore

Bookmarks Archiving · Knowledge Management · Note Taking

16,356

Self-hosted read-it-later platform with highlights, newsletters, PDFs, and seamless Obsidian and Logseq integration.

View details
90
Repo Health
74
Technical
65
Dependency
Built with
TypeScript 26%
JavaScript 24%
HTML 20%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers