mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-15 17:08:21 -04:00
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
#!/usr/bin/env bun
|
|
|
|
import { $ } from "bun"
|
|
import { rm } from "node:fs/promises"
|
|
import path from "node:path"
|
|
import { fileURLToPath } from "node:url"
|
|
|
|
process.chdir(fileURLToPath(new URL("..", import.meta.url)))
|
|
|
|
await rm("dist", { recursive: true, force: true })
|
|
await $`bun tsc -p tsconfig.build.json`
|
|
|
|
const root = path.resolve("src")
|
|
const files = await Array.fromAsync(new Bun.Glob("**/*.ts").scan({ cwd: root, absolute: true }))
|
|
const result = await Bun.build({
|
|
entrypoints: files.filter((file) => !file.endsWith(".d.ts")),
|
|
root,
|
|
outdir: "dist",
|
|
target: "node",
|
|
format: "esm",
|
|
packages: "external",
|
|
external: ["#sqlite", "#pty", "#fff", "#photon-wasm", "#shell-parser-wasm", "#process-lock-ffi", "#v1-migration"],
|
|
splitting: true,
|
|
loader: {
|
|
".txt": "text",
|
|
".md": "text",
|
|
},
|
|
naming: {
|
|
entry: "[dir]/[name].[ext]",
|
|
chunk: "chunks/[name]-[hash].[ext]",
|
|
asset: "assets/[name]-[hash].[ext]",
|
|
},
|
|
})
|
|
if (!result.success) throw new AggregateError(result.logs, "Failed to build Core")
|