-
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: Refactor blocks away from _.map()
#47188
Conversation
@@ -269,7 +269,7 @@ export function categories( state = DEFAULT_CATEGORIES, action ) { | |||
( { slug } ) => slug === action.slug | |||
); | |||
if ( categoryToChange ) { | |||
return map( state, ( category ) => { | |||
return state.map( ( category ) => { |
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.
Always an array:
export function categories( state = DEFAULT_CATEGORIES, action ) { |
@@ -553,12 +553,11 @@ export function getGroupingBlockName( state ) { | |||
*/ | |||
export const getChildBlockNames = createSelector( | |||
( state, blockName ) => { | |||
return map( | |||
getBlockTypes( state ).filter( ( blockType ) => { | |||
return getBlockTypes( state ) |
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.
Always an array:
( state ) => Object.values( state.blockTypes ), |
Size Change: -5 B (0%) Total Size: 1.33 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.
Thank you, @tyxla!
Flaky tests detected in be6014c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3931252386
|
What?
This PR removes Lodash's
_.map()
from the blocks 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-fetch
package haslodash
as a dependency #39495How?
We're using
Array.prototype.map()
instead.Testing Instructions