fkhadra / fkhadra/react-on-screen

import throttle from 'lodash/throttle' is actually better at reducing bundle size than 'lodash.throttle'

Open
#55 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
402
Forks
50
PR merge metrics
No merged PRs in 30d

Description

See https://github.com/lodash/lodash/issues/3838

If two lodash per-method packages, e.g. `lodash.throttle` and `lodash.debounce`, depend on an underlying lodash function (public or internal API), that function will be inlined in each of the modular build packages, bloating webpack bundle size. The modular build packages can't share any code.

On the other hand, if your package imports from `lodash/throttle`, and another package imports from `lodash/debounce`, they *can* share any underlying code they depend on and the webpack bundle will be smaller.

So the per-method packages really have no advantages, and John-David Dalton pointed out that they're going to be removed in v5.

Having `lodash` as a dependency is perfectly fine as long as you always import from submodules, never its root module.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.