From d0ea74556f74d8c503ffb7b70f41cbe2ce14db98 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 24 Feb 2021 15:59:38 -0500 Subject: [PATCH] fix: init devtools after feature flag checks --- packages/runtime-core/src/renderer.ts | 12 ++++++++++-- packages/vue/src/dev.ts | 8 +------- packages/vue/src/index.ts | 2 +- packages/vue/src/runtime.ts | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 898ae077d78..bc1d154527b 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -36,7 +36,8 @@ import { NOOP, hasOwn, invokeArrayFns, - isArray + isArray, + getGlobalThis } from '@vue/shared' import { queueJob, @@ -75,7 +76,8 @@ import { ComponentPublicInstance } from './componentPublicInstance' import { devtoolsComponentAdded, devtoolsComponentRemoved, - devtoolsComponentUpdated + devtoolsComponentUpdated, + setDevtoolsHook } from './devtools' import { initFeatureFlags } from './featureFlags' import { isAsyncWrapper } from './apiAsyncComponent' @@ -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, diff --git a/packages/vue/src/dev.ts b/packages/vue/src/dev.ts index d980d20a48b..99ba49a2085 100644 --- a/packages/vue/src/dev.ts +++ b/packages/vue/src/dev.ts @@ -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( diff --git a/packages/vue/src/index.ts b/packages/vue/src/index.ts index 62445c0f411..4874bb0d5f2 100644 --- a/packages/vue/src/index.ts +++ b/packages/vue/src/index.ts @@ -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() } diff --git a/packages/vue/src/runtime.ts b/packages/vue/src/runtime.ts index d69ab48b4f9..1452fceb003 100644 --- a/packages/vue/src/runtime.ts +++ b/packages/vue/src/runtime.ts @@ -3,7 +3,7 @@ import { initDev } from './dev' import { warn } from '@vue/runtime-dom' -if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { +if (__DEV__) { initDev() }