Skip to content

chore(bench): add self-contained bundle-size baselines - #826

Merged
harlan-zw merged 2 commits into
mainfrom
chore/bench-selfcontained-baselines
Jul 13, 2026
Merged

harlan-zw merged 2 commits into
mainfrom
chore/bench-selfcontained-baselines

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every bundle fixture in bench/bundle/*.config.ts externalizes hookable, including the "full" variants — so inlining/removing a dependency in a future refactor could move the real bundle size without the tracked numbers catching it.

  • Adds client-sc-build.config.ts / server-sc-build.config.ts: copies of the minimal client/server unbuild configs with externals: ['hookable'] removed, so hookable is inlined into the bundle.
  • Wires the new fixtures (clientSelfContained, serverSelfContained) into bundles.ts and the test:bundle-size script chain.
  • Adds brotli (br) size tracking alongside raw/gzip in update.ts and bundle-report.ts (used by both analyze.ts and report.ts), additive only — existing last.json entries keep their {size, gz} shape, new/regenerated ones get {size, gz, br}.
  • update.ts now merges into last.json instead of overwriting it wholesale, so a partial build (e.g. only the two new self-contained fixtures) can't perturb baselines it didn't rebuild. Required-bundle validation only fires when there's neither a fresh dist file nor a prior committed value.

New baseline numbers

Bundle Raw Gzip Brotli vs externalized equivalent (gzip)
Client (Self-Contained) 13,830 B 5,584 B 5,067 B Client (Minimal, externalized hookable): 5,263 B → +321 B
Server (Self-Contained) 12,255 B 4,971 B 4,480 B Server (Minimal, externalized hookable): 4,658 B → +313 B

Self-contained bundles are larger than their externalized equivalents, as expected (they carry hookable's ~1 kB source instead of assuming it's a shared/deduped external).

Verification

  • git diff bench/bundle/last.json (pre-commit) showed only additions — clientSelfContained / serverSelfContained keys — no changes to any existing values.
  • Ran the two new unbuild configs directly and via the full test:bundle-size chain; numbers are reproducible.
  • Ran a full rebuild of all existing fixtures locally (without re-running update.ts) to confirm bundle-report.ts's new Brotli column renders correctly and last.json stays untouched for pre-existing entries.
  • pnpm lint clean, no unrelated diffs.

Deviations from spec

  • Used bun directly (available in this environment) for update.ts/analyze.ts/report.ts — no fallback needed.
  • bundle-report.ts (shared by analyze.ts and report.ts) also gained a brotliSize/baseBrotliSize pair on BundleData and a new "Brotli" column in the collapsed "All bundles" table, so brotli numbers are visible in the PR comment, not just persisted to last.json. This is additive and doesn't change the gzip-driven grew/shrank/new status logic.

Test plan

  • pnpm lint
  • Built client-sc-build.config.ts and server-sc-build.config.ts directly, confirmed hookable is inlined (visualizer/unbuild output shows hookable/dist/index.mjs bundled in)
  • bun bench/bundle/update.ts merges new keys only, verified via git diff bench/bundle/last.json
  • bun bench/bundle/analyze.ts / report.ts render the new fixtures with a Brotli column

Summary by CodeRabbit

  • New Features

    • Added self-contained client and server bundle builds.
    • Bundle reports now include raw, gzip, and Brotli size metrics.
    • Added bundle-size tracking for the new self-contained outputs.
  • Improvements

    • Bundle baselines now support partial rebuilds while preserving existing results.
    • Bundle-size checks now cover the additional self-contained variants.

Every bundle fixture externalizes hookable, including the "full" ones, so
inlining/removing it in a future refactor could silently move the number
without the report catching it. Add clientSelfContained/serverSelfContained
fixtures that inline hookable, and start tracking brotli size alongside
gzip/raw wherever bundle stats are computed. update.ts now merges into
last.json instead of overwriting it, so a partial build can't perturb
baselines it didn't regenerate.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@harlan-zw, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 738e0493-183c-4905-bdfb-90ea086df184

📥 Commits

Reviewing files that changed from the base of the PR and between 3647c7c and f95c8d0.

📒 Files selected for processing (1)
  • bench/bundle/update.ts
📝 Walkthrough

Walkthrough

The bundle benchmarking pipeline adds self-contained client and server builds, persists Brotli metrics in last.json, and displays raw, gzip, and Brotli sizes in bundle reports. Bundle status comparisons continue to use gzipped size deltas.

Changes

Bundle metrics pipeline

Layer / File(s) Summary
Self-contained bundle builds
bench/bundle/client-sc-build.config.ts, bench/bundle/server-sc-build.config.ts, bench/bundle/bundles.ts, bench/bundle/last.json, package.json
Adds self-contained client and server builds, registers their outputs, stores their baseline metrics, and runs them from the bundle-size test script.
Baseline size persistence
bench/bundle/update.ts
Merges existing bundle statistics, preserves baselines for missing artifacts, and records raw, gzip, and Brotli sizes for rebuilt bundles.
Brotli report rendering
bench/bundle/bundle-report.ts
Collects current and baseline Brotli sizes and adds Brotli and raw-size columns while retaining gzip-based status markers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BundleBuilds
  participant UpdateScript
  participant BaselineFile
  participant BundleReport
  BundleBuilds->>UpdateScript: Generate bundle artifacts
  UpdateScript->>BaselineFile: Read existing statistics
  UpdateScript->>BaselineFile: Write raw, gzip, and Brotli sizes
  BundleReport->>BaselineFile: Read fallback baseline metrics
  BundleReport->>BundleReport: Render raw, gzip, and Brotli columns
Loading

Possibly related PRs

  • unjs/unhead#793: Introduces the baseline comparison and reporting foundation extended by this bundle metrics change.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, conventional, and accurately summarizes the main change: adding self-contained bundle-size baselines.
Description check ✅ Passed The description covers the change, rationale, verification, and baselines, though it doesn't follow the template's checkbox and linked-issue sections exactly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/bench-selfcontained-baselines

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… stats

The merge behavior meant a required bundle that failed to build but had
committed history would silently keep its old numbers. Keep the merge, but
warn per-bundle when a dist file is missing and old stats are carried
forward, mark those rows as (stale) in the console.table output, and print
a summary count. Still throw when a required bundle is missing and has no
history to fall back on.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle Size

✅ No notable changes · 🆕 2 new bundles tracked

All bundles (14)
Bundle Gzipped Brotli Raw
Core
Client (Minimal) 5.1 kB 4.7 kB 12.8 kB ✅
Client (Full) 8.5 kB 7.7 kB 22 kB ✅
Client (Self-Contained) 5.5 kB 4.9 kB 13.5 kB 🆕
Server (Minimal) 4.5 kB 4.1 kB 11.3 kB ✅
Server (Self-Contained) 4.9 kB 4.4 kB 12 kB 🆕
Vue
Vue Client (Minimal) 5.6 kB 5.1 kB 13.8 kB ✅
Vue Client (Full) 9.2 kB 8.4 kB 23.9 kB ✅
Vue Server (Minimal) 5 kB 4.5 kB 12.3 kB ✅
React
React Client (Minimal) 5.6 kB 5 kB 13.8 kB ✅
React Client (Full) 9.4 kB 8.5 kB 24.4 kB ✅
React Server (Minimal) 4.8 kB 4.4 kB 12 kB ✅
Schema.org
Schema.org (Minimal) 9.6 kB 8.7 kB 26.4 kB ✅
Schema.org Imports 0.1 kB 0.1 kB 0.1 kB ✅
Schema.org Vue Meta 0.4 kB 0.3 kB 0.8 kB ✅

⚡ Performance (directional)

✅ No significant change (within CI noise)

All benchmarks (9)
Benchmark PR Δ RME
SSR render (CPU) 0.410 ms ~ noise ±12.2%
SSR render (wall) 0.278 ms ~ noise ±5.8%
SSR allocated / render 267.8 KiB ~ noise —
Schema.org cached render (CPU) 0.388 ms ~ noise ±5.7%
Schema.org cached render (wall) 0.263 ms ~ noise ±2.0%
Schema.org cached allocated / render 145.4 KiB ~ noise —
CSR DOM mutations / nav 38 ~ noise —
CSR re-render (CPU) 0.864 ms ~ noise ±4.8%
CSR re-render (wall) 0.490 ms ~ noise ±1.8%

Baseline: main @ b9254db · 2026-07-12 · gzipped is the headline size metric · perf is directional (shared-runner, gated)

@harlan-zw
harlan-zw merged commit 62c4387 into main Jul 13, 2026
7 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 19, 2026
1 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant