{"library":"neon-load-or-build","title":"Neon Bindings Loader with Prebuild Support","description":"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install neon-load-or-build"],"cli":{"name":"neon","version":null}},"imports":["module.exports = require('neon-load-or-build')({ moduleName: 'my-package', dir: __dirname + '/..' })","npm install neon-load-or-build","require('neon-load-or-build')({ moduleName: 'my-package', dir: __dirname + '/..' })"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"{\n  \"name\": \"my-package\",\n  \"version\": \"1.0.0\",\n  \"scripts\": {\n    \"install\": \"neon-load-or-build\"\n  },\n  \"dependencies\": {\n    \"neon-load-or-build\": \"^2.2.2\",\n    \"neon-bindings\": \"^0.7.1\" // Assuming your project uses neon-bindings\n  }\n}\n\n// In your native module's lib/index.js\nconst path = require('path');\nconst neonLoader = require('neon-load-or-build');\n\nmodule.exports = neonLoader({\n  moduleName: 'my-package',\n  dir: path.join(__dirname, '..'),\n  // For nodejs-mobile, moduleName is mandatory:\n  // moduleName: 'my-package', \n  // For testing in a browser-like environment (if applicable) or if needing specific environment variables:\n  // process.env.SOME_VAR = process.env.SOME_VAR ?? ''; \n});\n","lang":"javascript","description":"Demonstrates how to integrate `neon-load-or-build` into a Neon project's `package.json` and module loading logic to enable prebuild support.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}