From 111f76849e2dea62f8c44cc42f10bbc06bff2cd1 Mon Sep 17 00:00:00 2001 From: Akuria <46207353+Akur1a@users.noreply.github.com> Date: Mon, 11 May 2026 23:18:42 +0800 Subject: [PATCH] fix: check for __VUE_INSPECTOR__ before calling openInEditor When Options API is disabled via @vitejs/plugin-vue features config, the Vue compiler does not initialize __VUE_INSPECTOR__, causing a TypeError when trying to open a component in the editor. Add a null check for target.__VUE_INSPECTOR__ before calling openInEditor, and log a helpful warning when the inspector is not available. Fixes #824 --- packages/devtools-kit/src/core/open-in-editor/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/devtools-kit/src/core/open-in-editor/index.ts b/packages/devtools-kit/src/core/open-in-editor/index.ts index 65ca37852..09199b602 100644 --- a/packages/devtools-kit/src/core/open-in-editor/index.ts +++ b/packages/devtools-kit/src/core/open-in-editor/index.ts @@ -29,7 +29,12 @@ export function openInEditor(options: OpenInEditorOptions = {}) { } else if (devtoolsState.vitePluginDetected) { const _baseUrl = target.__VUE_DEVTOOLS_OPEN_IN_EDITOR_BASE_URL__ ?? baseUrl - target.__VUE_INSPECTOR__.openInEditor(_baseUrl, file, line, column) + if (target.__VUE_INSPECTOR__) { + target.__VUE_INSPECTOR__.openInEditor(_baseUrl, file, line, column) + } + else { + console.warn('[Vue DevTools] Component inspector is not available. If you have disabled the Options API, the component inspector may not be initialized.') + } } } }