-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Lodash: Remove from Navigation components
#41865
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
Conversation
|
Size Change: +1.92 kB (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
mirka
left a comment
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.
Looks good!
| * External dependencies | ||
| */ | ||
| import { deburr } from 'lodash'; | ||
| import removeAccents from 'remove-accents'; |
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.
| // eslint-disable-next-line no-unused-vars | ||
| const { children, ...newNode } = value; |
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.
Has this ever come up in the other Lodash removal PRs? I wonder if we should consider the ignoreRestSiblings option. I can see it has only been discussed once before in #3208 (comment).
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.
Good call - and yeah! I think I introduced at least one other of these disables, and I don't particularly fancy that. Will try your suggestion in another PR, thanks 👍
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.
Suggestion that we enable ignoreRestSiblings: #41897.
tyxla
left a comment
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.
|
Oh sorry, missed that. Let's add one then! |
|
Added in #41933, including a few others I missed. Will try to include one every time from now on. |

What?
This PR removes all of the Lodash from the
Navigationcomponent group. 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-fetchpackage haslodashas a dependency #39495How?
We have to deal essentially a few methods, and migration away from them is pretty straightforward:
uniqueIdWe're just using a straightforward non-exposed counter instead.
filterWe're using
Array.prototype.filter()in combination withObject.values()to convert to an array where necessary.deburrWe're using the
remove-accentspackage instead, as we already did in a few other instances (see #41687 and #41702).findWe're using
Array.prototype.some()as we're not really interested in using the results, but rather just checking if a value is found with the specified criteria.omitWe're using simple object destructuring to omit properties with certain keys from objects.
Testing Instructions
npm run storybook:devnpm run test-unit packages/components/src/navigation