Swiggy Balvinder Gambhir

How Swiggy Optimizes Configuration Time for Android Apps that Use React Native

Original post Optimizing Configuration Time for Android Apps that Use React Native

M8 Related OWASP risk: Security Misconfiguration Learn more →

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

Critical Insight

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).

Continue reading

What This Article Covers

Problem

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.

Solution

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.

Impact

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.

The modified native_modules.gradle script is available as a gist, and the caching strategy could work for any hybrid app dealing with similar build bottlenecks.

This page summarizes “Optimizing Configuration Time for Android Apps that Use React Native” by Swiggy, published Oct 25, 2022. All credit for the original work goes to the authors.

Read the original on bytes.swiggy.com (opens in new tab)

AI tools for React Native

Browse all AI tools →