Bundle Treemap

Bundle size by module, laid out by compressed size. Raw bytes overstate text-heavy modules dramatically — a 400KB locale file that gzips to 12KB dominates a raw treemap and barely matters on the wire.

src/components/ui/bundle-treemap.tsx

About

From the component's own source, where it was written.

Bundle size by module, as a treemap.

Area is size, so the thing taking the space is the thing that looks big. A sorted bar chart answers "what is largest"; a treemap answers "what is this bundle *made of*", which is the question you have when a build doubles.

Gzipped size drives the layout when it is supplied. Raw bytes overstate text-heavy modules dramatically — a 400KB locale file that gzips to 12KB dominates a raw-size treemap and is nearly irrelevant on the wire.

Squarified layout, not a naive slice-and-dice: long thin slivers cannot be compared by eye or clicked, which defeats the point of the shape.

Install

npx astralyx-ui add bundle-treemap

Usage

import { BundleTreemap } from '@/components/ui/bundle-treemap'

<BundleTreemap modules={modules} />

Composer

Change the props and the source below follows.

Total 1.5 MB284 KB gzipped

Props
tsx
<BundleTreemap modules={modules} useGzip={true} />

Examples

Where the bytes went

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

BundleTreemap

Extends Omit<ComponentProps<'div'>, 'children' | 'height'>.

PropTypeDefaultDescription
modulesBundleModule[]required{ name, size, gzip? }. Sizes in bytes.
heightnumber260—
useGzipbooleantrueLay out by compressed size when available. Toggle it in the composer to see the locale file take over.
totalLabelReactNode'Total'—
gzipLabelReactNode'gzipped'—

Functions

FunctionSignatureDescription
squarify(values: number[], width: number, height: number) => [number, number, number, number][]Squarified treemap over a 0–1 box. Rows are grown while the worst aspect ratio in the row keeps improving, which is what avoids slivers.

Types

BundleModule

Bundle size by module, as a treemap.

FieldTypeDescription
namestring—
sizenumberRaw bytes.
gzip?numberCompressed bytes. Drives the layout when present.

Behaviour

TopicDetailDescription
layoutsquarifiedNot slice-and-dice: long thin slivers cannot be compared by eye or clicked, which defeats the shape.
why a treemapcompositionA sorted bar chart answers "what is largest". A treemap answers "what is this bundle made of", which is the question when a build doubles.