nx
nx copied to clipboard
Nx 17 - Buildable Angular libs fail lint upon generation with `The "tslib" package is not used by "my-lib" project`
Current Behavior
When generating a buildable Angular library, lint for the new library fails right away with the following error:
9:5 error The "tslib" package is not used by "my-lib" project @nx/dependency-checks
Expected Behavior
Newly generated Angular libraries (buildable or not) should not fail lint.
GitHub Repo
https://github.com/abaran30/nx-angular-playground
Steps to Reproduce
- Clone the above repo;
gh repo clone abaran30/nx-angular-playground npm ci- Generate a new buildable Angular library:
npx nx generate @nx/angular:library --name=my-lib --buildable=true --projectNameAndRootFormat=derived --standalone=false --style=none --no-interactive - Run
npx nx run my-lib:lint
Nx Report
> NX Report complete - copy this into the issue template
Node : 18.15.0
OS : darwin-arm64
npm : 9.5.0
nx : 17.1.2
@nx/js : 17.1.2
@nx/jest : 17.1.2
@nx/linter : 17.1.2
@nx/eslint : 17.1.2
@nx/workspace : 17.1.2
@nx/angular : 17.1.2
@nx/cypress : 17.1.2
@nx/devkit : 17.1.2
@nx/eslint-plugin : 17.1.2
@nrwl/tao : 17.1.2
@nx/web : 17.1.2
@nx/webpack : 17.1.2
typescript : 5.2.2
Failure Logs
9:5 error The "tslib" package is not used by "my-lib" project @nx/dependency-checks
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
Lint errors found in the listed files.
Package Manager Version
No response
Operating System
- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
As shown in the failure logs, the lint error is fixable with the --fix option. The fixer removes tslib from the the library's package.json dependencies. Should tslib not be included upon generation?
Similarly I get an error during lint if I don't utilize @angular/core in a utility library.
6:3 error The "@angular/core" package is not used by "my-util-lib" project. @nx/dependency-checks
My organization uses these Angular libraries to hold utilities - some of which might just be plain TypeScript functions & could contain shared Angular Pipes for instance.
Is the expected behavior here to remove @angular/core from the library's package.json until an Angular class is used?
That seems kinda annoying to do if I wanted to add an Angular Pipe to a utility library that previously only contained a TypeScript helper function.
same behavior with latest nx
angular monorepo project with generated publishable library
9:5 error The "tslib" package is not used by "mylibpublishable" project @nx/dependency-checks
> NX Report complete - copy this into the issue template
Node : 18.18.0
OS : win32-x64
npm : 10.2.0
nx : 17.3.0
@nx/js : 17.3.0
@nx/jest : 17.3.0
@nx/linter : 17.3.0
@nx/eslint : 17.3.0
@nx/workspace : 17.3.0
@nx/angular : 17.3.0
@nx/cypress : 17.3.0
@nx/devkit : 17.3.0
@nx/eslint-plugin : 17.3.0
@nrwl/tao : 17.3.0
@nx/web : 17.3.0
@nx/webpack : 17.3.0
typescript : 5.3.3
Hey! It looks your GH Repo is 404ing. Could you provide me with another repo so that I can investigate further?
@Coly010 my apologies; did a repo cleanup and forgot I had one linked to this issue 😅.
I updated the issue description with a new repo; updated to latest Nx and issue is still reproducible.
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.