Skip to content

Commit 7d38af9

Browse files
committed
build w/ bun to avoid internal deps hell
1 parent 69c814d commit 7d38af9

4 files changed

Lines changed: 59 additions & 71 deletions

File tree

build.bun.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bun
2+
import { $ } from "bun";
3+
4+
// Run TypeScript compiler for type declarations
5+
await $`tsc`;
6+
7+
const isDevelopment = Bun.env.NODE_ENV === "development";
8+
9+
// Build all JavaScript/TypeScript files
10+
function buildJs(entrypoint: string, opts: Record<string, string> = {}) {
11+
return Bun.build({
12+
entrypoints: [entrypoint],
13+
outdir: "dist",
14+
target: "browser",
15+
minify: !isDevelopment,
16+
...(isDevelopment ? {
17+
sourcemap: "inline",
18+
} : {}),
19+
...opts
20+
})
21+
}
22+
23+
await Promise.all([
24+
buildJs("src/app.ts", { outdir: "dist/src" }),
25+
buildJs("src/app-bridge.ts", { outdir: "dist/src" }),
26+
buildJs("src/react/index.tsx", { outdir: "dist/src/react" }),
27+
])

build.esbuild.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env tsx
2+
import { execSync } from "child_process";
3+
import * as esbuild from "esbuild";
4+
5+
// Run TypeScript compiler for type declarations
6+
execSync("tsc", { stdio: "inherit" });
7+
8+
const isDevelopment = process.env.NODE_ENV === "development";
9+
10+
// Build all JavaScript/TypeScript files
11+
async function buildJs(
12+
entrypoint: string,
13+
opts: { outdir?: string; target?: "browser" | "node" } = {},
14+
) {
15+
return esbuild.build({
16+
entryPoints: [entrypoint],
17+
outdir: opts.outdir ?? "dist",
18+
platform: opts.target === "node" ? "node" : "browser",
19+
format: "esm",
20+
bundle: true,
21+
minify: !isDevelopment,
22+
sourcemap: isDevelopment ? "inline" : false,
23+
});
24+
}
25+
26+
await Promise.all([
27+
buildJs("src/app.ts", { outdir: "dist/src" }),
28+
buildJs("src/app-bridge.ts", { outdir: "dist/src" }),
29+
buildJs("src/react/index.tsx", { outdir: "dist/src/react" }),
30+
]);

build.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"start:sandbox-proxy": "python3 sandbox_proxy.py",
2929
"start": "npm run build && npm run start:example-server",
3030
"start:dev": "NODE_ENV=development npm start",
31-
"build": "tsc && tsx build.ts",
31+
"build": "bun build.bun.ts",
3232
"prepare": "npm run build",
3333
"prettier:base-cmd": "prettier -u --ignore-path ./.gitignore --ignore-path ./.prettierignore",
3434
"prettier": "yarn prettier:base-cmd \"$(pwd)/**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --check",
@@ -45,6 +45,7 @@
4545
},
4646
"dependencies": {
4747
"@modelcontextprotocol/sdk": "^1.20.1",
48+
"bun": "^1.3.2",
4849
"esbuild": "~0.19.10",
4950
"react": "^19.2.0",
5051
"react-dom": "^19.2.0",

0 commit comments

Comments
 (0)