Compare Node.js Module Sizes With a CLI

Measuring the real install size of a module from npm is kind of an art because different package managers and different versions of those package managers resolve the dependency graph differently. Some account for shared dependencies and peer dependencies. Others measure a "bundled" size and compression because they focus on front end code. Also, tools differ in how they math KB/MB, kib, etc. But if you are mostly comparing alternatives and use the same tool to compare, you generally get a good, relative baseline.

So, my goal isn't necessarily to see how various modules combine on disk, but which package from a set I want to use for a specific purpose.

Enter howfat. You can use it anywhere npm is installed with npx:

> npx howfat enquirer
enquirer@2.4.1 (3 deps, 219.2kb, 63 files, ©MIT)
├── ansi-colors@4.1.3 (25.53kb, 6 files, ©MIT)
╰─┬ strip-ansi@6.0.1 (1 dep, 9.41kb, 10 files, ©MIT)
  ╰── ansi-regex@5.0.1 (5.48kb, 5 files, ©MIT)

You can format results with a "reporter" (some graphs create HUGE trees):

> npx howfat -r simple @inquirer/prompts
Dependencies: 112
Size: 6.26mb
Files: 1076

You can provide multiple package names:

> npx howfat -r table minimist chalk prompts

And even measure the current project directory:

> npx howfat .

Again, this isn't necessarily for getting a specific, real size on disk, but it is a great way to compare and get a general idea of weights while considering various modules.

Also, inquirer.js is huge on disk, y tho?

from Sanity.io (196.03ms) to HTML (13.60ms)