-1

What's the difference these imports in terms of React application bundle size?

import _ from 'lodash' // then use _.get
import { get } from 'lodash'
import get from 'lodash/get'
Alex
  • 1,210
  • 3
  • 21
  • 34
  • I think this would depend greatly on your specific app structure, chosen bundler, and configuration settings. What is stopping you from experimenting and finding out for yourself - run a build with each of the three possibilities and compare the bundle sizes. – jered Dec 18 '20 at 09:41
  • Found correct answer I was looking for here: https://stackoverflow.com/questions/35250500/correct-way-to-import-lodash – Alex Dec 18 '20 at 10:08

1 Answers1

0

Found correct answer I was looking for here

import concat from 'lodash/concat';
import orderBy from 'lodash/orderBy';
import filter from 'lodash/filter';

it only loads the needed modules (results in smaller bundler size)

https://www.blazemeter.com/blog/the-correct-way-to-import-lodash-libraries-a-benchmark

Alex
  • 1,210
  • 3
  • 21
  • 34