fix: init devtools after feature flag checks

This commit is contained in:
Evan You 2021-02-24 15:59:38 -05:00
parent d9f91e26f9
commit d0ea74556f
4 changed files with 13 additions and 11 deletions

View File

@ -36,7 +36,8 @@ import {
NOOP, NOOP,
hasOwn, hasOwn,
invokeArrayFns, invokeArrayFns,
isArray isArray,
getGlobalThis
} from '@vue/shared' } from '@vue/shared'
import { import {
queueJob, queueJob,
@ -75,7 +76,8 @@ import { ComponentPublicInstance } from './componentPublicInstance'
import { import {
devtoolsComponentAdded, devtoolsComponentAdded,
devtoolsComponentRemoved, devtoolsComponentRemoved,
devtoolsComponentUpdated devtoolsComponentUpdated,
setDevtoolsHook
} from './devtools' } from './devtools'
import { initFeatureFlags } from './featureFlags' import { initFeatureFlags } from './featureFlags'
import { isAsyncWrapper } from './apiAsyncComponent' import { isAsyncWrapper } from './apiAsyncComponent'
@ -430,6 +432,12 @@ function baseCreateRenderer(
initFeatureFlags() initFeatureFlags()
} }
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
const target = getGlobalThis()
target.__VUE__ = true
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__)
}
const { const {
insert: hostInsert, insert: hostInsert,
remove: hostRemove, remove: hostRemove,

View File

@ -1,12 +1,6 @@
import { setDevtoolsHook, initCustomFormatter } from '@vue/runtime-dom' import { initCustomFormatter } from '@vue/runtime-dom'
import { getGlobalThis } from '@vue/shared'
export function initDev() { export function initDev() {
const target = getGlobalThis()
target.__VUE__ = true
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__)
if (__BROWSER__) { if (__BROWSER__) {
if (!__ESM_BUNDLER__) { if (!__ESM_BUNDLER__) {
console.info( console.info(

View File

@ -7,7 +7,7 @@ import * as runtimeDom from '@vue/runtime-dom'
import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared' import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared'
import { InternalRenderFunction } from 'packages/runtime-core/src/component' import { InternalRenderFunction } from 'packages/runtime-core/src/component'
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { if (__DEV__) {
initDev() initDev()
} }

View File

@ -3,7 +3,7 @@
import { initDev } from './dev' import { initDev } from './dev'
import { warn } from '@vue/runtime-dom' import { warn } from '@vue/runtime-dom'
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { if (__DEV__) {
initDev() initDev()
} }