Nx: Nx dep-graph does not exclude projects from the generated graph

Created on 19 Sep 2019  路  6Comments  路  Source: nrwl/nx

Expected Behavior

Running nx dep-graph --exclude=my-project would remove my-project and it's dependencies from the generated graph

Current Behavior

Running nx dep-graph --exclude=my-project generates the graph but keeps my-project and it's dependencies in the generated graph

Context

Versions:

@nrwl/angular - 8.5.0

Edit:

I tried using this functionality as per the dep-graph API at https://nx.dev/web/api/workspace/npmscripts/dep-graph#exclude

community enhancement

Most helpful comment

I agree with JVHeerden. This functionality can help in larger projects where the graph is currently very unclear:

image

I think this feature can be useful during library optimization

All 6 comments

At the moment, we do not support the functionality to exclude nodes from the dep-graph it only shows you the full graph. The fact that it shows up in documentation is a mistake.

Do you believe this would be useful? What was your motivation behind using excludes with dep-graph?

I think someone from the community could look into a fix. It would be in our yargs configuration: https://github.com/nrwl/nx/blob/master/packages/workspace/src/command-line/nx-commands.ts

Do you believe this would be useful? What was your motivation behind using excludes with dep-graph?

I do believe it would. We currently use an Nx-powered mono-repo with over 50 feature modules and even more shared modules. A lot of the projects are being shared between all of the feature modules in the repo (a cdk, for instance).

The generated dependency graph gets very convoluted if all the feature projects have dependencies linked to the shared projects.

Excluding the projects that we know are shared would enable us to properly visualise the other dependencies.

Just an idea of the amount of dependencies a single one of our shared projects have in the workspace:
image

I agree with JVHeerden. This functionality can help in larger projects where the graph is currently very unclear:

image

I think this feature can be useful during library optimization

I think it's a useful feature. But I would extend it to a more full-featured query language.

For instance, I think it might be useful to do something like this:

nx dep-graph --filter=todos-feature-main #maybe filter isnt' the best name for the flag

Show the graph where every node is either an ancestor or a descendant of todos-feature-main.

In this case if you want to see what your library affects, you can do:

nx dep-graph --filter=my-shared-library

And if you want to see what your application depends on, you can run:

nx dep-graph --filter=myapp

I think it can be used in combination with exclude, something like:

nx dep-grpah --filter=myapp,theirapp --exclude=shared-utils

What do you think?

Do you want to try to submit PR implementing it? I'm happy to point you to the right place where they change has to be made.

@vsavkin this would be perfect. Links up perfectly to https://github.com/nrwl/nx/issues/1841 . Would love to give it a shot.

Cannot wait to see this feature rollout

Was this page helpful?
0 / 5 - 0 ratings