aio-cli icon indicating copy to clipboard operation
aio-cli copied to clipboard

size audit of aio-cli node_modules, improvement suggestions

Open shazron opened this issue 3 years ago • 5 comments

Only listing those with at least double digit sizes in megabytes, and only for a production build via npm i --production. Total size of node_modules is 466M

$ du | sort -nr | cut -f2- | xargs du -hs
466M      .
144M	./@parcel
128M	./@parcel/transformer-js
 68M	./aws-sdk
 32M	./aws-sdk/clients
 17M	./aws-sdk/dist
 17M	./rxjs
 16M	./yeoman-environment
 16M	./yeoman-environment/node_modules
 15M	./aws-sdk/apis
 15M	./@adobe
 11M	./yeoman-environment/node_modules/rxjs

@parcel/transformer-js is the biggest, mainly because it includes pre-built native binding .node files for all the platforms. This can be optimized by not including .node files that are not used by the current platform. There is nothing we can do however to affect this, since the .node files are packed into the tarball for the package version, and not compiled post-install per platform. The linux .node files themselves contribute 90M. Parcel is used in the app plugin for aio app run.

aws-sdk is used in @adobe/aio-lib-web which is in turn used by the app plugin for deploy/undeploy (for S3 only). This is v2 of the sdk - we can improve this if we move to v3 where each service has its own package, and we only use S3.

yeoman-environment is used by the app plugin, to run the yeoman generators when creating an app. The bulk of it is rxjs@7.

rxjs is used by multiple modules - events plugin (events-lib), inquirer (cli UI). v6 is 17M.

shazron avatar Mar 27 '22 15:03 shazron

Using cost-of-modules for aio-cli:

┌────────────────────────────────────────┬───────────────┬─────────┐
│ name                                   │ children      │ size    │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-app              │ 2425          │ 545.61M │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-events           │ 169           │ 25.04M  │
├────────────────────────────────────────┼───────────────┼─────────┤
│ inquirer                               │ 23            │ 7.02M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/plugin-plugins                  │ 43            │ 6.87M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-runtime          │ 74            │ 6.71M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/plugin-not-found                │ 41            │ 5.69M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/plugin-autocomplete             │ 7             │ 4.66M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ cli-ux                                 │ 48            │ 3.78M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/command                         │ 28            │ 2.97M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-console          │ 42            │ 2.47M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-certificate      │ 18            │ 2.42M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/plugin-help                     │ 24            │ 2.37M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/plugin-warn-if-update-available │ 9             │ 2.03M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-info             │ 38            │ 1.91M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-auth             │ 37            │ 1.77M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-plugin-config           │ 7             │ 1.08M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/config                          │ 25            │ 0.81M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ node-fetch                             │ 3             │ 0.46M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ ora                                    │ 18            │ 0.41M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ @oclif/color                           │ 9             │ 0.20M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ semver                                 │ 2             │ 0.12M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ chalk                                  │ 3             │ 0.10M   │
├────────────────────────────────────────┼───────────────┼─────────┤
│ 22 modules                             │ 1077 children │ 347.04M │
└────────────────────────────────────────┴───────────────┴─────────┘

shazron avatar Mar 30 '22 03:03 shazron

Using cost-of-modules for aio-cli-plugin-app:

┌────────────────────────────────┬───────────────┬─────────┐
│ name                           │ children      │ size    │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-lib-web             │ 1357          │ 398.40M │
├────────────────────────────────┼───────────────┼─────────┤
│ yeoman-environment             │ 457           │ 34.82M  │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-lib-runtime         │ 198           │ 24.74M  │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-lib-console     │ 63            │ 15.43M  │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-lib-ims             │ 81            │ 10.04M  │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/generator-aio-app       │ 87            │ 9.17M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @parcel/reporter-cli           │ 76            │ 9.11M   │
├────────────────────────────────┼───────────────┼─────────┤
│ inquirer                       │ 23            │ 7.02M   │
├────────────────────────────────┼───────────────┼─────────┤
│ cli-ux                         │ 48            │ 3.78M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @oclif/command                 │ 43            │ 3.30M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-lib-core-networking │ 20            │ 2.28M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-lib-core-logging    │ 35            │ 2.14M   │
├────────────────────────────────┼───────────────┼─────────┤
│ ajv                            │ 5             │ 1.44M   │
├────────────────────────────────┼───────────────┼─────────┤
│ js-yaml                        │ 3             │ 0.72M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @oclif/plugin-help             │ 31            │ 0.65M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-cli-lib-app-config  │ 6             │ 0.63M   │
├────────────────────────────────┼───────────────┼─────────┤
│ chokidar                       │ 17            │ 0.61M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-lib-core-config     │ 5             │ 0.55M   │
├────────────────────────────────┼───────────────┼─────────┤
│ node-fetch                     │ 3             │ 0.46M   │
├────────────────────────────────┼───────────────┼─────────┤
│ serve-static                   │ 24            │ 0.45M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @oclif/config                  │ 7             │ 0.44M   │
├────────────────────────────────┼───────────────┼─────────┤
│ ora                            │ 18            │ 0.41M   │
├────────────────────────────────┼───────────────┼─────────┤
│ http-terminator                │ 10            │ 0.33M   │
├────────────────────────────────┼───────────────┼─────────┤
│ execa                          │ 19            │ 0.33M   │
├────────────────────────────────┼───────────────┼─────────┤
│ fs-extra                       │ 6             │ 0.22M   │
├────────────────────────────────┼───────────────┼─────────┤
│ @adobe/aio-lib-env             │ 2             │ 0.14M   │
├────────────────────────────────┼───────────────┼─────────┤
│ chalk                          │ 5             │ 0.13M   │
├────────────────────────────────┼───────────────┼─────────┤
│ hjson                          │ 0             │ 0.12M   │
├────────────────────────────────┼───────────────┼─────────┤
│ debug                          │ 1             │ 0.05M   │
├────────────────────────────────┼───────────────┼─────────┤
│ lodash.clonedeep               │ 0             │ 0.05M   │
├────────────────────────────────┼───────────────┼─────────┤
│ upath                          │ 0             │ 0.03M   │
├────────────────────────────────┼───────────────┼─────────┤
│ pure-http                      │ 0             │ 0.03M   │
├────────────────────────────────┼───────────────┼─────────┤
│ dotenv                         │ 0             │ 0.02M   │
├────────────────────────────────┼───────────────┼─────────┤
│ which                          │ 1             │ 0.02M   │
├────────────────────────────────┼───────────────┼─────────┤
│ get-port                       │ 0             │ 0.01M   │
├────────────────────────────────┼───────────────┼─────────┤
│ dedent-js                      │ 0             │ 0.01M   │
├────────────────────────────────┼───────────────┼─────────┤
│ 36 modules                     │ 1008 children │ 328.81M │
└────────────────────────────────┴───────────────┴─────────┘

shazron avatar Mar 30 '22 03:03 shazron

Using cost-of-modules for aio-lib-web:

┌─────────────────────────────┬──────────────┬─────────┐
│ name                        │ children     │ size    │
├─────────────────────────────┼──────────────┼─────────┤
│ parcel                      │ 1470         │ 336.99M │
├─────────────────────────────┼──────────────┼─────────┤
│ aws-sdk                     │ 16           │ 68.25M  │
├─────────────────────────────┼──────────────┼─────────┤
│ @adobe/aio-lib-core-tvm     │ 21           │ 3.25M   │
├─────────────────────────────┼──────────────┼─────────┤
│ @adobe/aio-lib-core-logging │ 36           │ 2.15M   │
├─────────────────────────────┼──────────────┼─────────┤
│ joi                         │ 7            │ 0.73M   │
├─────────────────────────────┼──────────────┼─────────┤
│ js-yaml                     │ 3            │ 0.72M   │
├─────────────────────────────┼──────────────┼─────────┤
│ @adobe/aio-lib-core-config  │ 6            │ 0.53M   │
├─────────────────────────────┼──────────────┼─────────┤
│ fs-extra                    │ 6            │ 0.22M   │
├─────────────────────────────┼──────────────┼─────────┤
│ mime-types                  │ 1            │ 0.21M   │
├─────────────────────────────┼──────────────┼─────────┤
│ lodash.clonedeep            │ 0            │ 0.05M   │
├─────────────────────────────┼──────────────┼─────────┤
│ klaw                        │ 1            │ 0.04M   │
├─────────────────────────────┼──────────────┼─────────┤
│ regenerator-runtime         │ 0            │ 0.03M   │
├─────────────────────────────┼──────────────┼─────────┤
│ 12 modules                  │ 652 children │ 283.26M │
└─────────────────────────────┴──────────────┴─────────┘

shazron avatar Mar 30 '22 03:03 shazron

parcel takes up 60% of the size of the cli.

After discussion, here are the alternatives:

  1. remove parcel use, and use webpack -- we are already using webpack for action bundling
  2. move parcel use to the template (which has web assets - currently the exc-shell)
  3. use pnpm a. although this is about the size of the parcel download, and not about package caching (via symlinks) which is pnpm's strength
  4. use yarn a. although this is about the size of the parcel download, and not about copying packages from a global cache which is yarn's strength

shazron avatar Mar 30 '22 14:03 shazron

JIRA issue created: https://jira.corp.adobe.com/browse/ACNA-1578

aiojbot avatar Mar 30 '22 15:03 aiojbot