Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

deps: reduce lodash usage #537

Merged
merged 1 commit into from
Sep 20, 2023
Merged

Conversation

sjbarag
Copy link
Contributor

@sjbarag sjbarag commented Sep 20, 2023

All of lodash.js is currently included when ui-components gets bundled, but only _.camelCase is actually necessary. Remove two unnecessary lodash functions:

  • _.get was only used to provide a fallback for a top-level property, and is equivalent to Foo[bar].
  • _.isEmpty was only called for a string | React.Component, and is equivalent to str !== ""

All that remains is _.camelCase, which is now imported via 'lodash/camelCase' to avoid depending on the entire lodash.js file.

All of lodash.js is currently included when ui-components gets bundled,
but only _.camelCase is actually necessary. Remove two unnecessary
lodash functions:

* _.get was only used to provide a fallback for a top-level property,
  and is equivalent to Foo[bar].
* _.isEmpty was only called for a string | React.Component, and is
  equivalent to str !== ""

All that remains is _.camelCase, which is now imported via
'lodash/camelCase' to avoid depending on the entire lodash.js file.
@sjbarag sjbarag requested a review from a team as a code owner September 20, 2023 17:36
Copy link
Collaborator

@laurenbarker laurenbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! The less lodash the better 🎉

@nathanstilwell
Copy link
Contributor

Nice. If all the only dependency is _.camelCase, depending on the size we might just swap it out for camelCase (by sindresorhus) which is about 11k unpacked. Then we could drop lodash entirely.

@sjbarag sjbarag merged commit 690d074 into cockroachdb:master Sep 20, 2023
@sjbarag sjbarag deleted the use-less-lodash branch September 20, 2023 20:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants