-
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: Remove completely from @wordpress/i18n
package
#43677
Conversation
Size Change: 0 B Total Size: 1.24 MB ℹ️ View Unchanged
|
if ( ! isEmpty( comments ) ) { | ||
if ( ! isEmpty( comments.reference ) ) { | ||
if ( Object.values( comments ).length ) { | ||
if ( comments.reference ) { |
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.
This now throws an error if comments
is null
or undefined
TypeError: Cannot convert undefined or null to object
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.
Nice catch. Fix suggested in #45414.
Test instructions to reproduce would be really helpful to ensure we fixed it properly @manzoorwanijk .
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.
Simply run npx pot-to-php path/to/translations.pot path/to/translations.php your-text-domain
to see the error.
What?
This PR removes all of the Lodash from the
@wordpress/i18n
package, including thelodash
dependency altogether.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 dealing with straightforwardly replacing
isEmpty()
against a predictable data structure, where sometimes it will be a string, and sometimes - an object.Testing Instructions
.pot
file (or generate one).packages/i18n/tools/pot-to-php.js PATH_TO_POT foobar.php
still works well and exports all translations to the provided PHP file.