Closed everdimension closed 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.
import { assign, keys } from "lodash";
lodash
assign
keys
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.
Hi @everdimension. Lodash is only pulled in for the SSR code, which should never be included in a JS bundle.
When writing things like
import { assign, keys } from "lodash";
you're actually importing the wholelodash
module and then just accessing itsassign
andkeys
methods.But lodash exposes all its methods as separate modules.
Therefore by writing the following instead:
you significantly reduce bundle size by only importing what you actually need.