Skip to content

Commit 529a4d5

Browse files
authored
fix(build-node): preserve Bun linker for node-pty install (#20364)
1 parent 751d42d commit 529a4d5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

packages/opencode/script/build-node.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import { fileURLToPath } from "url"
88
const __filename = fileURLToPath(import.meta.url)
99
const __dirname = path.dirname(__filename)
1010
const dir = path.resolve(__dirname, "..")
11+
const root = path.resolve(dir, "../..")
12+
13+
function linker(): "hoisted" | "isolated" {
14+
// jsonc-parser is only declared in packages/opencode, so its install location
15+
// tells us whether Bun used a hoisted or isolated workspace layout.
16+
if (fs.existsSync(path.join(dir, "node_modules", "jsonc-parser"))) return "isolated"
17+
if (fs.existsSync(path.join(root, "node_modules", "jsonc-parser"))) return "hoisted"
18+
throw new Error("Could not detect Bun linker from jsonc-parser")
19+
}
1120

1221
process.chdir(dir)
1322

@@ -41,7 +50,9 @@ const migrations = await Promise.all(
4150
)
4251
console.log(`Loaded ${migrations.length} migrations`)
4352

44-
await $`bun install --os="*" --cpu="*" @lydell/node-pty@1.2.0-beta.10`
53+
const link = linker()
54+
55+
await $`bun install --linker=${link} --os="*" --cpu="*" @lydell/node-pty@1.2.0-beta.10`
4556

4657
await Bun.build({
4758
target: "node",

0 commit comments

Comments
 (0)