cli icon indicating copy to clipboard operation
cli copied to clipboard

Netlify-cli is very bloated

Open RDIL opened this issue 2 years ago • 2 comments

Which problem is this feature request solving?

Netlify CLI is very, very big. It consumes roughly 194 megabytes of disk space when installed. This is easily one of, if not the biggest dependencies that a project can have. It would really benefit it to be smaller (faster install times, faster runtime environment, etc). Docusaurus removed it because of that: https://github.com/facebook/docusaurus/pull/7216

This is a graph of all the dependencies present from a single install of netlify-cli: Screen Shot 2022-04-20 at 10 38 34

Describe the solution you'd like

Ideas:

  • Bundle all the code, and run it through a minifier first, removing all dependencies from the package (when installed by consumers) - also use source maps to keep stack traces and such in-tact
  • Evaluate the dependency chain thoroughly to use smaller and less bloated packages

Pull request (optional)

  • [ ] I can submit a pull request.

RDIL avatar Apr 20 '22 14:04 RDIL

Correction: 333MB of node_modules on its own, just that it uses some popular modules like express, lodash, and rxjs that luckily manage to be reused in Docusaurus' monorepo.

I really don't understand why it pulls in so much stuff just to run a dev server locally.

Josh-Cena avatar Apr 20 '22 14:04 Josh-Cena

There are some low-hanging fruits to pruning dependency size. For example, netlify-cli depends on inquirer which pulls in rxjs. Switching to prompts will save 23MB on its own. See https://github.com/facebook/docusaurus/pull/4012 and https://github.com/facebook/create-react-app/pull/10083 for examples.

Pulling in both esbuild and babel also seems fishy to me, not to mention transitively pulling in [email protected] through precinct. I don't know exactly what features netlify-cli offers, but if it doesn't actually use the features of the typescript compiler, I strongly suggest considering forking that dependency.

It also pulls in a lot of type dependencies which can be refactored out to a separate package.

Josh-Cena avatar Apr 20 '22 15:04 Josh-Cena

Following up – I just ran yarn why netlify-cli on the Netlify dashboard's repo.

It returned 273.17MB:

[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "netlify-cli"
info This module exists because it's specified in "devDependencies".
info Disk size without dependencies: "8.75MB"
info Disk size with unique dependencies: "77.49MB"
info Disk size with transitive dependencies: "273.17MB"
info Number of shared dependencies: 467

kaelig avatar Mar 24 '23 23:03 kaelig

Closing in favour of https://github.com/netlify/cli/issues/3941 which has detailed plans

sarahetter avatar Sep 14 '23 19:09 sarahetter