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

Go
71%
Apache 2.0

OSV.dev

Security

3,001

Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.

View details
87
Repo Health
82
Technical
66
Dependency
Built with
Go 71%
Python 19%
Updated 1 weeks ago
TypeScript
51%
ZLIB

Portainer

Devops

38,707

A lightweight, open-source web UI that puts Docker, Kubernetes, and Podman management within reach of any team—no CLI expertise required.

View details
93
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 51%
Go 38%
Updated 1 weeks ago
Python
45%
Other

Redash

Analytics · Data Engineering

28,849

Redash lets anyone connect to 35+ SQL and NoSQL data sources, write a query in the browser, and turn the result into a shared dashboard — no separate BI suite required.

View details
91
Repo Health
74
Technical
61
Dependency
Built with
Python 45%
JavaScript 29%
TypeScript 19%
Updated 1 weeks ago
TypeScript
97%
AGPL 3.0

Responsively App

Design Tools · Developer Tools

25,464

Preview and interact with your responsive web design across every device size simultaneously — no more manual resizing.

View details
79
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 3 weeks ago
TypeScript
89%
Other

strapi

CMS

73,368

Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.

View details
93
Repo Health
84
Technical
63
Dependency
Built with
TypeScript 89%
JavaScript 11%
Updated 1 weeks ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 6 days ago
TypeScript
41%
AGPL 3.0

Wiki.js

Collaboration · Knowledge Management

29,081

A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.

View details
95
Repo Health
67
Technical
60
Dependency
Built with
TypeScript 41%
Vue 39%
JavaScript 16%
Updated 6 days ago
TypeScript
96%
GPL 3.0

Wire

Collaboration · Team Chat · Video Conferencing

1,192

Open source end-to-end encrypted messaging for teams and enterprises — self-host for complete control over your communications and data.

View details
93
Repo Health
8
Technical
68
Dependency
Built with
TypeScript 96%
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