cli icon indicating copy to clipboard operation
cli copied to clipboard

fix(cli-config): include peer dependencies when finding dependencies

Open tido64 opened this issue 1 year ago • 3 comments

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

tido64 avatar Jun 21 '24 06:06 tido64

cc @szymonrybczak @thymikee

tido64 avatar Jun 21 '24 06:06 tido64

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?

TMisiukiewicz avatar Jul 03 '24 11:07 TMisiukiewicz

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?

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

tido64 avatar Jul 04 '24 02:07 tido64

@TMisiukiewicz: Anything I can help with to move this forward?

tido64 avatar Sep 19 '24 07:09 tido64

@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?

TMisiukiewicz avatar Sep 20 '24 07:09 TMisiukiewicz

@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.

tido64 avatar Sep 20 '24 07:09 tido64