Open mfazekas opened 2 weeks ago
This is (sadly) a known bug. The issue is happening regardless of you using includesGeneratedCode
or not.
I have an internal ticket to work on this. Sadly fixing it would be a breaking change for every codegen user so we're being a bit caution on when we should fix.
@cortinico thanks much.
Another issue is that outputDir
is not relative to package root, but to cwd. So in the reproducer if run:
cd ReproducerApp
npx react-native codegen --path ../RTNCalculator --platform android
it generates into ./android/codegen
which is ReproducerApp/android/codegen
instead of ../RTNCalculator/android/codegen
.
RTNCalculator/package.json
:
"includesGeneratedCode": true,
"outputDir": {
"android": "android/codegen"
}
Is this a bug? Shall I open a separate issue for it?
it generates into
./android/codegen
which isReproducerApp/android/codegen
instead of../RTNCalculator/android/codegen
.
mmm I'm not sure this follows to your previous statement.
If as you said, the path is relative to cwd (being ./ReproducerApp
in your example), then stuff should be generated inside:
./RTNCalculator/android/codegen
no?
mmm I'm not sure this follows to your previous statement. If as you said, the path is relative to cwd (being
./ReproducerApp
in your example), then stuff should be generated inside:./RTNCalculator/android/codegen
no?
Sorry if I wasn't clear. I'd expect
"includesGeneratedCode": true,
"outputDir": {
"android": "android/codegen"
}
to always generate into RTNCaclulator/android/codegen
so always into the lib, but if I run from the app directory it creates new folder in the app
cd ReproducerApp
npx react-native codegen --path ../RTNCalculator --platform android
it generates into ReproducerApp/android/codegen
ReproducerApp % ls -la android/codegen/java/com/rtncalculator
total 8
drwxr-xr-x 3 boga staff 96 Jun 20 14:24 .
drwxr-xr-x 4 boga staff 128 Jun 20 14:24 ..
-rw-r--r-- 1 boga staff 1130 Jun 20 14:24 NativeRTNCalculatorSpec.java
@dmytrorykun can help you more here as he implemented the react-native codegen
command. But yes this is probably a separate bug which needs a separate issue
This is definitely a bug. I'll take a look
@dmytrorykun opened issue #45112
We've been hitting this issue in react-native-builder-bob. I've added a script to patch this behavior there. You can find the script here
For folks who want to use this, when we land this in bob, you will be able to call it with --target codegen
and it should generate the codegen specs and patch this.
Description
react-native codegen ignores javaPackageName in package.json/codeGenConfig/andorid/javaPackageName and uses
com.facebook.fbreact.specs
Steps to reproduce
See https://github.com/mfazekas/rn-codegen-javapackagename
See https://github.com/facebook/react-native/blob/2a6a895b17fdd4112349853e08a50c4c90886cb8/packages/react-native/scripts/codegen/generate-artifacts-executor.js#L454-L462
React Native Version
0.74.2
Affected Platforms
Runtime - Android
Areas
Codegen
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/mfazekas/rn-codegen-javapackagename/
Screenshots and Videos
No response