Native addons
Loading native code into Bare for work JavaScript can't naturally express, and building prebuilt binaries for every platform you ship to.
For code that JavaScript can't naturally express—tight cryptography loops, codec work, hardware access—Bare loads native addons. The bare-addon template is the starting point: write the addon in C, C++, Rust, or any language with a C-compatible ABI, expose it through Bare's addon API, and call it from JavaScript like any module.
See bare-addon-resolve for the low-level resolution algorithm, and bare-make for the build tool addons compile with.
WebAssembly builds
From Bare 1.36.0, an addon package can also ship a WebAssembly build of the same code. Bare runs it sandboxed through WASI, which limits its file and system access to what the application grants, though it still reaches whatever JavaScript can. Bare loads it when an import asks for it, and falls back to it when the package has no native build for the platform, or, on a sealed process, when its native build isn't already loaded. See WebAssembly addons.
Building prebuilt binaries
Shipping an addon to users means compiling it for every platform and architecture you support, not just your own machine. Native-addon CI prebuilds covers the GitHub Actions pipeline—compile-prebuilds, upload-prebuilds, download-prebuilds, merge-prebuilds, and the setup actions that go with them—that runs bare-make across a CI matrix and collects the results.
See also
- Native-addon CI prebuilds—the GitHub Actions pipeline for cross-platform builds.
bare-makereference—the build tool.bare-addon-resolvereference—addon resolution.- Inside Bare—the runtime addons load into.
- WebAssembly addons—the sandboxed WebAssembly build of an addon.
Last updated on