/** * Bundle the PearData GUI (app.js + local modules) to CJS for Electron. * * CJS require() works with nodeIntegration. esbuild inlines local sources and * leaves node_modules as external require()s resolved from electron/../node_modules. */ 'use strict' const path = require('path') const { build } = require('esbuild') const root = path.resolve(__dirname, '..') const outfile = path.join(root, 'electron', 'app.bundle.cjs') async function main() { await build({ entryPoints: [path.join(root, 'app.js')], bundle: true, platform: 'node', format: 'cjs', outfile, packages: 'external', sourcemap: true, logLevel: 'info', banner: { js: '/* peardata electron GUI bundle — generated by scripts/build-client-bundle.cjs */\n', }, }) console.log('[build-client-bundle] wrote', outfile) } main().catch((err) => { console.error(err) process.exit(1) })