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

Builder helper files (vite.config.ts etc.) influence the package dependencies on create package json #17905

Closed
2 of 4 tasks
LayZeeDK opened this issue Jul 1, 2023 · 2 comments · Fixed by #17930
Closed
2 of 4 tasks
Assignees
Labels
outdated scope: core core nx functionality scope: linter Issues related to Eslint support in Nx type: bug

Comments

@LayZeeDK
Copy link
Contributor

LayZeeDK commented Jul 1, 2023

Current Behavior

The executor used for the specified build target causes the @nx/dependency-checks ESLint rule to output false positives.

Expected Behavior

The executor used to build a library should not cause any peer dependencies to be added to the library's package.json file.

GitHub Repo

https://github.com/LayZeeDK/nx-dependency-checks-executor-dependency-issue

Steps to Reproduce

  1. Configure the @nx/dependency-checks ESLint rule for a publishable library.
    project.json:
    {
      "targets": [
        "lint": {
          "executor": "@nx/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": [
              "libs/angular-design-system/**/*.ts",
              "libs/angular-design-system/**/*.html",
              "libs/angular-design-system/package.json",
              "libs/angular-design-system/project.json"
            ]
          }
        }
      ]
    }
    .eslintrc.json:
    {
      "overrides": [
        {
          "files": ["*.json"],
          "parser": "jsonc-eslint-parser",
          "rules": {
            "@nx/dependency-checks": [
              "error",
              {
                "buildTargets": ["build"],
                "checkMissingDependencies": true,
                "checkObsoleteDependencies": true,
                "checkVersionMismatches": true,
                "ignoredDependencies": []
              }
            ]
          }
        }
      ]
    }
  2. Run a lint task
    nx run-many --targets=lint

Nx Report

Node   : 18.16.1
   OS     : win32-x64
   npm    : 9.5.1
   
   nx                 : 16.5.0-beta.2
   @nx/js             : 16.5.0-beta.2
   @nx/jest           : 16.5.0-beta.2
   @nx/linter         : 16.5.0-beta.2
   @nx/workspace      : 16.5.0-beta.2
   @nx/angular        : 16.5.0-beta.2
   @nx/cypress        : 16.5.0-beta.2
   @nx/devkit         : 16.5.0-beta.2
   @nx/eslint-plugin  : 16.5.0-beta.2
   @nx/react          : 16.5.0-beta.2
   @nrwl/tao          : 16.5.0-beta.2
   @nx/vite           : 16.5.0-beta.2
   @nx/web            : 16.5.0-beta.2
   @nx/webpack        : 16.5.0-beta.2
   typescript         : 5.1.6
   ---------------------------------------
   Local workspace plugins:
         @myorg/angular-design-system
         @myorg/react-design-system

Failure Logs

√  nx run angular-app:lint  [existing outputs match the cache, left as is]
    √  nx run angular-app-e2e:lint  [existing outputs match the cache, left as is]                                              

    ×  nx run angular-design-system:lint
       Linting "angular-design-system"...
=============ing target lint for 4 projects

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
    ⠏    nx run angular-design-system:lint
You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.1.0

YOUR TYPESCRIPT VERSION: 5.1.6

Please only submit bug reports when using the officially supported version.

=============

C:\projects\github\LayZeeDK\nx-dependency-checks-executor-dependency-issue\libs\angular-design-system\package.json
  4:3  error  The "angular-design-system" uses the package "jest-preset-angular", but it is missing from the project's "package.json"                @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "@angular-devkit/build-angular", but it is missing from the project's "package.json"      @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "@angular/compiler-cli", but it is missing from the project's "package.json"              @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "@angular/compiler", but it is missing from the project's "package.json"                  @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "rxjs", but it is missing from the project's "package.json"          
                     @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "zone.js", but it is missing from the project's "package.json"       
                     @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "typescript", but it is missing from the project's "package.json"    
                     @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "jest", but it is missing from the project's "package.json"          
                     @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "jest-environment-jsdom", but it is missing from the project's "package.json"             @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "ng-packagr", but it is missing from the project's "package.json"    
                     @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "@angular/platform-browser-dynamic", but it is missing from the project's "package.json"  @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "@angular/platform-browser", but it is missing from the project's "package.json"          @nx/dependency-checks
  4:3  error  The "angular-design-system" uses the package "@angular/animations", but it is missing from the project's "package.json"                @nx/dependency-checks

✖ 13 problems (13 errors, 0 warnings)
  13 errors and 0 warnings potentially fixable with the `--fix` option.

Lint errors found in the listed files.




    ×  nx run react-design-system:lint
       Linting "react-design-system"...
=============ing target lint for 4 projects

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
    ⠹    nx run react-design-system:lint
You may find that it works just fine, or you may not.
    √    2/3 succeeded [2 read from cache]
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.1.0

YOUR TYPESCRIPT VERSION: 5.1.6

Please only submit bug reports when using the officially supported version.

=============

C:\projects\github\LayZeeDK\nx-dependency-checks-executor-dependency-issue\libs\react-design-system\package.json
  12:3  error  The "react-design-system" uses the package "vite", but it is missing from the project's "package.json"           
           @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "@vitejs/plugin-react-swc", but it is missing from the project's "package.json"  @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "vite-tsconfig-paths", but it is missing from the project's "package.json"       @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "vite-plugin-dts", but it is missing from the project's "package.json"
           @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "@types/node", but it is missing from the project's "package.json"    
           @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "less", but it is missing from the project's "package.json"           
           @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "sass", but it is missing from the project's "package.json"           
           @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "stylus", but it is missing from the project's "package.json"         
           @nx/dependency-checks
  12:3  error  The "react-design-system" uses the package "terser", but it is missing from the project's "package.json"         
           @nx/dependency-checks

✖ 9 problems (9 errors, 0 warnings)
  9 errors and 0 warnings potentially fixable with the `--fix` option.

Lint errors found in the listed files.



                                                                                                                                
 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— 
                                                                                                                                
 >  NX   Ran target lint for 4 projects (2s)                                                                                    
                                                                                                                                
    √    2/4 succeeded [2 read from cache]                                                                                      
                                                                                                                                
    ×    2/4 targets failed, including the following:                                                                           
         - nx run angular-design-system:lint
         - nx run react-design-system:lint

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Assign to @meeroslav.

@meeroslav meeroslav self-assigned this Jul 2, 2023
@meeroslav meeroslav added the scope: linter Issues related to Eslint support in Nx label Jul 2, 2023
@LayZeeDK LayZeeDK changed the title linter: @nx/dependency-checks false positives caused by executors linter: @nx/dependency-checks false positives caused by build executors Jul 3, 2023
@meeroslav
Copy link
Contributor

The first project angular-design-system correctly reports missing dependencies:

  • It reports missing jest-preset-angular since this file is used in src/test-setup.ts, but this file is not filtered out in the nx.json. This bit is missing:
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "production": [
      "default",
      "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
      "!{projectRoot}/src/test-setup.ts", // exclude test-setup from prod
      "!{projectRoot}/tsconfig.spec.json",
      "!{projectRoot}/jest.config.[jt]s",
      "!{projectRoot}/.eslintrc.json"
    ],
    "sharedGlobals": []
  },
  • Additionally @angular/core, @angular/common, @angular/router and tslib are not used.
  • The second is a bit tricky, since all the dependencies are found in vite.config.ts which is rightfully part of the production named input, although none of those dependencies participate in the actual output. I need to think about the way we can filter those files.

@meeroslav meeroslav added the scope: core core nx functionality label Jul 3, 2023
@meeroslav meeroslav changed the title linter: @nx/dependency-checks false positives caused by build executors Builder helper files (vite.config.ts etc.) influence the package dependencies on create package json Jul 3, 2023
@github-actions
Copy link

github-actions bot commented Aug 5, 2023

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 Aug 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: core core nx functionality scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants