/** * desktop/build.mjs — bundle the Electron main + preload with esbuild. * * Source is ESM TypeScript (desktop/src/*.ts); output is CJS (.cjs) so Electron * loads it as the main/preload entry regardless of package "type". `electron` * and `node-pty` are marked external (provided by the Electron runtime / loaded * as a native addon at runtime, never bundled). The compiled server under * ../dist is loaded via a runtime dynamic import (a computed specifier), so * esbuild leaves it external automatically. */ import { build } from 'esbuild' const shared = { bundle: true, platform: 'node', target: 'node20', format: 'cjs', sourcemap: true, logLevel: 'info', external: ['electron', 'node-pty'], } await build({ ...shared, entryPoints: ['src/main.ts'], outfile: 'build/main.cjs' }) await build({ ...shared, entryPoints: ['src/preload.ts'], outfile: 'build/preload.cjs' })