Skip to content

perf(dashboard): Split first-load vendor code into stable chunks - #2818

Merged
BYK merged 1 commit into
mainfrom
perf/dashboard-vendor-chunks
Nov 7, 2026
Merged

BYK merged 1 commit into
mainfrom
perf/dashboard-vendor-chunks

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

#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 after
Transcript before after

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.

via @BYK.

--

View Session in Sentry

@vercel

vercel Bot commented Nov 6, 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 6, 2026 2:14pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Captured Memories Popover · Mobile
Conversation Captured Memories Popover · Mobile
Changed
Conversation Child Agents · Desktop
Conversation Child Agents · Desktop
Changed
Conversation Child Agents · Mobile
Conversation Child Agents · Mobile
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Details Watched Linked Work · Mobile
Conversation Details Watched Linked Work · Mobile
Changed
Show 4 more changed screenshots
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Recalled Memories Popover · Desktop
Conversation Recalled Memories Popover · Desktop
Changed
Conversation Recalled Memories Popover · Mobile
Conversation Recalled Memories Popover · Mobile
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@BYK
BYK merged commit ca64902 into main Nov 7, 2026
43 checks passed
@BYK
BYK deleted the perf/dashboard-vendor-chunks branch November 7, 2026 00:56
BYK added a commit that referenced this pull request Nov 9, 2026
…ndor chunk (#2993)

After #2818, `vendor` (~227 KB br) still changed in 0.286.0 and 0.287.0,
with no dependency change. App code had added lucide icons
(`corner-left-up`, then `bell` and `bell-off`). Each new icon adds a
module to the chunk that holds lucide. That changed `vendor`'s hash and
its export names, so the small app chunks that import from it changed
too.

This PR adds three groups to `tsdown.client.config.ts`:

- **`vendor-icons`:** `lucide-react`.
- **`vendor-ui`:** `@base-ui/*`. App code imports Base UI the same way,
one component at a time.
- **`junior`:** the `@sentry/junior` workspace package.

The `vendor` test now checks the whole module path. pnpm injects
`@sentry/junior` under `node_modules/.pnpm/...`, so the old lookahead
`node_modules[\\/](?!@sentry[\\/]junior)` matched the `.pnpm` segment
and let 120 KB of `@sentry/junior` into `vendor`. Its build changes with
core releases, so `vendor` could change even when the dashboard didn't.
Excluding it from `vendor` without giving it a group of its own split
the first load into 31–33 small chunks. The `junior` group keeps it in
one chunk. That group has the lowest priority so that `vendor` takes zod
first; otherwise zod would come in as a dependency of `@sentry/junior`.

## Which packages get their own group

New named imports in the last 21 days of dashboard commits (248
commits), counting only names that were not imported anywhere before:

| Package | Commits that add a new import |
|---|---|
| `lucide-react` (icons) | 28 |
| `@base-ui/react` (components) | 11 |
| `@tanstack/react-query` (hooks) | 4, one of them type-only |

react-query stays in `vendor`. Its new hooks rarely add modules, and
another group would cost one more preload.

## Hash stability

On both main and this branch I added one new icon (`Anchor`, in
`CommandPalette`) to first-load app code and rebuilt. These first-load
files got a new hash:

| | main | this PR |
|---|---|---|
| First-load files | 9 | 2 |
| Files | `client` (109,104 B), `vendor` (226,584 B), `format`,
`PageHeader`, `tooltip`, `PageContentSkeleton`, `button`, `schema`,
`skeleton` | `client` (108,873 B), `vendor-icons` (7,190 B) |
| First-load bytes to download again (br) | 345,018 B | 116,063 B |
| All changed files, including lazy route chunks | 46 files, 560,467 B |
35 files, 238,298 B |

## Cold first load

Chromium, built dashboard with mock data, JS only, br-11:

| Route | main | this PR |
|---|---|---|
| `/conversations` | 19 files, 1,889,070 B raw, 465,975 B br | 22 files,
1,888,141 B raw, 469,249 B br |
| `/conversations/:id` | 26 files, 2,652,793 B raw, 653,291 B br | 29
files, 2,651,864 B raw, 656,532 B br |

- **Preloads:** 18 → 21.
- **Lazy code:** none moved into the first load. Raw first-load bytes
are the same.
- **Cost:** about 3.3 KB br more on a cold load, from the three extra
files.

| Chunk | raw | br |
|---|---|---|
| `vendor` (main) | 893,576 | 226,534 |
| `vendor` | 552,190 | 142,481 |
| `vendor-ui` | 218,712 | 60,737 |
| `junior` | 80,308 | 19,457 |
| `vendor-icons` | 41,388 | 7,113 |

## Screenshots

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

| | main | this PR |
|---|---|---|
| Conversations |
![before](https://junior-prod.sentry.dev/public/artifacts/22ffbf0a-ed44-48ca-893b-5dae335a45f2.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/fc7ee757-8620-4c1a-a077-d0efa105ec95.png)
|
| Transcript |
![before](https://junior-prod.sentry.dev/public/artifacts/56477707-d5d1-483a-a0ba-7ab91a583819.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/60021e83-810c-46ae-93dc-4493fa11706a.png)
|

## Checks

- Full dashboard build on Node 24.22.1
- Dashboard unit tests after the build: 408 passed
- Dashboard `pnpm typecheck` and root `pnpm lint` pass
- `pnpm test:e2e:dashboard`: 128 passed

`pnpm dev` links the injected `@sentry/junior` dist to
`packages/junior/dist`, so bundles from `pnpm dev` split differently:
main gets 31 preloads there. All numbers above come from regular builds,
where pnpm syncs the injected copy after `build`.

<!-- 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 — b6308046 Deployed Nov 6, 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