Faisal Khurshid
Faisal Khurshid

Reputation: 1909

Lodash: individual function import weighs more than importing whole library

Why individually importing lodash functions weigh more than loading the whole library at once (top line)?

enter image description here

The whole library cost 71.5k but individually importing some functions weigh around 162k. What's the reason?

Upvotes: 2

Views: 492

Answers (1)

TrèsAbhi
TrèsAbhi

Reputation: 105

There are a lot of mutual dependencies (mutual code that they all share) between those individual imports. The extension that you are using is most likely evaluating the weights of the imports with that mutual code for every single function separately. That ends up increasing the count for individual imports. Modern bundlers will ensure mutual code stays mutual; importing individual functions should still be more efficient.

Upvotes: 4

Related Questions