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

generatePackageJson omits dependencies with package aliases #27098

Closed
1 of 4 tasks
stephenwade opened this issue Jul 24, 2024 · 4 comments · Fixed by #27124
Closed
1 of 4 tasks

generatePackageJson omits dependencies with package aliases #27098

stephenwade opened this issue Jul 24, 2024 · 4 comments · Fixed by #27124

Comments

@stephenwade
Copy link
Contributor

stephenwade commented Jul 24, 2024

Current Behavior

When I use the @nx/webpack:webpack executor with the generatePackageJson option, the resulting package.json file doesn't include any dependencies that are defined with package aliases.

Here's an example of a package.json file with a package alias:

{
  "dependencies": {
    "lodash": "3.10.1",
    "lodash-4": "npm:lodash@4.17.21"
  }
}

I have reproduced this issue with PNPM v8 and NPM. The repro repository uses NPM.

Expected Behavior

I expect the generated package.json file to include all the dependencies used in the project, including those with package aliases.

GitHub Repo

https://github.com/stephenwade/nx-issue-repro-scaling-carnival

Steps to Reproduce

  1. Look at package.json and app/src/main.ts. They use dependencies "lodash" and "lodash-4".
  2. Run npm ci
  3. Run npx nx build
  4. Look at dist/app/package.json. It only has the dependency "lodash".

Nx Report

Node   : 20.15.1
OS     : darwin-arm64
npm    : 10.8.2

nx             : 19.4.0
@nx/js         : 19.4.0
@nx/workspace  : 19.4.0
@nx/devkit     : 19.4.0
@nrwl/tao      : 19.4.0
@nx/webpack    : 19.4.0
typescript     : 5.4.5

Failure Logs

No error messages are reported. It just produces an incorrect result.

Package Manager Version

npm 10.8.2

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@phihochzwei
Copy link

Have you checked if this is something similar to #26604 ?

@stephenwade
Copy link
Contributor Author

It isn't similar. I believe that issue happens because TypeORM doesn't have a direct dependency on mssql, so Nx can't infer that mssql belongs in the generated package.json file.

In this issue, the app code explicitly uses the dependency with a package alias, but that dependency still isn't added to the generated package.json file.

@stephenwade
Copy link
Contributor Author

@leosvelperez Can the fix be merged, please?

Copy link

github-actions bot commented Sep 7, 2024

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 Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants