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

vitest generator adds duplicate ^build to test target default dependsOn #30288

Open
1 of 4 tasks
cogwirrel opened this issue Mar 6, 2025 · 0 comments · May be fixed by #30289
Open
1 of 4 tasks

vitest generator adds duplicate ^build to test target default dependsOn #30288

cogwirrel opened this issue Mar 6, 2025 · 0 comments · May be fixed by #30289

Comments

@cogwirrel
Copy link
Contributor

Current Behavior

When adding multiple typescript libraries with vitest, the generator keeps appending to dependsOn in the test target default, eg:

"targetDefaults": {
  ...
  "test": {
    "dependsOn": [
      "^build",
      "^build",
      "^build",
      "^build",
      "^build"
    ]
  },
}

This doesn't cause any issues, but it'd be nice not to keep appending the redundant entry :)

Expected Behavior

No duplicate dependency added.

GitHub Repo

No response

Steps to Reproduce

  1. Create a workspace (pnpm dlx create-nx-workspace)
  2. Generate a ts library with vitest as the unitTestRunner (pnpm exec nx generate @nx/js:library --directory=lib1 --unitTestRunner=vitest --no-interactive)
  3. Generate another (pnpm exec nx generate @nx/js:library --directory=lib2 --unitTestRunner=vitest --no-interactive)
  4. Observe duplicate entry in nx.json

Nx Report

$ pnpm nx report

 NX   Report complete - copy this into the issue template

Node           : 20.18.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.4.1

nx             : 20.4.6
@nx/js         : 20.4.6
@nx/workspace  : 20.4.6
@nx/devkit     : 20.4.6
@nx/vite       : 20.4.6
@nx/web        : 20.4.6
typescript     : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/vite/plugin

Failure Logs

Package Manager Version

pnpm 10.4.1

Operating System

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

Additional Information

No response

cogwirrel added a commit to cogwirrel/nx that referenced this issue Mar 6, 2025
Every time the vitest generator was run a new duplicate '^build' dependency was added to the
target defaults for the test task. Updated to ensure it is specified only once.

Fixes nrwl#30288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant