Skip to content

Codegen page lacks info and is confusing #4460

Closed
@ospfranco

Description

@ospfranco

Description

I have a RN library that was shipping the generated artifacts using RN 0.76. When I tried to add it to a RN 75 I started getting this compilation error:

Image

This is confusing as it is on the generated code. I stumbled for hours trying to re-generate everything but nothing helped. I then tried to update the app to 76 and it magically started working. I tried to revert back to 75 but it kept working.

I then started googling trying to see if the problem was my package and gratuitously landed on this page

https://reactnative.dev/docs/the-new-architecture/codegen-cli#including-generated-code-into-libraries

It finally dawned on me I had the "includesGeneratedCode": true set. This is the default used by react-native-builder-bob. So, I was shipping the generated code which, contrary to what's described on that page, it cannot be true to be guaranteed stable across RN versions. What's the entire point of codegen if it will be generated against one specific version?!

I'm on the process of disabling the flag and shipping only the source files so codegen happens on build time of the app but I'm just trying to understand if I'm holding it wrong or what's mentioned on the page is just not true

I don't know if you can confidently ship this feature. I know it's not necessarily fault of the codegen cli but rather the template but at least to me it seems stability across versions CANNOT be guaranteed, right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions