Skip to content

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

Open
@jedwards1211

Description

@jedwards1211

See lodash/lodash#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions