callstack / react-native-builder-bob

👷‍♂️ Simple set of CLIs to scaffold and build React Native libraries for different targets
https://callstack.github.io/react-native-builder-bob/
2.78k stars 184 forks source link

feat: disable RNTA temporarily #658

Open atlj opened 1 week ago

atlj commented 1 week ago

Summary

  1. Disables the RNTA temporarily
  2. Mentions you need to add package.json to your exports in the docs
  3. Automatically adds package.json with bob if you don't have includesGeneratedCode: true.
  4. Closes #637

Why the changes?

Currently, there are two approaches with React Native Codegen.

1. Pregenerate

If you have includesGeneratedCode: true in your codegenConfig, you can generate the Codegen specs in the build time and ship them with your library. This is the recommended way.

2. Let the app generate

If you don't have includesGeneratedCode: true, when the application builds, the React Native Codegen is invoked and goes through all the dependencies of the app and generates the codegen specs. However, if you have ESModule exports and if you haven't added your package.json to the exports property, then the Codegen silently skips your library.


Because Codegen silently fails when you don't have package.json in the exports or don't build Codegen specs at the build time, people might have big problems figuring out this on their own. So we're temporarily disabling RNTA until we enable build time spec generation for it.

Test plan

CRNL

  1. Generate a library using crnl
  2. Make sure the RNTA isn't an option there

Bob

  1. Do bob init on a library
  2. Make sure package.json is added to the exports field.
tido64 commented 5 days ago

Hey @atlj, I'm just trying to understand how RNTA leads to this bug and what we can do to forward fix it instead of disabling it. Afaics, isn't this a bug in core?

atlj commented 5 days ago

Hey @tido64 thanks for jumping in, we don't have any problems with RNTA itself right now. The root problem is that we haven't implemented the precompiled codegen spec shipping feature for RNTA yet, which is currently causing some fragmentations. The plan is to disable the RNTA option temporarily and bring it back with full precompiled codegen spec shipping.

If you're curious about what we need to implement in CRNL for this, you can take a look at #566 where we implemented this feature for vanilla example apps.