SPB Git

Repository Public

build.mjs 1.1 KB 12 lines javascript

1// Bundle each service into a single ESM file (no node_modules needed at runtime).2import { execSync } from 'node:child_process';3import { build } from 'esbuild';4// v6-alerts: the commit shown on the monitoring screen (SPW_COMMIT wins; empty when the build is not made from a git checkout)5let commit = process.env.SPW_COMMIT ?? '';6if (!commit) { try { commit = execSync('git rev-parse --short HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim(); } catch { /* not a checkout */ } }7const define = { __SPW_COMMIT__: JSON.stringify(commit) };8const banner = { js: "import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);" };9for (const [entry, out] of [['services/api/src/main.ts', 'dist/api.mjs'], ['services/isolated-signer/src/main.ts', 'dist/signer.mjs'],10  ['services/research-runner/src/main.ts', 'dist/research-runner.mjs']]) // v7: the research runner, a standalone bundle for a research node11  await build({ entryPoints: [entry], outfile: out, bundle: true, platform: 'node', target: 'node24', format: 'esm', banner, define, legalComments: 'none', logLevel: 'info' });12
Files main
Menu

Theme