Skip to content

Commit

Permalink
feat: add ability to generate a local library (#469)
Browse files Browse the repository at this point in the history
### 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

https://github.com/callstack/react-native-builder-bob/assets/1174278/d1da73f7-8a57-4911-9200-07c937d3b940
  • Loading branch information
satya164 authored Sep 29, 2023
1 parent c6fc8e7 commit bf94f69
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 91 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ jobs:
--author-url https://test.test \
--repo-url https://test.test \
--type ${{ matrix.type }} \
--languages ${{ matrix.language }}
--languages ${{ matrix.language }} \
--no-local
- name: Cache dependencies of library
id: library-yarn-cache
Expand Down
Loading

0 comments on commit bf94f69

Please sign in to comment.