From 863d591f4162ca1cceab418692d12743603c6969 Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Wed, 8 Apr 2026 12:52:00 -0500 Subject: [PATCH] fix: VS Code extension activation and YAML file support - Add mainFields to esbuild config so jsonc-parser ESM build is used, fixing the unbundled ./impl/format require - Add onCommand activation event so the command works before the editor/panel is opened - Support dockercompose, github-actions-workflow, and home-assistant language IDs --- apps/vscode/esbuild.mjs | 1 + apps/vscode/package.json | 5 +++-- apps/vscode/src/extension.ts | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/vscode/esbuild.mjs b/apps/vscode/esbuild.mjs index 9e3f2b1..1725fef 100644 --- a/apps/vscode/esbuild.mjs +++ b/apps/vscode/esbuild.mjs @@ -24,6 +24,7 @@ const extensionConfig = { target: "node18", sourcemap: !isProduction, minify: isProduction, + mainFields: ["module", "main"], alias: workspaceAliases, }; diff --git a/apps/vscode/package.json b/apps/vscode/package.json index bf3e9c9..f3d39cd 100644 --- a/apps/vscode/package.json +++ b/apps/vscode/package.json @@ -15,7 +15,8 @@ ], "activationEvents": [ "onCustomEditor:visualJson.editor", - "onView:visualJson.panel" + "onView:visualJson.panel", + "onCommand:visualJson.openWithVisualJson" ], "main": "./dist/extension.js", "contributes": { @@ -46,7 +47,7 @@ "type": "webview", "id": "visualJson.panel", "name": "visual-json", - "when": "resourceLangId == json || resourceLangId == jsonc || resourceLangId == yaml" + "when": "resourceLangId == json || resourceLangId == jsonc || resourceLangId == yaml || resourceLangId == dockercompose || resourceLangId == github-actions-workflow || resourceLangId == home-assistant" } ] }, diff --git a/apps/vscode/src/extension.ts b/apps/vscode/src/extension.ts index f848b50..2d2a977 100644 --- a/apps/vscode/src/extension.ts +++ b/apps/vscode/src/extension.ts @@ -28,11 +28,17 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.commands.registerCommand("visualJson.openWithVisualJson", () => { const activeEditor = vscode.window.activeTextEditor; + const yamlLike = new Set([ + "yaml", + "dockercompose", + "github-actions-workflow", + "home-assistant", + ]); if ( activeEditor && (activeEditor.document.languageId === "json" || activeEditor.document.languageId === "jsonc" || - activeEditor.document.languageId === "yaml") + yamlLike.has(activeEditor.document.languageId)) ) { vscode.commands.executeCommand( "vscode.openWith",