fix(android): apply codegen plugin unconditionally, not gated on isNewArchitectureEnabled - #4
Conversation
…wArchitectureEnabled
RN's autolinking discovers this module's codegen libraryName by regexing the
raw text of android/build.gradle (findLibraryName.js) rather than evaluating
this file's Groovy conditionals. So the app-level build always registers this
module for codegen and expects android/build/generated/source/codegen/jni/
to exist, regardless of isNewArchitectureEnabled().
Because `apply plugin: 'com.facebook.react'` and the `react { ... }` codegen
block were gated behind isNewArchitectureEnabled(), consuming apps with
newArchEnabled=false never actually ran this module's own codegen task, so
that directory was never created. This produces a hard CMake configure
failure for any consumer:
CMake Error: add_subdirectory given source
".../react-native-esc-pos-printer/android/build/generated/source/codegen/jni/"
which is not an existing directory
This is also unconditionally required going forward: RN 0.82+ no longer
supports opting out of New Architecture (newArchEnabled is ignored), so
codegen must always run regardless of that flag.
Applies the plugin and configures the react{} codegen extension
unconditionally, matching how other actively-maintained RN modules declare
codegen. No behavior change for consumers already on New Architecture.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Minor bump rather than a patch: consuming apps now get a real behavior change (codegen artifacts are always generated, not just when newArchEnabled=true), not just a bugfix in the strict sense.
Summary
RN's Android autolinking discovers this module's codegen
libraryNameby regexing the raw text ofandroid/build.gradle(findLibraryName.jsin@react-native-community/cli-config-android) rather than evaluating this file's Groovy conditionals. So the consuming app's build always registers this module for codegen and expectsandroid/build/generated/source/codegen/jni/to exist — regardless ofisNewArchitectureEnabled().Because
apply plugin: 'com.facebook.react'and thereact { ... }codegen block here were gated behindisNewArchitectureEnabled(), a consuming app withnewArchEnabled=falsenever actually ran this module's own codegen task, so that directory was never created. This produces a hard CMake configure failure for any consumer:This also matters going forward regardless of that flag: RN 0.82+ no longer supports opting out of New Architecture (
newArchEnabledis ignored and a warning is printed), so codegen must always run.Change
Applies the
com.facebook.reactplugin and configures thereact { }codegen extension unconditionally, matching how other actively-maintained RN modules declare codegen (they don't gate it onisNewArchitectureEnabled()either). No behavior change for consumers already on New Architecture; unblocks consumers on RN 0.82+/0.84+ where new arch is forced on.Base branch note
Targeting
rohit/publish-github-packagerather thanmain:mainhas since diverged to a restructuredpackage/layout (a different major-version line) whereandroid/build.gradleno longer exists at this path.rohit/publish-github-packageis the actual lineage this org'sv2.2.xreleases (up tov2.2.4) are cut from, so this is the branch av2.2.5-style patch release would come from.Test plan
newArchEnabled=false(or on RN 0.82+/0.84+ where the flag is ignored) successfully runsgenerateCodegenArtifactsFromSchemafor this module andconfigureCMakeDebugno longer fails with theadd_subdirectoryerror above.🤖 Generated with Claude Code