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 does not honor package.json based workspace settings for projects #29739

Open
1 of 4 tasks
techfg opened this issue Jan 24, 2025 · 0 comments
Open
1 of 4 tasks

nx does not honor package.json based workspace settings for projects #29739

techfg opened this issue Jan 24, 2025 · 0 comments

Comments

@techfg
Copy link

techfg commented Jan 24, 2025

Current Behavior

Using the workspace based approach to identify nx projects, nx does not seem to be properly identifying projects based on items in the workspaces property of package.json.

Given a file system of the below, the following issues arise:

Image

Scenario 1 - Basic project

  "workspaces": [
    "packages/*",
    "packages/ui/*"
  ]

Image

Actual Behavior - Works as expected, all 4 projects are properly identified

Scenario 2 - Adjusted workspaces to only include root level folders inside of packages directory

  "workspaces": [
    "packages/*"
  ]

Image

Actual Behavior: @nx-workspaces-not-honored/uilib1 and @nx-workspaces-not-honored/uilib2 are listed in projects with their fully qualified names

Scenario 3 - Added @nx/eslint to packagelib2

  "workspaces": [
    "packages/*"
  ]

Image

Actual Behavior: @nx-workspaces-not-honored/packagelib1fake is listed as a project in addition to @nx-workspaces-not-honored/uilib1 and @nx-workspaces-not-honored/uilib2 all with their fully qualified names.

Scenario 4 - Explicitly exclude workspace folders

  "workspaces": [
    "packages/*",
    "!packages/packagelib1/src/packagelib1fake",
    "!packages/ui/**"
  ]

Image

Actual Behavior: @nx-workspaces-not-honored/packagelib1fake is listed as a project in addition to @nx-workspaces-not-honored/uilib1 and @nx-workspaces-not-honored/uilib2 all with their fully qualified names.

Expected Behavior

  • Scenario 1 - Works as expected
  • Scenario 2 - Only packagelib1 and packagelib2 should be listed as projects
  • Scenario 3 - Only packagelib1 and packagelib2 should be listed as projects
  • Scenario 4 - Only packagelib1 and packagelib2 should be listed as projects

GitHub Repo

https://github.com/techfg/nx-workspaces-not-honored-repro

Steps to Reproduce

Scenario 1

git clone https://github.com/techfg/nx-workspaces-not-honored-repro.git
git checkout main
npm install
npx nx show projects

Scenario 2

git clone https://github.com/techfg/nx-workspaces-not-honored-repro.git
git checkout packages-root-only
npm install
npx nx show projects

Scenario 3

git clone https://github.com/techfg/nx-workspaces-not-honored-repro.git
git checkout add-eslint
npm install
npx nx show projects

Scenario 4

git clone https://github.com/techfg/nx-workspaces-not-honored-repro.git
git checkout explicit-exclude
npm install
npx nx show projects

Nx Report

Node           : 20.11.1
OS             : linux-x64
Native Target  : x86_64-linux
npm            : 10.5.0

nx                 : 20.3.3
@nx/js             : 20.3.3
@nx/eslint         : 20.3.3
@nx/workspace      : 20.3.3
@nx/devkit         : 20.3.3
@nx/eslint-plugin  : 20.3.3
typescript         : 5.6.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/eslint/plugin

Failure Logs

N/A

Package Manager Version

No response

Operating System

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

Additional Information

  1. This seems similar/same as Nx does not ignore package.json based on workspace settings #22348
  2. This seems to be two different issues since it requires eslint to trigger Scenario 3. If it's preferred that I create a separate issue for that one, just let me know, happy to do so.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants