Search code examples
reactjslodash

Lodash imports entire bundle on named imports


Both the lines below are contributing the same size to the bundle.

import _ from "lodash";

import { get } from "lodash";

I am expecting Line-2 to be of less size. ( Refer to the image )

Named imports cost less in Ant Design which is not working in lodash.

Is there a way to reduce this?

enter image description here


Solution

  • Use default imports

    The below line should do the job.

    import get from 'lodash/get'
    

    Yes, Ant Design named imports would give you the component you import.

    This functionality is yet to be seen in lodash.