-
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 away from _.mapValues()
in data registry
#47742
Conversation
Size Change: +6 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
}; | ||
} ); | ||
return Object.fromEntries( | ||
Object.entries( attributes ).map( ( [ key, attribute ] ) => { |
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.
Will always be a properly defined registry object:
gutenberg/packages/data/src/registry.js
Line 354 in 3bc98f0
const registryWithPlugins = withPlugins( registry ); |
gutenberg/packages/data/src/registry.js
Line 312 in 3bc98f0
let registry = { |
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.
Straightforward conversion, LGTM. Thank you, @tyxla! 👍
Flaky tests detected in 57ad6bc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4085269675
|
What?
This PR removes Lodash's
_.mapValues()
from the@wordpress/data
registry creation module. There is just a single use in that module 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 replacing
_.mapValues()
withObject.fromEntries( Object.entries().map() )
.Testing Instructions