-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
executable file
·88 lines (78 loc) · 2 KB
/
build.js
File metadata and controls
executable file
·88 lines (78 loc) · 2 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bun
import { build } from "bun"
import { existsSync, mkdirSync } from "fs"
import { relative } from "path"
const outdir = "./zig-out/web-dist"
// Ensure output directory exists
if (!existsSync(outdir)) {
mkdirSync(outdir, { recursive: true })
}
try {
const y = await build({
entrypoints: ["./web/threadworker.ts"],
root: "./web",
outdir,
target: "browser",
naming: {
entry: "[dir]/[name].[hash].[ext]"
},
splitting: false,
sourcemap: "inline"
})
const wasm_thread_worker_path = relative(outdir, y.outputs[0].path)
const x = await build({
entrypoints: ["./web/xtcworker.ts"],
root: "./web",
outdir,
target: "browser",
naming: {
entry: "[dir]/[name].[hash].[ext]"
},
splitting: false,
sourcemap: "inline",
loader: {
".wren": "text",
".wasm": "file"
},
define: {
"process.env.THREAD_WORKER": JSON.stringify(wasm_thread_worker_path)
}
})
const worker_path = relative(outdir, x.outputs[0].path)
console.log("✅ Worker build completed successfully")
console.log(`📁 XTC worker: ${worker_path}`)
console.log(`📁 Thread worker: ${wasm_thread_worker_path}`)
const result = await build({
entrypoints: ["./web/index.html"],
root: "./web",
outdir,
define: {
"process.env.XTC_WORKER": JSON.stringify(worker_path),
"process.env.THREAD_WORKER": JSON.stringify(wasm_thread_worker_path)
},
naming: {
entry: "[dir]/[name].[ext]",
asset: "[name].[hash].[ext]"
},
target: "browser",
splitting: false,
sourcemap: "inline",
loader: {
".wren": "text",
".wasm": "file"
}
})
if (result.success) {
console.log("✅ Build completed successfully")
console.log(`📁 Output: ${outdir}`)
} else {
console.error("❌ Build failed")
for (const message of result.logs) {
console.error(message)
}
process.exit(1)
}
} catch (error) {
console.error("❌ Build error:", error)
process.exit(1)
}