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

fix: resolve react native dir in monorepo in android build #692

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

rolud
Copy link
Contributor

@rolud rolud commented Nov 15, 2024

📜 Description

I updated resolveReactNativeDirectory in android/react-native-helpers.gradle to handle custom directory structures in a more generic way.

As in the previous version, I followed how software-mansion resolved this problem.

💡 Motivation and Context

I am working on a monorepo that's follow this structure

apps
├── react-native-app
│   ├── node_modules
│   │   └── react-native-keyboard-controller
packages
node_modules
├── react-native
package.json

The previous monorepo workaround was limited to two hardcoded paths.

My monorepo is build with Turborepo. Referring to their docs:

Referencing node_modules in your code

The specific locations for node_modules within the Workspace are not a part of the public API of package managers. This means that referencing node_modules directly (like node ./node_modules/a-package/dist/index.js) can be brittle, since the location of the dependency on disk can change with other dependency changes around the Workspace.

Instead, rely on conventions of the Node.js ecosystem for accessing dependency modules whenever possible.

We can't be sure that react-native and react-native-keyboard-controller folders are in the same node_modules folder.

📢 Changelog

fixed android build in monorepo

Android

resolve node modules react native directory using node resolver instead of hardcoded paths

🤔 How Has This Been Tested?

I tested android build in a monorepo created with turbo repo, in standalone react native app repo and in the example app.

📸 Screenshots (if appropriate):

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko
Copy link
Owner

Thank you ❤️ Changes look good to me!

I triggered CI - let's see whether it pass or not 👀

Copy link
Contributor

github-actions bot commented Nov 15, 2024

📊 Package size report

Current size Target Size Difference
159647 bytes 159566 bytes 81 bytes 📈

@kirillzyusko kirillzyusko self-assigned this Nov 15, 2024
@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 🤖 android Android specific labels Nov 15, 2024
@kirillzyusko kirillzyusko merged commit eeb70a8 into kirillzyusko:main Nov 15, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Android specific 🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants