FormidableLabs / freactal

Clean and robust state management for React and React-like libs.
MIT License
1.65k stars 46 forks source link

import only needed modules from lodash #54

Closed everdimension closed 7 years ago

everdimension commented 7 years ago

When writing things like import { assign, keys } from "lodash"; you're actually importing the whole lodash module and then just accessing its assign and keys methods.

But lodash exposes all its methods as separate modules.

Therefore by writing the following instead:

import assign from "lodash/assign";
import keys from "lodash/keys";

you significantly reduce bundle size by only importing what you actually need.

divmain commented 7 years ago

Hi @everdimension. Lodash is only pulled in for the SSR code, which should never be included in a JS bundle.