diff --git a/bun.lock b/bun.lock index 7d5ea89d945..7bb937ce5dc 100644 --- a/bun.lock +++ b/bun.lock @@ -914,6 +914,7 @@ "patchedDependencies": { "solid-js@1.9.10": "patches/solid-js@1.9.10.patch", "virtua@0.49.1": "patches/virtua@0.49.1.patch", + "@ff-labs/fff-bun@0.9.3": "patches/@ff-labs%2Ffff-bun@0.9.3.patch", "gcp-metadata@8.1.2": "patches/gcp-metadata@8.1.2.patch", "@ai-sdk/google@3.0.73": "patches/@ai-sdk%2Fgoogle@3.0.73.patch", "@ai-sdk/xai@3.0.82": "patches/@ai-sdk%2Fxai@3.0.82.patch", diff --git a/package.json b/package.json index 61800b8fa74..8ea2430ac6c 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,7 @@ "@types/node": "catalog:" }, "patchedDependencies": { + "@ff-labs/fff-bun@0.9.3": "patches/@ff-labs%2Ffff-bun@0.9.3.patch", "@npmcli/agent@4.0.2": "patches/@npmcli%2Fagent@4.0.2.patch", "@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch", "@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch", diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index 782aa07c733..09300965fe4 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -165,7 +165,7 @@ for (const item of targets) { const workerRelativePath = path.relative(dir, parserWorker).replaceAll("\\", "/") await Bun.build({ - conditions: ["node"], + conditions: ["bun", "node"], tsconfig: "./tsconfig.json", plugins: [plugin], external: ["node-gyp"], diff --git a/patches/@ff-labs%2Ffff-bun@0.9.3.patch b/patches/@ff-labs%2Ffff-bun@0.9.3.patch new file mode 100644 index 00000000000..b60128af9e1 --- /dev/null +++ b/patches/@ff-labs%2Ffff-bun@0.9.3.patch @@ -0,0 +1,34 @@ +diff --git a/src/download.ts b/src/download.ts +index 3454256..6dca25a 100644 +--- a/src/download.ts ++++ b/src/download.ts +@@ -7,7 +7,6 @@ + */ + + import { existsSync } from "node:fs"; +-import { createRequire } from "node:module"; + import { dirname, join } from "node:path"; + import { fileURLToPath } from "node:url"; + import { getLibFilename, getNpmPackageName } from "./platform"; +@@ -54,14 +53,14 @@ export function binaryExists(): boolean { + * in the same directory. + */ + function resolveFromNpmPackage(): string | null { +- const packageName = getNpmPackageName(); +- + try { +- // Use createRequire to resolve the platform package's location +- const require = createRequire(join(getPackageDir(), "package.json")); +- const packageJsonPath = require.resolve(`${packageName}/package.json`); +- const packageDir = dirname(packageJsonPath); +- const binaryPath = join(packageDir, getLibFilename()); ++ const binaryPath = process.platform === "win32" ++ ? require(`../../../../../@ff-labs+fff-bin-win32-${process.arch}@0.9.3/node_modules/@ff-labs/fff-bin-win32-${process.arch}/fff_c.dll`) ++ : process.platform === "darwin" ++ ? require(`../../../../../@ff-labs+fff-bin-darwin-${process.arch}@0.9.3/node_modules/@ff-labs/fff-bin-darwin-${process.arch}/libfff_c.dylib`) ++ : getNpmPackageName().endsWith("musl") ++ ? require(`../../../../../@ff-labs+fff-bin-linux-${process.arch}-musl@0.9.3/node_modules/@ff-labs/fff-bin-linux-${process.arch}-musl/libfff_c.so`) ++ : require(`../../../../../@ff-labs+fff-bin-linux-${process.arch}-gnu@0.9.3/node_modules/@ff-labs/fff-bin-linux-${process.arch}-gnu/libfff_c.so`); + + if (existsSync(binaryPath)) { + return binaryPath;