30 lines
961 B
JavaScript
30 lines
961 B
JavaScript
import { spawn } from 'node:child_process'
|
|
import { createRequire } from 'node:module'
|
|
import path from 'node:path'
|
|
import { appendBuildOldSpaceOption } from './node-old-space-limit.mjs'
|
|
|
|
const require = createRequire(import.meta.url)
|
|
const electronVitePackageJson = require.resolve('electron-vite/package.json')
|
|
const electronViteCli = path.join(path.dirname(electronVitePackageJson), 'bin', 'electron-vite.js')
|
|
|
|
// Release builds have started OOMing on GitHub's macOS runners during the
|
|
// renderer bundle. Reserve memory on smaller hosts so the OS does not kill Vite.
|
|
const nodeOptions = appendBuildOldSpaceOption(process.env.NODE_OPTIONS)
|
|
|
|
const child = spawn(process.execPath, [electronViteCli, 'build', ...process.argv.slice(2)], {
|
|
stdio: 'inherit',
|
|
env: {
|
|
...process.env,
|
|
NODE_OPTIONS: nodeOptions
|
|
}
|
|
})
|
|
|
|
child.on('exit', (code, signal) => {
|
|
if (signal) {
|
|
process.kill(process.pid, signal)
|
|
return
|
|
}
|
|
|
|
process.exit(code ?? 1)
|
|
})
|