But I didn't have data to back that claim up, so I made some measurements to find out.
Command-line argument parsing is a common need and there are a variety of packages to make it easier.
I found nine of the most popular and installed each into a new, blank project as a standard
dependency item in
Then I counted the number of direct dependencies for that package, the total (transitive) number of packages that end up being installed, and the size (in bytes) of disk space consumed (on Windows).
I tabulated the results below and follow with a few observations.
Important: I made no attempt to assess the quality or usefulness of these packages. They are all popular and each offers a different approach to the problem. Some are feature-rich, while others offer a simple API. I am not promoting or critiquing any of them; rather, I am using the aggregate as a source of data.
|Size on Disk
These metrics were captured on 2017-11-25 and may have changed by the time you read this.
- The two most popular packages are the smallest on disk and have no dependencies; the third and fourth most popular are the biggest and have the most dependencies.
- Packages with fewer dependencies tend to have the smallest size; those with the most dependencies have the largest.
- The difference between the extremes of direct dependency count is about 10x.
- The difference between extremes for transitive dependency count is about 40x.
- The difference between disk space extremes is about 20x.
While this was a simple experiment that doesn't represent the whole Node ecosystem, it seems reasonable to conclude that:
Similar packages can exhibit differences of an order of magnitude (or more) in dependency count and size. If that matters for your scenario, measure before you choose!
For my part, I tend to resist taking on additional dependencies when possible and prefer using dependencies that adhere to the same principle. Reinventing the wheel is wasteful, of course - but sometimes less is more and it's good to keep complexity to a minimum.