Skip to content

Commit 3bacef6

Browse files
kraenhansenclaude
andcommitted
docs: describe the vendored Hermes instead of a patched one
Node-API is implemented in Hermes itself now, so nothing is patched or forked: we build from a pinned commit on the static_h branch. Also corrects HOW-IT-WORKS, which described the removed jsi::Runtime::createNodeApiEnv. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8d818c1 commit 3bacef6

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ patch or workaround:
6060

6161
## Critical Build Dependencies
6262

63-
- **Custom Hermes**: Currently depends on a patched Hermes with Node-API support (see [facebook/hermes#1377](https://github.com/facebook/hermes/pull/1377))
63+
- **Vendored Hermes**: Builds Hermes from a pinned commit on the `static_h` branch, which carries Hermes' first-party Node-API implementation (`API/napi`, target `hermesNapi`). The pin lives in `packages/host/src/node/cli/hermes.ts` and is fetched by the `vendor-hermes` command.
6464
- **Prebuilt Binary Spec**: All tools must output to the exact naming scheme:
6565
- Android: `*.android.node/` with jniLibs structure + `react-native-node-api-module` marker file
6666
- iOS: `*.apple.node` (XCFramework renamed) + marker file

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
## How does this work?
2020

2121
> [!IMPORTANT]
22-
> This library is currently dependent on a custom version of Hermes and therefore has a very limited range of supported React Native versions.
23-
> Once the [PR adding Node-API support to Hermes](https://github.com/facebook/hermes/pull/1377) merges, we expect this restriction to be lifted.
22+
> This library builds Hermes from a pinned commit on its `static_h` branch, which carries [Hermes' first-party Node-API implementation](https://github.com/facebook/hermes/tree/static_h/API/napi).
23+
> React Native has not shipped that Hermes yet, so the range of supported React Native versions is very limited — see the `react-native` peer dependency of the [host package](packages/host/package.json) for the version we currently build against.
24+
> We expect this restriction to be lifted once React Native ships a Hermes with Node-API included.
2425
2526
> [!NOTE]
2627
> This library only works for iOS and Android and we want to eventually support React Native for Windows, macOS, visionOS and other out-of-tree platforms too.
@@ -35,10 +36,9 @@ This mono-repository hosts the development of a few packages:
3536

3637
Responsible for adding Node-API support to your React Native application:
3738

38-
- Declares a Podspec which downloads a special version of Hermes, with Node-API support,
39-
- instructing React Native's Hermes Podspecs to compile from this custom source-code.
40-
- patching React Native's JSI copy, with the updates introduced by our special version of Hermes.
41-
- we expect this to eventually be removed, as Node-API support gets merged into Hermes upstream.
39+
- Declares a Podspec which vendors Hermes from a pinned commit on its `static_h` branch, where Node-API is implemented,
40+
- instructing React Native's Hermes Podspecs to compile from this checkout.
41+
- we expect this to eventually be removed, as React Native starts shipping a Hermes with Node-API included.
4242
- Automatically discovers and adds Node-API binaries, matching the [the prebuilt binary specification](./docs/PREBUILDS.md)
4343
- This is driven by the platform specific build tools (through the Podspec on iOS and eventually Gradle on Android)
4444
- Implements a TurboModule with a `requireNodeAddon` function responsible for

docs/ANDROID.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Building Hermes from source
44

5-
Because we're using a version of Hermes patched with Node-API support, we need to build React Native from source.
5+
Because we build Hermes from source (a pinned commit carrying its Node-API implementation), we need to build React Native from source too.
66

77
Follow [the React Native documentation on how to build from source](https://reactnative.dev/contributing/how-to-build-from-source#update-your-project-to-build-from-source).
88

@@ -23,7 +23,7 @@ In particular, you will have to edit the `android/settings.gradle` file as follo
2323
> + }
2424
> ```
2525
26-
To download our custom version of Hermes, you need to run from your app package:
26+
To fetch the pinned Hermes, you need to run from your app package:
2727
2828
```
2929
npx react-native-node-api vendor-hermes
@@ -39,7 +39,7 @@ export REACT_NATIVE_OVERRIDE_HERMES_DIR=$(npx react-native-node-api vendor-herme
3939
4040
## Cleaning your React Native build folders
4141
42-
If you've accidentally built your app without Hermes patched, you can clean things up by deleting the `ReactAndroid` build folder.
42+
If you've accidentally built your app without the vendored Hermes, you can clean things up by deleting the `ReactAndroid` build folder.
4343
4444
```
4545
rm -rf node_modules/react-native/ReactAndroid/build

docs/HOW-IT-WORKS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ The native implementation of `requireNodeAddon` is responsible for loading the d
3939

4040
In any case the native code stores the initialization function in a data-structure.
4141

42-
## `react-native-node-api` creates a `node_env` and initialize the Node-API module
42+
## `react-native-node-api` creates a `napi_env` and initialize the Node-API module
4343

44-
The initialization function of a Node-API module expects a `node_env`, which we create by calling `createNodeApiEnv` on the `jsi::Runtime`.
44+
The initialization function of a Node-API module expects a `napi_env`, which we create by calling `hermes_napi_create_env` with the low-level Hermes VM runtime behind the `jsi::Runtime`. As in Node.js, each addon gets its own environment.
4545

4646
## The library's C++ code initialize the `exports` object
4747

4848
An `exports` object is created for the Node-API module and both the `napi_env` and `exports` object is passed to the Node-API module's initialization function and the third party code is able to call the Node-API free functions:
4949

50-
- The engine-specific functions (see [js_native_api.h](https://github.com/nodejs/node/blob/main/src/js_native_api.h)) are implemented by the `jsi::Runtime` (currently only Hermes supports this).
50+
- The engine-specific functions (see [js_native_api.h](https://github.com/nodejs/node/blob/main/src/js_native_api.h)) are implemented by the engine itself (currently only Hermes implements Node-API).
5151
- The runtime-specific functions (see [node_api.h](https://github.com/nodejs/node/blob/main/src/node_api.h)) are implemented by `react-native-node-api`.
5252

5353
## `my-app` regain control and call `add`

0 commit comments

Comments
 (0)