nrwl / nx

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

Yarn workspaces are not respected in project graph #22176

Closed kasperpeulen closed 2 months ago

kasperpeulen commented 8 months ago

Current Behavior

I have set up this workspace syntax in a yarn berry project:

  "workspaces": {
    "packages": [
      "addons/*",
      "frameworks/*",
      "lib/*",
      "deprecated/*",
      "builders/*",
      "ui/*",
      "presets/*",
      "renderers/*"
    ]
  },

This is recognized correctly by yarn

❯ yarn workspaces list
➤ YN0000: .
➤ YN0000: addons/a11y
➤ YN0000: addons/actions
➤ YN0000: addons/backgrounds
➤ YN0000: addons/controls
➤ YN0000: addons/docs
➤ YN0000: addons/essentials
➤ YN0000: addons/gfm
➤ YN0000: addons/highlight
➤ YN0000: addons/interactions
➤ YN0000: addons/jest
➤ YN0000: addons/links
➤ YN0000: addons/measure
➤ YN0000: addons/onboarding
➤ YN0000: addons/outline
➤ YN0000: addons/storysource
➤ YN0000: addons/themes
➤ YN0000: addons/toolbars
➤ YN0000: addons/viewport
➤ YN0000: builders/builder-manager
➤ YN0000: builders/builder-vite
➤ YN0000: builders/builder-webpack5
➤ YN0000: frameworks/angular
➤ YN0000: frameworks/ember
➤ YN0000: frameworks/html-vite
➤ YN0000: frameworks/html-webpack5
➤ YN0000: frameworks/nextjs
➤ YN0000: frameworks/preact-vite
➤ YN0000: frameworks/preact-webpack5
➤ YN0000: frameworks/react-vite
➤ YN0000: frameworks/react-webpack5
➤ YN0000: frameworks/server-webpack5
➤ YN0000: frameworks/svelte-vite
➤ YN0000: frameworks/svelte-webpack5
➤ YN0000: frameworks/sveltekit
➤ YN0000: frameworks/vue3-vite
➤ YN0000: frameworks/vue3-webpack5
➤ YN0000: frameworks/web-components-vite
➤ YN0000: frameworks/web-components-webpack5
➤ YN0000: lib/channels
➤ YN0000: lib/cli
➤ YN0000: lib/cli-sb
➤ YN0000: lib/cli-storybook
➤ YN0000: lib/client-logger
➤ YN0000: lib/codemod
➤ YN0000: lib/core-common
➤ YN0000: lib/core-events
➤ YN0000: lib/core-server
➤ YN0000: lib/core-webpack
➤ YN0000: lib/csf-plugin
➤ YN0000: lib/csf-tools
➤ YN0000: lib/docs-tools
➤ YN0000: lib/instrumenter
➤ YN0000: lib/manager-api
➤ YN0000: lib/node-logger
➤ YN0000: lib/preview
➤ YN0000: lib/preview-api
➤ YN0000: lib/react-dom-shim
➤ YN0000: lib/router
➤ YN0000: lib/source-loader
➤ YN0000: lib/telemetry
➤ YN0000: lib/test
➤ YN0000: lib/theming
➤ YN0000: lib/types
➤ YN0000: presets/create-react-app
➤ YN0000: presets/html-webpack
➤ YN0000: presets/preact-webpack
➤ YN0000: presets/react-webpack
➤ YN0000: presets/server-webpack
➤ YN0000: presets/svelte-webpack
➤ YN0000: presets/vue3-webpack
➤ YN0000: renderers/html
➤ YN0000: renderers/preact
➤ YN0000: renderers/react
➤ YN0000: renderers/server
➤ YN0000: renderers/svelte
➤ YN0000: renderers/vue3
➤ YN0000: renderers/web-components
➤ YN0000: ui/blocks
➤ YN0000: ui/components
➤ YN0000: ui/manager
➤ YN0000: Done in 0s 2ms

However nx also finds projects, which are test fixtures:

❯ nx show projects --type lib
test-fixture
multiple-lockfiles
pnpm-workspace
web-components-webpack5
web-components-vite
preact-webpack5
server-webpack5
svelte-webpack5
builder-webpack5
react-webpack5
builder-manager
html-webpack5
preset-create-react-app
vue3-webpack5
web-components
preact-vite
preset-preact-webpack
preset-server-webpack
preset-svelte-webpack
svelte-vite
builder-vite
preset-react-webpack
react-vite
html-vite
preset-html-webpack
preset-vue3-webpack
sveltekit
vue3-vite
addon-interactions
addon-backgrounds
addon-storysource
angular
react-dom-shim
addon-essentials
addon-onboarding
client-logger
nextjs
source-loader
storybook
addon-highlight
core-webpack
ember
instrumenter
preact
server
svelte
addon-controls
addon-toolbars
addon-viewport
core-common
core-events
core-server
manager-api
node-logger
preview-api
react
addon-actions
addon-measure
addon-outline
csf-plugin
docs-tools
html
vue3
addon-themes
components
csf-tools
telemetry
addon-links
channels
addon-a11y
addon-docs
addon-jest
codemod
preview
theming
addon-mdx-gfm
manager
router
sb
blocks
types
test
cli
scripts
root
image

I can add fixtures to .nxignore, but this would cause caching issues for test. If I change a fixture, the test cache should be invalidated.

Expected Behavior

In a yarn project:

nx show projects = yarn workspaces list + extra project.json directories

GitHub Repo

No response

Steps to Reproduce

  1. Create a yarn berry nx monorepo.
  2. Add a test fixture with a package.json in one of the projects.
  3. See that is part of the nx graph.

Nx Report

NX   Report complete - copy this into the issue template

Node   : 18.18.0
OS     : darwin-arm64
yarn   : 4.1.1

nx (global)    : 18.0.6
nx             : 18.0.6
@nx/js         : 18.0.6
@nx/linter     : 18.0.6
@nx/eslint     : 18.0.6
@nx/workspace  : 18.0.6
@nx/devkit     : 18.0.6
@nrwl/tao      : 18.0.6
@nx/vite       : 18.0.6
typescript     : 5.3.3
---------------------------------------
Community plugins:
@storybook/angular : 8.0.0-rc.0
---------------------------------------
Local workspace plugins:
         @storybook/angular


### Failure Logs

_No response_

### Package Manager Version

_No response_

### Operating System

- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)

### Additional Information

_No response_
FrozenPandaz commented 3 months ago

I suspect this has been resolved now. Could you see if the issue has been resolved in the latest versions of Nx please?

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because no results of retrying on the latest version of Nx was provided within 7 days. It will be closed in 21 days if no results are provided. If the issue is still present, please reply to keep it active. If the issue was not present, please close this issue. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 1 month 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.