react-native-firebase size in application bundle much bigger than required

Created on 6 Oct 2018  路  1Comment  路  Source: invertase/react-native-firebase

Issue

react-native-firebase size in application bundle is much bigger than required. To reproduce, I used this technique (in the folder of project that contains and uses only import { analytics, messaging, notifications } from 'react-native-firebase'):

npm install -g source-map-explorer
react-native bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output main2.jsbundle --sourcemap-output main2.jsbundle.map
source-map-explorer main2.jsbundle main2.jsbundle.map

The process produces this picture (only react-native-firebase part):
size map of <a href="react-native-firebase@5.0.0">react-native-firebase@5.0.0</a>

158Kb is a very big overhead for whole bundle size... my estimate is about 50Kb
To compare:

  • all our application screens & logic is about 300Kb (all code is used)
  • whole react-native is about 500Kb (should be no more than ~400Kb, but it's another issue)

So can we structure code in a way that will allow to include only useful code in the bundle?
I see two main issues currently:

  1. It imports unused modules
  2. It imports modules not for target platform

Environment

  1. Application Target Platform: iOS
  2. Development Operating System: macOS
  3. Build Tools: not relevant here
  4. React Native version: 0.57.2
  5. React Native Firebase Version: 5.0.0
  6. Firebase Module: analytics, messaging, notifications (but any other combinations should be optimized)
  7. Are you using typescript? yes (but not relevant)
Build Error JavaScript

Most helpful comment

@vovkasm v6.0.0 (early WIP) is a full restructure / re-write to split into a mono-repo setup with multiple packages, which will solve this. Not much for now that we can do though, but it is something that is coming, soon 鈩笍.

I'd add that v6 is not as drastic as it sounds though, for the end user. It's mainly splitting everything up for easier installs (fewer steps & more automation), removing technical debt and stability & internals re-writes of certain modules.

Ping me on discord if you'd like to discuss it / give any feedback.


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

>All comments

@vovkasm v6.0.0 (early WIP) is a full restructure / re-write to split into a mono-repo setup with multiple packages, which will solve this. Not much for now that we can do though, but it is something that is coming, soon 鈩笍.

I'd add that v6 is not as drastic as it sounds though, for the end user. It's mainly splitting everything up for easier installs (fewer steps & more automation), removing technical debt and stability & internals re-writes of certain modules.

Ping me on discord if you'd like to discuss it / give any feedback.


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

Was this page helpful?
0 / 5 - 0 ratings