Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: outputDir is not relative to the package, but to the current directory #45112

Closed
mfazekas opened this issue Jun 22, 2024 · 2 comments
Closed
Assignees
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@mfazekas
Copy link
Contributor

Description

If my rtn-caclulator package.json have:

"includesGeneratedCode": true,
    "outputDir": {
      "android": "android/codegen"
    }

i'd expect codegen to generate into rtn-caclulator/android/codegen but codegen will generate code into andorid/codegen so it'll depend on where i execute codegen from.

Steps to reproduce

  1. clone https://github.com/mfazekas/rn-codegen-javapackagename/
cd ReproducerApp
yarn install
npx react-native codegen --path ../RTNCalculator --platform android
ReproducerApp % ls -la android/codegen/java/com/rtncalculator/                             
total 8
drwxr-xr-x  3 boga  staff    96 Jun 22 07:20 .
drwxr-xr-x  3 boga  staff    96 Jun 22 07:20 ..
-rw-r--r--  1 boga  staff  1130 Jun 22 07:20 NativeRTNCalculatorSpec.java

It think that in code the issue is that in the bellow code projectRoot points to the project's root, while outputDirFromPkgJson is just a relative path.

if (outputDirFromPkgJson != null) {
baseOutputPath = outputDirFromPkgJson;
} else {
baseOutputPath = projectRoot;
}

React Native Version

0.74.2

Affected Platforms

Runtime - Android

Areas

Codegen

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (12) arm64 Apple M2 Max
  Memory: 106.42 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.2
    path: ~/.nvm/versions/node/v18.20.2/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.nvm/versions/node/v18.20.2/bin/yarn
  npm:
    version: 10.5.0
    path: ~/.nvm/versions/node/v18.20.2/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.2
    path: /Users/boga/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.15989.150.2411.11948838
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 20.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.7.8
    path: /Users/boga/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.2
    wanted: 0.74.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

-

Reproducer

https://github.com/mfazekas/rn-codegen-javapackagename/

Screenshots and Videos

@mfazekas mfazekas added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jun 22, 2024
@cortinico cortinico added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Triage 🔍 labels Jun 22, 2024
@dmytrorykun dmytrorykun self-assigned this Jun 25, 2024
dmytrorykun added a commit to dmytrorykun/react-native that referenced this issue Jun 25, 2024
Summary:
This is a fix for facebook#45112
This diff changes the codegen so that the output path is computed relative to project root (or `path` if provided) instead of current working directory.

Changelog: [General][Fixed] - Codegen computes output path relative to project root instead of current working directory.

Reviewed By: fkgozali

Differential Revision: D59009821
@dmytrorykun
Copy link
Contributor

Thank you for a high quality issue! The fix is on the way #45165

facebook-github-bot pushed a commit that referenced this issue Jun 26, 2024
Summary:
Pull Request resolved: #45165

This is a fix for #45112
This diff changes the codegen so that the output path is computed relative to project root (or `path` if provided) instead of current working directory.

Changelog: [General][Fixed] - Codegen computes output path relative to project root instead of current working directory.

Reviewed By: fkgozali

Differential Revision: D59009821

fbshipit-source-id: 3a138a3508fc239c8600b8c9f242f1c665f8e3c0
@dmytrorykun
Copy link
Contributor

Picks requested.
0.74: reactwg/react-native-releases#335
0.75: reactwg/react-native-releases#336

Titozzz pushed a commit that referenced this issue Jul 1, 2024
Summary:
Pull Request resolved: #45165

This is a fix for #45112
This diff changes the codegen so that the output path is computed relative to project root (or `path` if provided) instead of current working directory.

Changelog: [General][Fixed] - Codegen computes output path relative to project root instead of current working directory.

Reviewed By: fkgozali

Differential Revision: D59009821

fbshipit-source-id: 3a138a3508fc239c8600b8c9f242f1c665f8e3c0
cortinico pushed a commit that referenced this issue Jul 1, 2024
Summary:
Pull Request resolved: #45165

This is a fix for #45112
This diff changes the codegen so that the output path is computed relative to project root (or `path` if provided) instead of current working directory.

Changelog: [General][Fixed] - Codegen computes output path relative to project root instead of current working directory.

Reviewed By: fkgozali

Differential Revision: D59009821

fbshipit-source-id: 3a138a3508fc239c8600b8c9f242f1c665f8e3c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

3 participants