4, partial 5
This commit is contained in:
31
build.ts
31
build.ts
@@ -1,5 +1,8 @@
|
||||
import solidPlugin from "@opentui/solid/bun-plugin"
|
||||
import { copyFileSync, existsSync, mkdirSync } from "node:fs"
|
||||
import { join, dirname } from "node:path"
|
||||
|
||||
// Build the JavaScript bundle
|
||||
await Bun.build({
|
||||
entrypoints: ["./src/index.tsx"],
|
||||
outdir: "./dist",
|
||||
@@ -9,4 +12,32 @@ await Bun.build({
|
||||
plugins: [solidPlugin],
|
||||
})
|
||||
|
||||
// Copy the native library to dist for distribution
|
||||
const platform = process.platform
|
||||
const arch = process.arch
|
||||
|
||||
// Map platform/arch to OpenTUI package names
|
||||
const platformMap: Record<string, string> = {
|
||||
"darwin-arm64": "darwin-arm64",
|
||||
"darwin-x64": "darwin-x64",
|
||||
"linux-x64": "linux-x64",
|
||||
"linux-arm64": "linux-arm64",
|
||||
"win32-x64": "win32-x64",
|
||||
"win32-arm64": "win32-arm64",
|
||||
}
|
||||
|
||||
const platformKey = `${platform}-${arch}`
|
||||
const platformPkg = platformMap[platformKey]
|
||||
|
||||
if (platformPkg) {
|
||||
const libName = platform === "win32" ? "opentui.dll" : "libopentui.dylib"
|
||||
const srcPath = join("node_modules", `@opentui/core-${platformPkg}`, libName)
|
||||
|
||||
if (existsSync(srcPath)) {
|
||||
const destPath = join("dist", libName)
|
||||
copyFileSync(srcPath, destPath)
|
||||
console.log(`Copied native library: ${libName}`)
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Build complete")
|
||||
|
||||
Reference in New Issue
Block a user