election-live icon indicating copy to clipboard operation
election-live copied to clipboard

Cherry pick lodash to decrease bundle size?

Open MicroBenz opened this issue 6 years ago • 3 comments

I've seen that this project is using lodash. Maybe it will better to use lodash with "cherry pick" import to reduce the bundle size.

For example instead of using

import _ from 'lodash'
_.random()

Use this instead

import random from 'lodash/random'

MicroBenz avatar Mar 24 '19 12:03 MicroBenz

Can also use import { random } from 'lodash' and use babel-plugin-lodash

kristw avatar Mar 24 '19 14:03 kristw

Yesterday, I tried to add gatsby-lodash-plugin main problem is they don't allow us to use _.chain. So we need to change it to _.compose instead.

MicroBenz avatar Mar 25 '19 03:03 MicroBenz

Use flow instead of _.chain krub and other functions from lodash/fp instead of lodash.

kristw avatar Mar 25 '19 16:03 kristw