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

why library's package.json inside dist folder not showing peer dependency of react and react-dom? #13947

Closed
nsit8919 opened this issue Dec 21, 2022 · 5 comments
Labels
outdated scope: core core nx functionality scope: react Issues related to React support for Nx stale type: question / discussion

Comments

@nsit8919
Copy link

Current Behavior

showing dependency of react and react-dom in package.json file . react build

Expected Behavior

react and react-dom should come in peer dependency as it is library .

Github Repo

No response

Steps to Reproduce

Hi Follow all steps mentioned here

https://nx.dev/getting-started/react-standalone-tutorial
But when I am creating build of my library .In the package.json file inside dist folder .It is showing react and react-dom as dependency . It should show as a peer dependency . is it possible ?

Nx Report

NX

Failure Logs

No response

Additional Information

No response

@nsit8919 nsit8919 changed the title why library not showing peer dependency of react and react-dom? why library's package.json inside dist folder not showing peer dependency of react and react-dom? Dec 21, 2022
@atanaskanchev
Copy link

I think this PR is fixing that

@meeroslav meeroslav added type: question / discussion scope: react Issues related to React support for Nx scope: core core nx functionality and removed type: bug labels Dec 21, 2022
@meeroslav
Copy link
Contributor

@nsit8919, you didn't mention which build you have selected for that library.

Generally, packages are considered as dependencies if they are directly used (via import in the code). If you want to have it otherwise, you can create a package.json in the root of the project and specify those dependencies as peerDependencies e.g.

{
  "name": "my-package",
  "peerDependencies": {
    "react": "^18.0.0",
    "react-dom":  "^18.0.0"
  }
}

The resulting generated package.json would be this package.json expanded with missing dependencies and information. This is a common approach when creating publishable packages where the version you expect is more fluid than the one set in your root package.json or you expect some of the packages to be peer dependencies (as it is in your case)

@meeroslav
Copy link
Contributor

If you still feel there is a bug, please provide a minimal reproduction so we can look into it.

@github-actions
Copy link

github-actions bot commented Feb 5, 2023

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: core core nx functionality scope: react Issues related to React support for Nx stale type: question / discussion
Projects
None yet
Development

No branches or pull requests

3 participants