Skip to content

Commit 9a3ed0c

Browse files
author
Dev Agent Amelia
committed
ci: add scripts/build.mjs to repo for GitHub Actions build step
1 parent fb87568 commit 9a3ed0c

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Desktop.ini
2020
# Source code (kept private — published via npm only)
2121
src/
2222
tests/
23-
scripts/
23+
scripts/*
24+
!scripts/build.mjs
2425
mcp-template/
2526
autoparc/
2627
assets/

scripts/build.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env node
2+
/**
3+
* build.mjs — esbuild production build.
4+
*
5+
* Bundles all entrypoints into minified ESM files.
6+
* No source maps, no .d.ts declarations — internal structure not exposed.
7+
*/
8+
import * as esbuild from "esbuild";
9+
import { rmSync } from "node:fs";
10+
import { resolve, dirname } from "node:path";
11+
import { fileURLToPath } from "node:url";
12+
13+
const __dirname = dirname(fileURLToPath(import.meta.url));
14+
const ROOT = resolve(__dirname, "..");
15+
16+
try {
17+
rmSync(resolve(ROOT, "dist"), { recursive: true });
18+
} catch {
19+
// dist/ didn't exist yet
20+
}
21+
22+
await esbuild.build({
23+
// Top-level entrypoints (shebang added via banner)
24+
// install.ts and http-server.ts are dynamically imported by server.ts —
25+
// listing them here gives them a stable name in dist/ and ensures correct
26+
// chunk resolution at runtime.
27+
entryPoints: [
28+
"src/server.ts",
29+
"src/setup-auth.ts",
30+
"src/doctor.ts",
31+
"src/install.ts",
32+
"src/http-server.ts",
33+
],
34+
outdir: "dist",
35+
bundle: true, // inline all static imports from our own code
36+
minify: true, // strip whitespace, mangle identifiers
37+
splitting: true, // code-split dynamic import() correctly (ESM only)
38+
platform: "node",
39+
target: "node20",
40+
format: "esm",
41+
packages: "external", // leave node_modules as peer imports (not inlined)
42+
absWorkingDir: ROOT,
43+
});
44+
45+
console.log("✅ Build complete — dist/ ready");

0 commit comments

Comments
 (0)