From 40dd80a41e3b4c84e3b658077dd6ae4d00fcc4ef Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Sun, 15 Mar 2026 19:35:07 -0600 Subject: [PATCH] fix(voice): replace __dirname with import.meta.dirname for ESM compat Co-Authored-By: Claude Opus 4.6 (1M context) --- src/resources/extensions/voice/index.ts | 7 ++++--- src/tests/extension-smoke.test.ts | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/resources/extensions/voice/index.ts b/src/resources/extensions/voice/index.ts index 3c5698fa1..69b0069f3 100644 --- a/src/resources/extensions/voice/index.ts +++ b/src/resources/extensions/voice/index.ts @@ -7,9 +7,10 @@ import * as fs from "node:fs"; import * as path from "node:path"; import * as readline from "node:readline"; -const SWIFT_SRC = path.join(__dirname, "speech-recognizer.swift"); -const RECOGNIZER_BIN = path.join(__dirname, "speech-recognizer"); -const PYTHON_SCRIPT = path.join(__dirname, "speech-recognizer.py"); +const __extensionDir = import.meta.dirname!; +const SWIFT_SRC = path.join(__extensionDir, "speech-recognizer.swift"); +const RECOGNIZER_BIN = path.join(__extensionDir, "speech-recognizer"); +const PYTHON_SCRIPT = path.join(__extensionDir, "speech-recognizer.py"); const IS_DARWIN = process.platform === "darwin"; const IS_LINUX = process.platform === "linux"; diff --git a/src/tests/extension-smoke.test.ts b/src/tests/extension-smoke.test.ts index cf41ecd7b..1177a09ce 100644 --- a/src/tests/extension-smoke.test.ts +++ b/src/tests/extension-smoke.test.ts @@ -26,9 +26,6 @@ const SKIP_EXTENSIONS = new Set([ // rewrites .js→.ts imports and fails because core.ts doesn't exist. // Works fine at runtime via jiti which loads core.js directly. "browser-tools", - // Uses __dirname at module scope — valid in CJS/jiti but crashes in ESM test runner. - // TODO: fix voice/index.ts to use import.meta.dirname or fileURLToPath(import.meta.url) - "voice", ]); test("all bundled extensions can be imported without throwing", async () => {