Skip to content

Contributing: Decrease the size of the node_modules needed to be downloaded #26993

Open

Description

Similar to #29008.

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

As pointed out by @tellthemachines initially, the size of the node_modules needed to be downloaded is really huge for regular contributors. It might be an issue for contributors with really high-end devices, but it certainly could be a problem for contributors with lower-end devices.

Running npm install on master produces the following result:

$ npm install
$ du -hs node_modules
1.6G	node_modules

1.6G of node_modules!

Let's further investigate the contents of the gigantic node_modules folder.

$ du -hs node_modules/* | sort -hr | head -n 20
214M	node_modules/appium
151M	node_modules/@storybook
139M	node_modules/hermes-engine
 72M	node_modules/nodegit
 67M	node_modules/react-native
 57M	node_modules/typescript
 46M	node_modules/@babel
 39M	node_modules/jsc-android
 32M	node_modules/@jest
 23M	node_modules/react-dev-utils
 21M	node_modules/enzyme
 20M	node_modules/metro-inspector-proxy
 18M	node_modules/@icons
 17M	node_modules/rxjs
 17M	node_modules/inquirer
 16M	node_modules/@types
 15M	node_modules/wait-on
 13M	node_modules/prettier
 12M	node_modules/metro
 10M	node_modules/stylelint

We can see that most of the hugest packages are only for testing or native bindings (appium, hermes-engine, react-native, jsc-android, metro...). We don't need them for regular development. In fact, we tend to forward them to CI when opening PRs anyways.

Describe the solution you'd like

Move those packages which don't need to be downloaded for regular development to optionalDependencies. Then defaults to install packages with optional=false.

This way, regular installs (npm install) won't download them, resulting in smaller size of node_modules needed. We can still install them via npm install --optional when necessary or in CI environment.

Caveats

  • optionalDependencies isn't really optionalDevDependencies though, but it's the best we can get.
  • Not decreasing the size enough though, but still are improvements.
  • What does it mean to the native developers? Are we sacrificing their DX for ours?

Describe alternatives you've considered

None that I can think of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions