Lodash: Refactor away from _.set() in getNodesWithSettings()#52278
Lodash: Refactor away from _.set() in getNodesWithSettings()#52278
_.set() in getNodesWithSettings()#52278Conversation
|
Size Change: -5 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Pretty straightforward to trace - presets is already declared to be an object, and path is already an array of strings (see PRESET_METADATA declaration).
We needed to add support for arrays in order to properly work with root and nested arrays.
|
Flaky tests detected in d491d6e56e45ca86800be67cd00504a0d43c8234. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5454375786
|
d491d6e to
6f36e49
Compare
6f36e49 to
0e44ec1
Compare
|
Ready for a review after #52280 landed. |
Mamaduka
left a comment
There was a problem hiding this comment.
LGTM. I couldn't spot any regressions ✅
What?
This PR removes Lodash's
_.set()from thegetNodesWithSettings()global styles function.We have a few more usages of
set()left in the codebase, but we might have to tread carefully, since some of them may have to deal with Unicode characters, and I prefer testing them one by one.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 replacing the usage with the existing
setImmutablyutility function, which should do the job even better - there's no need to specifically mutate, as long as we preserve all the prior changes.Testing Instructions