You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
/@vite/client stub's createHotContext returns a hot context without the documented "data" property #11528
I am doing: running unit tests with environment: 'happy-dom'. Vite's importAnalysis
plugin rewrites any module whose source references import.meta.hot by prepending
and Vitest serves the /@vite/client id with a hard-coded stub (defaultClientStub in packages/vitest/src/runtime/moduleRunner/moduleEvaluator.ts).
What I expect is: the stub's hot context to honor the documented ViteHotContext contract
(https://vite.dev/guide/api-hmrreadonly data, "Vite creates one import.meta.hot.data
object for each module path"). The stub already replicates the rest of the surface
(accept, prune, dispose, decline, invalidate, on, send).
What actually happens is: import.meta.hot is the stub object (truthy, so if (import.meta.hot)
guards pass) but import.meta.hot.data is undefined, so any legitimate hot.data[key] reader
crashes. Real-world example: @lexical/extension's HMRExtension (wired with the documented configExtension(HMRExtension, { hot: import.meta.hot ?? null }) pattern) throws TypeError: Cannot read properties of undefined (reading 'lexicalHMR:…') in every unit test
that mounts an editor.
createHotContext should probably return undefined, to be honest
Agreed, undefined seems like the right end state it matches what builds already do. Just noting the stub breaks the documented contract today (truthy context, missing data), so seeding it with data: {} would still be worth shipping either way
Activity
sheremet-va commentedon Oct 8, 2026
createHotContextshould probably returnundefined, to be honestAlxs39 commentedon Oct 8, 2026
Agreed,
undefinedseems like the right end state it matches what builds already do. Just noting the stub breaks the documented contract today (truthy context, missingdata), so seeding it withdata: {}would still be worth shipping either way