Skip to content
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

Review Lodash dependency #18

Open
cjke opened this issue Dec 1, 2020 · 1 comment
Open

Review Lodash dependency #18

cjke opened this issue Dec 1, 2020 · 1 comment
Assignees

Comments

@cjke
Copy link

cjke commented Dec 1, 2020

Hello, cool library!

Would it be possible to review the approach to importing lodash? I've seen the PR that recommended the es approach, and agree that was not the way to go.

I think there are two simple solutions:

Option 1. Import with a slash as recommended at the end of the official docs: https://lodash.com/per-method-packages
For example, in astar-finder.ts:

import { minBy, remove } from 'lodash';

Becomes

import minBy from 'lodash/minBy';
import remove from 'lodash/remove';

This should dramatically cut down the bundle size.

Option 2. Alternatively, perhaps set lodash as a peer dependency?
At the moment, if I too use lodash, I end up with a double sized bundle, which would be removed when set as a peer.
(but I still prefer option 2, or maybe even both)

Example of a project using lodash + astar-typescript using lodash 😱
image

@digitsensitive
Copy link
Owner

Hello @cjke

Thank you for your input. It might be that I am going to rewrite the core of the library and maybe not use lodash.js anymore. I am not sure though, when this is going to happen.

Option 1 sounds reasonable.

I have never used peerDependencies, but I believe that this will not work. If I add lodash.js as a peerDependencies I will not be able to access it from my library. See this article:

https://classic.yarnpkg.com/blog/2018/04/18/dependencies-done-right
--> The peerDependencies object guarantees that, for each entry, any package that requires you (...)

Keep you updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants