'How to minimize bundle size by improving import way of lodash?
how do you import lodash into your projects?
import _ from 'lodash'
As far as I understand, if you are importing as above, this includes the entire lodash library in the bundle. To shrink the bundle size,
import get from 'lodash/get'
When you import it as , it only includes the get function in the bundle. But if too many lodash functions are used, there are too many import lines. I have installed a package called babel-plugin-transform-imports for this. with this package
import { get } from 'lodash'
and only includes functions that are required (in this example, get) at build time. But when I examine the bundle with source-map-analyzer, the bundle gets bigger, interestingly enough.
It decreases the build size of the Component that I applied by 2.5KB, but the total app itself increases by 1KB.
Has anyone dealt with this before? What do you do for this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
