refactor: migrate from lodash to es-toolkit#2707
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplaces lodash with es-toolkit across the project, updating dependencies and refactoring all lodash-based utilities, hooks, and components to use es-toolkit APIs instead, while keeping existing behavior intact. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Where lodash helpers were used for object/array transformations (e.g.,
get,set,merge,cloneDeep,isEqual), double-check that the es-toolkit equivalents handlenull/undefined, array-like values, and prototype edge cases the same way, or add small adapters where behavior intentionally differs. - For any lodash utilities that had configurable options (like
debounce,throttle,uniqBy,sortBy), verify that the es-toolkit versions match the default options and call signatures you rely on (especially leading/trailing invocation and result memoization), and adjust the call sites to make those assumptions explicit if needed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Where lodash helpers were used for object/array transformations (e.g., `get`, `set`, `merge`, `cloneDeep`, `isEqual`), double-check that the es-toolkit equivalents handle `null`/`undefined`, array-like values, and prototype edge cases the same way, or add small adapters where behavior intentionally differs.
- For any lodash utilities that had configurable options (like `debounce`, `throttle`, `uniqBy`, `sortBy`), verify that the es-toolkit versions match the default options and call signatures you rely on (especially leading/trailing invocation and result memoization), and adjust the call sites to make those assumptions explicit if needed.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Why not lodash-es then? |
|
Preview is ready. |
|
🎭 Component Tests Report is ready. |
I suppose lodash-es has the same flaws as normal lodash: legacy code, bigger size, slower and poor TypeScript support |
|
What is a size difference in uikit case between lodash-es and new library? In our case we already have lodash-es in project, and new library woul be just additional code, that won't be reused |
It depends whether or not your other dependencies bring es-toolkit into bundle.
So normal lodash is also adds additional code that is not resused. This PR should reduce your bundle size, cuz es-toolkit is much smaller than lodash. |
|
We already making our bundle smaller by aliasing lodash to lodash-es in our bundler (this is triggering tree shacking for lodash imports) |
Hello. It's a suggestion to migrate from
lodashtoes-toolkit.The main advantages are: it's smaller, faster, more es-friendly and ts-friendly and popular enough.
https://github.com/toss/es-toolkit
Summary by Sourcery
Replace lodash usage across the codebase with es-toolkit utilities and update dependencies accordingly.
Enhancements:
Build: