Skip to content

♻️ refactor: migrate from lodash-es to es-toolkit#58

Merged
canisminor1990 merged 4 commits intomasterfrom
refactor/migrate-to-es-toolkit
Dec 25, 2025
Merged

♻️ refactor: migrate from lodash-es to es-toolkit#58
canisminor1990 merged 4 commits intomasterfrom
refactor/migrate-to-es-toolkit

Conversation

@Innei
Copy link
Member

@Innei Innei commented Dec 24, 2025

Summary

  • Replace lodash-es with es-toolkit for better performance and smaller bundle size
  • es-toolkit is 2-3x faster and up to 97% smaller than lodash
  • Uses es-toolkit/compat for full API compatibility with lodash

Changes

  • Replace lodash-es throttle with es-toolkit/compat throttle in useAudioVisualizer.ts
  • Replace lodash-es flatten with es-toolkit/compat flatten in:
    • SpeechSynthesisTTS/options.ts
    • EdgeSpeechTTS/options.ts
    • MicrosoftSpeechTTS/voiceList.ts
  • Remove @types/lodash-es dev dependency (es-toolkit has built-in types)

Test plan

  • Type checking passes (npm run type-check)
  • Linting passes (npm run lint)
  • No circular dependencies introduced (npm run lint:circular)

🤖 Generated with Claude Code

Replace lodash-es with es-toolkit for better performance and smaller bundle size. es-toolkit is 2-3x faster and up to 97% smaller than lodash.

- Replace lodash-es throttle with es-toolkit/compat throttle
- Replace lodash-es flatten with es-toolkit/compat flatten
- Remove @types/lodash-es dev dependency (es-toolkit has built-in types)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings December 24, 2025 13:53
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @Innei, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@lobehubbot
Copy link
Member

👍 @Innei


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/lobehub/lobe-tts/@lobehub/tts@58

commit: 6755170

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the codebase to replace lodash-es with es-toolkit for improved performance and reduced bundle size. The migration uses es-toolkit/compat to ensure full API compatibility with lodash functions.

  • Replace all lodash-es imports with es-toolkit/compat equivalents (throttle and flatten)
  • Remove lodash-es and @types/lodash-es dependencies from package.json
  • Update several unrelated dependencies (@lobehub/ui, dumi-theme-lobehub)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/react/hooks/useAudioVisualizer.ts Migrates throttle import from lodash-es to es-toolkit/compat
src/core/SpeechSynthesisTTS/options.ts Migrates flatten import from lodash-es to es-toolkit/compat
src/core/EdgeSpeechTTS/options.ts Migrates flatten import from lodash-es to es-toolkit/compat
src/core/MicrosoftSpeechTTS/voiceList.ts Migrates flatten import from lodash-es to es-toolkit/compat
package.json Replaces lodash-es with es-toolkit, removes @types/lodash-es, and updates @lobehub/ui and dumi-theme-lobehub versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"@lobehub/lint": "^1.26.3",
"@lobehub/ui": "3.3.5",
"@types/lodash-es": "^4.17.12",
"@lobehub/ui": "^4.0.0",
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

This change updates @lobehub/ui from version 3.3.5 to ^4.0.0, which appears unrelated to the lodash-es to es-toolkit migration stated in the PR description. This could introduce unintended breaking changes or behavior modifications. Consider separating this upgrade into its own PR to maintain focus and make it easier to identify the source of any issues that arise.

Suggested change
"@lobehub/ui": "^4.0.0",
"@lobehub/ui": "3.3.5",

Copilot uses AI. Check for mistakes.
"dpdm": "^3.14.0",
"dumi": "^2.4.21",
"dumi-theme-lobehub": "3.0.1",
"dumi-theme-lobehub": "4.0.0",
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

This change updates dumi-theme-lobehub from version 3.0.1 to 4.0.0, which appears unrelated to the lodash-es to es-toolkit migration stated in the PR description. This major version bump could introduce breaking changes. Consider separating this upgrade into its own PR to maintain focus and isolate potential issues.

Suggested change
"dumi-theme-lobehub": "4.0.0",
"dumi-theme-lobehub": "3.0.1",

Copilot uses AI. Check for mistakes.
package.json Outdated
},
"peerDependencies": {
"@lobehub/ui": "3.3.5",
"@lobehub/ui": "^3.3.5 || ^4.0.0",
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

This change updates the peerDependencies range for @lobehub/ui to allow both ^3.3.5 and ^4.0.0. While this is likely related to the @lobehub/ui devDependency update, it appears unrelated to the lodash-es to es-toolkit migration stated in the PR description. Consider separating dependency upgrades into a separate PR.

Suggested change
"@lobehub/ui": "^3.3.5 || ^4.0.0",
"@lobehub/ui": "^4.0.0",

Copilot uses AI. Check for mistakes.
@canisminor1990 canisminor1990 merged commit d4dd3aa into master Dec 25, 2025
3 of 5 checks passed
@canisminor1990 canisminor1990 deleted the refactor/migrate-to-es-toolkit branch December 25, 2025 03:19
@lobehubbot
Copy link
Member

❤️ Great PR @Innei ❤️


The growth of project is inseparable from user feedback and contribution, thanks for your contribution!
项目的成长离不开用户反馈和贡献,感谢您的贡献!

github-actions bot pushed a commit that referenced this pull request Dec 25, 2025
## [Version&nbsp;4.0.0](v3.0.2...v4.0.0)
<sup>Released on **2025-12-25**</sup>

#### ♻ Code Refactoring

- **misc**: Migrate from lodash-es to es-toolkit.

#### ✨ Features

- **misc**: Bump v4 [force major].

#### 🐛 Bug Fixes

- **misc**: Fix build.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Migrate from lodash-es to es-toolkit, closes [#58](#58) ([d4dd3aa](d4dd3aa))

#### What's improved

* **misc**: Bump v4 [force major] ([cae0509](cae0509))

#### What's fixed

* **misc**: Fix build ([85c2559](85c2559))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants