-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Lodash: Remove completely #52571
Lodash: Remove completely #52571
Conversation
Size Change: 0 B Total Size: 1.43 MB ℹ️ View Unchanged
|
Thanks for your great job 🎉 I just wanted to ask, am I correct that when this PR is merged, it will remove If so, for example, if a developer developing a custom block uses |
Flaky tests detected in dc7c89a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5543500008
|
Well, to be precise, #52561 removed
FWIW, a developer working on a custom block outside of Gutenberg always needed to either:
Removing Lodash as a dependency from Gutenberg doesn't change any of that, and the above 2 still remain. The change matters for Gutenberg and its core blocks and features, and is best experienced by apps and external parties that utilize the But then it's worth noting that most of the Lodash functions no longer need to be used - modern JavaScript can natively support most of what Lodash provides. So I'd strongly question any custom block that actually needs to use Lodash. Hope that helps, but please let me know if I can further clarify any of the nuances above. |
Thank you for the detailed explanation! I have personally developed custom blocks that use Lodash functions and will try to remove them. |
In the meantime, this PR is ready for a review 👀 |
Nice - let me know if I can help with any of that - feel free to start a discussion and don't hesitate to ping me there! The migration took some time but now at its end, I'm fully convinced that in 2023 Lodash is an unnecessary burden. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me 🎉
- ✅ The code example in the reference guide seems to be correct
- ✅ Unit tests for the
dependency-extraction-webpack-plugin
package also pass successfully. - ✅ If I add the import of a
lodash
function to your code, eslint will output an error as before
My concern is that lodash
and @types/lodash
are still in the project's package-lock.json. I'm not familiar with npm package dependency management in Gutenberg projects, but These depend on external libraries (not Gutenberg packages) so they cannot be removed, is it correct?
That's a valid observation, but from what I've seen before, these usages are in Storybook, or other tooling that's not directly exposed to the end user, so those shouldn't be significant concerns. In the following weeks, I'll be keeping an eye on what else in the wp-admin uses lodash and finding opportunities for cleaning up. Thanks for taking a look, @t-hamano 🙌 |
What?
This PR removes the last Lodash usage from Gutenberg. 🎉
Fixes #52545.
Why?
Lodash is known to unnecessarily inflate the bundle size of packages, and in most cases, it can be replaced with native language functionality. See these for more information and rationale:
@wordpress/api-fetch
package haslodash
as a dependency #39495How?
We're doing some ESLint cleanup, updating some docs, and removing the Lodash dependency.
Testing Instructions
Verify all checks are green.
Testing Instructions for Keyboard
None
Screenshots or screencast
None.