-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat(crnl): support nitro modules #721
base: main
Are you sure you want to change the base?
Conversation
letsgoooooo!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really excited for this!
packages/create-react-native-library/src/exampleApp/generateExampleApp.ts
Show resolved
Hide resolved
@@ -85,10 +91,16 @@ | |||
"eslint-config-prettier": "^9.0.0", | |||
"eslint-plugin-prettier": "^5.0.1", | |||
"jest": "^29.7.0", | |||
<% if (project.nitro) { -%> | |||
"nitro-codegen": "^<%- versions.nitroCodegen %>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah here we have it - ok good!
packages/create-react-native-library/templates/common/CONTRIBUTING.md
Outdated
Show resolved
Hide resolved
packages/create-react-native-library/templates/native-common/android/build.gradle
Show resolved
Hide resolved
public var hybridContext = margelo.nitro.HybridContext() | ||
public var memorySize: Int { | ||
getSizeOf(self) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should really work on getting this lifted into the spec instead of having it at user class level. Maybe Nitro 19
|
||
packagingOptions { | ||
excludes = [ | ||
"META-INF", | ||
"META-INF/**", | ||
"**/libc++_shared.so", | ||
"**/libfbjni.so", | ||
"**/libjsi.so", | ||
"**/libfolly_json.so", | ||
"**/libfolly_runtime.so", | ||
"**/libglog.so", | ||
"**/libhermes.so", | ||
"**/libhermes-executor-debug.so", | ||
"**/libhermes_executor.so", | ||
"**/libreactnative.so", | ||
"**/libreactnativejni.so", | ||
"**/libturbomodulejsijni.so", | ||
"**/libreact_nativemodule_core.so", | ||
"**/libjscexecutor.so" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still need those days?, I created a rn turbo modules recently then migrated to nitro later, and i didn't got any symbol conflict as we used to have in the past
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I tried to build nitro without these, but I got an error mentioning some of these libs were duplicated so these are needed for nitro modules right now.
- name: Run nitro codegen | ||
if: matrix.type == 'nitro-module' | ||
run: | | ||
yarn nitrogen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to run this manually?
Also contributing guide needs to include the workflow in case there are any new steps - like running this (and when is it needed)
packages/create-react-native-library/src/exampleApp/generateExampleApp.ts
Outdated
Show resolved
Hide resolved
packages/create-react-native-library/templates/common/CONTRIBUTING.md
Outdated
Show resolved
Hide resolved
packages/create-react-native-library/templates/nitro-module/android/$CMakeLists.txt
Outdated
Show resolved
Hide resolved
packages/create-react-native-library/templates/nitro-module/$nitro.json
Outdated
Show resolved
Hide resolved
@@ -49,7 +52,11 @@ def supportsNamespace() { | |||
|
|||
android { | |||
if (supportsNamespace()) { | |||
<% if (project.nitro) { -%> | |||
namespace "com.margelo.nitro.<%- project.package -%>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this the library's namespace? then it shouldn't have margelo.com since that's not the library's organization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @mrousavy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm this doesn't seem good. i wouldn't feel comfortable having my own library under margelo's domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea Nitro expects margelo.com namespaces for all Hybrid Objects.
This was to simplify the ProGuard annotations (if something is missing from com.margelo it was stripped out, which we explicitly deal with) - and also it makes cross-referencing Hybrid Objects from other Nitro Modules easier since we don't have to worry about different namespaces here.
Also, it's at least a little bit of branding 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wouldn't feel comfortable having my own library under margelo's domain.
All the generated code from Turbo Modules are under facebook's domain. This is the same here, the generated code is under margelo domain.
Nitro expects registered hybrid objects to be under the same domain as well, not any custom configurable domain - which is the same as how it works in C++ Turbo Modules.
This was just to simplify the whole thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the generated code from Turbo Modules are under facebook's domain. This is the same here, the generated code is under margelo domain.
Having the generated code or a specific part of the code vs the entire package like it's done here are quite different things. I'm sure bigger companies would have restrictions on using their namespace and publishing to their internal registries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I understand, but this is not gonna change anytime soon as it might require larger changes in the Nitrogen codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a bigger company reaches out to me because they want to use Nitro but can't because of namespace restrictions, then I'll work on that with them. For now, I don't see a problem in it tbh.
@@ -72,7 +78,7 @@ | |||
"devDependencies": { | |||
"@commitlint/config-conventional": "^17.0.2", | |||
"@evilmartians/lefthook": "^1.5.0", | |||
<% if (example === 'vanilla') { -%> | |||
<% if (example === 'vanilla' && !project.nitro) { -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be more future-proof to add configs based on what type of project it is rather than what type of project it is not. That way adding a new type won't require adding new condition to each call site.
I think we should just add a key for the official module type and use it for these checks (here and other places) instead of !project.nitro
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've introduced project.moduleConfig
(which replaces project.module
) as an union type of native-modules
, turbo-modules
, nitro-modules
. This is the native modules api that we use.
5df5303
to
54d0fa5
Compare
…TING.md Co-authored-by: Marc Rousavy <[email protected]>
Co-authored-by: Marc Rousavy <[email protected]>
WIP until #732 is merged
Summary
Adds Nitro Modules support to
create-react-native-library
.What's next?
Test plan
Prior to all cases:
yarn
andyarn prepare
bin/create-react-native-library
Example app
yarn nitrogen
to create nitro bindingsPublished lib
https://github.com/wclr/yalc
(yalc publish
)yalc add your-lib