request: Replace lodash with a smaller alternative
Is there an existing issue or pull request for this?
- [x] I have searched the existing issues and pull requests
Feature description
This package uses a few utilities from lodash and lists it in the dependencies. This means all users of the library will have to download the entire lodash library, which can be improved!
Desired solution
I would recommend bundling the library by moving it to the devDeps, this would allow tsup to treeshake the ununsed code and make sure only used functions are included in the published library.
You can also replace lodash entirely by using smaller alternatives to the two functions you use (get and uniqWith). I would still recommend bundling whatever you use, since the utility functions in question are very small and usually turns out less than 1kb in size after bundling them 😄
The easiest replacement is es-toolkit which implements compatible functions compatible with lodash, but faster and smaller.
Alternatives considered
There's also dlv for get, but it only supports foo.0.bar syntax and not foo[0].bar like in your documentation
And uniqWith is a fairly simple function that could be manually written for the project
Additional context
I can open a PR for this if you're up for it!
There's also some other changes I am open to help with if you want:
tsupis no longer actively maintained in favor oftsdownrimrafis generally not necessary anymore, either letting bundlers clean dirs by themselves or usingpremoveinsteadfast-deep-equalcould be replaced withdequalas it's ever so slightly faster and better, but the differences are not very large.
The size of lodash is honestly irrelevant, because the chance that you're writing a project that doesn't also get lodash from another transient source is zero to none. Even something like ESLint requires it transiently.
The tsup to tsdown migration is one we need to do to practically all repos, and PRs would definitely be welcome.
rimraf could also be replaced with yarn rm -rf pretty sure (even on windows)
Another reason not to use lodash now adays is that it isn't actively maintained anymore, on top of it often being very slow because of its composed nature!
a project that doesn't also get lodash from another transient source is zero to none.
This is not true! For example, most of my projects are already free of lodash thanks to people taking the initiative and removing it for the other benefits. 😄
ESLint specifically only depends on lodash.merge at this point and are planning to remove it in the future.
Deciding to not improve the codebase because others might not is in my opinion not a good reason to not do it, especially when others are willing to help with it. 🙂
At the very least you could use the function packages (e.g. lodash.get) instead of the full library, but they are even less maintained than the main library which is why switching to es-toolkit and bundling is the best option IMO.
I'll start working on tsdown and rimraf in the meantime!