Share a Statoscope report

Bundle size regressions have a specific failure mode: they are caught by a number and explained by a structure. CI says the main chunk grew 84 KB, and the only thing that explains why is a treemap and a module graph somebody has to open.

So the number goes into a PR comment, the structure stays on the machine that built it, and the fix is somebody guessing which dependency came back.

webpack --json > stats.json
npx @statoscope/cli generate stats.json -o report.html

One self-contained file: treemap, chunk breakdown, module reasons, and Statoscope's validation rules.

The diff is the report

The single-build view is interesting. The comparison is actionable:

npx @statoscope/cli generate stats.json \
  --reference main-stats.json \
  -o report.html

That renders what changed against the base branch — added modules, grown chunks, duplicated packages — which is the exact question a reviewer has and the exact question a size number cannot answer.

Publish it per pull request

Drop report.html into Comma, or from CI:

npx @statoscope/cli generate stats.json --reference main-stats.json -o report.html

REPORT=$(curl -fsS -X POST "https://commareports.com/api/v1/reports" \
  -H "Authorization: Bearer $COMMA_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --rawfile html report.html \
        --arg t "Bundle — PR #$PR_NUMBER" '{title: $t, html: $html}')")

echo "Bundle report: $(echo "$REPORT" | jq -r .url)" >> "$GITHUB_STEP_SUMMARY"

Scripts run inside a sandboxed iframe (allow-scripts, no allow-same-origin), so the treemap zooms and the module search works. See the API reference and publishing from CI.

A new report per PR keeps each comparison with the change it belongs to. For the trunk build, PATCH one saved id instead: the URL becomes the standing bundle page and each publish appends a revision, so the growth curve is scrubbable rather than remembered.

Validation, then the link

Statoscope's validation rules turn "the bundle got big" into a gate:

// statoscope.config.js — fail on a package appearing twice, or a chunk over budget

Gate on the rule; publish the report either way. The run that trips the rule is the one where somebody needs to see the treemap, and a job that exits before publishing throws away the only artifact that explains the failure.

Comments beat a size number

A bundle review is a short conversation with a specific answer: which import did this, and is it worth it. Anchored threads keep both halves on the chunk — "this is moment coming back through the date picker; switching to date-fns in #4102" — so the next person reads the resolution instead of rediscovering the cause. See commenting on HTML.

Limits

  • Entry HTML: 5 MB. A very large stats file produces a large report — Statoscope's --compression option and trimming the stats to the fields it needs both help.
  • Assets: 25 MB per file, 250 MB and 500 files total.
  • 60 requests/minute per token.

Try it

Comma is free — unlimited reports, unlimited commenters, unlimited revision history.

Publish a bundle report →

Related