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 graph and @nx/enforce-module-boundaries break when customizing workspaceLayout.appsDir to src #30541

Open
1 of 4 tasks
denchiklut opened this issue Mar 29, 2025 · 0 comments

Comments

@denchiklut
Copy link

denchiklut commented Mar 29, 2025

Current Behavior

After customizing the workspace layout in nx.json:

"workspaceLayout": {
    "appsDir": "src",
    "libsDir": "libs"
}

With the following monorepo structure:

- src
  └─ web         // tag: scope:fe
- libs
  └─ uikit       // tag: scope:core
- package.json    // name: "my-org"
- nx.json

Running nx graph shows an unexpected extra project, in addition to the correct ones:
✅ Expected:

  • web
  • uikit

❌ Actual:

  • web
  • uikit
  • my-org (name from package.json)

This "ghost" root-level project seems to be inferred automatically, which causes issues downstream.

Side Effect
This behavior also breaks the ESLint @nx/enforce-module-boundaries rule:

'@nx/enforce-module-boundaries': [
  'error',
  {
    allow: ['^.*/eslint(\\.base)?\\.config\\.mjs$'],
    depConstraints: [
      {
        sourceTag: 'scope:*',
        onlyDependOnLibsWithTags: ['scope:core'],
      },
    ],
  },
]

Expected Behavior

  1. nx graph should only show 2 projects:
  • web
  • uikit
  1. nx lint web should pass.

GitHub Repo

https://github.com/denchiklut/nx-demo

Steps to Reproduce

  1. Clone the demo repo: https://github.com/denchiklut/nx-demo
  2. Run the project graph: nx graph ➜ You’ll see an unexpected extra project (named after the root package.json).
  3. Run lint on the web app: nx lint web ➜ This will fail due to a broken @nx/enforce-module-boundaries rule.
  4. Rename the src directory to apps and now both nx graph and nx lint web work as expected.

Nx Report

Node           : 22.13.1
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 1.22.22

nx (global)            : 20.6.4
nx                     : 20.6.4
@nx/js                 : 20.6.4
@nx/jest               : 20.6.4
@nx/eslint             : 20.6.4
@nx/workspace          : 20.6.4
@nx/devkit             : 20.6.4
@nx/eslint-plugin      : 20.6.4
@nx/module-federation  : 20.6.4
@nx/next               : 20.6.4
@nx/node               : 20.6.4
@nx/react              : 20.6.4
@nx/web                : 20.6.4
@nx/webpack            : 20.6.4
typescript             : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin
---------------------------------------
Cache Usage: 932.00 B / 92.64 GB

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

No response

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

1 participant