Optimizing Configuration Time for Android Apps that Use React Native
Article Summary
Swiggy's Android team was losing 1+ minute on every single build. For a team generating 55 builds daily, that's death by a thousand paper cuts.
Balvinder Gambhir from Swiggy's engineering team diagnosed why adding React Native to their super app caused Gradle configuration times to skyrocket. The culprit? A native_modules.gradle script executing expensive node commands on every build.
Key Takeaways
- Configuration time jumped from seconds to 1m 26s after adding React Native
- 86% of time spent executing native_modules.gradle script repeatedly
- Caching node config command output slashed configuration to 12 seconds
- Team now saves 1 hour per day across 55 daily builds
- Solution uses patch-package to ensure consistent script across all developers
By caching the output of expensive node commands in the React Native build process, Swiggy reduced Gradle configuration time by 86% (from 1m 26s to 12s).
About This Article
Swiggy's React Native integration was running expensive node commands every time Gradle configured the build. The node config command alone took up most of the 1m 26s total configuration time.
Balvinder Gambhir's team added output caching for the node config command. They stored results in node_command_output.json and checked it against package.json and package-lock.json to see if the cache was still valid. They then shared the updated script using patch-package.
Configuration time dropped from 1m 26s to 12s, a reduction of 86%. The Android team saves about 1 hour daily across 55 builds, with each build taking 74 seconds less.