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
{{ message }}
Repository navigation
Commit e75c50a
Browse filesBrowse the repository at this point in the historyBrowse files
Move the stub into a node-api-stub package and link it as node-api
- Add a `node-api-stub` package holding `getNodeApiFunctions()`,
`generateFunction` and the stub generator with its CMake project.
weak-node-api's generator and the host's injector generator now read
the function list from it, and weak-node-api no longer builds a stub.
- In `hermes` mode, cmake-rn adds the stub to the addon's own build
(and leaves it out of the prebuilds), so the addon doesn't need
weak-node-api to be built.
- Rename the CMake target to `node-api` (`node-api-config.cmake`).
- Remove `tests/async/binding.gyp`, which made gyp-to-cmake overwrite
the hand-written CMakeLists.txt with one linking weak-node-api.
- Port verify-hermes-linkage to TypeScript, comparing the real Hermes
against node-api-headers' symbol list instead of a stub binary.
Refs #494
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U2xSE4PR7T7WFxexRhihBT
Copy file name to clipboardExpand all lines: .changeset/node-api-linkage.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,11 @@
2
2
"cmake-rn": major
3
3
"react-native-node-api": minor
4
4
"weak-node-api": minor
5
+
"node-api-stub": minor
5
6
---
6
7
7
8
Add `--node-api-linkage <weak-node-api|hermes|none>` to `cmake-rn`, replacing `--no-weak-node-api-linkage` (use `--node-api-linkage none`).
8
9
9
-
Addons linking the new neutral `node-api-linkage` CMake target (`find_package(node-api-linkage REQUIRED CONFIG)`) link whatever the mode selects. With `hermes` they link a link-time stub of `libhermesvm`, so they record `hermesvm` and call Hermes directly instead of going through `weak-node-api`. The stub is generated from the Node-API headers and built alongside `weak-node-api`; it never ships in an app. Addons naming the `weak-node-api` target directly keep linking it in every mode but `none`. The default stays `weak-node-api`.
10
+
Addons linking the new `node-api` CMake target (`find_package(node-api REQUIRED CONFIG)`) link whatever the mode selects. With `hermes` they link a link-time stub of `libhermesvm`, built along with the addon, so they record `hermesvm` and call Hermes directly instead of going through `weak-node-api`, which doesn't need to be built. The stub never ships in an app. Addons naming the `weak-node-api` target directly keep building alongside. The default stays `weak-node-api`.
11
+
12
+
The new `node-api-stub` package holds the stub and `getNodeApiFunctions()`, which moved there from `weak-node-api`.
Copy file name to clipboardExpand all lines: packages/cmake-rn/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
@@ -88,19 +88,19 @@ endif()
88
88
89
89
### Choosing what to link with `--node-api-linkage`
90
90
91
-
An addon can instead link the neutral `node-api-linkage` target, which links whatever `--node-api-linkage <mode>` selects:
91
+
An addon can instead link the `node-api` target, which links whatever `--node-api-linkage <mode>` selects:
92
92
93
93
-`weak-node-api` (the default): the `weak-node-api` library described above.
94
-
-`hermes`: a link-time stub of Hermes' `hermesvm` library, so the addon records `hermesvm` and calls Hermes' Node-API directly. The stub is never loaded or shipped: the app's own Hermes provides the implementation at runtime. This requires a Hermes exporting Node-API (such as the one vendored by `react-native-node-api`), and the addon gets Hermes' own `napi_fatal_error` instead of the host's.
94
+
-`hermes`: a link-time stub of Hermes' `hermesvm` library from [`node-api-stub`](../node-api-stub), built along with the addon, so the addon records `hermesvm` and calls Hermes' Node-API directly. The stub is never shipped: the app's own Hermes provides the implementation at runtime. This doesn't need `weak-node-api` to be built, but requires a Hermes exporting Node-API (such as the one vendored by `react-native-node-api`), and the addon gets Hermes' own `napi_fatal_error` instead of the host's.
The `weak-node-api` target stays available in every mode but `none`, so addons linking it directly can be built alongside.
104
+
Addons linking the `weak-node-api` target directly can be built alongside: it's defined in the `weak-node-api` mode, and in the `hermes` mode whenever `weak-node-api` is built.
105
105
106
106
This is different from how `cmake-js` "injects" the Node-API for linking (via `${CMAKE_JS_INC}`, `${CMAKE_JS_SRC}` and `${CMAKE_JS_LIB}`). To allow for interoperability between these tools, we inject these when you pass `--cmake-js` to `cmake-rn`.
0 commit comments