diff --git a/packages/opencode/script/build-node.ts b/packages/opencode/script/build-node.ts index c004c7096ed2..94e153bc3a57 100755 --- a/packages/opencode/script/build-node.ts +++ b/packages/opencode/script/build-node.ts @@ -8,6 +8,15 @@ import { fileURLToPath } from "url" const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) const dir = path.resolve(__dirname, "..") +const root = path.resolve(dir, "../..") + +function linker(): "hoisted" | "isolated" { + // jsonc-parser is only declared in packages/opencode, so its install location + // tells us whether Bun used a hoisted or isolated workspace layout. + if (fs.existsSync(path.join(dir, "node_modules", "jsonc-parser"))) return "isolated" + if (fs.existsSync(path.join(root, "node_modules", "jsonc-parser"))) return "hoisted" + throw new Error("Could not detect Bun linker from jsonc-parser") +} process.chdir(dir) @@ -41,7 +50,9 @@ const migrations = await Promise.all( ) console.log(`Loaded ${migrations.length} migrations`) -await $`bun install --os="*" --cpu="*" @lydell/node-pty@1.2.0-beta.10` +const link = linker() + +await $`bun install --linker=${link} --os="*" --cpu="*" @lydell/node-pty@1.2.0-beta.10` await Bun.build({ target: "node",