Reputation: 1178
I want to know do unused packages cause APK
size to grow?
Consider I install dozens of NPM
packages for my project but I never import and use them. These files obviously increase my project folder size but do they affect APK
size when building APK
?
The question can be answered about .ipa
too.
Upvotes: 1
Views: 804
Reputation: 709
APK Analyzer will not look for any unused dependent NPM packages because all your javascript code is bundled by metro before being included in your Android project as an index.android.bundle asset:
Metro is a JavaScript bundler. It takes in an entry file and various options, and gives you back a single JavaScript file that includes all your code and its dependencies.
So any unused dependencies must be pruned before creating the apk. Read about Tree shaking, which does exactly that:
Tree shaking is a process in which the bundler includes only the code that is actually used.
Note that only modules that have a dependency from your code will be included in the bundle.
Upvotes: 2