Reputation: 311
I have two Expo (React Native) apps that share most of their code and are already in production. We are trying to move them to a monorepo directory structure as follows:
lerna.json
package.json
packages/
mobile-1/
app.json
index.js
package.json
mobile-2/
app.json
index.js
package.json
mobile-common/
src/
... actual app code ...
index.js
package.json
The way our setup works is that we export a function that starts the app from mobile-common/index.js
and mobile-{1,2}/index.js
are supposed to call this function with initialization parameters specific to each of them.
The problem with this setup is that mobile-common
makes use of react-native
and expo
dependencies, which are also required by exp
to start the React Native packager which causes certain issues at build time. We tried the following:
mobile-common
, expo
and react-native
to the dependencies in mobile-{1,2}/package.json
and doing lerna bootstrap
. This allows us to run the packager but mobile apps crash while building because they find duplicate dependencies.lerna bootstrap --hoist
also did not work.npm link
also produced issues at build time with duplicate dependencies.We really want to move to this kind of structure because our previous structure didn't easily allow us to run both apps side by side, and it is becoming increasingly necessary.
Thanks for helping us out!
Upvotes: 4
Views: 2341
Reputation: 773
If you want to setup expo with a monorepo you can look at my example here.
Currently the expo packages must remain in the root package.json because of limitations with watchman not resolving symlinks properly.
Upvotes: 1