-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Proposal
Enable Platform Shaking for React Native Bundle Size Optimization
Problem
The app’s Hermes Bytecode (HBC) bundle is larger than necessary. The Metro bundler and Babel transformer are using default configurations that do not enable Metro’s import support, which prevents Metro from performing platform-specific code elimination.
Additionally, the app includes expo/metro-config in metro.config.js, which is unnecessary since we do not use the Expo CLI. A larger bundle size leads to slower app startup times and higher memory consumption.
Solution
Enable platform shaking by aligning Metro and Babel configurations and removing the unnecessary Expo Metro config dependency. This allows Metro to exclude unused, platform-specific code from the final bundle.
Results
With these changes, we reduced the bundle size from 37.1 MB to 34.2 MB (~2.9 MB reduction, approximately 8%).
We still need to test this on ad-hoc builds to confirm all works correctly
Draft PR -> https://github.com/Expensify/App/pull/80110/files
Inspiration -> https://x.com/thymikee/status/2013321153700340183
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022024957569917353966
- Upwork Job ID: 2024957569917353966
- Last Price Increase: 2026-02-20