Show HN: Static builds of popular open source libraries on npmjs.org

1 month ago 6

License

Pre-compiled static builds of popular open source libraries for Node.js and Bun

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.

  • 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
npm install @ffilibs/libgit2-beta

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();
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
Platform x64 ARM64
macOS
Linux
Windows

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

To build a library locally:

cd packages/libgit2 ./build.sh

The build script will:

  1. Download the source code
  2. Configure with appropriate flags
  3. Compile with all CPU cores
  4. Package into release.tar.gz

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"

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!
  1. Create a new directory in packages/
  2. Add build.sh and build.ps1 scripts
  3. Configure static build with appropriate flags
  4. Test on all supported platforms
  5. Submit a pull request

This project is licensed under the MIT License.


Built with ❤️ for the JavaScript and Bun community

Read Entire Article