RepoPilotOpen in app →

webpack/webpack-bundle-analyzer

Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap

Healthy

Healthy across the board

weakest axis
Use as dependencyHealthy

Permissive license, no critical CVEs, actively maintained — safe to depend on.

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • Last commit 6w ago
  • 29+ active contributors
  • Distributed ownership (top contributor 26% of recent commits)
  • MIT licensed
  • CI configured
  • Tests present

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the “Healthy” badge

Paste into your README — live-updates from the latest cached analysis.

RepoPilot: Healthy
[![RepoPilot: Healthy](https://repopilot.app/api/badge/webpack/webpack-bundle-analyzer)](https://repopilot.app/r/webpack/webpack-bundle-analyzer)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/webpack/webpack-bundle-analyzer on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: webpack/webpack-bundle-analyzer

Generated by RepoPilot · 2026-05-06 · Source

Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/webpack/webpack-bundle-analyzer shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

Verdict

GO — Healthy across the board

  • Last commit 6w ago
  • 29+ active contributors
  • Distributed ownership (top contributor 26% of recent commits)
  • MIT licensed
  • CI configured
  • Tests present

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live webpack/webpack-bundle-analyzer repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/webpack/webpack-bundle-analyzer.

What it runs against: a local clone of webpack/webpack-bundle-analyzer — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in webpack/webpack-bundle-analyzer | Confirms the artifact applies here, not a fork | | 2 | License is still MIT | Catches relicense before you depend on it | | 3 | Default branch main exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 72 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>webpack/webpack-bundle-analyzer</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of webpack/webpack-bundle-analyzer. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/webpack/webpack-bundle-analyzer.git
#   cd webpack-bundle-analyzer
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of webpack/webpack-bundle-analyzer and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "webpack/webpack-bundle-analyzer(\\.git)?\\b" \\
  && ok "origin remote is webpack/webpack-bundle-analyzer" \\
  || miss "origin remote is not webpack/webpack-bundle-analyzer (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
  && ok "license is MIT" \\
  || miss "license drift — was MIT at generation time"

# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
  && ok "default branch main exists" \\
  || miss "default branch main no longer exists"

# 4. Critical files exist
test -f "src/BundleAnalyzerPlugin.js" \\
  && ok "src/BundleAnalyzerPlugin.js" \\
  || miss "missing critical file: src/BundleAnalyzerPlugin.js"
test -f "src/analyzer.js" \\
  && ok "src/analyzer.js" \\
  || miss "missing critical file: src/analyzer.js"
test -f "src/tree/Node.js" \\
  && ok "src/tree/Node.js" \\
  || miss "missing critical file: src/tree/Node.js"
test -f "client/viewer.jsx" \\
  && ok "client/viewer.jsx" \\
  || miss "missing critical file: client/viewer.jsx"
test -f "src/viewer.js" \\
  && ok "src/viewer.js" \\
  || miss "missing critical file: src/viewer.js"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 72 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~42d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/webpack/webpack-bundle-analyzer"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

webpack-bundle-analyzer is a webpack plugin and CLI utility that visualizes bundle content as an interactive, zoomable treemap visualization. It parses minified bundles to show real module sizes and supports gzip, Brotli, and Zstandard compression analysis, helping developers identify bloat and optimize their builds. Dual-source monolith: src/ contains the Node.js plugin/analyzer logic (compiled to lib/ via Babel), while client/ contains a React-based viewer (JSX components in client/components/, compiled to public/ via webpack). Entry point is lib/index.js (plugin) and lib/bin/analyzer.js (CLI), both serving stats to an embedded Express server or static HTML.

Who it's for

Webpack users (React, Vue, Angular developers) who need to understand what's in their production bundles, identify accidental dependencies, and optimize bundle size. DevOps and performance engineers use it to track and audit bundle composition in CI/CD pipelines.

Maturity & risk

Production-ready and actively maintained. Version 5.3.0 with a formal changelog, GitHub Actions CI/CD setup (main.yml and release.yml workflows), extensive test suite (test command with Jest), TypeScript support (lint:types script), and professional tooling (changesets for versioning, Prettier/ESLint enforcement). The webpack organization backing indicates stability.

Low risk overall. Single-maintainer model (Yury Grunin listed as author) is mitigated by webpack org stewardship. Build depends on Node.js version constraints (.nvmrc present) and uses OpenSSL legacy provider for Node ≥17 (visible in test script). No major red flags in file structure, though webpack peer dependency version management could be fragile across versions.

Active areas of work

Active development: the repo has .changeset/ directory configured for semantic versioning and automated releases. TypeScript adoption in progress (tsc linting enabled). Recent focus on compatibility (OpenSSL legacy provider workaround in test script) and client-side tooling (ESLint, Prettier formatting). No specific breaking changes evident, but version 5.x suggests major API changes from earlier releases.

Get running

git clone https://github.com/webpack/webpack-bundle-analyzer.git
cd webpack-bundle-analyzer
npm install
npm run build
npm test

Daily commands: Development workflow: npm run watch:analyzer (rebuilds plugin on changes) and npm run watch:viewer (webpack dev server for React UI on port 8888, likely). For one-off builds: npm run build:analyzer && npm run build:viewer. To test: npm test or npm run test-dev (Jest watch mode). Plugin runs as webpack plugin automatically; CLI accessible via bin/analyzer.js.

Map of the codebase

  • src/BundleAnalyzerPlugin.js — Main webpack plugin entry point—orchestrates bundle analysis and report generation; essential for understanding the plugin's initialization flow
  • src/analyzer.js — Core analysis engine that parses webpack stats and generates the interactive treemap data structure; critical for bundle size calculations
  • src/tree/Node.js — Base class for the tree data structure representing modules and folders; foundational abstraction for all bundle visualization
  • client/viewer.jsx — React entry point for the interactive frontend UI; renders the treemap visualization and handles user interactions
  • src/viewer.js — Server-side HTTP viewer that serves the interactive HTML/JS bundle analysis report to the browser
  • src/statsUtils.js — Utilities for parsing webpack stats objects; bridges webpack's output format to internal bundle analysis data
  • package.json — Build configuration and dependency declarations; defines npm scripts, build targets, and required webpack versions

How to make changes

Add a New Tree Node Type

  1. Create a new class extending BaseFolder or Node in src/tree/ (src/tree/Node.js)
  2. Implement required methods: getChildren(), getSize(), and toJSON() (src/tree/Module.js)
  3. Update the tree builder in src/analyzer.js to instantiate your new node type (src/analyzer.js)
  4. Add corresponding UI rendering logic in client/components/ModulesTreemap.jsx if visual representation differs (client/components/ModulesTreemap.jsx)

Add a New UI Control or Filter

  1. Create a new React component in client/components/ (e.g., MyControl.jsx) (client/components/Checkbox.jsx)
  2. Add state management for the control in client/store.js (client/store.js)
  3. Integrate the component into client/components/Sidebar.jsx or another parent component (client/components/Sidebar.jsx)
  4. Implement filtering logic to update the treemap display in ModulesTreemap.jsx (client/components/ModulesTreemap.jsx)

Support a New Bundle Stats Format

  1. Add parsing logic to src/statsUtils.js to normalize the new format (src/statsUtils.js)
  2. Update src/parseUtils.js if module relationship extraction differs (src/parseUtils.js)
  3. Add test fixtures in test/bundles/ for the new format (test/bundles/validBundleWithIIFE.modules.json)
  4. Update src/analyzer.js to use the new utilities when detecting the format (src/analyzer.js)

Add a Custom Size Calculation Method

  1. Implement a new size calculator function in src/sizeUtils.js (src/sizeUtils.js)
  2. Update src/analyzer.js to compute sizes using the new method for all nodes (src/analyzer.js)
  3. Add UI controls in client/components/Switcher.jsx to select between size calculation methods (client/components/Switcher.jsx)
  4. Update client/store.js to persist the user's size calculation preference (client/store.js)

Why these technologies

  • React + Canvas — Canvas provides high-performance rendering of large treemaps with thousands of rectangles; React manages interactivity state and updates efficiently
  • Node.js HTTP server (Express-like) — Lightweight server to serve the interactive report in a browser without requiring external dependencies; allows real-time port selection
  • Webpack stats JSON — Standard webpack output format that is universally compatible; contains all necessary metadata about modules, chunks, and sizes
  • Hierarchical tree data structure — Mirrors the natural file system and module organization, enabling efficient treemap layout algorithms and intuitive UI navigation

Trade-offs already made

  • Single-page React app over server-rendered HTML

    • Why: Enables responsive interactivity (zooming, panning) without network latency; stats JSON is embedded once at page load
    • Consequence: Initial HTML file is larger (~1MB) but subsequent interactions are instant; only suitable for one bundle report per page view
  • Canvas rendering instead of SVG

    • Why: Canvas scales to tens of thousands of rectangles without performance degradation
    • Consequence: Less accessible (no native text selection); requires custom tooltip/context menu implementation
  • Synchronous tree building in main thread during build

    • Why: Simpler implementation; build process is already blocking
    • Consequence: Very large bundles (>100k modules) may cause noticeable build delays; not suitable for realtime analysis during watch mode
  • Multiple size metrics (parsed, gzipped, brotli) computed upfront

    • Why: Avoids runtime compression; provides instant switching between metrics in UI
    • Consequence: Build time increases linearly with bundle size; stats JSON includes redundant size data

Non-goals (don't propose these)

  • Does not analyze bundle runtime performance or execution time—only static size metrics
  • Does not support real-time streaming analysis during active webpack watch mode
  • Does not provide automated optimization suggestions or dependency refactoring
  • Does not generate server-side rendered reports; requires a browser to view
  • Not designed for CI/CD integration with automated size thresholds (would need external tooling)

Traps & gotchas

OpenSSL legacy provider: tests require NODE_OPTIONS=--openssl-legacy-provider on Node ≥17; missing this causes crypto errors. Webpack version pinning: plugin tested against specific webpack versions (see bin/install-test-webpack-versions.sh); using incompatible webpack may cause stats parsing failures. Dual build requirement: both npm run build:analyzer and npm run build:viewer must succeed for a working release; partial builds ship broken. Port conflicts: dev server defaults to 8888 (inferred); ensure free on development machine.

Architecture

Concepts to learn

  • Treemap layout algorithm — Core visualization technique used by ModulesTreemap.jsx; understanding how rectangles are positioned recursively by size is essential to modifying the layout or adding new interaction modes
  • Webpack stats JSON schema — Plugin parses webpack's compilation stats object to extract module sizes, chunks, and dependencies; misunderstanding the schema leads to parsing bugs
  • Source maps and minification — README advertises support for parsing minified bundles to show real module sizes; this relies on source map parsing and module boundary detection, non-trivial for obfuscated code
  • Compression algorithms (Gzip, Brotli, Zstandard) — Plugin shows multiple compressed sizes; understanding how each compression scheme trades CPU for ratio helps interpret results for different deployment targets
  • React component state management patterns — Client-side UI (Sidebar.jsx, ModulesList.jsx) manages selection and filter state; contributors need to follow React patterns for prop drilling or memoization to avoid unnecessary re-renders of the expensive treemap
  • Webpack plugin hooks lifecycle — Plugin integrates via webpack's Tapable hooks (compilation, emit, etc.); understanding when and where to intercept compilation is crucial for modifying how stats are captured or output
  • Babel AST transformation — Build pipeline transpiles ES6+ client code via Babel before shipping; understanding .babelrc targets and presets helps debug compatibility issues or add modern syntax support

Related repos

  • danvk/source-map-explorer — Alternative bundle analyzer using source maps instead of webpack stats; complements this tool for size forensics
  • samccone/bundle-buddy — Earlier treemap-based bundle visualizer; direct predecessor/inspiration for webpack-bundle-analyzer's zoomable UI
  • webpack/webpack — Parent project and core dependency; plugin hooks into webpack compilation pipeline and consumes stats output
  • facebook/create-react-app — Common integration point; CRA users rely on this plugin via react-scripts for built-in bundle analysis
  • FormidableLabs/webpack-dashboard — Complementary webpack CLI tool; both provide real-time bundle insights but with different UI paradigms (dashboard vs. treemap)

PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add unit tests for client/lib utilities (PureComponent.jsx, localStorage.js, utils.js)

The client-side utilities lack dedicated test coverage. PureComponent.jsx, localStorage.js, and utils.js are core utilities used across components but appear to have no corresponding test files in the jest.config.js setup. This is critical for a visualization tool where client-side state management and DOM utilities are essential.

  • [ ] Create client/tests/localStorage.test.js covering get/set/remove operations and edge cases
  • [ ] Create client/tests/utils.test.js for utility functions used in treemap calculations
  • [ ] Create client/tests/PureComponent.test.jsx for lifecycle and rendering behavior
  • [ ] Verify tests run with existing jest.config.js (NODE_OPTIONS=--openssl-legacy-provider jest)
  • [ ] Add test coverage reporting to npm run test:coverage

Add GitHub Actions workflow for testing against multiple Webpack versions

The bin/install-test-webpack-versions.sh script exists but there's no corresponding CI workflow. Given that webpack-bundle-analyzer is a webpack plugin with broad compatibility requirements, testing against webpack v5 and v6 (and potentially older v4) in CI is critical to catch breaking changes early.

  • [ ] Create .github/workflows/webpack-compat.yml workflow file
  • [ ] Add matrix strategy testing against webpack@^4, webpack@^5, webpack@^6 (once released)
  • [ ] Reference the existing bin/install-test-webpack-versions.sh in the workflow
  • [ ] Run npm test after each webpack version installation
  • [ ] Add status badge to README.md linking to this workflow

Create TypeScript definitions for public API (lib/index.js and lib/bin/analyzer.js)

The package.json shows TypeScript linting is configured (lint:types runs tsc), but there are no .d.ts files for the main entry points. Since this is a plugin/CLI tool used in webpack configurations, providing proper TypeScript definitions for BundleAnalyzerPlugin options and CLI arguments would significantly improve developer experience.

  • [ ] Create lib/index.d.ts with BundleAnalyzerPlugin class definition and all constructor options
  • [ ] Create lib/bin/analyzer.d.ts for CLI argument types
  • [ ] Document all plugin options (analyzerMode, reportFilename, defaultSizes, etc.) with JSDoc
  • [ ] Update tsconfig.json to include these definitions in the build output
  • [ ] Add test verification in lint:types that definitions match runtime behavior

Good first issues

  • Add E2E tests for CLI analyzer.js: The lib/bin/analyzer.js CLI entry point lacks integration tests. Add Jest test suite in test/ directory that calls CLI with sample webpack stats and verifies output file generation and server startup.
  • Document treemap zoom interactions in JSDoc: ModulesTreemap.jsx component lacks comments explaining pan/zoom/click behavior. Add inline JSDoc for each event handler and state update method to onboard contributors on interaction logic.
  • Add TypeScript definitions for plugin options: README lists analyzerMode, analyzerPort, etc. but no corresponding index.d.ts exists. Create lib/index.d.ts with JSDoc-backed type stubs or full TS interfaces for BundleAnalyzerPlugin constructor options.

Top contributors

Recent commits

  • 9ba43c7 — chore(release): new release (#714) (github-actions[bot])
  • 8a91940 — ci: trusted publishers (#713) (alexander-akait)
  • b3f44b0 — fix: race condition in writeStats (#711) (colinaaa)
  • 3710653 — refactor: adding typescript jsdocs types (#710) (alexander-akait)
  • 77599a4 — refactor: improve prop types and fix mobx (#709) (alexander-akait)
  • 26b83f6 — test: refactor infra (#708) (alexander-akait)
  • 2588e54 — ci: add codecov and fix test (#705) (alexander-akait)
  • be761ef — update eslint and apply eslint-config-webpack (#701) (alexander-akait)
  • 1c23a2a — refactor: more ES6 code and code improvements (#700) (alexander-akait)
  • 4af64e3 — chore: improve package.json (#695) (alexander-akait)

Security observations

webpack-bundle-analyzer is a development tool with moderate security posture. The primary concerns are potential XSS vulnerabilities in client-side rendering, use of legacy OpenSSL providers indicating outdated dependencies, and insufficient input validation in the CLI analyzer. The codebase lacks explicit security headers when serving the UI. As this is primarily a development/analysis tool, exposure risk in production is limited, but bundle data processed should be treated as potentially untrusted input. No hardcoded secrets or obvious injection vulnerabilities were found in the file structure provided.

  • Medium · Potential XSS vulnerability in client-side rendering — client/components/*.jsx (especially ModulesTreemap.jsx, ModulesList.jsx, Treemap.jsx). The codebase contains React components that render bundle analysis data. Without proper sanitization, user-controlled input or malicious bundle data could lead to XSS attacks. Components like ModulesTreemap.jsx, ModulesList.jsx, and Treemap.jsx may be vulnerable if they render unsanitized module names or paths. Fix: Ensure all user-controlled data and bundle metadata are properly escaped before rendering. Use React's built-in XSS protection (automatic escaping in JSX) and validate/sanitize bundle data during parsing. Review client/utils.js and src/parseUtils.js for proper data sanitization.
  • Medium · OpenSSL legacy provider required for Node.js tests — package.json (test scripts). The package.json scripts use 'NODE_OPTIONS=--openssl-legacy-provider' for Jest tests. This indicates the codebase may be using outdated cryptographic dependencies or practices that require legacy OpenSSL support, which has weaker security standards. Fix: Update dependencies to versions compatible with modern Node.js OpenSSL. Remove the legacy provider flag and update webpack, webpack-cli, and related dependencies to their latest versions.
  • Medium · Missing input validation in analyzer CLI — src/bin/analyzer.js, src/analyzer.js. The CLI utility at src/bin/analyzer.js likely processes user-provided bundle statistics files and command-line arguments. Without proper validation, this could lead to path traversal, code injection, or denial of service attacks. Fix: Implement strict input validation for all CLI arguments and file paths. Use path.resolve() and validate that paths don't escape intended directories. Validate file sizes and content structure before processing.
  • Low · No explicit security headers configuration — src/analyzer.js, src/template.js. The bundle analyzer serves an interactive HTML viewer without visible security headers configuration. When running as a development server, it should include security headers to prevent clickjacking and other attacks. Fix: Add security headers (X-Frame-Options, X-Content-Type-Options, Content-Security-Policy) when serving the analyzer UI. Include X-Frame-Options: DENY or SAMEORIGIN and CSP headers that restrict script sources.
  • Low · LocalStorage usage without encryption — client/localStorage.js. The file client/localStorage.js manages client-side storage for UI state. While unlikely to contain sensitive data, any user preferences stored here are unencrypted and accessible to JavaScript. Fix: Review what data is stored in localStorage. Ensure no sensitive information (API keys, tokens, etc.) is persisted. If sensitive data must be stored, use encryption or restrict to sessionStorage instead.
  • Low · Dependency on Webpack plugin architecture trust — src/BundleAnalyzerPlugin.js, src/statsUtils.js. BundleAnalyzerPlugin integrates deeply with webpack's plugin system and processes untrusted bundle statistics. Malicious webpack plugins or corrupted stats files could potentially execute arbitrary code. Fix: Validate and sanitize all webpack stats objects before processing. Implement schema validation for the stats structure. Document security considerations for users loading this plugin.

LLM-derived; treat as a starting point, not a security audit.

Where to read next


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Healthy signals · webpack/webpack-bundle-analyzer — RepoPilot