Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix hardcoded path to codegen cli for monorepos (#35430)
Summary: Fixes #35429 This fix is fairly straightforward. Instead of hardcoding two separate paths for this repo or a simple user's project, we ask Node to resolve `react-native-codegen`. Because `react-native-codegen` is moved [into the `/packages/*` folder](https://github.com/facebook/react-native/blob/main/package.json#L104), it's part of a workspace in this repository. That means that this fix works not only for monorepos in general but also resolves the right path within the react native repository. You can test this out yourself when running this command in either the root, or any other workspace in this repository: ```bash node --print "require('path').dirname(require.resolve('react-native-codegen/package.json'))" ``` I've tested this on Node 16 and 18, and seems to work nicely. Note that you _**have to specify `react-native-codegen/package.json`**_. That's because the `react-native-codegen` package itself is technically invalid; it's missing an entry point within the package (no `main`). When running `node --print "require.resolve('react-native-codegen')"` Node can't resolve the main entry point, and will fail during this process. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [iOS] [Fixed] - Fix incorrect codegen CLI paths in monorepo projects Pull Request resolved: #35430 Test Plan: See PR #35429 Reviewed By: cortinico Differential Revision: D41475878 Pulled By: cipolleschi fbshipit-source-id: f0c362b64cf9c3543a3a031d7eaf302c1314e3f0
- Loading branch information