Neon Bindings Loader with Prebuild Support

2.2.2 · active · verified Tue Apr 21

neon-load-or-build is a specialized build tool and bindings loader designed for projects utilizing Neon Bindings, providing robust support for precompiled native modules (prebuilds). As of version 2.2.2, it aims to significantly improve the installation experience of Node.js native add-ons by checking for existing builds or prebuilds before initiating a potentially time-consuming compilation process. While no explicit release cadence is documented, its version history suggests a stable and mature project. A key differentiator is its integration with Neon's build system, offering a CLI command similar to `neon build` but with prebuild checks. It's particularly crucial for `nodejs-mobile` environments, where specifying `moduleName` is mandatory for correct module resolution across iOS and Android. The tool is heavily inspired by `node-gyp-build` and `prebuildify`, inheriting their approach to streamlining native module distribution by prioritizing prebuilds over on-the-fly compilation. This design choice enables developers to bundle platform-specific prebuilds (e.g., for `musl` or specific ARM architectures), reducing install-time friction and ensuring compatibility across various Node.js and Electron environments.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to integrate `neon-load-or-build` into a Neon project's `package.json` and module loading logic to enable prebuild support.

{
  "name": "my-package",
  "version": "1.0.0",
  "scripts": {
    "install": "neon-load-or-build"
  },
  "dependencies": {
    "neon-load-or-build": "^2.2.2",
    "neon-bindings": "^0.7.1" // Assuming your project uses neon-bindings
  }
}

// In your native module's lib/index.js
const path = require('path');
const neonLoader = require('neon-load-or-build');

module.exports = neonLoader({
  moduleName: 'my-package',
  dir: path.join(__dirname, '..'),
  // For nodejs-mobile, moduleName is mandatory:
  // moduleName: 'my-package', 
  // For testing in a browser-like environment (if applicable) or if needing specific environment variables:
  // process.env.SOME_VAR = process.env.SOME_VAR ?? ''; 
});

view raw JSON →