add the note about using babel-plugin-lodash/assert in order to decrease `bundle` size
a-tarasyuk opened this issue · 1 comments
SimpleRestClients imports by default entire lodash
. Users who use SimpleRestClients and don't use babel can have issues with bundle
size. I've made an experiment with the optimized version and the current production version - results provided below.
Note: optimized version uses direct import - import map from 'lodash/map'
and util function called invariant
instead of entire assert
library (assert package provides many methods, however, usually library uses only one of them - assert.ok.)
. There is unassert, however, this plugin completely removes asserts from production code. The sample application uses simple code from README.
Let's consider several use cases how users can use the library:
-
A user uses the library without any optimizations and does not use lodash
Asset Size Chunks Chunk Names bundle.js 58.8 KiB 0 [emitted] main
Asset Size Chunks Chunk Names bundle.js 108 KiB 0 [emitted] main
-
A user uses the library with babel optimizations and does not use lodash
Asset Size Chunks Chunk Names bundle.js 58.8 KiB 0 [emitted] main
Asset Size Chunks Chunk Names bundle.js 108 KiB 0 [emitted] main
-
A user uses the library without any optimizations and uses lodash
Asset Size Chunks Chunk Names bundle.js 128 KiB 0 [emitted] main
Asset Size Chunks Chunk Names bundle.js 108 KiB 0 [emitted] main
-
A user uses the library with babel optimizations and uses lodash
Asset Size Chunks Chunk Names bundle.js 60 KiB 0 [emitted] main
Asset Size Chunks Chunk Names bundle.js 128 KiB 0 [emitted] main
Seems that optimized version has only problems for the third case, and a user can solve it by adding babel optimization because an application depends on lodash and a user has to do it by default. Would be very helpful to add an example of the optimal configuration for webpack/rollup/etc. Does that make sense?
Yeah, feel free to submit a PR with an optimal configuration, or even modify the sample code to use it, and we can link it around from the various repos.