Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

tido64
Copy link
Contributor

@tido64 tido64 commented Jun 21, 2024

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/web-storage@0.2.6
cd node_modules/@react-native-webapis/web-storage
yarn react-native config

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@tido64
Copy link
Contributor Author

tido64 commented Jun 21, 2024

cc @szymonrybczak @thymikee

Copy link
Collaborator

@szymonrybczak szymonrybczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Maybe let's add some tests? :)

@TMisiukiewicz
Copy link
Collaborator

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?

@tido64
Copy link
Contributor Author

tido64 commented Jul 4, 2024

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: microsoft/rnx-kit#3200

@tido64
Copy link
Contributor Author

tido64 commented Sep 19, 2024

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

@TMisiukiewicz
Copy link
Collaborator

@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
Copy link
Contributor Author

tido64 commented Sep 20, 2024

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

Copy link
Collaborator

@TMisiukiewicz TMisiukiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification! 👍

@thymikee thymikee merged commit 0c1b1b2 into react-native-community:main Sep 23, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

config ignores peerDependencies and instead reads devDependencies
4 participants