You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The **Codegen** CLI is a great tool for library developers. It can be used to peek at the generated code to see which interfaces you need to implement. Or you can generate the code if you want to ship it in your library.
44
+
The Codegen CLI is a great tool for library developers. It can be used to take a sneak-peek at the generated code to see which interfaces you need to implement.
45
45
46
-
This setup has several benefits:
46
+
Normally the generated code is not included in the library, and the app that uses the library is responsible for running the Codegen at build time.
47
+
This is a good setup for most cases, but Codegen also offers a mechanism to include the generated code in the library itself via the `includesGeneratedCode` property.
48
+
49
+
It's important to understand what are the implications of using `includesGeneratedCode = true`. Including the generated code comes with several benefits such as:
47
50
48
51
- No need to rely on the app to run **Codegen** for you, the generated code is always there.
49
-
- The implementation files are always consistent with the generated interfaces.
52
+
- The implementation files are always consistent with the generated interfaces (this makes your library code more resilient against API changes in codegen).
50
53
- No need to include two sets of files to support both architectures on Android. You can only keep the New Architecture one, and it is guaranteed to be backwards compatible.
51
-
- No need to worry about **Codegen** version mismatch between what is used by the app, and what was used during library development.
52
54
- Since all native code is there, it is possible to ship the native part of the library as a prebuild.
53
55
56
+
On the other hand, you also need to be aware of one drawback:
57
+
58
+
- The generated code will use the React Native version defined inside your library. So if your library is shipping with React Native 0.76, the generated code will be based on that version. This could mean that the generated code is not compatible with apps using **previous** React Native version used by the app (e.g. an App running on React Native 0.75).
59
+
60
+
## Enabling `includesGeneratedCode`
61
+
54
62
To enable this setup:
55
63
56
64
- Add the `includesGeneratedCode` property into your library's `codegenConfig` field in the `package.json` file. Set its value to `true`.
The **Codegen** CLI is a great tool for library developers. It can be used to peek at the generated code to see which interfaces you need to implement. Or you can generate the code if you want to ship it in your library.
44
+
The Codegen CLI is a great tool for library developers. It can be used to take a sneak-peek at the generated code to see which interfaces you need to implement.
45
45
46
-
This setup has several benefits:
46
+
Normally the generated code is not included in the library, and the app that uses the library is responsible for running the Codegen at build time.
47
+
This is a good setup for most cases, but Codegen also offers a mechanism to include the generated code in the library itself via the `includesGeneratedCode` property.
48
+
49
+
It's important to understand what are the implications of using `includesGeneratedCode = true`. Including the generated code comes with several benefits such as:
47
50
48
51
- No need to rely on the app to run **Codegen** for you, the generated code is always there.
49
-
- The implementation files are always consistent with the generated interfaces.
52
+
- The implementation files are always consistent with the generated interfaces (this makes your library code more resilient against API changes in codegen).
50
53
- No need to include two sets of files to support both architectures on Android. You can only keep the New Architecture one, and it is guaranteed to be backwards compatible.
51
-
- No need to worry about **Codegen** version mismatch between what is used by the app, and what was used during library development.
52
54
- Since all native code is there, it is possible to ship the native part of the library as a prebuild.
53
55
56
+
On the other hand, you also need to be aware of one drawback:
57
+
58
+
- The generated code will use the React Native version defined inside your library. So if your library is shipping with React Native 0.76, the generated code will be based on that version. This could mean that the generated code is not compatible with apps using **previous** React Native version used by the app (e.g. an App running on React Native 0.75).
59
+
60
+
## Enabling `includesGeneratedCode`
61
+
54
62
To enable this setup:
55
63
56
64
- Add the `includesGeneratedCode` property into your library's `codegenConfig` field in the `package.json` file. Set its value to `true`.
The **Codegen** CLI is a great tool for library developers. It can be used to peek at the generated code to see which interfaces you need to implement. Or you can generate the code if you want to ship it in your library.
44
+
The Codegen CLI is a great tool for library developers. It can be used to take a sneak-peek at the generated code to see which interfaces you need to implement.
45
45
46
-
This setup has several benefits:
46
+
Normally the generated code is not included in the library, and the app that uses the library is responsible for running the Codegen at build time.
47
+
This is a good setup for most cases, but Codegen also offers a mechanism to include the generated code in the library itself via the `includesGeneratedCode` property.
48
+
49
+
It's important to understand what are the implications of using `includesGeneratedCode = true`. Including the generated code comes with several benefits such as:
47
50
48
51
- No need to rely on the app to run **Codegen** for you, the generated code is always there.
49
-
- The implementation files are always consistent with the generated interfaces.
52
+
- The implementation files are always consistent with the generated interfaces (this makes your library code more resilient against API changes in codegen).
50
53
- No need to include two sets of files to support both architectures on Android. You can only keep the New Architecture one, and it is guaranteed to be backwards compatible.
51
-
- No need to worry about **Codegen** version mismatch between what is used by the app, and what was used during library development.
52
54
- Since all native code is there, it is possible to ship the native part of the library as a prebuild.
53
55
56
+
On the other hand, you also need to be aware of one drawback:
57
+
58
+
- The generated code will use the React Native version defined inside your library. So if your library is shipping with React Native 0.76, the generated code will be based on that version. This could mean that the generated code is not compatible with apps using **previous** React Native version used by the app (e.g. an App running on React Native 0.75).
59
+
60
+
## Enabling `includesGeneratedCode`
61
+
54
62
To enable this setup:
55
63
56
64
- Add the `includesGeneratedCode` property into your library's `codegenConfig` field in the `package.json` file. Set its value to `true`.
0 commit comments