netlify / cli

Netlify Command Line Interface

Home Page:http://cli.netlify.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Netlify-cli is very bloated

RDIL opened this issue · 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: facebook/docusaurus#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.

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.

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 facebook/docusaurus#4012 and facebook/create-react-app#10083 for examples.

Pulling in both esbuild and babel also seems fishy to me, not to mention transitively pulling in typescript@3.9.10 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.

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 "netlify-cli@13.2.1"
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

Closing in favour of #3941 which has detailed plans