From ee68c525f06e02c78655ade680a579e4cf85a314 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 11:03:45 +0800 Subject: [PATCH] build: avoid exporting setDevTools in global prod build --- packages/runtime-core/src/devtools.ts | 2 +- packages/runtime-core/src/index.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/devtools.ts b/packages/runtime-core/src/devtools.ts index 240a4aa04a7..bf6f09f3267 100644 --- a/packages/runtime-core/src/devtools.ts +++ b/packages/runtime-core/src/devtools.ts @@ -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 diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 06300cbf68f..232afba46f1 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -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