DEV Community

Discussion on: The node_modules problem

 
wtgtybhertgeghgtwtg profile image
wtgtybhertgeghgtwtg

I'd say that 15 lines of code to save 7kb and a broken implementation is worth every bit of it.

In all likelihood, you're not saving 7kb; another library you're using probably has the same requirement and probably uses that same package. And if you get all libraries to do as you do, you now have n identical implementations of a 1kb function as opposed to a constant 7kb.

if we don't draw the line anywhere, well... we end up with 1875 subfolders in our node_modules folder.

node_modules aren't huge because somebody pulls into a small library. They're huge because people'll publish unneeded files, or don't split up their library into more focused libraries, or don't make an effort to deduplicate their dependency trees, or keep support for old node versions, or pin to specific versions so other dependencies can't deduplicate.

I just wish library developers were more careful when adding dependencies

It doesn't have to be a wish; if it is important to you, it is totally within your power to attempt to rectify that which you find a mistake (at least as far as open source goes). Many repositories will be responsive or even appreciative if you make an issue.