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

buildable @nrwl:js/lib doesn't collect dependencies to package.json #8945

Closed
ziacik opened this issue Feb 11, 2022 · 3 comments · Fixed by #9073
Closed

buildable @nrwl:js/lib doesn't collect dependencies to package.json #8945

ziacik opened this issue Feb 11, 2022 · 3 comments · Fixed by #9073

Comments

@ziacik
Copy link
Contributor

ziacik commented Feb 11, 2022

Current Behavior

I have two libs, one is @nrwl/node:lib and the other is @nrwl/js:lib. Both are buildable. Both use one external dependency, e.g. dayjs.
Now after I build both of them, the node lib has the dayjs listed as dependency in its generated package.json in the dist. But the js library does not.

Expected Behavior

The @nrwl/js:lib should list its external dependencies in the generated package.json in dist too, just like @nrwl/node:lib.

Steps to Reproduce

  1. create a workspace with one @nrwl/node:lib and one @nrwl/js:lib
  2. npm i dayjs
  3. use the dayjs in both of the libraries
  4. nx affected:build
  5. check the generated package.jsons.

Repro repo:
https://github.com/ziacik/nx-bug-4

Environment

>  NX   Report complete - copy this into the issue template

   Node : 14.17.6
   OS   : linux x64
   npm  : 6.14.15
   
   nx : undefined
   @nrwl/angular : undefined
   @nrwl/cli : 13.8.1
   @nrwl/cypress : undefined
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.1
   @nrwl/eslint-plugin-nx : 13.8.1
   @nrwl/express : undefined
   @nrwl/jest : 13.8.1
   @nrwl/js : 13.8.1
   @nrwl/linter : 13.8.1
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : 13.8.1
   @nrwl/nx-cloud : undefined
   @nrwl/react : undefined
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : undefined
   @nrwl/tao : 13.8.1
   @nrwl/web : undefined
   @nrwl/workspace : 13.8.1
   typescript : 4.5.5
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:

@jasongerbes
Copy link
Contributor

I am having the same issue. Both the @nrwl/js:tsc and @nrwl/js:swc build executors are not updating the dependencies in the dist/libs/X/package.json file.

@FrozenPandaz can you please confirm the expected behaviour?

@jasongerbes
Copy link
Contributor

jasongerbes commented Feb 20, 2022

Having dug into this a bit, it looks like updatePackageJson util in @nrwl/js should perhaps be using createPackageJson from @nrwl/workspace to create/update the package.json file.

The createPackageJson util updates the dependencies and devDependencies based on the ProjectGraph, and is currently used by @nrwl/node:build and @nrwl/next:build.

Update: This observation wasn't quite correct. It looks like the updateBuildableProjectPackageJsonDependencies is what should be used by the @nrwl/js:tsc and @nrwl/js:swc executors. I have created a PR for this change, see #9073

@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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants