Revert "fix(hmr): prevent __VUE_HMR_RUNTIME__ from being overwritten by vue runtime in 3rd-party libraries" (#13925)

This reverts commit 1392734ae5.
This commit is contained in:
edison 2025-09-24 18:02:05 +08:00 committed by GitHub
parent 8bb8fb2362
commit 6b68f72673
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 11 deletions

View File

@ -31,18 +31,12 @@ export interface HMRRuntime {
// Note: for a component to be eligible for HMR it also needs the __hmrId option // Note: for a component to be eligible for HMR it also needs the __hmrId option
// to be set so that its instances can be registered / removed. // to be set so that its instances can be registered / removed.
if (__DEV__) { if (__DEV__) {
const g = getGlobalThis() getGlobalThis().__VUE_HMR_RUNTIME__ = {
// vite-plugin-vue/issues/644, #13202
// custom-element libraries bundle Vue to simplify usage outside Vue projects but
// it overwrite __VUE_HMR_RUNTIME__, causing HMR to break.
if (!g.__VUE_HMR_RUNTIME__) {
g.__VUE_HMR_RUNTIME__ = {
createRecord: tryWrap(createRecord), createRecord: tryWrap(createRecord),
rerender: tryWrap(rerender), rerender: tryWrap(rerender),
reload: tryWrap(reload), reload: tryWrap(reload),
} as HMRRuntime } as HMRRuntime
} }
}
const map: Map< const map: Map<
string, string,