Description
❯ npm ls react-native
ipfs-car@0.3.3 /Users/oli/Code/vasco-santos/ipfs-car
└─┬ ipfs-core-types@0.5.2
└─┬ interface-datastore@4.0.2
└─┬ ipfs-utils@8.1.3
└─┬ react-native-fetch-api@1.0.2
└─┬ react-native@0.64.2
a trimmed down look at the node_modules
dir after npm install
with npm@7
in a project that depends on ipfs-utils
now has >100MiB of react-native deps forced on it.
ncdu 1.15.1
--- /Users/oli/Code/vasco-santos/ipfs-car/node_modules ---
40.2 MiB [###### ] /react-native
38.3 MiB [###### ] /jsc-android
20.1 MiB [### ] /hermes-engine
6.7 MiB [# ] /@react-native-community
4.1 MiB [ ] /react-devtools-core
3.1 MiB [ ] /flow-parser
npm@7
started forcing everyone to install the cumulative peerDependencies for any that are not explcitly depended on.
Automatically installing peer dependencies is an exciting new feature introduced in npm 7.
– https://github.blog/2021-02-02-npm-7-is-now-generally-available/#peer-dependencies
the workaround is to npm i --legacy-peer-deps
but it seems awkward to expect all consumers to do that.
The culprit (aside from npm@7) is (at least) the dep on react-native-fetch-api
which brings in rn as a peerDep:
https://github.com/react-native-community/fetch/blob/8903bb7ee2c673da52f2e84172bef0752f2bedc5/package.json#L61-L62
We might PR that repo to remove the peerDependency, now npm@7 is the current default installed with node@16, but it's not an unreasonable thing for a react-native extention to do... it's exactly what peerDependecies are for. It we can't upstream that change we should fork, as it's not reasonable for something like ipfs-core-types
to bring the entire react-native
party due to a transitive dep on ipfs-utils