React-sortable-hoc: Do not use lodash just because of 2 functions

Created on 9 Aug 2017  路  6Comments  路  Source: clauderic/react-sortable-hoc

Hello!
I think this awesome project can easily get rid of unneeded "lodash" dependency and just implement "random" and "sortBy" functions by itself.

We don't use lodash in our project, but it still gets into codebase just because of this react-sortable-hoc.

Most helpful comment

I think you can just import the lodash.random (https://www.npmjs.com/package/lodash.random) which is thinner, or lodash.sortBy.

You can actually chopped any modules from lodash and just import that. I think it will consumed less space.

All 6 comments

We found out that lodash used from this component takes about:

  • 104.7 KB raw
  • 23.21 KB minified
  • 6.79 KB minified+gzipped

Looks like custom functions could take order of magnitude less space.
What do you think? Would you like to receive a PR?

I think you can just import the lodash.random (https://www.npmjs.com/package/lodash.random) which is thinner, or lodash.sortBy.

You can actually chopped any modules from lodash and just import that. I think it will consumed less space.

You could also use babel-plugin-lodash to remove unneeded lodash modules since the build process is using babel already.

@iamrommel these builds will be deprecated soon, see: https://github.com/lodash/lodash/wiki/Roadmap

Normally you should just do

import random from 'lodash/random'

Then you only get the function you need and tree-shaking can eliminate the rest of the library.

At very least, don't use the shorthands functionality for orderBy so that we can shake out all of the extra lodash dependencies in our own projects.
See link for more details: https://github.com/lodash/lodash-webpack-plugin/issues/128

Removed lodash dependency in 0.7.0

Was this page helpful?
0 / 5 - 0 ratings