Skip to content

perf(dashboard): Build client scripts with rolldown to merge tiny chunks - #2765

Merged
BYK merged 2 commits into
mainfrom
perf/dashboard-chunk-merge
Nov 5, 2026
Merged

BYK merged 2 commits into
mainfrom
perf/dashboard-chunk-merge

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

The dashboard head preloads 58 modules, and many of them are under 1 KB. esbuild (tsup) splits every set of shared modules into its own chunk and has no minimum chunk size. Rolldown merges shared code into the chunks that load it, so the client scripts now build with tsdown (rolldown), which the repo already uses.

Route splitting from #2734/#2738 and the head preloads from #2738 are unchanged. Every route still loads its page lazily, and the manifest still lists the entry's static imports for modulepreload.

Changes

  • tsdown.client.config.ts builds the client JS. It keeps the defines, the @sentry/junior-plugin-api alias and the content-hashed names (client-[hash].js, chunks/[name]-[hash].js).
    • failOnWarn makes an unresolved import, such as server code reaching node:fs, fail the build, as before.
    • A small plugin emits the avatar .webp with an absolute /_junior/dashboard/assets/... URL. Rolldown's own asset loader gives a page-relative URL.
    • The manifest plugin walks the entry's static imports and finds the stylesheet and first-paint fonts in dist/public.
  • tsup.client.config.ts → tsup.styles.config.ts. esbuild still builds styles.css and the woff2 fonts, because rolldown CSS bundling is still experimental (@tsdown/css). This build runs first and cleans dist/public.
  • Hashes are base36 (hashCharacters: "base36"), so a hash never contains - or _. The asset-name regexes in public-assets.ts now accept lowercase. The stylesheet regex is now one exported constant.
  • build:client runs tsdown with --config-loader unrun, because Node's loader can't resolve the extensionless imports in src/public-assets. unrun (tsdown's recommended loader, which depends only on rolldown) is a new dev dependency. The tsx loader fails on Node 24 when the config imports Node builtins. unrun shims import.meta.resolve as a relative URL, so the plugin API alias uses createRequire.
  • Tests: rolldown writes relative chunk imports ("./chunks/..."), so the chunk regex in two dashboard tests changed.

Numbers

build:client output, br quality 11, first load of /conversations (entry + preloads):

main this PR
modulepreload links 58 21
First-load JS files 59 22
First-load raw 1,702,443 B 1,672,714 B
First-load br 474,749 B 419,596 B (−55 KB, −11.6%)
First-load files < 1 KB 19 5
First-load files < 4 KB 37 12
All files / raw 184 / 6,263,754 B 153 / 6,203,573 B

JS loaded in the browser per route, with mock conversations (files, br):

Route main this PR
/conversations 59, 474.7 KB 22, 419.6 KB
/conversations/:id 62, 652.3 KB 29, 606.9 KB
/system 65, 581.6 KB 32, 526.6 KB
/code 65, 574.9 KB 30, 511.9 KB

Largest files:

  • main: chunk 626 KB, wasm 622 KB, client 555 KB, chunk 383 KB, chunk 205 KB.
  • this PR: client 1,044 KB, cpp grammar 626 KB, wasm 622 KB, chart 324 KB, vue-vine grammar 190 KB.

The entry is larger because rolldown keeps code that the entry always loads in the entry, instead of in separate preloaded chunks. The first-load total goes down. The shiki grammars and the oniguruma wasm stay lazy.

Screenshots

Mock conversations. The pages look the same; the only pixel differences are spinners and the "thinking" shimmer.

main this PR
Conversations before after
Transcript before after

The memory API 404 on the transcript page also happens on main.

Conflicts

This replaces the client build config. Any open PR that changes tsup.client.config.ts or build:client will conflict. The static assets change (#2757) is already merged, and this branch is based on it.

Checks

  • pnpm test:e2e:dashboard: 100/100 passed.
  • Dashboard unit tests after a full pnpm build: 371/371 passed.
  • Dashboard pnpm typecheck, root pnpm lint, prettier on changed files: pass.
  • pnpm install --frozen-lockfile: pass.
  • build:client on Node 24.22.1 (CI's version) and Node 22: same output, entry client-dnc5pi1v.js, 21 preloads.
  • Dashboard unit tests on Node 24 after a full build: 371/371. Dashboard e2e on Node 24: 99/100 on the first run; the one failure (conversation-send "thinking" indicator timing) passed 3/3 on rerun.

via @BYK.

--

View Session in Sentry

esbuild has no minimum chunk size, so the dashboard head preloaded 58
modules, many under 1 KB. Rolldown merges shared code into the chunks
that load it. The stylesheet and fonts stay on esbuild.
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 5, 2026 7:15pm UTC

Request Review

@BYK
BYK enabled auto-merge (squash) November 5, 2026 19:13
tsx fails on Node 24 when the config imports node builtins
(ENOENT 'node:fs?tsx-namespace=...'). unrun bundles the config with
rolldown instead. It shims import.meta.resolve as a relative URL, so the
plugin API alias resolves with createRequire.
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

4 screenshot changes — 4 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Page · Desktop
Automation Page · Desktop
Changed
Conversation Event Log Virtual · Desktop
Conversation Event Log Virtual · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@BYK
BYK merged commit 36511d4 into main Nov 5, 2026
46 checks passed
@BYK
BYK deleted the perf/dashboard-chunk-merge branch November 5, 2026 19:23
BYK added a commit that referenced this pull request Nov 5, 2026
…#2767)

When a PR was approved, Junior's replies made claims about whether it
could merge without checking. Two examples:

- "your approval is on the previous commit … it'll need a quick
re-approve". On #2765, the approval still counted: the ruleset has
`dismiss_stale_reviews_on_push: false` and `require_last_push_approval:
false`. The PR was blocked only by the pending `ci / required` check.
- "it can be merged cleanly. I haven't merged it." This was after the
requester had already turned on auto-merge.

Junior's read-only installation token can read everything needed to get
this right: `autoMergeRequest`, `mergeStateStatus`, `reviewDecision`,
`gh pr checks --required`, and `GET
/repos/{o}/{r}/rules/branches/{branch}`. Classic branch protection
(`/branches/{b}/protection`) needs `administration: read`, which the app
doesn't have, so this change doesn't use it.

## Changes

- **Approval guidance** (`pull_request.review.approved`): before Junior
says anything about merging, it reads auto-merge, the merge state, the
review decision and the required checks. If auto-merge is on and only
checks remain, it says only that the PR merges when they pass. If
something else blocks it, it reads the branch rules and names the
blocking rule. It no longer says "I haven't merged it".
- **Ready-to-merge notice**: a PR with auto-merge on gets no notice.
Turning auto-merge on closes an open notice ("Auto-merge is on."), and
turning it off brings the notice back. `auto_merge_enabled` and
`auto_merge_disabled` now trigger the check. Reviews are not read when
auto-merge is on.
- **`github-code` api-surface**: adds commands for PR merge blockers and
branch merge rules.

## Checks

- `@sentry/junior-github` tests: 286/286 passed. The ready-notice
scenario now covers turning auto-merge on and off.
- `@sentry/junior-github` typecheck and `pnpm skills:check`: pass.

## Open

There is no eval for the approval reply wording yet. The guidance change
is checked only by the tests above, not with an LLM.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A696275a96da32dcbea1f856e -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A696275a96da32dcbea1f856e/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
BYK added a commit that referenced this pull request Nov 7, 2026
#2765 merged most first-load code into the entry, which grew it to 1,202
KB raw (281 KB br). The entry hash changes on every deploy, so each
deploy makes the next visit download all of it again.

This adds rolldown `codeSplitting.groups` to `tsdown.client.config.ts`.
Third-party code that the first load imports goes into three vendor
chunks:

- `vendor-react`: react, react-dom, scheduler, react-router
- `vendor-sentry`: the Sentry SDK (`@sentry/*` except the
`@sentry/junior*` workspace packages)
- `vendor`: all other first-load `node_modules`

The `$initial` tag limits each group to modules that the entry imports
statically. Lazy pages, the chart, grammars, and wasm stay lazy. App
code and workspace packages stay in the entry and route chunks.

## Hash stability

I built main and this branch, then changed one string (the
`CommandPalette` placeholder) and rebuilt each.

| | main | this PR |
|---|---|---|
| Files with a new hash | 33 | 27 |
| First-load files with a new hash | 1 (entry) | 1 (entry) |
| First-load bytes to download again | 280,599 B br | 97,541 B br |
| All changed bytes, incl. lazy route chunks | 491,186 B br | 214,012 B
br |

The three vendor chunks keep their hashes. The lazy route chunks still
change because they import shared app code from the entry. That is the
same on main.

| Chunk | raw | br |
|---|---|---|
| entry (main) | 1,201,783 | 280,643 |
| entry (this PR) | 486,650 | 97,520 |
| `vendor` | 886,741 | 225,084 |
| `vendor-react` | 285,775 | 77,310 |
| `vendor-sentry` | 127,891 | 37,621 |

A dependency update changes only the vendor chunk that holds it.

## Cold first load

JS fetched by Chromium with the mock dashboard (br-11):

| Route | main | this PR |
|---|---|---|
| `/conversations` | 23 files, 1,833,935 B raw, 460,671 B br | 18 files,
1,832,478 B raw, 452,514 B br |
| `/conversations/:id` | 30 files, 2,597,624 B raw, 647,970 B br | 25
files, 2,596,201 B raw, 639,884 B br |

modulepreloads: 22 → 17. The groups also take in 5 small `node_modules`
chunks.

## Screenshots

The pages look the same. The only pixel differences are the loading
spinner and the thinking shimmer.

| | main | this PR |
|---|---|---|
| Conversations |
![before](https://junior-prod.sentry.dev/public/artifacts/44d23cfc-f577-4b66-a39a-b58ffa74f9e7.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/d54b564a-e417-4ec2-aa45-078a330ae61d.png)
|
| Transcript |
![before](https://junior-prod.sentry.dev/public/artifacts/aad46535-e52a-4673-ba18-0b01810b9ab9.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/1f6596a7-4172-475a-b05d-a3528b98cebe.png)
|

## Checks

- Full dashboard build on Node 24.22.1
- Dashboard unit tests after the build: 378 passed
- `pnpm typecheck` (dashboard) and root `pnpm lint` pass
- `pnpm test:e2e:dashboard`: 103 passed, 1 failed. The failure is
`conversations-read-position.spec.ts` "catches the reader up on several
unread Turns" (`toBeInViewport`). It is flaky on main too: it failed 3
of 8 runs against a main build.

I took the measurements on main `e889f3909`, then rebased onto
`d987bf7dd`. The rebase did not touch the build config.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A596398f356e0f4652790df29aec95726 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/agent%3A596398f356e0f4652790df29aec95726/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 3e39bbb1 Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant