@@ -4,18 +4,22 @@ import { fileURLToPath } from "node:url";
44import { build } from "esbuild" ;
55
66const playgroundDir = resolve ( fileURLToPath ( new URL ( ".." , import . meta. url ) ) ) ;
7- const workerSourcePath = resolve ( playgroundDir , "../secure-exec/src/browser /worker.ts" ) ;
7+ const workerSourcePath = resolve ( playgroundDir , "../secure-exec-browser /src/worker.ts" ) ;
88const workerSourceDir = dirname ( workerSourcePath ) ;
99const workerOutputPath = resolve ( playgroundDir , "secure-exec-worker.js" ) ;
1010const appSourcePath = resolve ( playgroundDir , "frontend/app.ts" ) ;
1111const appOutputPath = resolve ( playgroundDir , "dist/app.js" ) ;
1212
1313const BRIDGE_IMPORT_BLOCK = `\tlet bridgeModule: Record<string, unknown>;
1414\ttry {
15- \t\tbridgeModule = await dynamicImportModule("../bridge/index.js ");
15+ \t\tbridgeModule = await dynamicImportModule("@secure-exec/core/internal/bridge ");
1616\t} catch {
17- \t\t// Vite browser tests execute source files directly, so \`.ts\` fallback is required.
18- \t\tbridgeModule = await dynamicImportModule("../bridge/index.ts");
17+ \t\t// Vite browser tests may need source fallback.
18+ \t\ttry {
19+ \t\t\tbridgeModule = await dynamicImportModule("@secure-exec/core/internal/bridge");
20+ \t\t} catch {
21+ \t\t\tthrow new Error("Failed to load bridge module from @secure-exec/core");
22+ \t\t}
1923\t}` ;
2024
2125async function writeGeneratedBundle ( outputPath : string , sourcePath : string ) : Promise < void > {
@@ -27,10 +31,10 @@ async function buildWorkerBundle(): Promise<void> {
2731 const originalSource = await readFile ( workerSourcePath , "utf8" ) ;
2832 const patchedSource = originalSource
2933 . replace (
30- 'import { mkdir } from "../fs-helpers .js";' ,
31- 'import { mkdir } from "../fs-helpers .js";\nimport * as browserWorkerBridgeModule from "../bridge/index.ts ";' ,
34+ 'import { validatePermissionSource } from "./permission-validation .js";' ,
35+ 'import { validatePermissionSource } from "./permission-validation .js";\nimport importedBridgeModule from "@secure-exec/core/internal/bridge ";' ,
3236 )
33- . replace ( BRIDGE_IMPORT_BLOCK , "\tconst bridgeModule = browserWorkerBridgeModule ;" ) ;
37+ . replace ( BRIDGE_IMPORT_BLOCK , "\tconst bridgeModule = { default: importedBridgeModule } ;" ) ;
3438
3539 await build ( {
3640 bundle : true ,
0 commit comments