refactor: use getGlobalThis when attachting hmr runtime

This commit is contained in:
Evan You 2021-09-23 11:53:00 -04:00
parent 114b856fd1
commit 1e5a0db4d4

View File

@ -8,7 +8,7 @@ import {
isClassComponent
} from './component'
import { queueJob, queuePostFlushCb } from './scheduler'
import { extend } from '@vue/shared'
import { extend, getGlobalThis } from '@vue/shared'
export let isHmrUpdating = false
@ -26,16 +26,7 @@ export interface HMRRuntime {
// 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.
if (__DEV__) {
const globalObject: any =
typeof global !== 'undefined'
? global
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: {}
globalObject.__VUE_HMR_RUNTIME__ = {
getGlobalThis().__VUE_HMR_RUNTIME__ = {
createRecord: tryWrap(createRecord),
rerender: tryWrap(rerender),
reload: tryWrap(reload)