Skip to content

Commit bae3d68

Browse files
committed
refactor: consume the top-level Nitro core layout
1 parent f2dd225 commit bae3d68

27 files changed

Lines changed: 129 additions & 134 deletions

‎.github/workflows/lint-typescript.yml‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ jobs:
5252
- name: Install npm dependencies (bun)
5353
run: bun install
5454

55-
- name: Test nitro-core
56-
run: bun nitro-core test
57-
5855
- name: Run TypeScript (tsc)
5956
run: bun typecheck
6057

@@ -74,10 +71,10 @@ jobs:
7471
working-directory: apps/example
7572
run: bun lint-ci
7673
- name: Run ESLint CI in nitro-core
77-
working-directory: packages/react-native-nitro-modules/nitro/packages/nitro-core
74+
working-directory: packages/react-native-nitro-modules/nitro/nitro-core
7875
run: bun lint-ci
79-
- name: Run ESLint CI in packages/react-native-nitro-modules/nitro/packages/nitrogen
80-
working-directory: packages/react-native-nitro-modules/nitro/packages/nitrogen
76+
- name: Run ESLint CI in packages/react-native-nitro-modules/nitro/nitrogen
77+
working-directory: packages/react-native-nitro-modules/nitro/nitrogen
8178
run: bun lint-ci
8279
- name: Run ESLint CI in packages/react-native-nitro-test-external
8380
working-directory: packages/react-native-nitro-test-external
@@ -93,10 +90,10 @@ jobs:
9390
working-directory: apps/example
9491
run: bun lint
9592
- name: Run ESLint with auto-fix in nitro-core
96-
working-directory: packages/react-native-nitro-modules/nitro/packages/nitro-core
93+
working-directory: packages/react-native-nitro-modules/nitro/nitro-core
9794
run: bun lint
98-
- name: Run ESLint with auto-fix in packages/react-native-nitro-modules/nitro/packages/nitrogen
99-
working-directory: packages/react-native-nitro-modules/nitro/packages/nitrogen
95+
- name: Run ESLint with auto-fix in packages/react-native-nitro-modules/nitro/nitrogen
96+
working-directory: packages/react-native-nitro-modules/nitro/nitrogen
10097
run: bun lint
10198
- name: Run ESLint with auto-fix in packages/react-native-nitro-test-external
10299
working-directory: packages/react-native-nitro-test-external

‎.github/workflows/run-nitrogen-init.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040

4141
- name: Run nitrogen init outside the repository
4242
working-directory: ${{ runner.temp }}
43-
run: node "$GITHUB_WORKSPACE/packages/react-native-nitro-modules/nitro/packages/nitrogen/lib/index.js" init react-native-math
43+
run: node "$GITHUB_WORKSPACE/packages/react-native-nitro-modules/nitro/nitrogen/lib/index.js" init react-native-math

‎CONTRIBUTING.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ Either is welcome. A clean, deterministic repro is often more valuable than a gu
2323
The React Native repository is a Bun monorepo with a pinned `packages/react-native-nitro-modules/nitro/` submodule from [margelo/nitro](https://github.com/margelo/nitro):
2424

2525
- [apps/example/](apps/example) — React Native example app that hosts the runtime test harness.
26-
- [packages/react-native-nitro-modules/nitro/packages/nitro-core/](https://github.com/margelo/nitro/tree/core-split/packages/nitro-core) - shared JS/TS definitions and runtime helpers, published from `nitro`.
27-
- [packages/react-native-nitro-modules/nitro/packages/nitrogen/](https://github.com/margelo/nitro/tree/core-split/packages/nitrogen) - the `nitrogen` code generator, maintained in `nitro`.
28-
- [packages/react-native-nitro-modules/](packages/react-native-nitro-modules) - the published React Native package and its CocoaPods, Gradle, and CMake configuration. Its native sources are staged from `packages/react-native-nitro-modules/nitro/packages/react-native-nitro-modules/`; its RN-specific JS is maintained here. Shared JS/TS comes from `nitro-core`.
26+
- [packages/react-native-nitro-modules/nitro/nitro-core/](https://github.com/margelo/nitro/tree/core-split/nitro-core) - shared native runtime and JS/TS API. The `nitro-core` npm package publishes only JS/TS.
27+
- [packages/react-native-nitro-modules/nitro/nitrogen/](https://github.com/margelo/nitro/tree/core-split/nitrogen) - the `nitrogen` code generator, maintained in `nitro`.
28+
- [packages/react-native-nitro-modules/](packages/react-native-nitro-modules) - the published React Native package and its CocoaPods, Gradle, and CMake configuration. Its native sources are staged from `packages/react-native-nitro-modules/nitro/nitro-core/`; its RN-specific JS is maintained here. Shared JS/TS comes from `nitro-core`.
2929
- [packages/react-native-nitro-test/](packages/react-native-nitro-test) — a Nitro module full of specs used as compile-time and runtime tests.
3030
- [packages/react-native-nitro-test-external/](packages/react-native-nitro-test-external) — a second Nitro module used to cover cross-module behavior.
3131
- [packages/template/](packages/template) - the `npx nitrogen init` React Native library template. It stays here with the CocoaPods/Gradle/CMake integration and React Native dependencies it configures.
@@ -50,17 +50,17 @@ bun lint-all # run all linters (JS/TS, C++, Swift, Kotlin)
5050

5151
The `packages/react-native-nitro-modules/nitro/` gitlink records the exact Nitro commit used by this repository. This repository develops on `main`; the submodule's development branch in `nitro` is `core-split`. Ordinary builds and `git submodule update --init --recursive` use the recorded commit. Do not use `git submodule update --remote` in builds.
5252

53-
Edit native sources in `packages/react-native-nitro-modules/nitro/packages/react-native-nitro-modules/` and shared JS/TS in `packages/react-native-nitro-modules/nitro/packages/nitro-core/`. The wrapper's `cpp/`, `ios/`, and `android/src/` directories are generated by `bun sync-core` and ignored by Git. The wrapper maintains `src/` for RN bootstrap, views, worklets, and shared API re-exports. The staging command owns only those directories and the additional shared files listed in `scripts/sync-core.mjs`. Keep handwritten package and build configuration outside them. Nitrogen is used directly from `packages/react-native-nitro-modules/nitro/packages/nitrogen/` and is not copied into the wrapper.
53+
Edit shared sources in `packages/react-native-nitro-modules/nitro/nitro-core/`: `cpp/`, `apple/`, and `android/src/` contain native code; `js/` contains the shared JS/TS API. The wrapper's `cpp/`, `ios/`, and `android/src/` directories are generated by `bun sync-core` and ignored by Git. The command maps core's `apple/` sources to the wrapper's existing `ios/` path. The wrapper maintains `src/` for RN bootstrap, views, worklets, and shared API re-exports. The staging command owns only those directories and the additional shared files listed in `scripts/sync-core.mjs`. Keep handwritten package and build configuration outside them. Nitrogen is used directly from `packages/react-native-nitro-modules/nitro/nitrogen/` and is not copied into the wrapper.
5454

5555
To update the pinned core:
5656

57-
1. Edit shared sources in `packages/react-native-nitro-modules/nitro/`. Stage new or deleted implementation files there so `bun sync-core` sees them. Existing tracked edits can be tested before committing with `bun run build`, `bun specs`, and the relevant native builds and tests from the wrapper root. The wrapper builds Nitrogen directly from `packages/react-native-nitro-modules/nitro/packages/nitrogen/`.
57+
1. Edit shared sources in `packages/react-native-nitro-modules/nitro/`. Stage new or deleted implementation files there so `bun sync-core` sees them. Existing tracked edits can be tested before committing with `bun run build`, `bun specs`, and the relevant native builds and tests from the wrapper root. The wrapper builds Nitrogen directly from `packages/react-native-nitro-modules/nitro/nitrogen/`.
5858
2. Run the standalone core build and typecheck from a separate `nitro` checkout with its own dependencies: `bun install`, `bun run build`, and `bun typecheck`.
5959
3. Commit and push the core changes first. Check out that commit in `packages/react-native-nitro-modules/nitro/`, then run `git add packages/react-native-nitro-modules/nitro` from the wrapper root before any further staging or builds. `bun sync-core` requires the core checkout's HEAD to match the gitlink in the wrapper's index.
6060
4. If the core version changed, run `bun update-core-version`. Run `bun install`, `bun specs`, and the relevant native checks, then commit the core pin, version/lockfile changes, and any intended generated test bindings here. Push the wrapper commit after the core commit is available remotely.
6161
5. On another checkout, run `git submodule update --init --recursive` followed by `bun install` after pulling the wrapper commit.
6262

63-
Prepare version changes in the standalone `nitro` repository with `bun version:set VERSION`. This updates `nitro-core`, Nitrogen, its core dependency, the native source manifest, and embedded JS/native versions. Build Nitrogen and refresh the core lockfile before committing. Publish `nitro-core` followed by `nitrogen` from the `nitro` repository, then use the final pushed core commit when updating the wrapper as described above. Nitrogen depends on `nitro-core` with a compatible semver range. The RN package depends on the exact core version to match its native runtime. All three packages use the coordinated release version.
63+
Prepare version changes in the standalone `nitro` repository with `bun version:set VERSION`. This updates `nitro-core`, Nitrogen, its core dependency, and embedded JS/native versions in `nitro-core/js/version.ts` and `nitro-core/cpp/utils/NitroDefines.hpp`. Build Nitrogen and refresh the core lockfile before committing. Publish `nitro-core` followed by `nitrogen` from the `nitro` repository, then use the final pushed core commit when updating the wrapper as described above. Nitrogen depends on `nitro-core` with a compatible semver range. The RN package depends on the exact core version to match its native runtime. All three packages use the coordinated release version.
6464

6565
`bun update-core-version` copies the authoritative version into the wrapper and test packages. Inspect real `npm pack` tarballs for `nitro-core`, `nitrogen`, and the RN package and run the native consumer checks before publishing. In this repository, `bun release` checks the existing version and publishes only `react-native-nitro-modules` through `npm publish`; it does not bump versions with release-it.
6666

@@ -118,7 +118,7 @@ If a PR adds dozens of new structs, enums, or spec files to reproduce a bug, it
118118
bun specs
119119
```
120120
This runs `nitrogen` for `react-native-nitro-test` (and transitively for `react-native-nitro-test-external`). Commit the generated files.
121-
4. **Implement the fix** in `packages/react-native-nitro-modules/nitro/packages/react-native-nitro-modules/` or `packages/react-native-nitro-modules/nitro/packages/nitrogen/`. Run `bun sync-core` after changing shared sources. Keep regression tests and their generated bindings in this repository.
121+
4. **Implement the fix** in `packages/react-native-nitro-modules/nitro/nitro-core/` or `packages/react-native-nitro-modules/nitro/nitrogen/` for shared changes, or in this repository for RN integration changes. Run `bun sync-core` after changing shared sources. Keep regression tests and their generated bindings in this repository.
122122
5. **Verify locally:**
123123
- `bun run build` — all packages build.
124124
- `bun typecheck` and `bun lint-all`.

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
They consist of two parts:
1313

1414
- [**react-native-nitro-modules**](packages/react-native-nitro-modules): The React Native package and native build integration for Nitro Modules
15-
- [**nitrogen**](https://github.com/margelo/nitro/tree/core-split/packages/nitrogen): An optional code-generator for nitro module library authors
15+
- [**nitrogen**](https://github.com/margelo/nitro/tree/core-split/nitrogen): An optional code-generator for nitro module library authors
1616

1717
## Example
1818

@@ -56,7 +56,7 @@ cd ios && pod install
5656
- [**Community Discord** 💬](https://margelo.com/discord)
5757
- [**Nitro Module Builder** AI GPT 🤖](https://chatgpt.com/g/g-6870125d0fcc8191925bd20a02c78bcf-nitro-module-builder)
5858
- [**How to build a Nitro Module** YouTube Tutorial ▶️](https://youtu.be/528SxTGnIlc?si=IxH7n09ZVe4iwRPv)
59-
- [**nitrogen**/README.md](https://github.com/margelo/nitro/blob/core-split/packages/nitrogen/README.md)
59+
- [**nitrogen**/README.md](https://github.com/margelo/nitro/blob/core-split/nitrogen/README.md)
6060
- [**react-native-nitro-modules**/README.md](./packages/react-native-nitro-modules/README.md)
6161
- [**react-native-nitro-test** example module](./packages/react-native-nitro-test/README.md)
6262
- [`TestObject.nitro.ts` example playground](./packages/react-native-nitro-test/src/specs/TestObject.nitro.ts)
@@ -89,7 +89,7 @@ We build fast and beautiful apps. Contact us at [margelo.com](https://margelo.co
8989

9090
This repository owns the React Native package, apps, test modules, docs, and templates. Shared runtime sources and Nitrogen live in [margelo/nitro](https://github.com/margelo/nitro), pinned here by the `packages/react-native-nitro-modules/nitro/` submodule.
9191

92-
For a fresh checkout, run `bun bootstrap` to initialize `packages/react-native-nitro-modules/nitro/`, install dependencies, and build the workspace. Run `bun bootstrap:ios` to also install the example app's iOS dependencies. Implementation changes belong in `packages/react-native-nitro-modules/nitro/`; `bun sync-core` copies them into the React Native package before builds and packing.
92+
For a fresh checkout, run `bun bootstrap` to initialize `packages/react-native-nitro-modules/nitro/`, install dependencies, and build the workspace. Run `bun bootstrap:ios` to also install the example app's iOS dependencies. Shared implementation changes belong in `packages/react-native-nitro-modules/nitro/nitro-core/`; `bun sync-core` copies its native sources into the React Native package before builds and packing. Shared JS/TS comes from the `nitro-core` dependency. RN bootstrap, views, and worklets integration remain in this repository.
9393

9494
Read [CONTRIBUTING.md](./CONTRIBUTING.md) for the contribution flow (PR expectations, the required test-per-fix rule, and the nitrogen workflow). For environment setup and reproduction walkthroughs, see the [contributing guide](https://nitro.margelo.com/docs/resources/contributing) on the docs site.
9595

0 commit comments

Comments
 (0)