Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Replace individual lodash.* packages with lodash or remove entirely #1054

Closed
1 task
dhruvkb opened this issue Mar 4, 2022 · 6 comments
Closed
1 task

Replace individual lodash.* packages with lodash or remove entirely #1054

dhruvkb opened this issue Mar 4, 2022 · 6 comments
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed

Comments

@dhruvkb
Copy link
Member

dhruvkb commented Mar 4, 2022

Problem

Individually packaged lodash functions are deprecated and their usage is discouraged. They also don't work well with TypeScript as individual @types/ packages need to be added for all of them.

Description

The use these functions should be replaced with lodash or lodash-es.

Alternatives

The deprecation notice provides some viable alternatives. A significant alternative is to remove lodash altogether and write some of the functions ourselves or use smaller third-party libraries with a more specific focus.

Implementation

  • 🙋 I would be interested in implementing this feature.
@dhruvkb dhruvkb added 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository labels Mar 4, 2022
@dhruvkb dhruvkb changed the title Replace individual lodash.* packages with lodash Replace individual lodash.* packages with lodash or remove entirely Mar 4, 2022
@dhruvkb dhruvkb added good first issue New-contributor friendly help wanted Open to participation from the community labels Mar 4, 2022
@sarayourfriend
Copy link
Contributor

A few reasons to remove lodash:

  1. Lodash is huge for what it is, minified it's 73.3kb. I wouldn't want to encourage using more of it.
  2. It doesn't tree shake well. Even if you use the lodash/whatever access the lodash library functions are all implemented in other lodash library functions so you end up still pulling in a large amount of the lodash library anyway.
  3. It has unusual semantics like list-first parameter order and swallows null/undefined in ways that encourage unsafe modern JavaScript. It has the appearance of something like a functional programming library but doesn't follow any conventional FP semantics (like list-last parameters or type safety).
  4. It encourages reaching for a library when built-in native Array and Object functions would work just as well (and be much faster thanks to heavy engine optimization).
  5. The functions it exports that don't have direct native replacements are typically less-efficient and focused than one-off libraries. For example, memize is better at memoization than lodash.memoize.

@dhruvkb
Copy link
Member Author

dhruvkb commented Mar 11, 2022

@sarayourfriend based on your points could you make a task-list of issues to remove Lodash usages one-by-one? That seems like a good way to create lots of small good first issues.

@sarayourfriend
Copy link
Contributor

Sure thing!

@sarayourfriend
Copy link
Contributor

Done! https://github.com/WordPress/openverse-frontend/milestone/14

@dhruvkb
Copy link
Member Author

dhruvkb commented Mar 11, 2022

Let's close this issue then?

@sarayourfriend
Copy link
Contributor

Closing as replaced by the milestone and subsequent issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed
Projects
None yet
Development

No branches or pull requests

2 participants