Skip to content

Switching lodash to the more modern and performant es-toolkit library. #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

okinawaa
Copy link

@okinawaa okinawaa commented Jul 3, 2025

Key Changes:

  1. package.json:
    - Replaced "lodash": "^4.17.21" with "es-toolkit": "^1.39.6"
    - Removed "@types/lodash": "^4.17.17" dev dependency
  2. src/utils.ts:
    - Changed imports from individual lodash modules to es-toolkit/compat
    - Updated comment from "lodash debounce" to "es-toolkit debounce"
  3. src/useResizeDetector.ts:
    - Updated DebouncedFunc type import from lodash to es-toolkit/compat
  4. src/types.ts:
    - Updated documentation links from lodash.com to es-toolkit.slash.page
    - Changed references from "lodash docs" to "es-toolkit docs"

The migration maintains 100% API compatibility while switching to the more modern and performant
es-toolkit library. All imports use the /compat path to ensure identical behavior to lodash.

Benefits

  • Bundle size reduction: debounce function code reduced from 378 lines to 110 lines (~3x smaller)
  • Cleaner implementation: es-toolkit removes unnecessary utilities like toNumber, isSymbol, etc., keeping only the essential logic needed for most use cases
  • Zero breaking changes: Build output diff shows identical results except for the migration itself
  • Full compatibility: es-toolkit/compat passes all lodash test cases and maintains 100% interface compatibility
  • Industry adoption: Already used by major projects like Storybook and Recharts
  • Performance Impact
    While debounce functions don't typically have significant performance implications, the substantial bundle size reduction (3x smaller) provides clear value for end users.

  es-toolkit library. All imports use the /compat path to ensure identical behavior to lodash.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert

@maslianok
Copy link
Owner

Related to #265

@okinawaa
Copy link
Author

@snelsi @maslianok
I hope you're doing well. I submitted this PR a while ago to migrate from lodash to es-toolkit, and I wanted to follow up respectfully.

The changes maintain 100% API compatibility which I believe would be valuable for users of this library.
I've ensured that all functionality remains identical by using the /compat path from es-toolkit.
If there are any concerns or areas that need improvement, I'm happy to address them. Could you please take a look when you have a chance? I'd really appreciate any feedback you might have.

Thank you for maintaining this great library! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants