11#!/usr/bin/env bun
22
33import { $ } from "bun"
4- import fs from "fs"
54import path from "path"
65import { fileURLToPath } from "url"
76import { createSolidTransformPlugin } from "@opentui/solid/bun-plugin"
@@ -49,6 +48,7 @@ const createEmbeddedWebUIBundle = async () => {
4948}
5049
5150const embeddedFileMap = skipEmbedWebUi ? null : await createEmbeddedWebUIBundle ( )
51+ const treeSitterWorker = await Bun . file ( fileURLToPath ( import . meta. resolve ( "@opentui/core/parser.worker" ) ) ) . text ( )
5252
5353const allTargets : {
5454 os : string
@@ -156,14 +156,9 @@ for (const item of targets) {
156156 console . log ( `building ${ name } ` )
157157 await $ `mkdir -p dist/${ name } /bin`
158158
159- const localPath = path . resolve ( dir , "node_modules/@opentui/core/parser.worker.js" )
160- const rootPath = path . resolve ( dir , "../../node_modules/@opentui/core/parser.worker.js" )
161- const parserWorker = fs . realpathSync ( fs . existsSync ( localPath ) ? localPath : rootPath )
162159 const workerPath = "./src/cli/tui/worker.ts"
163-
164- // Use platform-specific bunfs root path based on target OS
160+ const treeSitterWorkerPath = "opentui-tree-sitter-worker.js"
165161 const bunfsRoot = item . os === "win32" ? "B:/~BUN/root/" : "/$bunfs/root/"
166- const workerRelativePath = path . relative ( dir , parserWorker ) . replaceAll ( "\\" , "/" )
167162
168163 await Bun . build ( {
169164 conditions : [ "bun" , "node" ] ,
@@ -184,13 +179,21 @@ for (const item of targets) {
184179 execArgv : [ `--user-agent=opencode/${ Script . version } ` , "--use-system-ca" , "--" ] ,
185180 windows : { } ,
186181 } ,
187- files : embeddedFileMap ? { "opencode-web-ui.gen.ts" : embeddedFileMap } : { } ,
188- entrypoints : [ "./src/index.ts" , parserWorker , workerPath , ...( embeddedFileMap ? [ "opencode-web-ui.gen.ts" ] : [ ] ) ] ,
182+ files : {
183+ [ treeSitterWorkerPath ] : treeSitterWorker ,
184+ ...( embeddedFileMap ? { "opencode-web-ui.gen.ts" : embeddedFileMap } : { } ) ,
185+ } ,
186+ entrypoints : [
187+ "./src/index.ts" ,
188+ workerPath ,
189+ treeSitterWorkerPath ,
190+ ...( embeddedFileMap ? [ "opencode-web-ui.gen.ts" ] : [ ] ) ,
191+ ] ,
189192 define : {
190193 FFF_LIBC : JSON . stringify ( item . abi === "musl" ? "musl" : "gnu" ) ,
191194 OPENCODE_VERSION : `'${ Script . version } '` ,
192195 OPENCODE_MODELS_DEV : generated . modelsData ,
193- OTUI_TREE_SITTER_WORKER_PATH : bunfsRoot + workerRelativePath ,
196+ OTUI_TREE_SITTER_WORKER_PATH : bunfsRoot + treeSitterWorkerPath ,
194197 OPENCODE_WORKER_PATH : workerPath ,
195198 OPENCODE_CHANNEL : `'${ Script . channel } '` ,
196199 OPENCODE_LIBC : item . os === "linux" ? `'${ item . abi ?? "glibc" } '` : "" ,
0 commit comments