Skip to content

Build addon paths in TypeScript and expose dlopen(module, filename) #498

Closed

Description

@kraenhansen

Move platform path construction out of native code and expose a raw loading function that matches Node's process.dlopen. This is the shape core would eventually own (#447).

Decisions

  • Signature: dlopen(module, filename), with the same semantics as Node's process.dlopen and nothing added, so a difference from Node is a bug.
  • Name: exported as dlopen from react-native-node-api, and proposed as react-native/node-api for core. A bare dlopen is too ambiguous as a top-level react-native export. See Rename `requireNodeAddon` to `dlopen`? #263.
  • filename: what gets passed to the system's dlopen: lib<name>.so on Android, @rpath/<name>.framework/<name> on Apple. Core knows nothing about our layouts or naming.
  • No cache: a second call runs the addon's init again, as in Node.
  • No flags for now: adding an optional argument later breaks nobody.

Steps

  • Move the path construction in CxxNodeApiHostModule::loadNodeAddon into TypeScript.
  • Expose dlopen(module, filename). Exports reach JS through a generated global today (RN$NodeAddon_%p), so this needs a way to set module.exports.
  • Rebuild requireNodeAddon on top of it, moving the exports cache out of nodeAddons_ into TypeScript. Keep the behaviour of not caching a failed load. Its library name argument and the Babel output don't change here.
  • Confirm the cache stays per runtime.

Known differences

The { packageName, path } resolver is #222, layered on top of this.

Activity

  1. added
    enhancement
    Host 🏡
    Linking 🔗
    on Nov 1, 2026
  2. self-assigned this
    on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Host 🏡Linking 🔗enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions