-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-npm.ts
More file actions
executable file
·43 lines (34 loc) · 926 Bytes
/
build-npm.ts
File metadata and controls
executable file
·43 lines (34 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bun
import solidPlugin from "@opentui/solid/bun-plugin"
import path from "path"
import { fileURLToPath } from "url"
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
process.chdir(__dirname)
import pkg from "./package.json"
console.log("Building for npm publish...")
await Bun.$`mkdir -p dist`
// Build a JavaScript bundle for npm (not a binary)
const result = await Bun.build({
conditions: ["browser"],
tsconfig: "./tsconfig.json",
plugins: [solidPlugin],
sourcemap: "external",
target: "node",
minify: false,
entrypoints: ["./src/index.tsx"],
outdir: "./dist",
format: "esm",
define: {
VERSION: `'${pkg.version}'`,
},
})
if (!result.success) {
console.error("Build failed:")
for (const log of result.logs) {
console.error(log)
}
process.exit(1)
}
console.log("NPM build complete!")
console.log("Output: dist/index.js")