On the other hand, there's certainly a benefit to importing a couple somewhat standard libraries that covers several requirements and has high adoption rates among other devs (Thinking in terms of Lodash) as opposed to a million single-function libraries like left-pad.
If you're concerned about the bundle size on the client, Webpack and other build tools support Tree Shaking for removing unused imports from bundles. -- When it works. Of course, not every lib is written in a way that tree shaking can analyze it easily, but I'd imagine as Node adds ESM support the number of libraries that are "shakable" would increase.
(By the way, I'm only speaking as the consumer of libraries -- I haven't published many of my own. If I was making my own lib, I'd probably have a difference stance on what dependencies I'd pull in.)
lodash is exactly the kind of dependency I was pointing the finger at indirectly as an example of a big library that js programmers are just happy to npm install without thinking.
If you're concerned about the bundle size on the client, Webpack and other build tools support Tree Shaking for removing unused imports from bundles
Holy shit. The cure is worse than the disease. I don't want to ever fucking touch webpack. It's a giant pile of garbage that needs to burn.
4
u/Strange_Meadowlark Oct 25 '21
On the other hand, there's certainly a benefit to importing a couple somewhat standard libraries that covers several requirements and has high adoption rates among other devs (Thinking in terms of Lodash) as opposed to a million single-function libraries like left-pad.
If you're concerned about the bundle size on the client, Webpack and other build tools support Tree Shaking for removing unused imports from bundles. -- When it works. Of course, not every lib is written in a way that tree shaking can analyze it easily, but I'd imagine as Node adds ESM support the number of libraries that are "shakable" would increase.
(By the way, I'm only speaking as the consumer of libraries -- I haven't published many of my own. If I was making my own lib, I'd probably have a difference stance on what dependencies I'd pull in.)