Skip to content

ci: report client bundle size changes on pull requests - #1539

Merged
manudeli merged 4 commits into
mainfrom
manudeli/bundle-size-report
Nov 22, 2026
Merged

manudeli merged 4 commits into
mainfrom
manudeli/bundle-size-report

Conversation

@manudeli

@manudeli manudeli commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Build the exact main base SHA and the PR merge commit in parallel with the existing CI build command.
  • Compare all emitted client JavaScript and CSS in raw and per-file gzip bytes.
  • Compare the gzip size of the JS and CSS listed in the TanStack Start manifest for 15 key pages, including home, library landings, docs, blog, maintainers, showcase, and TanChat. Count shared assets once per page.
  • Post the total and per-page comparisons in one comment on same-repository PRs and update it on subsequent runs. Fork PRs upload the measurements.

Verification

Summary by CodeRabbit

  • Chores
    • Pull requests targeting the main branch now receive JavaScript and CSS bundle-size reports, including page-level totals, in an automatically updated comment.

@manudeli
manudeli requested a review from a team November 22, 2026 15:07
@changeset-bot

changeset-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 14435d2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds a GitHub Actions workflow that builds the base and pull request commits, measures JavaScript, CSS, and configured page gzip sizes, and posts or updates a pull request comment with the comparison.

Changes: Bundle Size Reporting

Layer / File(s) Summary
Build and publish size reports
.github/workflows/bundle-size.yml
The workflow builds the base and pull request commits, measures JavaScript, CSS, and configured page gzip sizes, then uploads each report as an artifact.
Validate reports and prepare comparison
.github/workflows/bundle-size.yml
The comment job downloads both reports, validates their metrics, checks the current pull request state and head SHA, and formats a Markdown comparison.
Create or update the report comment
.github/workflows/bundle-size.yml
The workflow updates an eligible marked bundle-size comment when its content differs. If no marked bot comment exists, it creates one.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant BuildJobs
  participant Artifacts
  participant CommentJob
  participant GitHubPullRequest
  BuildJobs->>Artifacts: Upload base and pull request size reports
  CommentJob->>Artifacts: Download both reports
  CommentJob->>GitHubPullRequest: Fetch current pull request state and head SHA
  CommentJob->>CommentJob: Validate reports and format size comparison
  CommentJob->>GitHubPullRequest: Create or update bundle-size comment
Loading

Suggested reviewers: tannerlinsley

Merge Risk: Minimal · up to 14435

This PR adds a CI workflow that reports client bundle size changes on pull requests. It does not touch application runtime code. No concrete defect was established, and a misconfiguration would most likely show up as a failed report job.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "ci: report client bundle size changes on pull requests" matches the main change. The PR adds a GitHub Actions workflow that builds the base and PR commits, measures client JavaScript and CS…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "ci: report client bundle size changes on pull requests" matches the main change. The PR adds a GitHub Actions workflow that builds the base and PR commits, measures client JavaScript and CSS sizes, and posts or updates a bundle size comment on same-repository PRs. The title is specific, concise, and follows a conventional commit style.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 973edf4f-0a6c-4708-9426-12a33a43161e
Commits

Reviewing files that changed from the base of the PR and between c542d3a and 14435d2.

Files selected for processing: 1

  • .github/workflows/bundle-size.yml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 14435d2 Commit Preview URL

Branch Preview URL
Nov 22 2026, 03:28 PM

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Asset Main PR merge build Change
JavaScript 19617.31 KiB 19617.31 KiB 0.00 KiB (0.00%)
JavaScript (gzip) 6451.46 KiB 6451.46 KiB 0.00 KiB (0.00%)
CSS 795.21 KiB 795.21 KiB 0.00 KiB (0.00%)
CSS (gzip) 121.46 KiB 121.46 KiB 0.00 KiB (0.00%)
Page Main (gzip) PR merge build (gzip) Change
/ 562.46 KiB 562.46 KiB 0.00 KiB (0.00%)
/libraries 532.35 KiB 532.35 KiB 0.00 KiB (0.00%)
/start/latest 557.14 KiB 557.14 KiB 0.00 KiB (0.00%)
/router/latest 557.44 KiB 557.44 KiB 0.00 KiB (0.00%)
/query/latest 555.89 KiB 555.89 KiB 0.00 KiB (0.00%)
/table/latest 588.70 KiB 588.70 KiB 0.00 KiB (0.00%)
/charts/latest 638.01 KiB 638.01 KiB 0.00 KiB (0.00%)
/ai/latest 582.81 KiB 582.81 KiB 0.00 KiB (0.00%)
Docs article 543.42 KiB 543.42 KiB 0.00 KiB (0.00%)
Framework docs article 543.42 KiB 543.42 KiB 0.00 KiB (0.00%)
/blog 536.56 KiB 536.56 KiB 0.00 KiB (0.00%)
/maintainers 535.64 KiB 535.64 KiB 0.00 KiB (0.00%)
/showcase 533.61 KiB 533.61 KiB 0.00 KiB (0.00%)
/chat 532.42 KiB 532.42 KiB 0.00 KiB (0.00%)
/chat/c/:conversationId 532.55 KiB 532.55 KiB 0.00 KiB (0.00%)

Page sizes sum the JS and CSS in the TanStack Start manifest for each route and its layouts. Shared files count once per page.

Compared with main at c542d3a. Gzip sizes are summed per file. Build run

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Scanning only dist/client/assets excludes client JavaScript copied from public, including the registered service worker, leaving the reported JavaScript totals incomplete.

1 open issue
What changed in this PR

Adds client bundle-size reporting to pull-request CI, separating measurement from comment publishing so fork builds retain read-only permissions.

Changes:

  • Builds the exact main base SHA and PR merge commit in parallel.
  • Uploads raw and per-file gzip JavaScript/CSS measurements.
  • Uses a separate workflow to validate reports and update one PR comment, with stale-run checks.
File Description
.github/​workflows/​bundle-size.yml Builds both revisions and uploads size measurements.
.github/​workflows/​bundle-size-comment.yml Validates reports and publishes guarded PR comment updates.

Review effort: Max

Comment thread .github/workflows/bundle-size.yml Outdated
Comment on lines +48 to +60
const entries = readdirSync('dist/client/assets', {
recursive: true,
withFileTypes: true,
})
for (const entry of entries) {
const extension = extname(entry.name).slice(1)
if (!entry.isFile() || (extension !== 'js' && extension !== 'css')) continue
const bytes = readFileSync(join(entry.parentPath, entry.name))
sizes[extension] += bytes.length
sizes[`${extension}Gzip`] += gzipSync(bytes).length
}
if (sizes.js === 0 || sizes.css === 0) {
throw new Error('Expected built JS and CSS in dist/client/assets')
@manudeli
manudeli merged commit 53107bd into main Nov 22, 2026
12 checks passed
@manudeli
manudeli deleted the manudeli/bundle-size-report branch November 22, 2026 15:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The bundle-size workflow omits shipped JavaScript outside dist/client/assets and can miss outer-layout assets when traversing the pruned manifest, producing misleading totals.

3 open issues

Review effort: Max

const client = 'dist/client'
const totals = { js: 0, jsGzip: 0, css: 0, cssGzip: 0 }
const gzipByHref = new Map()
const entries = readdirSync(join(client, 'assets'), {
Comment on lines +74 to +77
const parents = new Map()
for (const [id, route] of Object.entries(routes)) {
for (const child of route.children ?? []) parents.set(child, id)
}
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.

3 participants