Skip to content

[6.x] Replace underscore with lodash #11529

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

Merged
merged 25 commits into from
Mar 5, 2025
Merged

[6.x] Replace underscore with lodash #11529

merged 25 commits into from
Mar 5, 2025

Conversation

jasonvarga
Copy link
Member

@jasonvarga jasonvarga commented Mar 4, 2025

This PR:

  • Replaces underscore.js with lodash (lodash-es) since lodash is the more widely accepted standard because of performance, modularity, more battle tested, popularity, etc.
  • Removes the global _ helper and uses ES imports to improve bundle size*.
  • Removes a bunch of underscore/lodash usage with native js equivalents.
  • Snuck in removal of importer.js which was remnants from v2. It's not used and I only noticed it because it used an underscore method.

* Ironically, using lodash is a little heavier, but at least it's more modern. We may replace more bits with native JS in the future that will decrease bundle size further.

The removal of the _ helper is a breaking change and means addons will have to import lodash themselves.

+import { filter } from 'lodash-es';

-const filteredStuff = _.filter(stuff, fn);
+const filteredStuff = filter(stuff, fn);

However you may be able to just use native JS for most things anyway now. (And probably should.)

-const filteredStuff = _.filter(stuff, fn);
+const filteredStuff = stuff.filter(fn);

@jasonvarga jasonvarga marked this pull request as ready for review March 5, 2025 20:37
@jasonvarga jasonvarga merged commit e8ad32e into master Mar 5, 2025
18 checks passed
@jasonvarga jasonvarga deleted the underscore-to-lodash branch March 5, 2025 20:38
jasonvarga added a commit that referenced this pull request Mar 21, 2025
This was really just because this.field should have been this.fields - typo introduced in #11529. But, before I realized that, I simplified to native JS thinking that was part of it. Nope. But keeping the native JS is nice to get rid of a couple of lodash imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant