diff options
| author | Shoubhit Dash <[email protected]> | 2026-04-14 16:39:21 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-14 16:39:21 +0530 |
| commit | 5b60e51c9f36fd21036cff3012d90dd52cfa299e (patch) | |
| tree | ceb984f6a07aca736e3cd890d49ef2b61a0c3963 | |
| parent | 7cbe1627ec979e0523ab1a4c2c96def7cb352d06 (diff) | |
| download | opencode-5b60e51c9f36fd21036cff3012d90dd52cfa299e.tar.gz opencode-5b60e51c9f36fd21036cff3012d90dd52cfa299e.zip | |
fix(opencode): resolve ripgrep worker path in builds (#22436)
| -rwxr-xr-x | packages/opencode/script/build.ts | 10 | ||||
| -rw-r--r-- | packages/opencode/src/file/ripgrep.ts | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index c330bc0e3..6d1087f28 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -187,6 +187,7 @@ for (const item of targets) { const rootPath = path.resolve(dir, "../../node_modules/@opentui/core/parser.worker.js") const parserWorker = fs.realpathSync(fs.existsSync(localPath) ? localPath : rootPath) const workerPath = "./src/cli/cmd/tui/worker.ts" + const rgPath = "./src/file/ripgrep.worker.ts" // Use platform-specific bunfs root path based on target OS const bunfsRoot = item.os === "win32" ? "B:/~BUN/root/" : "/$bunfs/root/" @@ -213,12 +214,19 @@ for (const item of targets) { files: { ...(embeddedFileMap ? { "opencode-web-ui.gen.ts": embeddedFileMap } : {}), }, - entrypoints: ["./src/index.ts", parserWorker, workerPath, ...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : [])], + entrypoints: [ + "./src/index.ts", + parserWorker, + workerPath, + rgPath, + ...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : []), + ], define: { OPENCODE_VERSION: `'${Script.version}'`, OPENCODE_MIGRATIONS: JSON.stringify(migrations), OTUI_TREE_SITTER_WORKER_PATH: bunfsRoot + workerRelativePath, OPENCODE_WORKER_PATH: workerPath, + OPENCODE_RIPGREP_WORKER_PATH: rgPath, OPENCODE_CHANNEL: `'${Script.channel}'`, OPENCODE_LIBC: item.os === "linux" ? `'${item.abi ?? "glibc"}'` : "", }, diff --git a/packages/opencode/src/file/ripgrep.ts b/packages/opencode/src/file/ripgrep.ts index 70a708be1..abf7438dc 100644 --- a/packages/opencode/src/file/ripgrep.ts +++ b/packages/opencode/src/file/ripgrep.ts @@ -268,7 +268,12 @@ export namespace Ripgrep { .flatMap((item) => (item.type === "match" ? [row(item.data)] : [])) } - function target() { + declare const OPENCODE_RIPGREP_WORKER_PATH: string + + function target(): Effect.Effect<string | URL, Error> { + if (typeof OPENCODE_RIPGREP_WORKER_PATH !== "undefined") { + return Effect.succeed(OPENCODE_RIPGREP_WORKER_PATH) + } const js = new URL("./ripgrep.worker.js", import.meta.url) return Effect.tryPromise({ try: () => Filesystem.exists(fileURLToPath(js)), |
