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

Nx 17 - Buildable Angular libs fail lint upon generation with The "tslib" package is not used by "my-lib" project #21023

Closed
1 of 4 tasks
abaran30 opened this issue Jan 5, 2024 · 5 comments · Fixed by #23423
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@abaran30
Copy link

abaran30 commented Jan 5, 2024

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

Steps to Reproduce

  1. Clone the above repo; gh repo clone abaran30/nx-angular
  2. npm ci
  3. 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
  4. Run npx nx run my-lib:lint

Nx Report

 NX   Report complete - copy this into the issue template

Node   : 20.11.0
OS     : darwin-arm64
npm    : 10.2.4

nx                 : 19.0.4
@nx/js             : 19.0.4
@nx/jest           : 19.0.4
@nx/linter         : 19.0.4
@nx/eslint         : 19.0.4
@nx/workspace      : 19.0.4
@nx/angular        : 19.0.4
@nx/devkit         : 19.0.4
@nx/eslint-plugin  : 19.0.4
@nx/playwright     : 19.0.4
@nrwl/tao          : 19.0.4
@nx/web            : 19.0.4
@nx/webpack        : 19.0.4
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/playwright/plugin
@nx/eslint/plugin

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

  • 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?

@andy-bond
Copy link

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.

@AgentEnder AgentEnder added the scope: angular Issues related to Angular support in Nx label Jan 9, 2024
@alexanderPastornicky
Copy link

alexanderPastornicky commented Jan 31, 2024

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

nova-chrome pushed a commit to nova-chrome/shadcn-ng that referenced this issue Feb 16, 2024
@Coly010
Copy link
Contributor

Coly010 commented May 15, 2024

Hey! It looks your GH Repo is 404ing. Could you provide me with another repo so that I can investigate further?

@abaran30
Copy link
Author

@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.

Coly010 added a commit that referenced this issue May 16, 2024
…23423)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
When generating buildable and publishable angular libraries, we always
add `tslib` to the `package.json#dependencies`.
These libaries may not actually use this dependency and therefore it is
redundant.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Do not add `tslib` by default.
If users need it, they can add it when they do.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #21023
FrozenPandaz pushed a commit that referenced this issue May 21, 2024
…23423)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
When generating buildable and publishable angular libraries, we always
add `tslib` to the `package.json#dependencies`.
These libaries may not actually use this dependency and therefore it is
redundant.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Do not add `tslib` by default.
If users need it, they can add it when they do.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #21023

(cherry picked from commit 34547b3)
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 Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants