Skip to content

Commit dfb84d9

Browse files
committed
docs: mention its not recommended to not ship codegen scaffold
1 parent 2b52339 commit dfb84d9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docs/pages/build.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ yarn add --dev react-native-builder-bob
4343
"source": "src",
4444
"output": "lib",
4545
"targets": [
46+
"codegen",
4647
["commonjs", { "esm": true }],
4748
["module", { "esm": true }],
4849
["typescript", { "esm": true }]
@@ -109,9 +110,15 @@ yarn add --dev react-native-builder-bob
109110

110111
> If you're building TypeScript definition files, also make sure that the `types` field points to a correct path. Depending on the project configuration, the path can be different for you than the example snippet (e.g. `lib/typescript/index.d.ts` if you have only the `src` directory and `rootDir` is not set).
111112
112-
1. Export package.json if needed:
113+
1. Configure [React Native Codegen](https://reactnative.dev/docs/the-new-architecture/what-is-codegen)
113114

114-
If you don't have `"includesGeneratedCode": true` in your `codegenConfig`, and you ship your native library for the new architecture, you also have to add `"./package.json": "./package.json"` into the `exports` field. Otherwise, React Native Codegen will skip spec generation for your library when your library is consumed as an NPM library. You can find the related issue [here](https://github.com/callstack/react-native-builder-bob/issues/637).
115+
You can follow the [Official Codegen Setup Guide](https://reactnative.dev/docs/the-new-architecture/using-codegen) to enable Codegen.
116+
117+
It's also recommended to ship your Codegen generated scaffold code with your library since it has numerous benefits. To see the benefits and implement this behavior, you can see the [Official Codegen Shipping Guide](https://reactnative.dev/docs/the-new-architecture/codegen-cli#including-generated-code-into-libraries).
118+
119+
##### Opting out of Codegen shipping __(not recommended)__
120+
121+
If you have a reason to not ship Codegen generated scaffold code with your library, you need to remove the [codegen target](#codegen) and add `package.json` to your `exports` field. Otherwise, React Native Codegen will skip spec generation for your library when your library is consumed as an NPM library. You can find the related issue [here](https://github.com/callstack/react-native-builder-bob/issues/637).
115122

116123
```json
117124
"exports": {

0 commit comments

Comments
 (0)