You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
Copy file name to clipboardExpand all lines: AGENTS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ patch or workaround:
60
60
61
61
## Critical Build Dependencies
62
62
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.
64
64
-**Prebuilt Binary Spec**: All tools must output to the exact naming scheme:
65
65
- Android: `*.android.node/` with jniLibs structure + `react-native-node-api-module` marker file
Copy file name to clipboardExpand all lines: README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,9 @@
19
19
## How does this work?
20
20
21
21
> [!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.
24
25
25
26
> [!NOTE]
26
27
> 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:
35
36
36
37
Responsible for adding Node-API support to your React Native application:
37
38
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.
42
42
- Automatically discovers and adds Node-API binaries, matching the [the prebuilt binary specification](./docs/PREBUILDS.md)
43
43
- This is driven by the platform specific build tools (through the Podspec on iOS and eventually Gradle on Android)
44
44
- Implements a TurboModule with a `requireNodeAddon` function responsible for
Copy file name to clipboardExpand all lines: docs/ANDROID.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Building Hermes from source
4
4
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.
6
6
7
7
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).
8
8
@@ -23,7 +23,7 @@ In particular, you will have to edit the `android/settings.gradle` file as follo
23
23
> + }
24
24
> ```
25
25
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:
Copy file name to clipboardExpand all lines: docs/HOW-IT-WORKS.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,15 +39,15 @@ The native implementation of `requireNodeAddon` is responsible for loading the d
39
39
40
40
In any case the native code stores the initialization function in a data-structure.
41
41
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
43
43
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.
45
45
46
46
## The library's C++ code initialize the `exports` object
47
47
48
48
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:
49
49
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).
51
51
- 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`.
0 commit comments