Registry / aws / weak-node-api

weak-node-api

JSON →
library0.1.1jsnpmunverified

A linkable and runtime-injectable Node-API implementation that allows native addons to be built without direct linking against a Node-API provider. Version 0.1.1 is the latest stable release, part of the React Native Node-API project. It is a thin shim that exposes only Node-API function declarations, enabling runtime injection of the actual implementation by the host (e.g., React Native runtime), solving Android dynamic linker symbol resolution issues. Unlike typical Node-API bindings, it decouples addon compilation from the runtime, supporting React Native and potentially other contexts. Dependencies: none. Release cadence: early stage, active development.

npm install weak-node-api
INSTALL
IMPORT
SIG · WEAK-NODE-API
W
weak-node-api
awsjavascriptv0.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NodeApiHost
import { NodeApiHost } from 'weak-node-api'
import { WeakNodeApiHost } from 'weak-node-api'
Renamed from WeakNodeApiHost to NodeApiHost in v0.1.0.
NapiMixin
import { NapiMixin } from 'weak-node-api'
const NapiMixin = require('weak-node-api').NapiMixin
ESM only; no CommonJS support documented.
ModuleFunctionMap
import type { ModuleFunctionMap } from 'weak-node-api'
TypeScript type export, no value runtime.
defineNapiModule
import { defineNapiModule } from 'weak-node-api'
import defineNapiModule from 'weak-node-api'
Named export; default import is not available.

Demonstrates creating a NodeApiHost and defining a module with weak-node-api.

import { NodeApiHost, defineNapiModule, NapiMixin } from 'weak-node-api'; // Define a simple Node-API module const myModule = defineNapiModule({ napiVersion: 8, functions: { add: (env, napiValue) => { // implementation placeholder return 42; } } as any }); // Create a host that injects the implementation const host = new NodeApiHost({ module: myModule, // other options }); // Mixin example class MyAddon extends NapiMixin { // NapiMixin provides Node-API context } console.log('weak-node-api initialized');
Debug
Known issues
breakingWeakNodeApiHost class renamed to NodeApiHost in v0.1.0.
fix
Replace WeakNodeApiHost with NodeApiHost.
affects: <0.1.0
gotchaAll exports are ESM-only; there is no CommonJS build. Using require() will fail.
fix
Use import statements; if in CommonJS project, use dynamic import or switch to ESM.
affects: >=0.1.0
gotchaTypeScript users must ensure 'resolveJsonModule' and 'esModuleInterop' are set for proper type support.
fix
Add these to tsconfig.json: { compilerOptions: { module: 'esnext', moduleResolution: 'bundler', esModuleInterop: true } }
affects: >=0.1.0
deprecatedThe package is in early alpha; API may change without major semver bump.
fix
Pin exact version and monitor changes.
affects: <1.0.0
Errors
Common errors & fixes
Cannot find module 'weak-node-api' or its corresponding type declarations.
TypeScript cannot resolve types; likely missing @types or declaration files.
fix
Install the package and ensure tsconfig.json includes 'node' types. If still failing, add 'skipLibCheck': true.
ERR_REQUIRE_ESM: require() of ES Module /node_modules/weak-node-api/index.mjs from <file>.js not supported.
Using CommonJS require() on an ESM-only package.
fix
Switch to ES modules (use 'import') or use dynamic import: const weak = await import('weak-node-api');
TypeError: WeakNodeApiHost is not a constructor.
Using the old class name WeakNodeApiHost which was renamed in v0.1.0.
fix
Use NodeApiHost instead.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
28
Resources
weak-node-api — npm install weak-node-api · libregistry