Repository navigation
fix(bake): preserve module identity and HMR update order - #46704
RentnerKev wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Nested name reservation src/bundler/linker_context/renameSymbolsInChunk.rs, src/js_printer/renamer.rs, test/bake/dev/hot.test.ts |
InternalBakeDev reserves names from each file’s module scope before nested renaming. Tests cover barrel dependencies, nested shadowing, and namespace imports. |
Client output and source-map comparison src/runtime/bake/dev_server/incremental_graph.rs, src/runtime/bake/dev_server/finalize.rs, src/runtime/bake/dev_server/packed_map.rs, test/bake/dev/sourcemap.test.ts |
The dev server compares client output with the previous file and adds code to the current chunk only when output changed. Source-map hashes include quoted source contents and their byte lengths. Tests check that earlier HMR maps retain their source contents. |
HMR reload ordering src/runtime/bake/hmr-module.ts, src/runtime/bake/hmr-runtime-client.ts, test/bake/dev/hot.test.ts, test/js/bun/webview/webview-chrome.test.ts |
replaceModules waits for asynchronous reloads before invoking saved self-accept callbacks. The runtime client sets HMR script elements to load synchronously. Tests cover batched updates and browser update ordering. |
Suggested reviewers: alii, jarred-sumner
Priority:
Merge Risk: 
Minimal · up to 954b2
-
No concrete issue in the supplied evidence currently prevents merging, subject to the pending upstream checks.
Pre-merge checks: 
4
- 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.
What does this PR do?
Keep unchanged client modules stable across accepted HMR updates. Deferred-export barrels can be reanalyzed even when their cached module remains valid; their output currently depends on sibling modules in the incremental chunk. Use the existing per-file nested renamer for unminified dev-server factories and reserve each factory's unbound and pinned names locally.
Suppress a non-stale module's replacement only when its code, kind, and complete source map match. Explicitly invalidated or previously failed modules still emit. Include source content in the existing source-map hash so comment-only edits receive a new immutable map URL.
Also preserve update order at both client boundaries:
script.async = falsebefore assigning an HMR blob'ssrc, so a small second update cannot execute before a large first update that supplies its dependency.Promise.allhas settled asynchronous dependencies. This prevents stale sibling exports, duplicate disposal, and callbacks receiving the previous async export.These changes are limited to development output and the existing HMR runtime. They add no dependencies or production bundler modes.
How did you verify your code works?
Base:
a8fcd319be58ad4d284330b86602cfb3c8e49c83. Native release-with-assertions build on Debian 13 x64 in Bun's development container, using Clang 23, the pinned Rust nightly, and--lto=off:bun run rust:check-allfor all 12 configured targets, none skipped. These are cross-target compilation checks.The Chrome regression uses the existing WebView Chrome backend and availability detection. Only a root process supplies Chrome's required
--no-sandboxthrough the existingisRootharness flag.Final combined native validation on Windows x64, Linux x64, and macOS ARM64 passes 7 production and 14 development Router browser tests, plus all 9 imported-helper generator cases and 9 live-browser helper cases per platform. Native macOS: 118 pass and 3 existing todos across nine suites, all 12 selected regressions pass individually, and the Chrome ordering test passes. Complete macOS run. These combined-stack results are separate from the isolated own-draft build above. Upstream Buildkite remains pending. This PR does not include input-map composition, plugin watch dependencies, cached dependency closure delivery, or general cycle-initialization changes. Prepared with AI assistance.