fix(cli-config): include peer dependencies when finding dependencies
Summary:
config currently ignores peerDependencies and instead reads devDependencies, leading to missing dependencies.
Resolves #2419.
Test Plan:
In any project, run the following:
yarn add @react-native-webapis/[email protected]
cd node_modules/@react-native-webapis/web-storage
yarn react-native config
Checklist
- [x] Documentation is up to date to reflect these changes.
- [x] Follows commit message convention described in CONTRIBUTING.md
cc @szymonrybczak @thymikee
I was trying to test it, but couldn't see any change in the config output until I installed any of peer dependencies as a dev dependency, am I missing something? Since peer dependencies are not installed by default, might it be the case where a dependency cannot be found in node_modules?
I was trying to test it, but couldn't see any change in the
configoutput until I installed any of peer dependencies as a dev dependency, am I missing something? Since peer dependencies are not installed by default, might it be the case where a dependency cannot be found innode_modules?
The repro steps include running config under the node_modules folder, so it's definitely not a case of missing dependencies. Alternative repro steps can be found in this PR: https://github.com/microsoft/rnx-kit/issues/3200
@TMisiukiewicz: Anything I can help with to move this forward?
@tido64 I just want to clarify, what if you use a package manager that does not install peer dependencies automatically e.g. yarn classic? It would probably still not resolve the dependency properly?
@tido64 I just want to clarify, what if you use a package manager that does not install peer dependencies automatically e.g. yarn classic? It would probably still not resolve the dependency properly?
That isn't the issue here though? The issue is that the config algorithm doesn't consider peerDependencies at all and are missing out on dependencies that should be included. Whether they resolve is already handled elsewhere.
And to answer your question: IIRC, if a peer dependency is not installed (in case of Yarn classic, or maybe it's optional), CLI fails to resolve it and it is ignored.