nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.48k stars 2.34k forks source link

@nx/dependency-checks + tslib + swc listing problems #18033

Open gperdomor opened 1 year ago

gperdomor commented 1 year ago

Current Behavior

Lint targets with @nx/dependency-checks fails with this error:

   9:3  error  The "core" uses the following packages, but they are missing from the "dependencies":
    - nx
    - @swc-node/register
    - @swc/core
    - @swc/helpers  @nx/dependency-checks
  17:5  error  The "tslib" package is not used by "core"  

Two different issues:

Expected Behavior

@nx/dependency-checks should check tsconfig files to determine if tslib should be ignored or not 🤔 ...

as a workaround we can manually add ts to the ignoredDependencies field in eslint config but we lost the version mismatch validations

GitHub Repo

No response

Steps to Reproduce

1.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.4.0
   OS     : darwin-x64
   npm    : 9.8.0

   nx (global)        : 16.5.0
   nx                 : 16.5.0
   @nx/js             : 16.5.0
   @nx/jest           : 16.5.0
   @nx/linter         : 16.5.0
   @nx/workspace      : 16.5.0
   @nx/devkit         : 16.5.0
   @nx/eslint-plugin  : 16.5.0
   @nx/plugin         : 16.5.0
   @nrwl/tao          : 16.5.0
   nx-cloud           : 16.0.5
   typescript         : 5.1.6

Failure Logs

9:3  error  The "core" uses the following packages, but they are missing from the "dependencies":
    - @swc-node/register
    - @swc/core
    - @swc/helpers  @nx/dependency-checks
  17:5  error  The "tslib" package is not used by "core"

Operating System

Additional Information

No response

meeroslav commented 1 year ago

This should not be happening. Can you provide an example repo?

This rule is simply reading from the nx graph and filtering the files based on your build target's inputs, and then collecting those dependencies. It could be that some root files use those imports and are not properly ignored in the nx.json

Rezorl commented 1 year ago

The same error

image

 >  NX   Report complete - copy this into the issue template

   Node   : 20.6.1
   OS     : win32-x64
   yarn   : 1.22.19

   nx                 : 16.8.1
   @nx/js             : 16.8.1
   @nx/jest           : 16.8.1
   @nx/linter         : 16.8.1
   @nx/workspace      : 16.8.1
   @nx/angular        : 16.8.1
   @nx/cypress        : 16.8.1
   @nx/devkit         : 16.8.1
   @nx/eslint-plugin  : 16.8.1
   @nrwl/tao          : 16.8.1
   @nx/web            : 16.8.1
   @nx/webpack        : 16.8.1
   typescript         : 5.0.4

I fixed it by changing the rule in the .eslintrc.json file for the library:

   {
      "files": ["*.json"],
      "parser": "jsonc-eslint-parser",
      "rules": {
        "@nx/dependency-checks": [
          "error",
          {
            "ignoredDependencies": ["tslib"]
          }
        ]
      }
    }
theorlovsky commented 11 months ago

this is still an issue on v17

nx report ``` > NX Report complete - copy this into the issue template Node : 18.18.0 OS : darwin-arm64 npm : 10.1.0 nx : 17.0.1 @nx/js : 17.0.1 @nx/jest : 17.0.1 @nx/linter : 17.0.1 @nx/eslint : 17.0.1 @nx/workspace : 17.0.1 @nx/angular : 17.0.1 @nx/cypress : 17.0.1 @nx/devkit : 17.0.1 @nx/eslint-plugin : 17.0.1 @nx/nest : 17.0.1 @nx/node : 17.0.1 @nx/plugin : 17.0.1 @nrwl/tao : 17.0.1 @nx/web : 17.0.1 @nx/webpack : 17.0.1 typescript : 5.1.6 ```
github-actions[bot] commented 10 months ago

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.

meeroslav commented 9 months ago

Let me reopen it then and we'll get to it as soon as possible. If you want to speed it up, can you please create a reproducible mini repo?