-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: Refactor away from _.reject()
#42040
Conversation
Size Change: +57 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
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.
LGTM 👍
...( activeFormats?.filter( | ||
( { type } ) => type !== format.type | ||
) || [] ), |
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.
I checked this change in the native version and confirm it's working as expected 🎊 .
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.
Thanks for the confirmation @fluiddot 🙌
What?
Lodash's
reject()
is used only a few times in the entire codebase. This PR aims to remove that usage.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?
Removing
_.reject()
is straightforward in favor ofArray.prototype.filter()
.We also use the opportunity to remove a couple of stray
find()
usages that are easily replacible withArray.prototype.find()
.Testing Instructions
npm run test-unit packages/rich-text