Set expo prebuild arguments during eas build

I want to avoid downgrading my dependencies during expo prebuild.

In my repository, I have set "postinstall": "expo prebuild --skip-dependency-update expo,expo-updates,react-native,react-native-unimodules" which runs prebuild first.

expo run checks if the ios and android folders are there and does not run prebuild again if thats the case. But eas build does not do the same check and always runs expo prebuild again, downgrading my dependencies. (The check for eas build seems to be whether android and ios folders are gitignored, which they are in my case)

Is it possible to disable the downgrade behavior? For example by specifying the arguments passed to expo prebuild during eas builds? (–skip-dependency-update in particular)

for eas only file that are commited into repo matter(only git repo is uploaded to the builder), so from build service perspective project like that is managed one and we are enforcing specific package versions.

If you have good reason to override and you are prepared to deal with potential issue that his might cause you can force that behaviour by either

  • committing android and ios directory
  • build with EAS_NO_VCS=1 eas build - this will ignore git fully, but careful this disables all git functionality (you won’t have warning about uncommitted changes, commit hash will be missing on the website, if cli is introducing any changes we can’t display you diff of that)

EAS_NO_VCS=1 did not solve the problem

Even with EAS_NO_VCS=1 eas-cli’s resolveWorkflowAsync function still calls git check-ignore on AndroidManifest.xml / project.pbxproj and if they are gitignored, it sets the workflow to MANAGED which causes prebuild to be executed.

I can confirm that the android and ios folders are included in the bundle uploaded to EAS. In expo run, the existence of android and ios folders is what triggers prebuiild, in EAS Build, expo seems to just use the detected project type (managed / generic) which is based on the existence of native files and the corresponding gitignore config.

I wish there were one of these features:
a) expo prebuild should not downgrade dependencies
b) eas build runner should use the same logic as expo run for executing expo-prebuild: existence of ios and android folders
c) EXPO_PREBUILD_ARGS, EXPO_PREBUILD_SKIP_DEPENDENCY_UPDATE or eas.json / app.json config to set the arguments for prebuild

Even with EAS_NO_VCS=1 eas-cli’s resolveWorkflowAsync function still calls git check-ignore on

with that option, no git command should be called

I can confirm that the android and ios folders are included in the bundle uploaded to EAS

how did you verify this? bigger upload size is not 100% correct indicator

I forgot that we still respect .gitignore even with that option, if you want to upload android and ios dirs you also need to copy your .gitignore file to .easignore and remove android and ios from there

1 Like

how did you verify this? bigger upload size is not 100% correct indicator

I inspected the tarball that is generated by stepping the eas-cli’s execution and opening the temp file before it is uploaded and deleted

There’s also a job JSON: (eas build --local prints it)

{
    "type": "managed",
    "platform": "android",
    "projectRootDirectory": ".",
    "projectArchive": {
      "type": "PATH",
      "path": "/var/folders/4l/5q_1bbc93mb221kpmsz41jth0000gn/T/eas-cli-nodejs/7813e3b5-6861-4c70-9e58-2da6da59219a.tar.gz"
    },

I think whenever the job’s type is managed, expo prebuild is run.

Tests:

  • commit all files to git, no gitignore (type: generic, no prebuild)
  • gitignore android and ios (type: managed, prebuild is run)
  • gitignore android and ios, .easignore without ios and android (type: managed, prebuild is run)
  • EAS_NO_VCS=1 + gitignore android and ios (type: managed, prebuild is run)
  • EAS_NO_VCS=1 + gitignore android and ios + easignore without ios and android (type: managed, prebuild is run)

Neither .easignore nor EAS_NO_VCS=1 seem to work as escape hatches in my tests

Running into a similar issue here: EAS Build - Prebuild downgrading expo-updates causing crash

This is how I work around this issue:

// package.json 
"scripts": {
  "eas-build-post-install": "git checkout -- package.json yarn.lock && yarn install && expo prebuild --clean --skip-dependency-update react,react-native,expo-updates"
}

But honestly, having an escape hatch via a CLI, eas.json or app.json parameter would be great!
It would be even better if no packages were autoinstalled and instead expo doctor would warn if there is a mismatch.

1 Like

Perfect, thanks for sharing this! :slight_smile: