Why is the CLI binary 83 megabytes big?

Just curious about the CLI.
Does it need to be 83 megabytes?

$ du -h $@ | sort --human-numeric-sort -r | head -n 5
209M    /opt/google/chrome-unstable/chrome
152M    /opt/Bitwarden/bitwarden
83M     bw
40M     /boot/initrd.img-6.1.0-5-amd64
7.8M    /boot/vmlinuz-6.1.0-5-amd64

No GUI, so what’s in all those megabytes?

It shares a common codebase with desktop / web, which is written in typescript. To run typescript, a nodejs installation needs to be shipped with the CLI. Furthermore, the requried javascript/typescript libraries take up the majority of space, since they get stored as source-code.

Here are the top 10 libraries by space in the CLI:

1.3M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/acorn-globals
1.8M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/node-forge
3.0M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/tldts
3.4M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/zxcvbn
3.9M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/jsdom
4.1M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/caniuse-lite
4.9M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/lodash
9.1M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/@babel
12M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/rxjs
17M /usr/local/lib/node_modules/@bitwarden/cli/node_modules/inquirer

If you have a filesystem that supports compression (btrfs f.e) the actual size on disk is much smaller since source code is highly compressible.
Actual size on disk for me is 18 MB:

Processed 11497 files, 1770 regular extents (1770 refs), 9871 inline.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 34% 18M 53M 53M
none 100% 89K 89K 89K
zstd 34% 18M 53M 53M

Interestingly, some libraries include duplicates. F.e rxjs is listed in my listing above once, but appears again as a dependency of inquirer. This is just how npm is designed… There is a reason for memes like this I guess:
image

2 Likes