{"draft":null,"from":168,"to":169,"files":[{"path":"scripts/build-client.mjs","added":64,"removed":0,"diff":"--- /dev/null\n+++ b/scripts/build-client.mjs\n@@ -0,0 +1,64 @@\n+// Builds client/bin/abso.mjs: the whole client, client/abso.ts and everything it imports (yaml included),\n+// as one plain-JS file for Node 20 or later. Node 20 can't run the .ts files themselves (it has no type\n+// stripping), so this file is how a checkout runs on it:\n+//\n+//   node client/bin/abso.mjs help\n+//\n+//   npm run build:client           rebuilds it; run it after changing the client and push the result.\n+//   npm run check:client-bundle    fails when the file isn't what a build of this folder gives (the check runs it).\n+//\n+// The file is committed, so a fresh clone runs it with no install and no build. It sits one folder under\n+// client/, so the client's own folder (client-version.ts) is still client/. The build is deterministic:\n+// paths in it are relative to the repo, so it comes out the same on every machine.\n+//\n+// Plain JS on purpose: it runs before anything is built.\n+import { readFileSync, writeFileSync } from \"node:fs\";\n+import { createRequire } from \"node:module\";\n+import { dirname, join, resolve } from \"node:path\";\n+import { fileURLToPath } from \"node:url\";\n+\n+const root = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\n+const OUT = \"client/bin/abso.mjs\";\n+\n+/** The bundle's text, built in memory. */\n+export function buildClient() {\n+\tconst esbuild = createRequire(import.meta.url)(\"esbuild\");\n+\tconst result = esbuild.buildSync({\n+\t\tabsWorkingDir: root,\n+\t\tentryPoints: [\"client/abso.ts\"],\n+\t\tbundle: true,\n+\t\tplatform: \"node\",\n+\t\tformat: \"esm\",\n+\t\ttarget: \"node20\",\n+\t\twrite: false,\n+\t\toutfile: OUT,\n+\t\tlogLevel: \"warning\",\n+\t\t// A bundled CommonJS package (yaml) calls require(\"process\") lazily, which an ES module bundle\n+\t\t// can't do without a real require.\n+\t\tbanner: {\n+\t\t\tjs: [\n+\t\t\t\t\"// Built from client/abso.ts by scripts/build-client.mjs (npm run build:client). Don't edit it by hand.\",\n+\t\t\t\t'import { createRequire as __absoCreateRequire } from \"node:module\";',\n+\t\t\t\t\"const require = __absoCreateRequire(import.meta.url);\",\n+\t\t\t].join(\"\\n\"),\n+\t\t},\n+\t});\n+\treturn result.outputFiles[0].text;\n+}\n+\n+if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {\n+\tconst path = join(root, OUT);\n+\tconst text = buildClient();\n+\tif (process.argv.includes(\"--check\")) {\n+\t\tlet have = \"\";\n+\t\ttry {\n+\t\t\thave = readFileSync(path, \"utf8\").replace(/\\r\\n/g, \"\\n\");\n+\t\t} catch {}\n+\t\tif (have !== text) {\n+\t\t\tprocess.stderr.write(\n+\t\t\t\t`${OUT} is not a build of this folder's client: run npm run build:client and push the file it writes.\\n`,\n+\t\t\t);\n+\t\t\tprocess.exit(1);\n+\t\t}\n+\t} else writeFileSync(path, text);\n+}"}],"unmatched":[]}