meliorence / react-native-render-html

iOS/Android pure javascript react-native component that renders your HTML into 100% native views
https://meliorence.github.io/react-native-render-html/
BSD 2-Clause "Simplified" License
3.48k stars 589 forks source link

Import `mapObjIndexed` from `ramda` like all other `ramda` imports. #636

Closed markrickert closed 1 year ago

markrickert commented 1 year ago

Checks

Description

While inspecting my app with react-native-bundle-visualizer i noticed that ramda was including a LOT of things in the final metro bundle. I don't use ramda so running yarn why ramda revealed that this library was including it.

Normal javascript libraries like ramda, lodash, and date-fns don't tree-shake so their imports have to be referenced specifically. All of the ramda imports in this library are in the form of:

import identity from 'ramda/src/identity';

except the import to mapObjIndexed which was done like so:

import { mapObjIndexed } from 'ramda';

// Instead, we should be doing:
import mapObjIndexed from 'ramda/src/mapObjIndexed';

Because of the way mapObjIndexed is imported, metro includes ALL of ramda in the final bundle. This PR changes the import so that all the unnecessary parts of ramda aren't included in every app bundle that uses this library.

Overall, this will reduce the footprint of this library by about 55 kb. ramda used to take up 66.11 kb and now it will only take up 10.26 kb, a reduction of 84.5%!

Screenshots taken using react-native-bundle-visualizer

Before:

Screenshot 2023-06-20 at 3 57 48 PM

After:

Screenshot 2023-06-20 at 3 56 05 PM

codecov-commenter commented 1 year ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 76.92%. Comparing base (a02be71) to head (395616c). Report is 3 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #636 +/- ## ======================================= Coverage 76.92% 76.92% ======================================= Files 83 83 Lines 637 637 Branches 147 147 ======================================= Hits 490 490 Misses 7 7 Partials 140 140 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

serhiitonkoshkur commented 9 months ago

Hello @jsamr, Any updates on the release of this improvement?