diff --git a/src/cli/browser-cli-extension.ts b/src/cli/browser-cli-extension.ts index cc3ceca2e..735d2e57a 100644 --- a/src/cli/browser-cli-extension.ts +++ b/src/cli/browser-cli-extension.ts @@ -16,10 +16,20 @@ function bundledExtensionRootDir() { const here = path.dirname(fileURLToPath(import.meta.url)); // `here` is the directory containing this file. - // - In npm installs, that's typically `/dist/cli`. // - In source runs/tests, it's typically `/src/cli`. + // - In transpiled builds, it's typically `/dist/cli`. + // - In bundled builds, it may be `/dist`. // The bundled extension lives at `/assets/chrome-extension`. - return path.resolve(here, "../../assets/chrome-extension"); + // + // Prefer the most common layouts first and fall back if needed. + const candidates = [ + path.resolve(here, "../assets/chrome-extension"), + path.resolve(here, "../../assets/chrome-extension"), + ]; + for (const candidate of candidates) { + if (hasManifest(candidate)) return candidate; + } + return candidates[0]!; } function installedExtensionRootDir() {