-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 _.merge()
#48239
Conversation
Size Change: +290 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 291f545. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4232748699
|
017f2fc
to
4d6be7b
Compare
@@ -2,6 +2,10 @@ | |||
|
|||
## Unreleased | |||
|
|||
### Internal | |||
|
|||
- Lodash: Refactor away from `_.merge()` ([#48239](https://github.com/WordPress/gutenberg/pull/48239)). |
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.
In a changelog message I would say that the lodash
dependency has been removed from the package. It's something that's visible and useful for the package consumer, unlike the purely internal merge
refactor.
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.
Good call. Expanded the CHANGELOG message in 291f545
What?
This PR removes Lodash's
_.merge()
from thebabel-plugin-makepot
package. It's the last usage, so we're also deprecating that method. Finally, we're removing a stray_.isEmpty()
which is straightforward enough to remove.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
deepmerge
instead of_.merge()
, which has been properly used as a substitute in other places of the codebase where we need deep merging of objects. We're using an additional bool check andObject.values().length
to replace theisEmpty()
over an object.Testing Instructions
babel-plugin-makepot
in its build pipeline. If you don't have one, you could start with the one mentioned at babel-plugin-makepot: "translations is not iterable" #43793node_modules
, similar to how we did in Makepot: Fix translations object handling #43797.cc @jeremyfelt who has historically been capable to test changes on this package - I'd really appreciate a review on this one. 🙌