-
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
Components: Remove Lodash from DropdownMenu
#42218
Conversation
Size Change: +4 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
242097f
to
0a31dcc
Compare
if ( control.onClick ) { | ||
control.onClick(); | ||
{ controlSets | ||
?.map( ( controlSet, indexOfSet ) => |
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.
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.
Sure, done in 82d0d88.
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.
0a31dcc
to
cfb94a9
Compare
82d0d88
to
8c1d275
Compare
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.
🚀
8c1d275
to
d9af5c1
Compare
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 👍
d9af5c1
to
663f4b9
Compare
What?
This PR removes all of the Lodash from the
DropdownMenu
component. There are just a few usages and conversion is pretty straightforward.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 have to deal essentially a couple of methods, and migration away from them is pretty straightforward:
flatMap()
We're replacing it with a
map()
on the arrays, followed by a.flat()
to flatten the result array.isEmpty()
Since the usage is for arrays, ensuring they're not nullish and have
.length
is a substantial replacement.Testing Instructions
npm run test-unit packages/components/src/dropdown-menu
.