Repository navigation
feat: ship codegen-generated specs - #566
Merged
Merged
Conversation
satya164
reviewed
Jun 14, 2024
Collaborator
Author
|
move the codegen script and codegen patching into bob. |
atlj
force-pushed
the
@atlj/ship-codegen-specs
branch
3 times, most recently
from
July 5, 2024 18:03
70dc19f to
3425532
Compare
atlj
force-pushed
the
@atlj/ship-codegen-specs
branch
from
July 5, 2024 18:14
2aa76c8 to
d0b1ad2
Compare
I think it would be great to explain the advantages (or disadvantages) of this approach. My understand for example if you want to make android side work with old arch, the codgen generated interfaces, delegates can be usefull to be shipped with the project. |
satya164
requested changes
Jul 23, 2024
satya164
requested changes
Jul 29, 2024
atlj
force-pushed
the
@atlj/ship-codegen-specs
branch
from
August 11, 2024 13:40
72c5efe to
07df18c
Compare
atlj
force-pushed
the
@atlj/ship-codegen-specs
branch
from
August 16, 2024 11:53
d1e0764 to
39d2a07
Compare
satya164
approved these changes
Aug 16, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
So far with the new architecture-supported templates, we've been generating libraries that didn't ship their codegen-generated specs. This means the library's users had to build the codegen specs on their end (this was done implicitly). With this, the codegen-generated specs are generated at the build time and they are shipped with the library.
I've followed this guide from the React Native new arch working group.
Making sure example app builds are triggering codegen
An important problem to figure out was to make sure the codegen-generated specs were being built with each native build of the example app. To do that,
create-react-native-librarynow modifies non-legacy example apps and adds:example/android/build.gradlethat's triggered before each native build.pre_installhook toexample/ios/Podfilethat's triggered when user callspod install.These modifications make sure
yarn codegenis called on the repo root to generate the codegen specs.Notes
react-native codegenis called, the generated Java code doesn't follow thecodegenConfig.android.javaPackageNameproperty in thepackage.json. This means the generated Java files are stored in a default location with the wrong package name. To fix it, I've added a script that moves the codegen-generated files into the correct place. You can check codegen - javaPackageName is ignored with includesGeneratedCode and react-native codegen react/react-native#45079 to see more.Test plan
Test if Android builds trigger codegen
create-react-native-libraryandroid/generated.Test if installing pods triggers codegen
create-react-native-librarypod installinexample/iosios/generated.Test if iOS builds trigger codegen
create-react-native-librarypod installinexample/iosios/generatedsince that's generated by the pod install stepios/generated.Test if building the library triggers codegen
yarn prepareto emulate the library release processyarn packpackage.tgzios/generated, andandroid/generatedin the generated package.