-
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 _.omit()
from deprecated blocks
#43411
Conversation
Size Change: -26 B (0%) Total Size: 1.24 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 for working on this, @tyxla! 👍
? attributes.backgroundColor | ||
: undefined, | ||
} ), | ||
[ 'fontSize', 'textColor', 'backgroundColor', 'style' ] |
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.
I may be missing something, but it looks like your code isn't omitting these anymore?
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.
Thanks for double-checking - this is intentional. If you look at the original code, you'll notice that omit()
is called with a single argument by mistake. The second argument was being passed to migrateCustomColorsAndFontSizes()
and it just ignored it. So we never actually omitted them here and I preferred to keep the same behavior.
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, you're right, the array is outside of the omit
call! Missed that, sorry 👍
What?
This PR removes the
_.omit()
usage from all deprecated blocks.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?
_.omit()
is generally safe and easy to replace with object destructuring with spread and rest syntax. Changes are extremely straightforward and similar so I've decided to place them all in a single PR.Testing Instructions
Verify the older versions of these blocks still work well: