From 6d5e45084052708060b9abea823cf3dd5bc016e2 Mon Sep 17 00:00:00 2001 From: Andrey Bodrov Date: Wed, 26 Aug 2026 17:39:11 +0300 Subject: [PATCH] feat(fff-bun): recognise FreeBSD as a platform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On FreeBSD the package is unusable for two independent reasons, neither of them in the Rust code — `cargo build --release -p fff-c` builds crates/fff-c into a working libfff_c.so on FreeBSD as-is. 1. package.json's "os" list omits freebsd, so bun and npm skip installing the package entirely. A consumer importing it just gets "Cannot find module '@ff-labs/fff-bun'". 2. getTriple() throws "Unsupported platform: freebsd". It is reached from getNpmPackageName(), which resolveFromNpmPackage() calls *outside* its try/catch, so the throw escapes findBinary() instead of degrading to "no prebuilt available, fall back to the dev build". The fallback path exists and works; it is simply never reached. The two triples added to TRIPLE_TO_NPM_PACKAGE point at @ff-labs/fff-bin-freebsd-{x64,arm64}, which are not published. That is harmless: resolveFromNpmPackage() swallows the resolution failure and findBinary() continues to the locally built library. Publishing those packages later makes the mapping live with no further code change. Verified on FreeBSD 15.1 (amd64, bun 1.4.0, rustc 1.96.1): libfff_c.so loads through bun:ffi, and FileFinder.create() + fileSearch() return real results with git status and file metadata over a live tree. aarch64-unknown-freebsd is mapped but was not built or tested. --- packages/fff-bun/package.json | 3 ++- packages/fff-bun/src/platform.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/fff-bun/package.json b/packages/fff-bun/package.json index ec5ff0734..4813048ab 100644 --- a/packages/fff-bun/package.json +++ b/packages/fff-bun/package.json @@ -33,7 +33,8 @@ "darwin", "linux", "win32", - "android" + "android", + "freebsd" ], "cpu": [ "x64", diff --git a/packages/fff-bun/src/platform.ts b/packages/fff-bun/src/platform.ts index 11070e206..130661d99 100644 --- a/packages/fff-bun/src/platform.ts +++ b/packages/fff-bun/src/platform.ts @@ -20,6 +20,8 @@ export function getTriple(): string { osName = detectLinuxLibc(); } else if (platform === "win32") { osName = "pc-windows-msvc"; + } else if (platform === "freebsd") { + osName = "unknown-freebsd"; } else { throw new Error(`Unsupported platform: ${platform}`); } @@ -110,6 +112,8 @@ const TRIPLE_TO_NPM_PACKAGE: Record = { "x86_64-pc-windows-msvc": "@ff-labs/fff-bin-win32-x64", "aarch64-pc-windows-msvc": "@ff-labs/fff-bin-win32-arm64", "aarch64-linux-android": "@ff-labs/fff-bin-android-arm64", + "x86_64-unknown-freebsd": "@ff-labs/fff-bin-freebsd-x64", + "aarch64-unknown-freebsd": "@ff-labs/fff-bin-freebsd-arm64", }; /**