explodorama / files / tools / balance / run.mjs
run.mjs
d3e4ed26 2026-10-25 Pavel Safronov | 1 | /** |
| 2 | * The balance lab's launcher (PLAN.md §19.1): bundles tools/balance/lab.ts with the game's sim | |
| 3 | * (TypeScript) into .balance/lab.mjs with Vite, then runs it with the same arguments. | |
| 4 | * | |
| 5 | * npm run balance -- <command> [options] (npm run balance -- help) | |
| 6 | */ | |
| 7 | import { build } from 'vite' | |
| 8 | import { pathToFileURL } from 'node:url' | |
| 9 | import { resolve } from 'node:path' | |
| 10 | ||
| 11 | await build({ | |
| 12 | configFile: false, | |
| 13 | logLevel: 'warn', | |
| 14 | build: { | |
| 15 | ssr: 'tools/balance/lab.ts', | |
| 16 | outDir: '.balance', | |
| 17 | emptyOutDir: true, | |
| 18 | target: 'node22', | |
| 19 | minify: false, | |
| 20 | rollupOptions: { output: { entryFileNames: 'lab.mjs' } }, | |
| 21 | }, | |
| 22 | }) | |
| 23 | await import(pathToFileURL(resolve('.balance/lab.mjs')).href) |