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

collectDependencies marks some top-level deps as not top-level #14513

Closed
daiscog opened this issue Jan 20, 2023 · 2 comments · Fixed by #14832
Closed

collectDependencies marks some top-level deps as not top-level #14513

daiscog opened this issue Jan 20, 2023 · 2 comments · Fixed by #14832

Comments

@daiscog
Copy link
Contributor

daiscog commented Jan 20, 2023

Current Behavior

When automatically addiing peerDependencies to the built package.json files for publishable libs, some top-level dependencies can be missing if they are also dependencies of other dependencies

Expected Behavior

All top-level dependencies are included in the peerDependencies section of the built package.json, even if they are also dependencies of other dependencies.

Steps to Reproduce

With publishable libs where:

  • lib-a imports from lib-b and also from npm package @external/package
  • lib-b imports from npm package @external/package

After running nx run lib-a:build, the dist package.json file for the lib does not contain @external/package in the peerDependencies, even though lib-a imports from it.

Nx Report

Node : 16.16.0
   OS   : darwin x64
   npm  : 8.11.0
   
   nx : 14.1.10
   @nrwl/angular : 14.1.10
   @nrwl/cypress : 14.1.10
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.1.10
   @nrwl/eslint-plugin-nx : 14.1.10
   @nrwl/express : Not Found
   @nrwl/jest : 14.1.10
   @nrwl/js : Not Found
   @nrwl/linter : 14.1.10
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.1.10
   @nrwl/web : Not Found
   @nrwl/workspace : 14.1.10
   typescript : 4.6.4
   ---------------------------------------
   Community plugins:
         @ng-bootstrap/ng-bootstrap: 11.0.1
         @ngrx/component-store: 13.2.0
         @ngrx/effects: 13.2.0
         @ngrx/store: 13.2.0
         @compodoc/compodoc: 1.1.19
         @ngrx/eslint-plugin: 14.3.2
         @ngrx/store-devtools: 13.2.0
         @storybook/angular: 6.5.13

Additional Information

After debugging, it seems the issue is affected by the order of processing deps in the recursive collectDependencies function.

If this function processes the dependency on lib-b before it processes the dependency on the npm package, then the npm package is added as a non-top-level dependency to the accumulator, then skipped when it is processed as a top-level dependency because it already exists in the accumulator.

@iurii-iufimov
Copy link

@AgentEnder , can I ask you to clarify the status of this, please?

@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 May 27, 2023
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