// @ts-check // Bundles entry.ts and entryPost.ts into self-contained JS files for the // Gitea Actions runner. The runner clones this repo and runs dist/entry.js // directly — it does NOT run npm install, so all dependencies must be bundled. import { build } from "esbuild"; import { mkdirSync, rmSync } from "fs"; rmSync("./dist", { recursive: true, force: true }); mkdirSync("./dist", { recursive: true }); /** @type {import("esbuild").BuildOptions} */ const sharedConfig = { bundle: true, format: "esm", platform: "node", target: "node20", minify: false, sourcemap: false, external: [ "@valibot/to-json-schema", "effect", "sury", ], // CJS shim so CommonJS modules bundled into ESM work correctly banner: { js: `import { createRequire as __createRequire } from 'module'; import { fileURLToPath as __fileURLToPath } from 'url'; import { dirname as __dirnameFn } from 'path'; const require = __createRequire(import.meta.url); const __filename = __fileURLToPath(import.meta.url); const __dirname = __dirnameFn(__filename);`, }, treeShaking: true, }; await build({ ...sharedConfig, entryPoints: ["./entry.ts"], outfile: "./dist/entry.js", }); await build({ ...sharedConfig, entryPoints: ["./entryPost.ts"], outfile: "./dist/entryPost.js", }); console.log("» build completed successfully");