Skip to content

Commit 5b60e51

Browse files
authored
fix(opencode): resolve ripgrep worker path in builds (#22436)
1 parent 7cbe162 commit 5b60e51

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

packages/opencode/script/build.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ for (const item of targets) {
187187
const rootPath = path.resolve(dir, "../../node_modules/@opentui/core/parser.worker.js")
188188
const parserWorker = fs.realpathSync(fs.existsSync(localPath) ? localPath : rootPath)
189189
const workerPath = "./src/cli/cmd/tui/worker.ts"
190+
const rgPath = "./src/file/ripgrep.worker.ts"
190191

191192
// Use platform-specific bunfs root path based on target OS
192193
const bunfsRoot = item.os === "win32" ? "B:/~BUN/root/" : "/$bunfs/root/"
@@ -213,12 +214,19 @@ for (const item of targets) {
213214
files: {
214215
...(embeddedFileMap ? { "opencode-web-ui.gen.ts": embeddedFileMap } : {}),
215216
},
216-
entrypoints: ["./src/index.ts", parserWorker, workerPath, ...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : [])],
217+
entrypoints: [
218+
"./src/index.ts",
219+
parserWorker,
220+
workerPath,
221+
rgPath,
222+
...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : []),
223+
],
217224
define: {
218225
OPENCODE_VERSION: `'${Script.version}'`,
219226
OPENCODE_MIGRATIONS: JSON.stringify(migrations),
220227
OTUI_TREE_SITTER_WORKER_PATH: bunfsRoot + workerRelativePath,
221228
OPENCODE_WORKER_PATH: workerPath,
229+
OPENCODE_RIPGREP_WORKER_PATH: rgPath,
222230
OPENCODE_CHANNEL: `'${Script.channel}'`,
223231
OPENCODE_LIBC: item.os === "linux" ? `'${item.abi ?? "glibc"}'` : "",
224232
},

packages/opencode/src/file/ripgrep.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,12 @@ export namespace Ripgrep {
268268
.flatMap((item) => (item.type === "match" ? [row(item.data)] : []))
269269
}
270270

271-
function target() {
271+
declare const OPENCODE_RIPGREP_WORKER_PATH: string
272+
273+
function target(): Effect.Effect<string | URL, Error> {
274+
if (typeof OPENCODE_RIPGREP_WORKER_PATH !== "undefined") {
275+
return Effect.succeed(OPENCODE_RIPGREP_WORKER_PATH)
276+
}
272277
const js = new URL("./ripgrep.worker.js", import.meta.url)
273278
return Effect.tryPromise({
274279
try: () => Filesystem.exists(fileURLToPath(js)),

0 commit comments

Comments
 (0)