Lodash: Remove from Navigation components#41865
Merged
Conversation
|
Size Change: +1.92 kB (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
mirka
approved these changes
Jun 22, 2022
| * External dependencies | ||
| */ | ||
| import { deburr } from 'lodash'; | ||
| import removeAccents from 'remove-accents'; |
Member
Comment on lines
+12
to
+13
| // eslint-disable-next-line no-unused-vars | ||
| const { children, ...newNode } = value; |
Member
There was a problem hiding this comment.
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).
Member
Author
There was a problem hiding this comment.
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 👍
Member
Author
There was a problem hiding this comment.
Suggestion that we enable ignoreRestSiblings: #41897.
Member
|
Oh sorry, missed that. Let's add one then! |
Member
Author
|
Added in #41933, including a few others I missed. Will try to include one every time from now on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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