Skip to content

Commit d77a52a

Browse files
committed
fix: produciton bundle by obfusicate dynamic import package with array
export "browser" won't solve the problem for Inspector, which have to dup the whole file
1 parent dd0d7f6 commit d77a52a

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Inspector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import highlightConfig from "./highlightConfig.js";
1414
let JSDOM: any = null;
1515

1616
if (typeof window === "undefined") {
17-
const s = "jsdom"; // somehow have to do this to avoid bundler issue
18-
JSDOM = (await import(s)).JSDOM;
17+
const pkgs = typeof window === "undefined" ? ["jsdom"] : [];
18+
JSDOM = (await import(pkgs[0])).JSDOM;
1919
}
2020

2121
function findNodeIdx(nodes: CDPNode[], nodeId: number): number {

src/extensionPath.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
let CHROME_INSPECTOR_SYNC_EXTENSION_PATH: string | undefined;
22

3+
const pkgs = typeof window === "undefined" ? ["url", "path"] : [];
4+
35
if (typeof window === "undefined") {
4-
const u = "url";
5-
const { fileURLToPath } = await import(u);
6-
const p = "path";
7-
const path = await import(p);
6+
const { fileURLToPath } = await import(pkgs[0]);
7+
const path = await import(pkgs[1]);
88
const __filename = fileURLToPath(import.meta.url);
99
const __dirname = path.dirname(__filename);
1010

0 commit comments

Comments
 (0)