From: Evan You Date: Tue, 26 Dec 2023 03:03:45 +0000 (+0800) Subject: build: avoid exporting setDevTools in global prod build X-Git-Tag: v3.4.0-rc.2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee68c525f06e02c78655ade680a579e4cf85a314;p=thirdparty%2Fvuejs%2Fcore.git build: avoid exporting setDevTools in global prod build --- diff --git a/packages/runtime-core/src/devtools.ts b/packages/runtime-core/src/devtools.ts index 240a4aa04a..bf6f09f326 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 06300cbf68..232afba46f 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