Skip to content

Commit ee68c52

Browse files
committed
build: avoid exporting setDevTools in global prod build
1 parent b4ebe7a commit ee68c52

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/runtime-core/src/devtools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum DevtoolsHooks {
2121
PERFORMANCE_END = 'perf:end'
2222
}
2323

24-
interface DevtoolsHook {
24+
export interface DevtoolsHook {
2525
enabled?: boolean
2626
emit: (event: string, ...payload: any[]) => void
2727
on: (event: string, handler: Function) => void

packages/runtime-core/src/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,18 @@ export const ErrorTypeStrings = (
150150
) as typeof _ErrorTypeStrings
151151

152152
// For devtools
153-
export { devtools, setDevtoolsHook } from './devtools'
153+
import {
154+
devtools as _devtools,
155+
setDevtoolsHook as _setDevtoolsHook,
156+
DevtoolsHook
157+
} from './devtools'
158+
159+
export const devtools = (
160+
__DEV__ || __FEATURE_PROD_DEVTOOLS__ ? _devtools : undefined
161+
) as DevtoolsHook
162+
export const setDevtoolsHook = (
163+
__DEV__ || __FEATURE_PROD_DEVTOOLS__ ? _setDevtoolsHook : NOOP
164+
) as typeof _setDevtoolsHook
154165

155166
// Types -------------------------------------------------------------------------
156167

@@ -377,6 +388,7 @@ import {
377388
softAssertCompatEnabled
378389
} from './compat/compatConfig'
379390
import { resolveFilter as _resolveFilter } from './helpers/resolveAssets'
391+
import { NOOP } from '@vue/shared'
380392

381393
/**
382394
* @internal only exposed in compat builds

0 commit comments

Comments
 (0)