EAS monorepo example
Enterprise-ready Expo Application Service monorepo with code sharing
Structure — Workflows — How to use it — Caveats — Common Errors
📁 Structure
apps
- Expo apps that only use packages and aren't aware of other apps.packages
- Node packages that may use external and/or local packages.
Apps
apps/ejected
- Expo bare app usingbabel
,eslint
, andui
packages.apps/managed
- Expo managed app usingbabel
,eslint
, andui
packages.apps/with-sentry
- Expo managed app withexpo-sentry
integrated.
Packages
packages/babel
- Preconfigured Babel configuration for Expo.packages/eslint
- Preconfigured ESLint coniguration for Expo.packages/ui
- Shared React Native UI components for the apps, using theeslint
package.
👷 Workflows
preview
- Publishes managed apps to a PR-specific release channel and adds a QR code to that PR.standalone
- Starts the EAS builds for user-provided OS and build profiles.test
- Ensures that the apps and packages are passing lint and build checks.
🚀 How to use it
To set this repository up, you need an Expo account with access to EAS. After that, you need to run these commands.
$ yarn
- This installs all required Node libraries using Yarn Workspaces$ yarn build
- To precompile the packages to publish them to NPM and/or use them in your apps.- Change the
expo.owner
andexpo.android.package
/expo.ios.bundleIdentifier
properties inapp.json
for all apps.
Starting apps
After the initial setup, you can start the apps from their app directories. Or you can use yarn workspace <name> expo start
command, see scripts
in package.json
.
$ yarn ejected expo run:android|ios
- This will executeexpo run:android|ios
in the ejected app.$ yarn managed expo start
- This will executeexpo start
in the managed app.$ yarn with-sentry expo start
- This will executeexpo start
in the with-sentry app.
⚠️ Caveats
Precompile packages
EAS only sends the files which are committed to the repository. That means the packages/*/build
folders need to be generated before building our apps. To tell EAS how to compile our packages, we can use the postinstall
hook.
Running EAS from apps directories
As of writing, the eas build
command needs to be executed from the package folder itself. EAS will still create a tarball with all files from your monorepo, but runs the build commands from this local folder. You can see this happening in the standalone workflow.
Using local credentials in CI
If you want to maintain the keystore or certificates yourself, you have to configure EAS with local credentials. When your CI provider doesn't allow you to add "secret files", you can encode these files to base64 strings and decode whenever you need it.
It's highly recommended to keep keystores and certificates out of your repository to avoid security issues.
❌ Common Errors
We are still testing for potential issues, but none are found yet!
with :heart: byCedric