Staaarter

Bundle Size Analyzer

A JavaScript bundle analysis panel: every chunk in a build gets a row with a proportional size bar, its raw KB, and a smaller secondary gzip-size bar underneath for comparison. Rows are color-coded by chunk type (app code, vendor, asset) with a small legend up top. Built for build-tool docs, CI reports, and performance-focused landing sections.

By Staaarter Team
DevTools
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/bundle-size-analyzer.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/devtools/devtools21.tsx instead.

Usage

The file also exports devtools21Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Devtools21, devtools21Demo } from "@/components/blocks/devtools/devtools21";

export default function Page() {
  return <Devtools21 {...devtools21Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"Bundle Size Analyzer"Section heading.
descriptionstringundefinedSection intro text below the heading.
chunksChunkItem[][]Rows in the bundle breakdown list, rendered in the order given.
classNamestringnoneExtra classes for the outer section element.

Types

type ChunkType = "app" | "vendor" | "asset";

type ChunkItem = {
  name: string;
  type: ChunkType;
  sizeKb: number;
  gzipKb: number;
};

Behavior notes

  • Entirely static; no client-side interactivity, no real bundle parsing. sizeKb and gzipKb are caller-supplied numbers, not computed from an actual build.
  • Every bar's width is calculated relative to the single largest chunk's sizeKb in the current chunks array, so bars stay comparable to each other but will rescale if the list of chunks changes.
  • The secondary gzip bar underneath each row is scaled against that same largest-raw-size baseline (not against its own row's raw size), so it visually communicates how much smaller compression makes that chunk relative to the whole set.
  • Chunk type colors are fixed (app code = sky, vendor = violet, asset = amber) and are not configurable per row beyond changing a chunk's type.
  • In the demo data, gzip size equals raw size for asset-type chunks (a PNG and a WOFF2 font): that is realistic, not a bug, since already-compressed binary formats do not shrink further under gzip the way text-based JS chunks do.