zx icon indicating copy to clipboard operation
zx copied to clipboard

Reduce package installation size

Open GaelGirodon opened this issue 2 years ago • 2 comments

The current installation size of the package may discourage its integration into other projects or packages that want to keep their size as low as possible (as mentioned in #687).

The installation size has increased significantly over releases, especially on 2.x, 5.x and 7.x:

1.15.2 2.1.0 3.1.0 4.3.0 5.3.0 6.2.5 7.2.3
1.38 MB 3.01 MB 3.01 MB 3.89 MB 10.5 MB 10.7 MB 16.3 MB

https://packagephobia.com/result?p=zx%401.15.2%2Czx%402.1.0%2Czx%403.1.0%2Czx%404.3.0%2Czx%405.3.0%2Czx%406.2.5%2Czx%407.2.3

98% of the installation size comes from 5 dependencies:

Dependency Install %
node-fetch 7.45 MB 47 %
@types/node 3.50 MB 22 %
@types/fs-extra 3.45 MB 22 %
yaml 636 kB 4 %
globby 577 kB 4 %
ps-tree 131 kB 1 %
fs-extra 114 kB 1 %
minimist 53.2 kB 0 %
chalk 42.5 kB 0 %
fx 19.5 kB 0 %
which 17.7 kB 0 %
@types/minimist 7.17 kB 0 %
@types/which 5.26 kB 0 %
@types/ps-tree 4.45 kB 0 %
webpod 357 B 0 %

https://packagephobia.com/result?p=@types/[email protected],@types/[email protected],@types/[email protected],@types/[email protected],@types/[email protected],[email protected],[email protected],fx,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]

The package size could be drastically reduced (-90%) by:

  1. [ ] Removing node-fetch (#687, #589): -47%
  2. [ ] Moving @types/* to dev (and optional?) dependencies: -44%
    • These types can still be installed if needed by TypeScript users
  3. [ ] Removing fs-extra and @types/fs-extra (#589): -22%

Tasks 1 and 3 are already planned for v8, could you consider the 2nd one as well? Thanks 🙂

GaelGirodon avatar Jan 07 '24 15:01 GaelGirodon

Moving @types/* to dev (and optional?) dependencies: -44% These types can still be installed if needed by TypeScript users

Yeap. We are going to build zx with esbuild and we can build .d.ts as well.

antonmedv avatar Jan 07 '24 15:01 antonmedv

Good news. We have a proposal, that reaches the 414Kb point (4.33MB with optional @types/fs-extra and @types/node) https://packagephobia.com/result?p=%40antongolub%2Fzx%2C+zx

antongolub avatar Feb 24 '24 12:02 antongolub

🎉 Awesome work @antongolub

antonmedv avatar Feb 24 '24 20:02 antonmedv