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

feat: add ability to generate a local library #469

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

satya164
Copy link
Member

@satya164 satya164 commented Sep 22, 2023

Summary

Currently, when we have local native modules and views, they become part of the android & ios source code, this makes upgrading the project to a newer React Native version harder as we also need to consider those changes.

This change lets us create a local library which is not part of the android & ios folders, but a separate directory in the repo, making it self contained. It also adds a new --no-example flag to generate the project without example.

More details in this RFC: react-native-community/discussions-and-proposals#702

How it works

  • If we detect a package.json in the current folder, we ask user whether they want to create a local library
  • If the project is a react-native project, we add entries to package.json based on the package manager to link the native library (which creates a symlink in node_modules)
  • If the project is not a react-native project, we don't modify package.json, but ask user to link based on the project setup - this is relevant for monorepo scenario

Test plan

  • Create a new project with npx react-native init
  • Run create-react-native-library in the project to create a local library
  • Import the library in App.tsx and use the exported method to verify functionality
  • Install dependencies and pods, then run the app on Android & iOS to verify that it works
Kapture.2023-09-22.at.17.00.37.mp4

@satya164 satya164 marked this pull request as draft September 22, 2023 15:18
@satya164 satya164 force-pushed the @satya164/local-modules branch 4 times, most recently from e64aba4 to 1f9f239 Compare September 22, 2023 15:28
@satya164 satya164 marked this pull request as ready for review September 22, 2023 15:31
@satya164 satya164 force-pushed the @satya164/local-modules branch 8 times, most recently from 1fc011d to 61909ce Compare September 26, 2023 10:19
@satya164 satya164 force-pushed the @satya164/local-modules branch from 61909ce to acb41c3 Compare September 29, 2023 09:48
@satya164 satya164 force-pushed the @satya164/local-modules branch from acb41c3 to 6470aad Compare September 29, 2023 10:20
@satya164 satya164 merged commit bf94f69 into main Sep 29, 2023
9 of 32 checks passed
@satya164 satya164 deleted the @satya164/local-modules branch September 29, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants