-
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 from Navigation
components
#41865
Conversation
Size Change: +1.92 kB (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.
Looks good!
@@ -1,11 +1,11 @@ | |||
/** | |||
* 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 disable
s, 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.
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
Navigation
component 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-fetch
package haslodash
as a dependency #39495How?
We have to deal essentially a few methods, and migration away from them is pretty straightforward:
uniqueId
We're just using a straightforward non-exposed counter instead.
filter
We're using
Array.prototype.filter()
in combination withObject.values()
to convert to an array where necessary.deburr
We're using the
remove-accents
package instead, as we already did in a few other instances (see #41687 and #41702).find
We'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.omit
We're using simple object destructuring to omit properties with certain keys from objects.
Testing Instructions
npm run storybook:dev
npm run test-unit packages/components/src/navigation