akveo / react-native-ui-kitten

:boom: React Native UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/react-native-ui-kitten/
MIT License
10.28k stars 951 forks source link

theme file is too huge! #1057

Closed heroic closed 3 years ago

heroic commented 4 years ago

πŸ› Bug Report

after running yarn start, and taking a look at the generated.json file, it seems the file is 3.8MB. This is too huge for a theme file. We should potentially use babel to tree-shake and remove the config for components that are not being used.

Also noted that this file is included as res in android. I'd expect this to be in index.bundle.js so that codepush can affect theme changes.

The final bundle also has these two files included, not sure why:

  1. node_modules_evadesign_eva_themes_light.json
  2. node_modules_evadesign_eva_themes_dark.json

To Reproduce

  1. Create a new app with ui kitten v4
  2. ./gradlew bundleRelease
  3. run size-analyzer check-bundle -d app-release.aab

Expected behavior

generated.json should be included in index.bundle.js

Sample project

https://github.com/heroic/uikitten-test

run, yarn, and then yarn start and then ls -la node_modules/@eva-design/eva/generated.json

The file size is abount 3.8MB

UI Kitten and Eva version

Package Version
@eva-design/eva 1.4.0
@ui-kitten/components 4.4.1

Environment information

System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Memory: 112.74 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.13.0 - /usr/local/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom_64
      Android NDK: 21.0.6113669
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  Languages:
    Python: 2.7.17 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.62.0 => 0.62.0 
  npmGlobalPackages:
    *react-native*: Not Found
lesmo commented 4 years ago

That doesn't seem right. Eva JSON files shouldn't be getting into your assets as far as I know. Even then, it's not as huge. What's the size of the files when you build for release?

For me, using ui-kitten with react-native-web renders a 3.5MB bundle - this is including all my packages and code. For Android, I couldn't see any json files in my /res folder.

heroic commented 4 years ago

@lesmo This is the analysis on "release" build. I use custom mappings. Do you have any custom mappings in your project?

lesmo commented 4 years ago

So when I took a look at your Sample Project section I didn't notice you were talking about the output from:

ls -la node_modules/@eva-design/eva/generated.json

This is the wrong way to think about it. The Metro Bundler does many things behind the scenes, including tree shaking, minifying and more.

I cloned your sample project, and ran react-native-bundle-visualizer to see the actual bundled size and it's components: image

As you can see, the bundled JS isn't even close to the size of the generated json you're talking about. Furthermore, in the actual report you can see that ui-kitten is taking only 224kb while @eva-design is taking only 9kb: image

The rest of the bundle is mostly React runtime and components.

heroic commented 4 years ago

@lesmo Did you run the size-analyze command on the build release bundle?

Here's the sample output from the example project:

Dynamically delivering large files7.1 MiB
Place large file base/res/raw/node_modules_evadesign_eva_generated.json inside an on demand dynamic-feature to avoid bundling in apk (saves 3.8 MiB)
Place large file base/assets/index.android.bundle inside an on demand dynamic-feature to avoid bundling in apk (saves 2.4 MiB)
Place large file base/res/raw/node_modules_evadesign_eva_mapping.json inside an on demand dynamic-feature to avoid bundling in apk (saves 282.0 kiB)
lesmo commented 4 years ago

By default, react-native-bundle-visualizer runs the build process for release bundle.

I noticed your output is for Android build (the bundle analyzer automatically builds for iOS), so I tried running the command with Android as target: image

The result is the same, the generated bundle is only 1.3mb in size: image

So then I ran:

$ cd android
$ ./gradlew assembleRelease

The React bundle generated during this process is, as expected, the same size as the bundle analyzer command (located under android/app/build/generated/assets/react/release): image

Furthermore, the files referenced in your comments are mere kilobytes in size: image

lesmo commented 4 years ago

I took one more crack at this. I don't know what size-analyzer tool is, or where to get it... but I built the file again and listed the files in it with the tools in the Android SDK:

$ apkanalyzer -h files list app-release.aab
Here's the file list ``` / /META-INF/ /META-INF/MANIFEST.MF /META-INF/ANDROIDD.RSA /META-INF/ANDROIDD.SF /base/ /base/resources.pb /base/native.pb /base/assets.pb /base/manifest/ /base/manifest/AndroidManifest.xml /base/lib/ /base/lib/x86_64/ /base/lib/x86_64/libyoga.so /base/lib/x86_64/libreactnativejni.so /base/lib/x86_64/libreactnativeblob.so /base/lib/x86_64/libnative-imagetranscoder.so /base/lib/x86_64/libnative-filters.so /base/lib/x86_64/libjsinspector.so /base/lib/x86_64/libjsijniprofiler.so /base/lib/x86_64/libjscexecutor.so /base/lib/x86_64/libjsc.so /base/lib/x86_64/libimagepipeline.so /base/lib/x86_64/libhermes-inspector.so /base/lib/x86_64/libhermes-executor-release.so /base/lib/x86_64/libhermes-executor-debug.so /base/lib/x86_64/libglog_init.so /base/lib/x86_64/libglog.so /base/lib/x86_64/libfolly_json.so /base/lib/x86_64/libfolly_futures.so /base/lib/x86_64/libfbjni.so /base/lib/x86_64/libfb.so /base/lib/x86_64/libc++_shared.so /base/lib/x86/ /base/lib/x86/libyoga.so /base/lib/x86/libreactnativejni.so /base/lib/x86/libreactnativeblob.so /base/lib/x86/libnative-imagetranscoder.so /base/lib/x86/libnative-filters.so /base/lib/x86/libjsinspector.so /base/lib/x86/libjsijniprofiler.so /base/lib/x86/libjscexecutor.so /base/lib/x86/libjsc.so /base/lib/x86/libimagepipeline.so /base/lib/x86/libhermes-inspector.so /base/lib/x86/libhermes-executor-release.so /base/lib/x86/libhermes-executor-debug.so /base/lib/x86/libglog_init.so /base/lib/x86/libglog.so /base/lib/x86/libfolly_json.so /base/lib/x86/libfolly_futures.so /base/lib/x86/libfbjni.so /base/lib/x86/libfb.so /base/lib/x86/libc++_shared.so /base/lib/armeabi-v7a/ /base/lib/armeabi-v7a/libyoga.so /base/lib/armeabi-v7a/libreactnativejni.so /base/lib/armeabi-v7a/libreactnativeblob.so /base/lib/armeabi-v7a/libnative-imagetranscoder.so /base/lib/armeabi-v7a/libnative-filters.so /base/lib/armeabi-v7a/libjsinspector.so /base/lib/armeabi-v7a/libjsijniprofiler.so /base/lib/armeabi-v7a/libjscexecutor.so /base/lib/armeabi-v7a/libjsc.so /base/lib/armeabi-v7a/libimagepipeline.so /base/lib/armeabi-v7a/libhermes-inspector.so /base/lib/armeabi-v7a/libhermes-executor-release.so /base/lib/armeabi-v7a/libhermes-executor-debug.so /base/lib/armeabi-v7a/libglog_init.so /base/lib/armeabi-v7a/libglog.so /base/lib/armeabi-v7a/libfolly_json.so /base/lib/armeabi-v7a/libfolly_futures.so /base/lib/armeabi-v7a/libfbjni.so /base/lib/armeabi-v7a/libfb.so /base/lib/armeabi-v7a/libc++_shared.so /base/lib/arm64-v8a/ /base/lib/arm64-v8a/libyoga.so /base/lib/arm64-v8a/libreactnativejni.so /base/lib/arm64-v8a/libreactnativeblob.so /base/lib/arm64-v8a/libnative-imagetranscoder.so /base/lib/arm64-v8a/libnative-filters.so /base/lib/arm64-v8a/libjsinspector.so /base/lib/arm64-v8a/libjsijniprofiler.so /base/lib/arm64-v8a/libjscexecutor.so /base/lib/arm64-v8a/libjsc.so /base/lib/arm64-v8a/libimagepipeline.so /base/lib/arm64-v8a/libhermes-inspector.so /base/lib/arm64-v8a/libhermes-executor-release.so /base/lib/arm64-v8a/libhermes-executor-debug.so /base/lib/arm64-v8a/libglog_init.so /base/lib/arm64-v8a/libglog.so /base/lib/arm64-v8a/libfolly_json.so /base/lib/arm64-v8a/libfolly_futures.so /base/lib/arm64-v8a/libfbjni.so /base/lib/arm64-v8a/libfb.so /base/lib/arm64-v8a/libc++_shared.so /base/root/ /base/root/okhttp3/ /base/root/okhttp3/internal/ /base/root/okhttp3/internal/publicsuffix/ /base/root/okhttp3/internal/publicsuffix/publicsuffixes.gz /base/root/META-INF/ /base/root/META-INF/androidx.documentfile_documentfile.version /base/root/META-INF/androidx.legacy_legacy-support-core-ui.version /base/root/META-INF/androidx.customview_customview.version /base/root/META-INF/androidx.coordinatorlayout_coordinatorlayout.version /base/root/META-INF/androidx.fragment_fragment.version /base/root/META-INF/androidx.interpolator_interpolator.version /base/root/META-INF/androidx.slidingpanelayout_slidingpanelayout.version /base/root/META-INF/androidx.vectordrawable_vectordrawable-animated.version /base/root/META-INF/androidx.versionedparcelable_versionedparcelable.version /base/root/META-INF/androidx.arch.core_core-runtime.version /base/root/META-INF/androidx.print_print.version /base/root/META-INF/androidx.core_core.version /base/root/META-INF/androidx.drawerlayout_drawerlayout.version /base/root/META-INF/androidx.lifecycle_lifecycle-viewmodel.version /base/root/META-INF/androidx.cursoradapter_cursoradapter.version /base/root/META-INF/androidx.asynclayoutinflater_asynclayoutinflater.version /base/root/META-INF/androidx.viewpager_viewpager.version /base/root/META-INF/androidx.swiperefreshlayout_swiperefreshlayout.version /base/root/META-INF/androidx.appcompat_appcompat.version /base/root/META-INF/androidx.lifecycle_lifecycle-livedata-core.version /base/root/META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version /base/root/META-INF/androidx.lifecycle_lifecycle-runtime.version /base/root/META-INF/androidx.lifecycle_lifecycle-livedata.version /base/root/META-INF/androidx.loader_loader.version /base/root/META-INF/androidx.vectordrawable_vectordrawable.version /base/root/META-INF/androidx.legacy_legacy-support-core-utils.version /base/dex/ /base/dex/classes.dex /base/res/ /base/res/xml/ /base/res/xml/rn_dev_preferences.xml /base/res/raw/ /base/res/raw/node_modules_evadesign_eva_themes_light.json /base/res/raw/node_modules_evadesign_eva_themes_dark.json /base/res/raw/node_modules_evadesign_eva_mapping.json /base/res/raw/node_modules_entities_lib_maps_xml.json /base/res/raw/node_modules_entities_lib_maps_legacy.json /base/res/raw/node_modules_entities_lib_maps_entities.json /base/res/raw/node_modules_entities_lib_maps_decode.json /base/res/raw/node_modules_domserializer_foreignnames.json /base/res/raw/node_modules_csstree_dist_defaultsyntax.json /base/res/raw/node_modules_cssselect_lib_procedure.json /base/res/raw/app.json /base/res/mipmap-xxxhdpi-v4/ /base/res/mipmap-xxxhdpi-v4/ic_launcher_round.png /base/res/mipmap-xxxhdpi-v4/ic_launcher.png /base/res/mipmap-xxhdpi-v4/ /base/res/mipmap-xxhdpi-v4/ic_launcher_round.png /base/res/mipmap-xxhdpi-v4/ic_launcher.png /base/res/mipmap-xhdpi-v4/ /base/res/mipmap-xhdpi-v4/ic_launcher_round.png /base/res/mipmap-xhdpi-v4/ic_launcher.png /base/res/mipmap-hdpi-v4/ /base/res/mipmap-hdpi-v4/ic_launcher_round.png /base/res/mipmap-hdpi-v4/ic_launcher.png /base/res/mipmap-mdpi-v4/ /base/res/mipmap-mdpi-v4/ic_launcher_round.png /base/res/mipmap-mdpi-v4/ic_launcher.png /base/res/layout-v26/ /base/res/layout-v26/abc_screen_toolbar.xml /base/res/layout-watch-v20/ /base/res/layout-watch-v20/abc_alert_dialog_title_material.xml /base/res/layout-watch-v20/abc_alert_dialog_button_bar_material.xml /base/res/layout-v16/ /base/res/layout-v16/notification_template_custom_big.xml /base/res/layout-v21/ /base/res/layout-v21/notification_template_icon_group.xml /base/res/layout-v21/notification_template_custom_big.xml /base/res/layout-v21/notification_action_tombstone.xml /base/res/layout-v21/notification_action.xml /base/res/layout-v21/abc_screen_toolbar.xml /base/res/layout-v22/ /base/res/layout-v22/abc_alert_dialog_button_bar_material.xml /base/res/layout-v17/ /base/res/layout-v17/select_dialog_singlechoice_material.xml /base/res/layout-v17/select_dialog_multichoice_material.xml /base/res/layout-v17/notification_template_custom_big.xml /base/res/layout-v17/notification_action_tombstone.xml /base/res/layout-v17/notification_action.xml /base/res/layout-v17/dev_loading_view.xml /base/res/layout-v17/abc_tooltip.xml /base/res/layout-v17/abc_select_dialog_material.xml /base/res/layout-v17/abc_search_view.xml /base/res/layout-v17/abc_popup_menu_header_item_layout.xml /base/res/layout-v17/abc_dialog_title_material.xml /base/res/layout-v17/abc_alert_dialog_title_material.xml /base/res/layout-v17/abc_alert_dialog_button_bar_material.xml /base/res/layout-v17/abc_action_mode_close_item_material.xml /base/res/layout/ /base/res/layout/support_simple_spinner_dropdown_item.xml /base/res/layout/select_dialog_singlechoice_material.xml /base/res/layout/select_dialog_multichoice_material.xml /base/res/layout/select_dialog_item_material.xml /base/res/layout/redbox_view.xml /base/res/layout/redbox_item_title.xml /base/res/layout/redbox_item_frame.xml /base/res/layout/notification_template_part_time.xml /base/res/layout/notification_template_part_chronometer.xml /base/res/layout/notification_template_icon_group.xml /base/res/layout/notification_action_tombstone.xml /base/res/layout/notification_action.xml /base/res/layout/fps_view.xml /base/res/layout/dev_loading_view.xml /base/res/layout/abc_tooltip.xml /base/res/layout/abc_select_dialog_material.xml /base/res/layout/abc_search_view.xml /base/res/layout/abc_search_dropdown_item_icons_2line.xml /base/res/layout/abc_screen_toolbar.xml /base/res/layout/abc_screen_simple_overlay_action_mode.xml /base/res/layout/abc_screen_simple.xml /base/res/layout/abc_screen_content_include.xml /base/res/layout/abc_popup_menu_item_layout.xml /base/res/layout/abc_popup_menu_header_item_layout.xml /base/res/layout/abc_list_menu_item_radio.xml /base/res/layout/abc_list_menu_item_layout.xml /base/res/layout/abc_list_menu_item_icon.xml /base/res/layout/abc_list_menu_item_checkbox.xml /base/res/layout/abc_expanded_menu_layout.xml /base/res/layout/abc_dialog_title_material.xml /base/res/layout/abc_cascading_menu_item_layout.xml /base/res/layout/abc_alert_dialog_title_material.xml /base/res/layout/abc_alert_dialog_material.xml /base/res/layout/abc_alert_dialog_button_bar_material.xml /base/res/layout/abc_activity_chooser_view_list_item.xml /base/res/layout/abc_activity_chooser_view.xml /base/res/layout/abc_action_mode_close_item_material.xml /base/res/layout/abc_action_mode_bar.xml /base/res/layout/abc_action_menu_layout.xml /base/res/layout/abc_action_menu_item_layout.xml /base/res/layout/abc_action_bar_up_container.xml /base/res/layout/abc_action_bar_title_item.xml /base/res/drawable-ldrtl-xxxhdpi-v17/ /base/res/drawable-ldrtl-xxxhdpi-v17/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-ldrtl-xxxhdpi-v17/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-ldrtl-xxxhdpi-v17/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-xxxhdpi-v4/ /base/res/drawable-xxxhdpi-v4/abc_text_select_handle_right_mtrl_light.png /base/res/drawable-xxxhdpi-v4/abc_text_select_handle_right_mtrl_dark.png /base/res/drawable-xxxhdpi-v4/abc_text_select_handle_left_mtrl_light.png /base/res/drawable-xxxhdpi-v4/abc_text_select_handle_left_mtrl_dark.png /base/res/drawable-xxxhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png /base/res/drawable-xxxhdpi-v4/abc_switch_track_mtrl_alpha.9.png /base/res/drawable-xxxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-xxxhdpi-v4/abc_scrubber_control_to_pressed_mtrl_005.png /base/res/drawable-xxxhdpi-v4/abc_scrubber_control_to_pressed_mtrl_000.png /base/res/drawable-xxxhdpi-v4/abc_ic_star_half_black_48dp.png /base/res/drawable-xxxhdpi-v4/abc_ic_star_half_black_36dp.png /base/res/drawable-xxxhdpi-v4/abc_ic_star_half_black_16dp.png /base/res/drawable-xxxhdpi-v4/abc_ic_star_black_48dp.png /base/res/drawable-xxxhdpi-v4/abc_ic_star_black_36dp.png /base/res/drawable-xxxhdpi-v4/abc_ic_star_black_16dp.png /base/res/drawable-xxxhdpi-v4/abc_ic_menu_share_mtrl_alpha.png /base/res/drawable-xxxhdpi-v4/abc_ic_menu_selectall_mtrl_alpha.png /base/res/drawable-xxxhdpi-v4/abc_ic_menu_paste_mtrl_am_alpha.png /base/res/drawable-xxxhdpi-v4/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-xxxhdpi-v4/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png /base/res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png /base/res/drawable-xxxhdpi-v4/abc_btn_radio_to_on_mtrl_015.png /base/res/drawable-xxxhdpi-v4/abc_btn_radio_to_on_mtrl_000.png /base/res/drawable-xxxhdpi-v4/abc_btn_check_to_on_mtrl_015.png /base/res/drawable-xxxhdpi-v4/abc_btn_check_to_on_mtrl_000.png /base/res/drawable-ldrtl-xxhdpi-v17/ /base/res/drawable-ldrtl-xxhdpi-v17/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-ldrtl-xxhdpi-v17/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-ldrtl-xxhdpi-v17/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-xxhdpi-v4/ /base/res/drawable-xxhdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_textfield_default_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_textfield_activated_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_text_select_handle_right_mtrl_light.png /base/res/drawable-xxhdpi-v4/abc_text_select_handle_right_mtrl_dark.png /base/res/drawable-xxhdpi-v4/abc_text_select_handle_middle_mtrl_light.png /base/res/drawable-xxhdpi-v4/abc_text_select_handle_middle_mtrl_dark.png /base/res/drawable-xxhdpi-v4/abc_text_select_handle_left_mtrl_light.png /base/res/drawable-xxhdpi-v4/abc_text_select_handle_left_mtrl_dark.png /base/res/drawable-xxhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_switch_track_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_scrubber_track_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_scrubber_control_to_pressed_mtrl_005.png /base/res/drawable-xxhdpi-v4/abc_scrubber_control_to_pressed_mtrl_000.png /base/res/drawable-xxhdpi-v4/abc_scrubber_control_off_mtrl_alpha.png /base/res/drawable-xxhdpi-v4/abc_popup_background_mtrl_mult.9.png /base/res/drawable-xxhdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png /base/res/drawable-xxhdpi-v4/abc_list_selector_disabled_holo_light.9.png /base/res/drawable-xxhdpi-v4/abc_list_selector_disabled_holo_dark.9.png /base/res/drawable-xxhdpi-v4/abc_list_pressed_holo_light.9.png /base/res/drawable-xxhdpi-v4/abc_list_pressed_holo_dark.9.png /base/res/drawable-xxhdpi-v4/abc_list_longpressed_holo.9.png /base/res/drawable-xxhdpi-v4/abc_list_focused_holo.9.png /base/res/drawable-xxhdpi-v4/abc_list_divider_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_ic_star_half_black_48dp.png /base/res/drawable-xxhdpi-v4/abc_ic_star_half_black_36dp.png /base/res/drawable-xxhdpi-v4/abc_ic_star_half_black_16dp.png /base/res/drawable-xxhdpi-v4/abc_ic_star_black_48dp.png /base/res/drawable-xxhdpi-v4/abc_ic_star_black_36dp.png /base/res/drawable-xxhdpi-v4/abc_ic_star_black_16dp.png /base/res/drawable-xxhdpi-v4/abc_ic_menu_share_mtrl_alpha.png /base/res/drawable-xxhdpi-v4/abc_ic_menu_selectall_mtrl_alpha.png /base/res/drawable-xxhdpi-v4/abc_ic_menu_paste_mtrl_am_alpha.png /base/res/drawable-xxhdpi-v4/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-xxhdpi-v4/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-xxhdpi-v4/abc_ic_commit_search_api_mtrl_alpha.png /base/res/drawable-xxhdpi-v4/abc_cab_background_top_mtrl_alpha.9.png /base/res/drawable-xxhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png /base/res/drawable-xxhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png /base/res/drawable-xxhdpi-v4/abc_btn_radio_to_on_mtrl_015.png /base/res/drawable-xxhdpi-v4/abc_btn_radio_to_on_mtrl_000.png /base/res/drawable-xxhdpi-v4/abc_btn_check_to_on_mtrl_015.png /base/res/drawable-xxhdpi-v4/abc_btn_check_to_on_mtrl_000.png /base/res/drawable-xxhdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png /base/res/drawable-ldrtl-xhdpi-v17/ /base/res/drawable-ldrtl-xhdpi-v17/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-ldrtl-xhdpi-v17/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-ldrtl-xhdpi-v17/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-xhdpi-v4/ /base/res/drawable-xhdpi-v4/notify_panel_notification_icon_bg.png /base/res/drawable-xhdpi-v4/notification_bg_normal_pressed.9.png /base/res/drawable-xhdpi-v4/notification_bg_normal.9.png /base/res/drawable-xhdpi-v4/notification_bg_low_pressed.9.png /base/res/drawable-xhdpi-v4/notification_bg_low_normal.9.png /base/res/drawable-xhdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_textfield_default_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_textfield_activated_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_text_select_handle_right_mtrl_light.png /base/res/drawable-xhdpi-v4/abc_text_select_handle_right_mtrl_dark.png /base/res/drawable-xhdpi-v4/abc_text_select_handle_middle_mtrl_light.png /base/res/drawable-xhdpi-v4/abc_text_select_handle_middle_mtrl_dark.png /base/res/drawable-xhdpi-v4/abc_text_select_handle_left_mtrl_light.png /base/res/drawable-xhdpi-v4/abc_text_select_handle_left_mtrl_dark.png /base/res/drawable-xhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_switch_track_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-xhdpi-v4/abc_scrubber_track_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_scrubber_control_to_pressed_mtrl_005.png /base/res/drawable-xhdpi-v4/abc_scrubber_control_to_pressed_mtrl_000.png /base/res/drawable-xhdpi-v4/abc_scrubber_control_off_mtrl_alpha.png /base/res/drawable-xhdpi-v4/abc_popup_background_mtrl_mult.9.png /base/res/drawable-xhdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png /base/res/drawable-xhdpi-v4/abc_list_selector_disabled_holo_light.9.png /base/res/drawable-xhdpi-v4/abc_list_selector_disabled_holo_dark.9.png /base/res/drawable-xhdpi-v4/abc_list_pressed_holo_light.9.png /base/res/drawable-xhdpi-v4/abc_list_pressed_holo_dark.9.png /base/res/drawable-xhdpi-v4/abc_list_longpressed_holo.9.png /base/res/drawable-xhdpi-v4/abc_list_focused_holo.9.png /base/res/drawable-xhdpi-v4/abc_list_divider_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_ic_star_half_black_48dp.png /base/res/drawable-xhdpi-v4/abc_ic_star_half_black_36dp.png /base/res/drawable-xhdpi-v4/abc_ic_star_half_black_16dp.png /base/res/drawable-xhdpi-v4/abc_ic_star_black_48dp.png /base/res/drawable-xhdpi-v4/abc_ic_star_black_36dp.png /base/res/drawable-xhdpi-v4/abc_ic_star_black_16dp.png /base/res/drawable-xhdpi-v4/abc_ic_menu_share_mtrl_alpha.png /base/res/drawable-xhdpi-v4/abc_ic_menu_selectall_mtrl_alpha.png /base/res/drawable-xhdpi-v4/abc_ic_menu_paste_mtrl_am_alpha.png /base/res/drawable-xhdpi-v4/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-xhdpi-v4/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-xhdpi-v4/abc_ic_commit_search_api_mtrl_alpha.png /base/res/drawable-xhdpi-v4/abc_cab_background_top_mtrl_alpha.9.png /base/res/drawable-xhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png /base/res/drawable-xhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png /base/res/drawable-xhdpi-v4/abc_btn_radio_to_on_mtrl_015.png /base/res/drawable-xhdpi-v4/abc_btn_radio_to_on_mtrl_000.png /base/res/drawable-xhdpi-v4/abc_btn_check_to_on_mtrl_015.png /base/res/drawable-xhdpi-v4/abc_btn_check_to_on_mtrl_000.png /base/res/drawable-xhdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png /base/res/drawable-ldrtl-hdpi-v17/ /base/res/drawable-ldrtl-hdpi-v17/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-ldrtl-hdpi-v17/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-ldrtl-hdpi-v17/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-hdpi-v4/ /base/res/drawable-hdpi-v4/notify_panel_notification_icon_bg.png /base/res/drawable-hdpi-v4/notification_bg_normal_pressed.9.png /base/res/drawable-hdpi-v4/notification_bg_normal.9.png /base/res/drawable-hdpi-v4/notification_bg_low_pressed.9.png /base/res/drawable-hdpi-v4/notification_bg_low_normal.9.png /base/res/drawable-hdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_textfield_default_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_textfield_activated_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_text_select_handle_right_mtrl_light.png /base/res/drawable-hdpi-v4/abc_text_select_handle_right_mtrl_dark.png /base/res/drawable-hdpi-v4/abc_text_select_handle_middle_mtrl_light.png /base/res/drawable-hdpi-v4/abc_text_select_handle_middle_mtrl_dark.png /base/res/drawable-hdpi-v4/abc_text_select_handle_left_mtrl_light.png /base/res/drawable-hdpi-v4/abc_text_select_handle_left_mtrl_dark.png /base/res/drawable-hdpi-v4/abc_tab_indicator_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_switch_track_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-hdpi-v4/abc_scrubber_track_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_scrubber_control_to_pressed_mtrl_005.png /base/res/drawable-hdpi-v4/abc_scrubber_control_to_pressed_mtrl_000.png /base/res/drawable-hdpi-v4/abc_scrubber_control_off_mtrl_alpha.png /base/res/drawable-hdpi-v4/abc_popup_background_mtrl_mult.9.png /base/res/drawable-hdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png /base/res/drawable-hdpi-v4/abc_list_selector_disabled_holo_light.9.png /base/res/drawable-hdpi-v4/abc_list_selector_disabled_holo_dark.9.png /base/res/drawable-hdpi-v4/abc_list_pressed_holo_light.9.png /base/res/drawable-hdpi-v4/abc_list_pressed_holo_dark.9.png /base/res/drawable-hdpi-v4/abc_list_longpressed_holo.9.png /base/res/drawable-hdpi-v4/abc_list_focused_holo.9.png /base/res/drawable-hdpi-v4/abc_list_divider_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_ic_star_half_black_48dp.png /base/res/drawable-hdpi-v4/abc_ic_star_half_black_36dp.png /base/res/drawable-hdpi-v4/abc_ic_star_half_black_16dp.png /base/res/drawable-hdpi-v4/abc_ic_star_black_48dp.png /base/res/drawable-hdpi-v4/abc_ic_star_black_36dp.png /base/res/drawable-hdpi-v4/abc_ic_star_black_16dp.png /base/res/drawable-hdpi-v4/abc_ic_menu_share_mtrl_alpha.png /base/res/drawable-hdpi-v4/abc_ic_menu_selectall_mtrl_alpha.png /base/res/drawable-hdpi-v4/abc_ic_menu_paste_mtrl_am_alpha.png /base/res/drawable-hdpi-v4/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-hdpi-v4/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-hdpi-v4/abc_ic_commit_search_api_mtrl_alpha.png /base/res/drawable-hdpi-v4/abc_cab_background_top_mtrl_alpha.9.png /base/res/drawable-hdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png /base/res/drawable-hdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png /base/res/drawable-hdpi-v4/abc_btn_radio_to_on_mtrl_015.png /base/res/drawable-hdpi-v4/abc_btn_radio_to_on_mtrl_000.png /base/res/drawable-hdpi-v4/abc_btn_check_to_on_mtrl_015.png /base/res/drawable-hdpi-v4/abc_btn_check_to_on_mtrl_000.png /base/res/drawable-hdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png /base/res/drawable-ldrtl-mdpi-v17/ /base/res/drawable-ldrtl-mdpi-v17/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-ldrtl-mdpi-v17/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-ldrtl-mdpi-v17/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-mdpi-v4/ /base/res/drawable-mdpi-v4/notify_panel_notification_icon_bg.png /base/res/drawable-mdpi-v4/notification_bg_normal_pressed.9.png /base/res/drawable-mdpi-v4/notification_bg_normal.9.png /base/res/drawable-mdpi-v4/notification_bg_low_pressed.9.png /base/res/drawable-mdpi-v4/notification_bg_low_normal.9.png /base/res/drawable-mdpi-v4/node_modules_reactnative_libraries_newappscreen_components_logo.png /base/res/drawable-mdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_textfield_default_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_textfield_activated_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_text_select_handle_right_mtrl_light.png /base/res/drawable-mdpi-v4/abc_text_select_handle_right_mtrl_dark.png /base/res/drawable-mdpi-v4/abc_text_select_handle_middle_mtrl_light.png /base/res/drawable-mdpi-v4/abc_text_select_handle_middle_mtrl_dark.png /base/res/drawable-mdpi-v4/abc_text_select_handle_left_mtrl_light.png /base/res/drawable-mdpi-v4/abc_text_select_handle_left_mtrl_dark.png /base/res/drawable-mdpi-v4/abc_tab_indicator_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_switch_track_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_spinner_mtrl_am_alpha.9.png /base/res/drawable-mdpi-v4/abc_scrubber_track_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_scrubber_control_to_pressed_mtrl_005.png /base/res/drawable-mdpi-v4/abc_scrubber_control_to_pressed_mtrl_000.png /base/res/drawable-mdpi-v4/abc_scrubber_control_off_mtrl_alpha.png /base/res/drawable-mdpi-v4/abc_popup_background_mtrl_mult.9.png /base/res/drawable-mdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png /base/res/drawable-mdpi-v4/abc_list_selector_disabled_holo_light.9.png /base/res/drawable-mdpi-v4/abc_list_selector_disabled_holo_dark.9.png /base/res/drawable-mdpi-v4/abc_list_pressed_holo_light.9.png /base/res/drawable-mdpi-v4/abc_list_pressed_holo_dark.9.png /base/res/drawable-mdpi-v4/abc_list_longpressed_holo.9.png /base/res/drawable-mdpi-v4/abc_list_focused_holo.9.png /base/res/drawable-mdpi-v4/abc_list_divider_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_ic_star_half_black_48dp.png /base/res/drawable-mdpi-v4/abc_ic_star_half_black_36dp.png /base/res/drawable-mdpi-v4/abc_ic_star_half_black_16dp.png /base/res/drawable-mdpi-v4/abc_ic_star_black_48dp.png /base/res/drawable-mdpi-v4/abc_ic_star_black_36dp.png /base/res/drawable-mdpi-v4/abc_ic_star_black_16dp.png /base/res/drawable-mdpi-v4/abc_ic_menu_share_mtrl_alpha.png /base/res/drawable-mdpi-v4/abc_ic_menu_selectall_mtrl_alpha.png /base/res/drawable-mdpi-v4/abc_ic_menu_paste_mtrl_am_alpha.png /base/res/drawable-mdpi-v4/abc_ic_menu_cut_mtrl_alpha.png /base/res/drawable-mdpi-v4/abc_ic_menu_copy_mtrl_am_alpha.png /base/res/drawable-mdpi-v4/abc_ic_commit_search_api_mtrl_alpha.png /base/res/drawable-mdpi-v4/abc_cab_background_top_mtrl_alpha.9.png /base/res/drawable-mdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png /base/res/drawable-mdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png /base/res/drawable-mdpi-v4/abc_btn_radio_to_on_mtrl_015.png /base/res/drawable-mdpi-v4/abc_btn_radio_to_on_mtrl_000.png /base/res/drawable-mdpi-v4/abc_btn_check_to_on_mtrl_015.png /base/res/drawable-mdpi-v4/abc_btn_check_to_on_mtrl_000.png /base/res/drawable-mdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png /base/res/drawable-v23/ /base/res/drawable-v23/abc_control_background_material.xml /base/res/drawable-watch-v20/ /base/res/drawable-watch-v20/abc_dialog_material_background.xml /base/res/drawable-v21/ /base/res/drawable-v21/notification_action_background.xml /base/res/drawable-v21/abc_list_divider_material.xml /base/res/drawable-v21/abc_edit_text_material.xml /base/res/drawable-v21/abc_dialog_material_background.xml /base/res/drawable-v21/abc_btn_colored_material.xml /base/res/drawable-v21/abc_action_bar_item_background_material.xml /base/res/drawable-v21/abc_ratingbar_small_material.xml /base/res/drawable-v21/abc_ratingbar_material.xml /base/res/drawable-v21/abc_ratingbar_indicator_material.xml /base/res/drawable/ /base/res/drawable/tooltip_frame_light.xml /base/res/drawable/tooltip_frame_dark.xml /base/res/drawable/redbox_top_border_background.xml /base/res/drawable/notification_tile_bg.xml /base/res/drawable/notification_icon_background.xml /base/res/drawable/notification_bg_low.xml /base/res/drawable/notification_bg.xml /base/res/drawable/abc_vector_test.xml /base/res/drawable/abc_textfield_search_material.xml /base/res/drawable/abc_text_cursor_material.xml /base/res/drawable/abc_tab_indicator_material.xml /base/res/drawable/abc_switch_thumb_material.xml /base/res/drawable/abc_spinner_textfield_background_material.xml /base/res/drawable/abc_seekbar_track_material.xml /base/res/drawable/abc_seekbar_tick_mark_material.xml /base/res/drawable/abc_seekbar_thumb_material.xml /base/res/drawable/abc_ratingbar_small_material.xml /base/res/drawable/abc_ratingbar_material.xml /base/res/drawable/abc_ratingbar_indicator_material.xml /base/res/drawable/abc_list_selector_holo_light.xml /base/res/drawable/abc_list_selector_holo_dark.xml /base/res/drawable/abc_list_selector_background_transition_holo_light.xml /base/res/drawable/abc_list_selector_background_transition_holo_dark.xml /base/res/drawable/abc_list_divider_material.xml /base/res/drawable/abc_item_background_holo_light.xml /base/res/drawable/abc_item_background_holo_dark.xml /base/res/drawable/abc_ic_voice_search_api_material.xml /base/res/drawable/abc_ic_search_api_material.xml /base/res/drawable/abc_ic_menu_overflow_material.xml /base/res/drawable/abc_ic_go_search_api_material.xml /base/res/drawable/abc_ic_clear_material.xml /base/res/drawable/abc_ic_arrow_drop_right_black_24dp.xml /base/res/drawable/abc_ic_ab_back_material.xml /base/res/drawable/abc_edit_text_material.xml /base/res/drawable/abc_dialog_material_background.xml /base/res/drawable/abc_cab_background_top_material.xml /base/res/drawable/abc_cab_background_internal_bg.xml /base/res/drawable/abc_btn_radio_material.xml /base/res/drawable/abc_btn_default_mtrl_shape.xml /base/res/drawable/abc_btn_colored_material.xml /base/res/drawable/abc_btn_check_material.xml /base/res/drawable/abc_btn_borderless_material.xml /base/res/color-v23/ /base/res/color-v23/abc_tint_switch_track.xml /base/res/color-v23/abc_tint_spinner.xml /base/res/color-v23/abc_tint_seek_thumb.xml /base/res/color-v23/abc_tint_edittext.xml /base/res/color-v23/abc_tint_default.xml /base/res/color-v23/abc_tint_btn_checkable.xml /base/res/color-v23/abc_color_highlight_material.xml /base/res/color-v23/abc_btn_colored_text_material.xml /base/res/color-v23/abc_btn_colored_borderless_text_material.xml /base/res/color-v21/ /base/res/color-v21/abc_btn_colored_borderless_text_material.xml /base/res/color/ /base/res/color/switch_thumb_material_light.xml /base/res/color/switch_thumb_material_dark.xml /base/res/color/abc_tint_switch_track.xml /base/res/color/abc_tint_spinner.xml /base/res/color/abc_tint_seek_thumb.xml /base/res/color/abc_tint_edittext.xml /base/res/color/abc_tint_default.xml /base/res/color/abc_tint_btn_checkable.xml /base/res/color/abc_secondary_text_material_light.xml /base/res/color/abc_secondary_text_material_dark.xml /base/res/color/abc_search_url_text.xml /base/res/color/abc_primary_text_material_light.xml /base/res/color/abc_primary_text_material_dark.xml /base/res/color/abc_primary_text_disable_only_material_light.xml /base/res/color/abc_primary_text_disable_only_material_dark.xml /base/res/color/abc_hint_foreground_material_light.xml /base/res/color/abc_hint_foreground_material_dark.xml /base/res/color/abc_btn_colored_text_material.xml /base/res/color/abc_btn_colored_borderless_text_material.xml /base/res/color/abc_background_cache_hint_selector_material_light.xml /base/res/color/abc_background_cache_hint_selector_material_dark.xml /base/res/anim/ /base/res/anim/catalyst_slide_up.xml /base/res/anim/catalyst_slide_down.xml /base/res/anim/catalyst_push_up_out.xml /base/res/anim/catalyst_push_up_in.xml /base/res/anim/catalyst_fade_out.xml /base/res/anim/catalyst_fade_in.xml /base/res/anim/abc_tooltip_exit.xml /base/res/anim/abc_tooltip_enter.xml /base/res/anim/abc_slide_out_top.xml /base/res/anim/abc_slide_out_bottom.xml /base/res/anim/abc_slide_in_top.xml /base/res/anim/abc_slide_in_bottom.xml /base/res/anim/abc_shrink_fade_out_from_bottom.xml /base/res/anim/abc_popup_exit.xml /base/res/anim/abc_popup_enter.xml /base/res/anim/abc_grow_fade_in_from_bottom.xml /base/res/anim/abc_fade_out.xml /base/res/anim/abc_fade_in.xml /base/assets/ /base/assets/index.android.bundle /BUNDLE-METADATA/ /BUNDLE-METADATA/com.android.tools.build.libraries/ /BUNDLE-METADATA/com.android.tools.build.libraries/dependencies.pb /BundleConfig.pb ```

The files we're concerned with are:

/base/res/raw/node_modules_evadesign_eva_themes_light.json
/base/res/raw/node_modules_evadesign_eva_themes_dark.json
/base/res/raw/node_modules_evadesign_eva_mapping.json

Which aren't as big as you're reporting (wc -m returns the char count, which essentially tells us the size in bytes of the file):

$ apkanalyzer -h files cat --file /base/res/raw/node_modules_evadesign_eva_themes_light.json app-release.aab | wc -m
   17335
$ apkanalyzer -h files cat --file /base/res/raw/node_modules_evadesign_eva_themes_dark.json app-release.aab | wc -m
   17323
$ apkanalyzer -h files cat --file /base/res/raw/node_modules_evadesign_eva_mapping.json app-release.aab | wc -m
  288808

So.... I can safely say your reported sizes are wrong. There's something you're doing differently.

About the "updatability" of the mappings through CodePush, I haven't had problems with that so far. The bundled JSONs that are out of reach from CodePush are the Eva design's defaults and are not very frequently updated as far as I know... if you ever need to update a major version of any library, you probably should be looking at uploading a whole new binary anyway.

heroic commented 4 years ago

@lesmo size-analyzer is the tool recommended by google. Here's the link: https://github.com/android/size-analyzer/releases/tag/v0.3.1

You can find google's article on reducing the bundle size where the tool is referenced here: https://developer.android.com/topic/performance/reduce-apk-size

Let me know if you still don't find a similar output as I am getting in the example project.

lesmo commented 4 years ago

Cool! You learn something new everyday!

So I did that...

$ ./size-analyzer check-bundle ../app-release.aab -d
Dynamically delivering large files1.8 MiB
Place large file base/assets/index.android.bundle inside an on demand dynamic-feature to avoid bundling in apk (saves 1.3 MiB)
Place large file base/res/raw/node_modules_evadesign_eva_mapping.json inside an on demand dynamic-feature to avoid bundling in apk (saves 282.0 kiB)
Place large file base/res/raw/node_modules_csstree_dist_defaultsyntax.json inside an on demand dynamic-feature to avoid bundling in apk (saves 56.4 kiB)
Place large file base/res/raw/node_modules_entities_lib_maps_entities.json inside an on demand dynamic-feature to avoid bundling in apk (saves 43.8 kiB)
File base/root/okhttp3/internal/publicsuffix/publicsuffixes.gz does not appear to be a needed file. Consider removing this file or placing it in the assets directory. If the file is added through a library dependency, consider using packagingOptions to exclude the file https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html (saves 33.2 kiB)
Place large file base/res/drawable-mdpi-v4/node_modules_reactnative_libraries_newappscreen_components_logo.png inside an on demand dynamic-feature to avoid bundling in apk (saves 23.5 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_light.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_dark.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/mipmap-xxxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 15.2 kiB)
Place large file base/res/mipmap-xxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 10.4 kiB)
Efficiently configuring proguard
It seems that you are not using Proguard/R8, consider enabling it in your application. (saves )
Total size savings of 1.8 MiB found.

As you can see, the Eva JSON files match the size I got with my not-so-sophisticated method. Did you customize Babel config? Metro?

heroic commented 4 years ago

@lesmo, yes I use react native navigation, and have a custom mapping. Sharing relevant parts below:

const MetroConfig = require('@ui-kitten/metro-config')

const evaConfig = {
  evaPackage: '@eva-design/eva',
  // Optional, but may be useful when using mapping customization feature.
  customMappingPath: './src/config/custom-mapping.json',
}

module.exports = MetroConfig.create(evaConfig, {
  resolver: {
    sourceExts: process.env.RN_SRC_EXT
      ? process.env.RN_SRC_EXT.split(',').concat(defaultSourceExts)
      : defaultSourceExts,
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
  serializer: {
    processModuleFilter: module => {
      return !module.path.endsWith(
        'react-native/Libraries/Renderer/implementations/ReactFabric-prod.js',
      );
    },
  },
})
{
  "strict": {
    "text-font-family": "lato-light",
    "title-font-family": "liberation-sans-regular"
  },
  "components": {
    "Card": {
      "meta": {
        "variantGroups": {
          "size": {
            "large": {
              "default": true
            },
            "tiny": {
              "default": false
            }
          }
        }
      },
      "appearances": {
        "outline": {
          "mapping": {
            "titleFontFamily": "title-font-family"
          },
          "variantGroups": {
            "size": {
              "large": {},
              "tiny": {
                "headerPaddingHorizontal": 12,
                "headerPaddingVertical": 8,
                "bodyPaddingHorizontal": 12,
                "bodyPaddingVertical": 8,
                "footerPaddingHorizontal": 12,
                "footerPaddingVertical": 8
              }
            }
          }
        },
        "filled": {
          "mapping": {},
          "variantGroups": {
            "size": {
              "large": {},
              "tiny": {
                "headerPaddingHorizontal": 12,
                "headerPaddingVertical": 8,
                "bodyPaddingHorizontal": 12,
                "bodyPaddingVertical": 8,
                "footerPaddingHorizontal": 12,
                "footerPaddingVertical": 8
              }
            }
          }
        }
      }
    },
  }
}
lesmo commented 4 years ago

Aha! That's probably where the problem lies. I've never toyed with Metro bundler, so I'm not sure what's going on here.

However, talking from my experience with WebPack, I can say that sometimes you could be missing some configs that make the resulting bundle ignore treeshaking for some paths... which can be useful in some scenarios, but maybe not on others.

That's my only suggestion for now. Perhaps updating your sample repo with the Metro config you have so it can be reproducible there can be useful.

heroic commented 4 years ago

@lesmo the sample project already has this config.

lesmo commented 4 years ago

Oh, sorry! I didn't read through the code, I just concerned myself with building and sizing it.

It's going to be next to impossible to figure out if the sample project doesn't reproduce your problem. Currently the sample project is building and sizing properly, so... can't help further until the sample reproduces the issue.

heroic commented 4 years ago

@lesmo not sure why you are not seeing the issue in the sample project, as it is happening for me. Did you run yarn start before building for release? Without it, the generated.json file will not be created.

lesmo commented 4 years ago

@lesmo not sure why you are not seeing the issue in the sample project, as it is happening for me. Did you run yarn start before building for release? Without it, the generated.json file will not be created.

As you can tell from my comments, I didn't do that. It doesn't sound right to me that the generated files get written to node_modules. If this is happening, sounds to me like a bug on the eva-design/eva package.

What would you say are the steps to reproduce this? By doing the steps you mentioned in the issue I don't get the outputs you're getting. I've ran yarn start, exited the process and ran the steps, but the result is the same:

$ yarn start
^C
$ ./size-analyzer check-bundle ../app-release.aab -d
Dynamically delivering large files1.8 MiB
Place large file base/assets/index.android.bundle inside an on demand dynamic-feature to avoid bundling in apk (saves 1.3 MiB)
Place large file base/res/raw/node_modules_evadesign_eva_mapping.json inside an on demand dynamic-feature to avoid bundling in apk (saves 282.0 kiB)
Place large file base/res/raw/node_modules_csstree_dist_defaultsyntax.json inside an on demand dynamic-feature to avoid bundling in apk (saves 56.4 kiB)
Place large file base/res/raw/node_modules_entities_lib_maps_entities.json inside an on demand dynamic-feature to avoid bundling in apk (saves 43.8 kiB)
File base/root/okhttp3/internal/publicsuffix/publicsuffixes.gz does not appear to be a needed file. Consider removing this file or placing it in the assets directory. If the file is added through a library dependency, consider using packagingOptions to exclude the file https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html (saves 33.2 kiB)
Place large file base/res/drawable-mdpi-v4/node_modules_reactnative_libraries_newappscreen_components_logo.png inside an on demand dynamic-feature to avoid bundling in apk (saves 23.5 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_light.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_dark.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/mipmap-xxxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 15.2 kiB)
Place large file base/res/mipmap-xxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 10.4 kiB)
Efficiently configuring proguard
It seems that you are not using Proguard/R8, consider enabling it in your application. (saves )
Total size savings of 1.8 MiB found.
heroic commented 4 years ago

@lesmo Here are the exact commands I ran:

  1. git clone git@github.com:heroic/uikitten-test.git
  2. cd uikitten-test
  3. yarn
  4. yarn start in new tab. wait for metro to start and print the react logo. go back to first tab
  5. cd android
  6. ./gradlew bundleRelease
  7. java -jar ~/Downloads/analyzer/bin/analyzer.jar check-bundle -d app/build/outputs/bundle/release/app-release.aab

Here's the output:

Dynamically delivering large files7.9 MiB
Place large file base/res/raw/node_modules_evadesign_eva_generated.json inside an on demand dynamic-feature to avoid bundling in apk (saves 3.8 MiB)
Place large file base/assets/index.android.bundle inside an on demand dynamic-feature to avoid bundling in apk (saves 3.6 MiB)
Place large file base/res/raw/node_modules_evadesign_eva_mapping.json inside an on demand dynamic-feature to avoid bundling in apk (saves 282.0 kiB)
Place large file base/res/raw/node_modules_csstree_dist_defaultsyntax.json inside an on demand dynamic-feature to avoid bundling in apk (saves 56.4 kiB)
Place large file base/res/raw/node_modules_entities_lib_maps_entities.json inside an on demand dynamic-feature to avoid bundling in apk (saves 43.8 kiB)
File base/root/okhttp3/internal/publicsuffix/publicsuffixes.gz does not appear to be a needed file. Consider removing this file or placing it in the assets directory. If the file is added through a library dependency, consider using packagingOptions to exclude the file https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html (saves 33.2 kiB)
Place large file base/res/drawable-mdpi-v4/node_modules_reactnative_libraries_newappscreen_components_logo.png inside an on demand dynamic-feature to avoid bundling in apk (saves 23.5 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_light.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_dark.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/mipmap-xxxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 15.2 kiB)
Place large file base/res/mipmap-xxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 10.4 kiB)
Efficiently configuring proguard
It seems that you are not using Proguard/R8, consider enabling it in your application. (saves )
Total size savings of 7.9 MiB found.
lesmo commented 4 years ago

Thanks! That's great! It's exactly what I needed. The yarn start command is crucial to reproduce this, I thought it kinda could be disregarded. Sorry about that!

I finally got it:

$ ./size-analyzer check-bundle -d app-release.aab
Dynamically delivering large files7.9 MiB
Place large file base/res/raw/node_modules_evadesign_eva_generated.json inside an on demand dynamic-feature to avoid bundling in apk (saves 3.8 MiB)
Place large file base/assets/index.android.bundle inside an on demand dynamic-feature to avoid bundling in apk (saves 3.6 MiB)
Place large file base/res/raw/node_modules_evadesign_eva_mapping.json inside an on demand dynamic-feature to avoid bundling in apk (saves 282.0 kiB)
Place large file base/res/raw/node_modules_csstree_dist_defaultsyntax.json inside an on demand dynamic-feature to avoid bundling in apk (saves 56.4 kiB)
Place large file base/res/raw/node_modules_entities_lib_maps_entities.json inside an on demand dynamic-feature to avoid bundling in apk (saves 43.8 kiB)
File base/root/okhttp3/internal/publicsuffix/publicsuffixes.gz does not appear to be a needed file. Consider removing this file or placing it in the assets directory. If the file is added through a library dependency, consider using packagingOptions to exclude the file https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html (saves 33.2 kiB)
Place large file base/res/drawable-mdpi-v4/node_modules_reactnative_libraries_newappscreen_components_logo.png inside an on demand dynamic-feature to avoid bundling in apk (saves 23.5 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_light.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/raw/node_modules_evadesign_eva_themes_dark.json inside an on demand dynamic-feature to avoid bundling in apk (saves 16.9 kiB)
Place large file base/res/mipmap-xxxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 15.2 kiB)
Place large file base/res/mipmap-xxhdpi-v4/ic_launcher_round.png inside an on demand dynamic-feature to avoid bundling in apk (saves 10.4 kiB)
Efficiently configuring proguard
It seems that you are not using Proguard/R8, consider enabling it in your application. (saves )
Total size savings of 7.9 MiB found.

I suggest we move this over to eva-design/eva. Perhaps @artyorsh can tell us if it should go in eva or here πŸ˜„

artyorsh commented 4 years ago

@lesmo I’d prefer leaving it here to keep it alive. Thanks for chipping in :)

lesmo commented 4 years ago

@lesmo I’d prefer leaving it here to keep it alive. Thanks for chipping in :)

Any idea what could be happening? This issue means everybody can save 3mb on their binary by just building on a clean, never yarn started project... which is kinda cool, but at the same time not so cool.

heroic commented 4 years ago

@lesmo yarn start is crucial as without it, with react native navigation, the mapping are computed on each screen load. It's mentioned in the document here: https://akveo.github.io/react-native-ui-kitten/docs/4.x/guides/improving-performance#improving-performance

I think it's still valid for v5

jamonholmgren commented 3 years ago

Just noting that we are running into the same thing on one of our projects. It's 4.1mb, which is far too much for our size budget. (I do have a call scheduled with the UI Kitten folks to talk about paying them to fix this issue.)

markrickert commented 3 years ago

Chiming in on behalf of @jamonholmgren above...

We had implemented the optimizations as described in the documentation for metro to preprocess the theme file. This works great for mobile since it speeds up application load time on mobile but on the web it includes a HUGE generated.json file. Our web build system is separate from our mobile build system.

The key to removing the 4mb+ generated.json from our final web production build was to remove the yarn command yarn ui-kitten bootstrap @eva-design/eva ./custom-eva-theme.json and simply import CustomEvaTheme from "custom-eva-theme.json" in our ApplicationProvider and pass it to the UIKitten ApplicationProvider component as a customMapping prop.

Thanks to the UIKitten team @artyorsh, Anton, and @malashkevich for their great support in helping get this figured out!

artyorsh commented 3 years ago

Thank you for the response @markrickert πŸ‘

A few words to summarize our call with InfiniteRed team:

  1. We didn't realize that UI Kitten users will use this framework on the web a lot... So we focused more on mobile and that's why this problem occurred. This is not a problem for mobile at all, because the final bundle is downloaded once. However this may affect web platform.

  2. The best way to fix for web without bringing any changes to the framework itself is to make sure that you don't have generated.json file in node modules in case you build a web project.

  3. To do this:

    • Make sure you don't have ui-kitten bootstrap script called
    • Modify your ApplicationProvider to have mapping, theme, and customMapping (if you have that) instead of spreading imported eva variable.
  4. If you build for both web and mobile:

    • Skip the step above to have better performance but pay attention on your build process, so that you're sure there is no generated.json for web, but there is for mobile. Having platform-dependent entry points (different ApplicationProviders) for platforms and building the web before building a mobile is a simplest solution.

We definitely need to mention this somewhere in the documentation 🀞

lesmo commented 3 years ago

This is actually pretty cool info! Thanks a lot!

I'm about to start a project where I'll be using React Native, SSR with Razzle and React Native Web, and UI Kitten. One of my main objectives is to be as optimal as possible, knowing this info is going to be super useful.

malashkevich commented 3 years ago

I will consider this issue as closed.

If you have still issues with the theme file size please refer to @artyorsh's comment above.

sschottler commented 3 years ago

I'm curious what performance considerations & benefits factored into building this large style lookup object (either in generated.json cache or in memory in schemaProcessor.process call without caching). The Button component alone results in about 44k lines in generated.json because all styles are repeated for every combination of appearance/variants/states. This probably leads to fast lookups/rerenders at runtime once the style lookup is built (or loaded from cache), but is the performance significantly better than not building a large style lookup object and merging on demand doing something like this?

// pseudo code for fetching styles for Button/filled/primary/medium/active:
const { Button } = mapping.components;

const styles = {
  // default appearance styles:
  ...Button.appearances.filled.mapping,
  // defaults can be overridden by variant styles:
  ...Button.appearances.filled.variantGroups.status.primary,
  ...Button.appearances.filled.variantGroups.size.medium,
  // overridden by state styles which could be on any variant (often status):
  ...Button.appearances.filled.variantGroups.status.primary.state.active
}

Is that even possible with the mapping structure? I might be missing something about how much knowledge the system can assume about style precedence at runtime without limiting flexibility...

sschottler commented 3 years ago

For anybody like me who may have been concerned about initial download size for mobile with generated.json build time styles, I just realized it’s pretty negligible (~ 100kb added to compressed aab/apk file for android). I created a UI Kitten starter template app and built it with & without generated.json and styles export in @eva-design/eva using: cd android && ./gradlew bundleRelease. aab files are just compressed files and if you unzip it from terminal, you will see generated.json in base/res/raw folder. The size-analyzer tool with the -d flag suggestions is giving you the size savings in uncompressed, so it’s not actually adding 3.8 MB to bundle/initial download from app store - only adds ~100kb compressed.