Repository navigation
fix(bake): invalidate affected framework client bundles - #46705
RentnerKev wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Identify and emit cached module paths src/runtime/bake/dev_server/incremental_graph.rs, src/runtime/bake/dev_server/finalize.rs, src/runtime/bake/dev_server/render.rs, test/bake/dev/bundle.test.ts |
The dev server traces client imports and adds cached module paths to HMR output when a cached-module boundary exists. Framework bundles are invalidated when their client file is marked in client_bits. The initial-response options set the boundary to None. Tests verify that editing a client entry point or its imported message module updates the client bundle and script URL. |
Filter cached modules during HMR src/runtime/bake/hmr-runtime-client.ts, src/runtime/bake/hmr-module.ts, test/bake/dev/bundle.test.ts |
The HMR callback passes optional cached module IDs to replaceModules. That function removes registered cached modules from the incoming update and adjusts source-map references. Tests cover eager, edited, transitive, and cyclic cached dependency closures. |
Suggested reviewers: alii
Priority:
Merge Risk: 
Minimal · up to 32f01
-
No merge-blocking issue was identified; the change is ready for normal merge checks.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title "fix(bake): invalidate affected framework client bundles" matches the main change. The diff adds logic in finalize_bundle that invalidates framework route bundles when a client file changes, which is the primary objective. The title does not mention the second part of the PR, which adds cached client-dependency closure restoration (cached_modules_start, include_cached_imports, replaceModules cachedModules). That omission is acceptable because the title need not cover every detail.
Full details: Description check
-
Explanation
The pull request description includes both required sections. It clearly explains the cache invalidation and cached dependency closure changes. It also provides detailed verification steps, test results, build details, and remaining validation limits.
-
- 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.
Comment @coderabbitai help to get the list of available commands.
|
I compared this with #42841, which fixes the same stale client script. These are the results on a debug build of main (179664e) with the two commits of this PR applied:
Two checks in that test file fail on main and with this PR. Both are outside the scope here:
#42841 will drop its client entry point part, because this PR covers it. The tests are here if they are useful: bun/test/bake/dev/bundle.test.ts Lines 417 to 575 in c245802 |
What does this PR do?
Invalidate a custom framework route's cached client bundle when its client entry or an imported module changes. HMR receives the new code, but a fresh page request can otherwise receive the old cached script and URL. Reuse the existing pass that traces affected client importers and decode the stored opaque client file ID before checking the client graph bitset.
Also include a cached dependency's reachable client definitions when an update introduces an edge to that dependency. After one document switches A to B, a newly loaded document only contains B; switching back to cached A must send A's dependency closure again. Trace the closure after graph edges have been updated and mark these additional definitions as fill-only, preserving modules and identities already loaded by other documents. This covers eager, edited, transitive, and cyclic dependencies.
How did you verify your code works?
Based on upstream
a8fcd319be58ad4d284330b86602cfb3c8e49c83. Native release-with-assertions build on Debian 13 x64 in the documented Bun development container, with Clang 23, the pinned Rust nightly, and--lto=off:bun run build:assert --lto=off -j2 test test/bake/dev/bundle.test.ts test/bake/dev/hot.test.ts test/bake/dev/plugins.test.ts test/bake/dev/sourcemap.test.ts test/bake/serve-plugins-dev-server.test.ts test/bake/dev/esm.test.tsbun run rust:check-all: all 12 configured targets pass, none skipped. These are compile checks, not native execution on twelve platforms.The tests use public APIs. The cached-closure implementation does not require the companion script-ordering change: its optional callback argument extends the existing upstream HMR queue metadata.
The final combined native Windows x64, Linux x64, and macOS ARM64 candidates pass 7 production and 14 development Router browser cases each without skips, including fresh-document cached dependency restoration and authored source maps. All 9 imported-helper generator cases and 9 live-browser helper cases pass per platform. The complete macOS run also passes 118 tests across nine native suites (3 existing todos), all 12 selected regressions individually, and the Chrome ordering test. These are integration-stack runs; isolated-branch Windows/macOS execution and upstream CI remain outstanding. Prepared with AI assistance; ready for maintainer review.