Commit bf94f69
authored
feat: add ability to generate a local library (#469)
### 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-07c937d3b9401 parent c6fc8e7 commit bf94f69
File tree
12 files changed
+278
-91
lines changed- .github/workflows
- packages
- create-react-native-library
- src
- utils
- templates
- common-example/example
- src
- common-local
- common
- native-common-example
- example
- scripts
- react-native-builder-bob/src
- utils
12 files changed
+278
-91
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
0 commit comments