-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Lodash: Refactor editor away from _.map()
#47191
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
56bf8ac to
bbbd61d
Compare
| options={ map( | ||
| availableTemplates, | ||
| ( templateName, templateSlug ) => ( { | ||
| options={ Object.entries( availableTemplates ?? {} ).map( |
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.
availableTemplates could be nullish, therefore falling back to an object.
| */ | ||
| export const unescapeTerms = ( terms ) => { | ||
| return map( terms, unescapeTerm ); | ||
| return ( terms ?? [] ).map( unescapeTerm ); |
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.
Terms could be nullish, so falling back to an empty array.
|
Size Change: +8 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in bbbd61d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3931437065
|
What?
This PR removes Lodash's
_.map()from the editor package. There are just a couple of 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're using
Array.prototype.map()instead. We're adding nullish coalescing where necessary.Testing Instructions