Skip to content

perf(bundled-dev): serve an already-built lazy route instead of recompiling it on reload - #23502

Draft
h-a-n-a wants to merge 3 commits into
mainfrom
fix/lazy-redirect-to-built-chunk
Draft

h-a-n-a wants to merge 3 commits into
mainfrom
fix/lazy-redirect-to-built-chunk

Conversation

@h-a-n-a

@h-a-n-a h-a-n-a commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Redirect the lazy request to the already-built lazy route instead of recompiling it again on reload.

@h-a-n-a
h-a-n-a force-pushed the fix/lazy-redirect-to-built-chunk branch from 0f16ec9 to 1b9850a Compare September 17, 2026 06:57
@h-a-n-a h-a-n-a changed the title fix(bundled-dev): serve an already-built lazy route instead of recompiling it on reload perf(bundled-dev): serve an already-built lazy route instead of recompiling it on reload Sep 17, 2026
…n it is safe

A full-build chunk runs and re-registers every module in it, so a client that
already holds one of those modules from a lazy payload would run it twice. The
redirect is now allowed only for a client that took no lazy payload and saw no
full build since it connected.

The bundle state is read after the running build finished, because an edit
marks the output stale only when its HMR task ends. Before, a request during
that task was answered with the pre-edit chunk.

Also: the redirect lookup is inside the middleware's try/catch, and the proxy
stubs are left out of the chunk map.

Claude-Session: https://claude.ai/code/session_01P1jv1ZxTBDDWFXbV6YA3Hm
@h-a-n-a
h-a-n-a force-pushed the fix/lazy-redirect-to-built-chunk branch from 43e9dd6 to ffd188b Compare September 18, 2026 06:34
The map is keyed by rolldown's module id, which keeps backslashes on Windows.

Claude-Session: https://claude.ai/code/session_01P1jv1ZxTBDDWFXbV6YA3Hm
@h-a-n-a
h-a-n-a marked this pull request as ready for review September 21, 2026 07:29
@h-a-n-a
h-a-n-a requested a review from sapphi-red September 21, 2026 07:29
@sapphi-red

sapphi-red commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Just in case, does this require a specific version of Rolldown? I guess no

@sapphi-red

Copy link
Copy Markdown
Member

Even if 302 is used, the browser treats the module as a different instance, would that be fine?
(haven't deeply thought)

@h-a-n-a

h-a-n-a commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

does this require a specific version of Rolldown?

I guess no, but this is actually built and tested on top of rolldown/rolldown#11000. We can delay it until it has been released. Let me draft it.

@h-a-n-a

h-a-n-a commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Even if 302 is used, the browser treats the module as a different instance, would that be fine?

This is only supposed to work on page refresh (instead of compiling all over again, it redirects the requests to already served chunks), so i think it will be fine.

@h-a-n-a
h-a-n-a marked this pull request as draft September 30, 2026 01:32

This branch has not been deployed

No deployments
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.

2 participants