Skip to content

Only import required lodash methods to reduce bundle size - #175

Closed
cvbuelow wants to merge 1 commit into
Eliav2:mainfrom
cvbuelow:refactor/lodash
Closed

Only import required lodash methods to reduce bundle size#175
cvbuelow wants to merge 1 commit into
Eliav2:mainfrom
cvbuelow:refactor/lodash

Conversation

@cvbuelow

Copy link
Copy Markdown

No description provided.

@joealden

Copy link
Copy Markdown

Would resolve #118.

@Eliav2 with v3 being abandoned (for now at least), and for how little time this would take to merge + release, could we please get this in as a 2.x.x release? Would be very much appreciated!

@Eliav2

Eliav2 commented Feb 19, 2024

Copy link
Copy Markdown
Owner

Sorry can't merge it for now because can't test it without setting up an proper environment.
What is the reason you still using this lib in 2024? Seriously, there is no better alternative this day?

@joealden

joealden commented Feb 19, 2024

Copy link
Copy Markdown

@Eliav2 I had a good look around when I introduced your lib to my work's codebase, and couldn't find anything as good that satisfied these points:

  • Ref based connections - a lot of other libs are id or class based, which isn't as ergonomic when we're wanting to render lines dynamically.
  • Grid based connections.
  • Something simple - we just use it to connect static elements in a UI (as well as moving things along these paths sometimes), we don't need or want all that comes with react-flow.

I had a look around again this weekend after I saw the deprecation notice, and still couldn't find anything that was as elegant. Today I tried implementing something custom within our codebase, but struggled with positioning, re-rendering, etc. I also tried patching your lib via yarn patch to peform the changes in this PR, but ran into problems due to the library being published to NPM already built via webpack.

I appreciate that it's a niche case!

@Eliav2

Eliav2 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Superseded, and thanks for this. Your diagnosis was right: the whole of lodash was ending up in the bundle, which is what #118 was reporting.

We went further than the targeted imports here. In #212 lodash was removed entirely, along with prop-types and @types/react, so the package now has zero runtime dependencies. The two lodash call sites turned out to be doing very little: isEqual was comparing four numbers, and the other use was a plain object spread.

The fix ships in 2.1.0.

@Eliav2 Eliav2 closed this Aug 8, 2026
@joealden

joealden commented Aug 8, 2026

Copy link
Copy Markdown

Even better - thanks! Appreciate the revival of this package, still using it today in production :)

@Eliav2

Eliav2 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

awesome to hear that @joealden

@cvbuelow
cvbuelow deleted the refactor/lodash branch August 10, 2026 13:46
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.

3 participants