bfc-node

Node.js bindings for BFC (@bfc-node/core) with prebuilt N-API binaries — ZSTD and libsodium statically linked, no compiler or node-gyp required.

TypeScriptnode.js · n-api · prebuilt binariesbfc & filesystemssource on github

Why

Use BFC from Node with nothing to install: no Git, CMake, C compiler, Python or node-gyp on the user’s machine.

How

  • BFC, ZSTD and libsodium are vendored as submodules and built into a static library by a dedicated CMake script, rather than BFC’s own build (which wants system libraries via pkg-config, always builds the CLI and sets a global -Werror).
  • check-drift.mjs parses upstream’s source list and fails CI if the vendored list has drifted.
  • Per-platform npm packages (macOS arm64, Linux x64/arm64 glibc, Windows x64); the loader falls back from an explicit path to a local build to the platform package.
  • Work runs on the libuv thread pool, and a per-handle mutex serializes access, because BFC handles aren’t thread-safe.
  • A typed API — createArchive (deterministic order), openArchive (list, stat, read, extract, verify) and openWriter — with coded BfcErrors.
const writer = await openWriter({ output: './out.bfc', compression: true });
await writer.addFile('assets/app.js', Buffer.from('console.log(1)'));
await writer.finish();
$ git clone https://github.com/zombocoder/bfc-node
← all projects