#!/usr/bin/env node // Bundles electron/main.ts and electron/preload.ts into dist-electron/*.js. // Uses esbuild (already a devDependency for the admin plugin dev-bundler, // lib/admin/plugin-dev.ts) rather than pulling in ts-node/tsx - the output // is plain CommonJS, so the packaged app needs no separate TS runtime. import { build } from "esbuild"; import { fileURLToPath } from "node:url"; import path from "node:path"; const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url))); const shared = { bundle: true, platform: "node", target: "node22", format: "cjs", sourcemap: true, // `electron` is provided by the Electron runtime itself; `electron-updater` // stays external so electron-builder ships it from node_modules as a // normal production dependency instead of us re-bundling its native-ish // internals (see electron-builder.config.js's file collection). external: ["electron", "electron-updater"], logLevel: "info", }; await build({ ...shared, entryPoints: [path.join(rootDir, "electron/main.ts")], outfile: path.join(rootDir, "dist-electron/main.js"), }); await build({ ...shared, entryPoints: [path.join(rootDir, "electron/preload.ts")], outfile: path.join(rootDir, "dist-electron/preload.js"), });