Skip to content

Commit 71dc042

Browse files
committed
fix: not init extensionPath for browser env
1 parent 48ce083 commit 71dc042

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/extensionPath.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { fileURLToPath } from "url";
2-
import path from "path";
1+
let CHROME_INSPECTOR_SYNC_EXTENSION_PATH: string | undefined;
32

4-
const __filename = fileURLToPath(import.meta.url);
5-
const __dirname = path.dirname(__filename);
3+
if (typeof window === "undefined") {
4+
const u = "url";
5+
const { fileURLToPath } = await import(u);
6+
const p = "path";
7+
const path = await import(p);
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
610

7-
export const CHROME_INSPECTOR_SYNC_EXTENSION_PATH = path.join(
8-
__dirname,
9-
"extension",
10-
);
11+
CHROME_INSPECTOR_SYNC_EXTENSION_PATH = path.join(__dirname, "extension");
12+
}
13+
14+
export { CHROME_INSPECTOR_SYNC_EXTENSION_PATH };

0 commit comments

Comments
 (0)