nrwl / nx

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

Nx v15 globbing for projects is too wide by default after deprecating workspace.json #12982

Closed zjkipping closed 1 year ago

zjkipping commented 1 year ago

Current Behavior

When running any nx affected or run-many --all command the globbing for projects is too wide on v15+ (which deprecated the workspace.json). It currently pulls in everything that would have been in the workspace.json + any nested angular apps/nx workspaces (with apps/libs) it can find.

Even if you leave the root workspace.json the nx affected seems to ignore it completely, which isn't very backwards compatible. We are hoping to remove this file as well, but will take a little bit to transition.

Expected Behavior

The globbing should only look for the projects in the apps and libs (possibly tools?) directories by default with an override inside the nx.json.

I assume the globbing checks for any sub workspace.json, angular.json, or project.json files anywhere inside the workspace.

Steps to Reproduce

We have a few top level folders that culminate with a template angular application and also a template nx workspace. We use these for easily making adjustments to our own internal systems that run around nx when upgrading nx/angular.

The folder structure would looking something like the below (slightly flattened):

_tools/
  template-workspace/
    apps/
      app-example/
        project.json
      app-example-e2e/
        project.json
    libs/
      lib-example/
        project.json
    tools/
    workspace.json
    package.json
  template-angular/
    angular.json
    package.json
apps/
 ... (large amount of valid apps with project.json files)
libs/
 ... (large amount of valid libs with project.json files)
tools/
workspace.json (deprecated & apparently ignored?)
package.json

With the above setup an nx affected command picks up all the projects in the root apps & libs folder, BUT it also picks up the below in the _tools folder:

If I have some time I will try and reproduce this in a public repo.

Workaround

We currently are adding --exclude=app-example,app-example-e2e,lib-example,template-workspace,template-angular at the end of all of our run-many --all and affected commands. Apparently adding the --exclude completely ignores caching though so this isn't a great solution...

Failure Logs

Nothing fails really other than the nested workspace/projects/angular apps that get picked up. More than likely due to mis-matching versions or anything else since they shouldn't be run in the first place.

Environment

Node : 18.12.0 OS : win32 x64 yarn : 1.22.5

nx : 15.0.7 @nrwl/angular : 15.0.7 @nrwl/cypress : 15.0.7 @nrwl/detox : Not Found @nrwl/devkit : 15.0.7 @nrwl/esbuild : Not Found @nrwl/eslint-plugin-nx : 15.0.7 @nrwl/expo : Not Found @nrwl/express : Not Found @nrwl/jest : 15.0.7 @nrwl/js : 15.0.7 @nrwl/linter : 15.0.7 @nrwl/nest : 15.0.7 @nrwl/next : Not Found @nrwl/node : 15.0.7 @nrwl/nx-cloud : 15.0.2 @nrwl/nx-plugin : Not Found @nrwl/react : Not Found @nrwl/react-native : Not Found @nrwl/rollup : Not Found @nrwl/schematics : Not Found @nrwl/storybook : 15.0.7 @nrwl/web : Not Found @nrwl/webpack : 15.0.7 @nrwl/workspace : 15.0.7 typescript : 4.8.4

Local workspace plugins:

Community plugins: @ngrx/data: 14.3.2 @ngrx/effects: 14.3.2 @ngrx/entity: 14.3.2 @ngrx/router-store: 14.3.2 @ngrx/store: 14.3.2 @ngrx/store-devtools: 14.3.2 @ngrx/schematics: 14.3.2

FrozenPandaz commented 1 year ago

The easier workaround would be to add _tools to your .nxignore file. This will ignore the projects and files in that directory. That should solve your issues.

FYI, the workspace.json in the root of your repo is not ignored. Rather, other projects are also being detected and added to the graph as well.

I added a note in the 15.0.0 release notes: https://github.com/nrwl/nx/releases/tag/15.0.0

Hopefully that solves your issues?

zjkipping commented 1 year ago

@FrozenPandaz Yes, that worked perfectly. Thank you! Didn't realize that existed. Easy to google for once you know the file exists 😄

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