fix(desktop): build preload as CJS so contextBridge actually fires
esbuild was emitting preload.js as ESM (format:"esm"), but Electron loads preload scripts via its sandboxed Node context, which is CJS. With an ESM preload, the contextBridge.exposeInMainWorld calls silently no-op, leaving window.fusionShell / window.fusionAPI undefined in the renderer — which is why the dashboard always fell through to "Can't reach the Fusion backend" and DesktopLaunchGate always logged "window.fusionShell unavailable; bypassing". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,13 @@ async function buildElectronEntrypoints(): Promise<void> {
|
||||
entryPoints: [join(packageRoot, "src", "preload.ts")],
|
||||
outfile: join(desktopDistDir, "preload.js"),
|
||||
bundle: true,
|
||||
format: "esm",
|
||||
// Preload scripts must be CommonJS — Electron loads them via the
|
||||
// sandboxed Node context, not as ESM. With format:"esm" the
|
||||
// contextBridge calls silently no-op and window.fusionShell /
|
||||
// window.fusionAPI stay undefined, which made the dashboard fall
|
||||
// through to "can't reach the Fusion backend" and the launch gate
|
||||
// always bypass.
|
||||
format: "cjs",
|
||||
platform: "node",
|
||||
target: "node22",
|
||||
sourcemap: true,
|
||||
|
||||
Reference in New Issue
Block a user