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

Prep for eas build #24

Merged
merged 3 commits into from
Aug 27, 2021
Merged

Prep for eas build #24

merged 3 commits into from
Aug 27, 2021

Conversation

bpringe
Copy link
Collaborator

@bpringe bpringe commented Aug 26, 2021

These small changes make it so that this project will work out of the box with EAS Build. I left out the EAS Build configuration because that is somewhat account-specific.

With EAS Build, if no App.js or index.js file exists at the root, it creates and index.js file that tries to import ./App, which it expects to export a root component, which it passes to registerRootComponent. This causes an error during the build process that looks like:

[stderr] Error loading assets JSON from Metro. Ensure you've followed all expo-updates installation steps correctly. Unable to resolve module ./App from /build/workingdir/build/index.js: 
[stderr] None of these files exist:
[stderr]   * App(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[stderr]   * App/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[stderr]   2 | import { registerRootComponent } from 'expo';
[stderr]   3 |
[stderr] > 4 | import App from './App';
[stderr]     |                  ^
[stderr]   5 |
[stderr]   6 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App);
[stderr]   7 | // It also ensures that whether you load the app in Expo Go or in a native build,

Since we're calling registerRootComponent in our ClojureScript, we want EAS Build to load our ./app/index.js file instead of creating one and loading that. To do this, we create our own index.js file at the root and import ./app/index.js.

Since the eas-cli by default does not send files to the build server that are ignored in .gitignore, and we want to ignore the shadow compilation output files, we use a build-specific npm hook that EAS Build will call to compile the cljs during the build process. The eas-build-post-install script in package.json is used to do this.

I've tested these changes myself in another branch on my fork by configuring EAS Build and running a build that creates an apk, downloading that apk, and running it on an emulator.

@PEZ PEZ merged commit ebbcf1f into PEZ:master Aug 27, 2021
@PEZ
Copy link
Owner

PEZ commented Aug 27, 2021

Thank you! This is awesome. I have tested that it works with non-EAS builds. Check!

@bpringe bpringe deleted the prep_for_eas_build branch August 28, 2021 00:16
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