3 ms·
There’s a lot of different metrics to look at when determining if one should install a dependency or not. One such metric I found to be missing for npm depende
by styfle 6y ago
There’s a lot of different metrics to look at when determining if one should install a dependency or not.
One such metric I found to be missing for npm dependencies was the install size, which is why I created https://packagephobia.com https://packagephobia.com
We need more tools to help make this decision because its easy to add a new dependency but its often hard to remove a dependency.
- dakiol 6y agoI'm not sure size is a good metric here. For example, a really tiny npm library like left pad (https://packagephobia.com/result?p=leftpad https://packagephobia.com/result?p=leftpad) is something you don't want to depend on (because you can implement it in a couple of lines), whereas date-fns (https://packagephobia.com/result?p=date-fns https://packagephobia.com/result?p=date-fns), which is way bigger than left pad, is a library I definitely don't mind depending on.
- styfle 6y agoThat’s a great example! You looked at the size and determined that it might not be worth bringing on a small dependency when you can implement it yourself (or rather use String.prototype.padStart). It’s not just size alone but size of transitive dependencies. Both examples you gave don’t have any dependencies (the publish size matches the install size). Take a look at some popular dependencies like request or jest and notice the number of transitive dependencies. https://packagephobia.com/result?p=request https://packagephobia.com/result?p=request https://packagephobia.com/result?p=jest https://packagephobia.com/result?p=jest