ffilibs
Pre-compiled static builds of popular open source libraries for Node.js and Bun
π― Project Goal
ffilibs provides pre-compiled static versions of popular open source libraries, packaged for easy distribution via npm. This eliminates the need to compile native dependencies from source, making it faster and easier to use powerful libraries like libgit2
, libssh2
, and others in your JavaScript/TypeScript projects.
Why ffilibs?
- β‘ Fast Installation: No more waiting for native compilation
- π§ Zero Dependencies: Static builds with no external library requirements
- π Cross-Platform: Support for macOS, Windows, and Linux on both x64 and ARM architectures
- π¦ npm Ready: Simple
npm install
- no build tools required - π¦ Bun Optimized: Works seaβ¦
ffilibs
Pre-compiled static builds of popular open source libraries for Node.js and Bun
π― Project Goal
ffilibs provides pre-compiled static versions of popular open source libraries, packaged for easy distribution via npm. This eliminates the need to compile native dependencies from source, making it faster and easier to use powerful libraries like libgit2
, libssh2
, and others in your JavaScript/TypeScript projects.
Why ffilibs?
- β‘ Fast Installation: No more waiting for native compilation
- π§ Zero Dependencies: Static builds with no external library requirements
- π Cross-Platform: Support for macOS, Windows, and Linux on both x64 and ARM architectures
- π¦ npm Ready: Simple
npm install
- no build tools required - π¦ Bun Optimized: Works seamlessly with Bunβs FFI capabilities
π Quick Start
Installation
npm install @ffilibs/libgit2-beta
Usage with Bun
Bun makes it incredibly easy to call into these native libraries:
import { dlopen, ptr, CString } from 'bun:ffi';
import path from 'path';
// Load the library
const lib = dlopen(path.join(process.cwd(), 'node_modules/@ffilibs/libgit2-beta/prebuilds/linux/arm/lib/libgit2.a'), {
git_libgit2_init: {
args: [],
returns: 'int',
},
git_libgit2_shutdown: {
args: [],
returns: 'int',
},
// Add more functions as needed
});
// Initialize libgit2
lib.symbols.git_libgit2_init();
// Your code here...
// Cleanup
lib.symbols.git_libgit2_shutdown();
π Available Libraries
Library | Version | Description | Package |
---|---|---|---|
libgit2 | 1.9.1 | Git implementation library | @ffilibs/libgit2-beta |
libssh2 | 1.9.0 | SSH2 lib | @ffilibs/libssh2-beta |
yogalayout.dev | 3.2.1 | Cross-platform layout engine | @ffilibs/yogalayout.dev-beta |
ποΈ Supported Platforms
Platform | x64 | ARM64 |
---|---|---|
macOS | β | β |
Linux | β | β |
Windows | β | β |
π οΈ Build Process
Each library is built with optimized settings:
- Static linking: No external dependencies
- Release mode: Optimized for performance
- Cross-platform: Built on GitHub Actions for all supported platforms
- Consistent configuration: SSH support enabled where applicable
Local Building
To build a library locally:
cd packages/libgit2
./build.sh
The build script will:
- Download the source code
- Configure with appropriate flags
- Compile with all CPU cores
- Package into
release.tar.gz
π€ Background
This project is inspired by a tweet from @thdxr:
βthere needs to be a project that provides static builds of common libraries (libgit2, treesitter, yoga, etc) for x64 + ARM + mac/windows/linux and publishes them to npm
bun makes it stupid easy to call into these, itβs just the packaging that is annoyingβ
π Contributing
We welcome contributions! Hereβs how you can help:
- π Report Issues: Found a bug? Create an issue
- π¦ Request Libraries: Need another library? Open a feature request
- π§ Improve Builds: Help optimize build scripts and configurations
- π Documentation: Help improve docs and examples
- π Hacktoberfest: This project participates in Hacktoberfest!
Adding a New Library
- Create a new directory in
packages/
- Add
build.sh
andbuild.ps1
scripts - Configure static build with appropriate flags
- Test on all supported platforms
- Submit a pull request
Contact
- GitHub: Create an issue or pull request
- X/Twitter: @bascodes
π License
This project is licensed under the MIT License.
Built with β€οΈ for the JavaScript and Bun community