Skip to content

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

@abaran30

Description

@abaran30

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?

Activity

andy-bond

andy-bond commented on Jan 5, 2024

@andy-bond

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.

alexanderPastornicky

alexanderPastornicky commented on Jan 31, 2024

@alexanderPastornicky

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

added a commit that references this issue on Feb 16, 2024
Coly010

Coly010 commented on May 15, 2024

@Coly010
Contributor

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

abaran30

abaran30 commented on May 15, 2024

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

3 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @alexanderPastornicky@AgentEnder@andy-bond@Coly010@abaran30

    Issue actions

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