import * as esbuild from 'esbuild';

console.log('Building Electron Main and Preload...');

await esbuild.build({
    entryPoints: ['electron/main.ts', 'electron/preload.ts'],
    bundle: true,
    platform: 'node',
    target: 'node18',
    external: ['electron'], // Do not bundle electron dependency
    outdir: 'dist-electron',
    format: 'cjs',
    outExtension: { '.js': '.cjs' }, // Output .cjs to avoid conflict with package.json "type": "module"
})
    .then(() => console.log('Build complete.'))
    .catch(() => process.exit(1));
