]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
build: avoid exporting setDevTools in global prod build
authorEvan You <yyx990803@gmail.com>
Tue, 26 Dec 2023 03:03:45 +0000 (11:03 +0800)
committerEvan You <yyx990803@gmail.com>
Tue, 26 Dec 2023 03:03:45 +0000 (11:03 +0800)
packages/runtime-core/src/devtools.ts
packages/runtime-core/src/index.ts

index 240a4aa04a781ec5d02a2ac988ac364dcee29618..bf6f09f32676328c4f3726d3462a6fd4d512ed70 100644 (file)
@@ -21,7 +21,7 @@ enum DevtoolsHooks {
   PERFORMANCE_END = 'perf:end'
 }
 
-interface DevtoolsHook {
+export interface DevtoolsHook {
   enabled?: boolean
   emit: (event: string, ...payload: any[]) => void
   on: (event: string, handler: Function) => void
index 06300cbf68f2d440f745f7ef00e5ea0f775163cd..232afba46f1367ba6683119ffad138de9c14738a 100644 (file)
@@ -150,7 +150,18 @@ export const ErrorTypeStrings = (
 ) as typeof _ErrorTypeStrings
 
 // For devtools
-export { devtools, setDevtoolsHook } from './devtools'
+import {
+  devtools as _devtools,
+  setDevtoolsHook as _setDevtoolsHook,
+  DevtoolsHook
+} from './devtools'
+
+export const devtools = (
+  __DEV__ || __FEATURE_PROD_DEVTOOLS__ ? _devtools : undefined
+) as DevtoolsHook
+export const setDevtoolsHook = (
+  __DEV__ || __FEATURE_PROD_DEVTOOLS__ ? _setDevtoolsHook : NOOP
+) as typeof _setDevtoolsHook
 
 // Types -------------------------------------------------------------------------
 
@@ -377,6 +388,7 @@ import {
   softAssertCompatEnabled
 } from './compat/compatConfig'
 import { resolveFilter as _resolveFilter } from './helpers/resolveAssets'
+import { NOOP } from '@vue/shared'
 
 /**
  * @internal only exposed in compat builds