I am using several functions from _ like sortBy . But I do not need complete lodash.
I am using other funtions too from lodash like following
import map from 'lodash/map'
But when I try following
import _ from 'lodash/_'
I get error cannot find module 'lodash/_'
If I simply use following it works
import _ from 'lodash'
But this will carry complete lodash in bundle file which increases size. Can any one please suggest me optimum way to import _ from lodash ?
You can install Lodash via NPM and then import only single functions. This works as follows:
import { merge, isEqual } from 'lodash';
// use them like regular functions
merge({ a: 1 }, { b: 2 });