Skip to content

Commit

Permalink
fix: init devtools after feature flag checks
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 24, 2021
1 parent d9f91e2 commit d0ea745
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
12 changes: 10 additions & 2 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import {
NOOP,
hasOwn,
invokeArrayFns,
isArray
isArray,
getGlobalThis
} from '@vue/shared'
import {
queueJob,
Expand Down Expand Up @@ -75,7 +76,8 @@ import { ComponentPublicInstance } from './componentPublicInstance'
import {
devtoolsComponentAdded,
devtoolsComponentRemoved,
devtoolsComponentUpdated
devtoolsComponentUpdated,
setDevtoolsHook
} from './devtools'
import { initFeatureFlags } from './featureFlags'
import { isAsyncWrapper } from './apiAsyncComponent'
Expand Down Expand Up @@ -430,6 +432,12 @@ function baseCreateRenderer(
initFeatureFlags()
}

if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
const target = getGlobalThis()
target.__VUE__ = true
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__)
}

const {
insert: hostInsert,
remove: hostRemove,
Expand Down
8 changes: 1 addition & 7 deletions packages/vue/src/dev.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { setDevtoolsHook, initCustomFormatter } from '@vue/runtime-dom'
import { getGlobalThis } from '@vue/shared'
import { initCustomFormatter } from '@vue/runtime-dom'

export function initDev() {
const target = getGlobalThis()

target.__VUE__ = true
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__)

if (__BROWSER__) {
if (!__ESM_BUNDLER__) {
console.info(
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as runtimeDom from '@vue/runtime-dom'
import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared'
import { InternalRenderFunction } from 'packages/runtime-core/src/component'

if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
if (__DEV__) {
initDev()
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { initDev } from './dev'
import { warn } from '@vue/runtime-dom'

if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
if (__DEV__) {
initDev()
}

Expand Down

0 comments on commit d0ea745

Please sign in to comment.