fix(bundled-dev): preserve import.meta.hot.data across HMR updates - #23005
Merged
sapphi-red merged 1 commit intoJul 22, 2026
Merged
Conversation
`handleModuleCacheRemoval` allocated a fresh object, handed it to the disposer, and overwrote the `dataMap` entry on every update. This dropped any direct mutation of `import.meta.hot.data` and never showed the disposer the previous object, contradicting Vite's documented contract that `hot.data` is persisted across module instances. Pass the existing `dataMap` entry to the disposer and leave it in place, so a re-executed module reuses the same object via the `HMRContext` ctor — matching the shared HMR client (`shared/hmr.ts`). Adds a `data.js` playground module + test asserting a directly-mutated counter and a dispose-written counter both persist across updates. Closes #23001
h-a-n-a
force-pushed
the
fix/preserve-hot-data-bundled-dev
branch
from
July 22, 2026 03:28
1966948 to
33186aa
Compare
sapphi-red
approved these changes
Jul 22, 2026
sapphi-red
merged commit Jul 22, 2026
f9ec81f
into
renovate/rolldown-related-dependencies
26 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #23001.
In bundled-dev mode,
BundledDevHMRClient.handleModuleCacheRemovalallocated a fresh object, handed it to the dispose callback, and overwrote the module'sdataMapentry on every update:This dropped any direct mutation of
import.meta.hot.dataon every update and never showed the disposer the previous object — the inverse of Vite's documented contract:Fix
Pass the existing
dataMapentry to the disposer and leave it in place, so a re-executed module reuses the same object via theHMRContextconstructor (if (!dataMap.has(ownerPath)) dataMap.set(ownerPath, {})). This mirrors the shared HMR client exactly (shared/hmr.ts):Test
Adds a
data.jsmodule to thehmr-full-bundle-modeplayground that incrementshot.data.counton each execution and adisposedcounter inside itsdispose()callback, plus a spec asserting both persist across successive updates (1/0 → 2/1 → 3/2). This covers both required behaviors: direct-mutation persistence and the disposer receiving the existing object.The test is intentionally ordered before the
invalidatetest — that test's cleanup restoresinvalidation-child.js, whosehot.invalidate()propagates to a parent without a shipped factory and forces a full page reload that would otherwise wipe this test'shot.data.pnpm test-serve hmr-full-bundle-modepasses.Note
Targets the
renovate/rolldown-related-dependenciesbranch (rolldown 1.2.0 + client-side HMR #22883), since that branch carries the renamedBundledDevHMRClient.🤖 Generated with Claude Code