Skip to content

Dependencies to remove/replace #3941

Open
@XhmikosR

Description

@XhmikosR

Is your feature request related to a problem? Please describe.

In an attempt to reduce the number of dependencies, and netlify-cli's size, I've made a couple of PRs:

Describe the solution you'd like

I think the following could be implemented to reduce the number of dependencies more (sorted randomly):

High Impact

  • find packages that don't depend on rxjs; it's ~3K files, ~4.5 MB
  • fork tabtab and update inquirer there and in cli but make sure inquirer-autocomplete-prompt is using the same inquirer/rxjs versions
  • submit upstream PR and/or replace listr with another package that doesn't depend on rxjs. The only fork I could find is https://github.com/cenk1cenk2/listr2, but this also depends on rxjs
  • replace inquirer with enquirer? https://packagephobia.com/result?p=enquirer%2Cinquirer It seems enquirer supports autocomplete and list prompts built-in without any dependencies, so this would solve a lot of issues, but only if tabtab switches to enquirer too thus getting rid of rxjs from your deps tree
  • remove update-notifier from cli and build packages?
  • remove lodash and/or use the 2-3 individual lodash packages or other replacement packages you might already be using elsewhere? Removing lodash, assuming it's removed from concordance and inquirer also, should yield another 1K files reduction
  • precinct; see https://github.com/dependents/node-precinct/pulls and https://github.com/pahen/detective-typescript/pulls and wait for new versions. These will save ~50MB from zip-it-and-ship-it and thus from all the packages that depend on it
  • update download; I have made a few upstream PRs but I doubt it's maintained. Might be worth picking up my patches and releasing new scoped packages. This should make gh-release-fetch a lot smaller

Medium/low Impact

  • yargs 17 in zip-it-and-ship-it so that it can be deduplicated: fix(deps): update dependency yargs to v17 zip-it-and-ship-it#933
  • replace minimist with commander in builders/netlify-lambda.js; commander is bigger compared to minimist, but commander is already a dependency
  • replace omit.js with Object spread when possible in all projects?
  • replace/remove read-pkg-up with find-up + own read functions - chore(deps): remove read-pkg-up #4043
  • maybe replace find-up with escalade in cli and all other Netlify packages: https://packagephobia.com/result?p=find-up%405.0.0%2Cescalade%2Cread-pkg-up%407.0.1
  • read-pkg-dir
  • find-pkg
  • find-pkg-dir
  • see if string-width is really needed in all netlify projects
  • see if path-exists is really needed in all netlify projects
  • del can be replaced with native when Node.js 12.x is dropped (it can be replaced already but because fs.rm/fs.rmDir has changed it would require a workaround) - fix(deps): remove del dependency #4017, should be removed after Node.js 12.x support is dropped (and also from the other Netlify packages when possible)
  • copy-template-dir: update upstream its dependencies
  • remove make-dir from all packages; you can just use fs.mkdir('dir', { recursive: true })
  • remove read-pkg-up from all packages
  • remove similar packages and use your own code, for example to find files, read JSON etc. tempy, tmp-promise, locate-path, find-up
  • be consistent with dependencies' versions across your packages so that they are deduplicated
  • see the esbuild solution; should help a lot
  • switching to ESM should also help
  • DO NOT update major packages without careful review and without first making sure the package can be deduplicated
  • Make the size benchmark fail if a threshold is not met. Might be worth switching to another solution later
  • Might be worth introducing a small @netlify/utils package with commonly used code like read, parse etc
  • use https://packagephobia.com, https://npm.anvaka.com/#/ and https://arve0.github.io/npm-download-size before any packages are added
  • Stop introducing new dependencies for a while
  • Typescript: make sure you use the proper ES target for your supported Node.js versions
  • maybe remove update-notifier from cli and/or any other netlify packages?
  • remove/replace deprecated packages
  • indent-string -> isn't the built-in padStart sufficient?
  • cron-parser -> reduce size by replacing its luxon dependency with something smaller
  • maybe replace cpy
  • streamline cp-file, cpy usage across all repos
  • use one common object merge package across all packages

Dev only

  • Replace nyc with c8 everywhere
  • If you use jest and coverage, make sure you use the build-in coverage provider and remove c8 or nyc etc

There are probably more packages that could be replaced, but the above should already help a bit. Feel free to add any other candidates to the list.

Also, this will be better if done across all Netlify packages since deduplication makes a huge impact.

Additional context

8.0.0:  1455 packages: 239 MB (251.578.159 bytes) - 20.720 Files, 3.759 Folders
8.6.0:  1373 packages: 235 MB (247.411.390 bytes) - 20.337 Files, 3.641 Folders
8.13.1: 1343 packages: 235 MB (246.929.792 bytes) - 20.563 Files, 3.622 Folders
main:   1343 packages: 235 MB (246.929.792 bytes) - 20.563 Files, 3.622 Folders
prec:   1341 packages: 183 MB (192.600.766 bytes) - 20.363 Files, 3.532 Folders
prec + tabtab + inquirer + prompt: 1321 packages: 185 MB (194.626.355 bytes) - 22.566 Files, 3.588 Folders
(needs listr to be updated to use rxjs 7.x too for the above to be optimal. Or try switching to listr2)
prec + tabtab + inquirer + prompt + listr2: 1286 packages: 180 MB (189.142.725 bytes) - 18.077 Files, 3.194 Folders
prec + tabtab + enquirer: 1259 packages: 175 MB (183.636.955 bytes) - 15.507 Files, 3.055 Folders

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuetype: featurecode contributing to the implementation of a feature and/or user facing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions