Nx: enforce-module-boundaries eslint rule takes ~3min on one file

Created on 11 Jun 2020  ·  2Comments  ·  Source: nrwl/nx

Current Behavior

Linting one small file of a large project (1000+ files) with the enforce-module-boundaries eslint rule on takes about ~3min. Linting that same file with this rule off it takes, <1s.

Expected Behavior

For the plugin to take slightly longer, not magnitudes longer.

Steps to Reproduce

I don't have a small repo where this occurs, because it seems to happen at scale.

The time sink happens on this recursive call: https://github.com/nrwl/nx/blob/master/packages/workspace/src/utils/runtime-lint-utils.ts#L170

Eslint config looks like:

{
    plugins: [
        '@nrwl/eslint-plugin-nx'
    ],
    rules: {
        '@nrwl/nx/enforce-module-boundaries': [
            'error',
            {
              "depConstraints": [
                {
                    "sourceTag": "scope:client",
                    "onlyDependOnLibsWithTags": ["scope:libs"]
                }
              ]
            }
        ]
    }
}

nx.json looks like:

        "my-app": {
            "tags": ["scope:client"]
        },
       "my-lib" : { "tags": ["scope:libs"] }


This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

Running like: time nx lint my-app

Getting:

my-app/index.js
  2:1  error  Circular dependency between "my-app" and "another-app" detected  @nrwl/nx/enforce-module-boundaries
  3:1  error  Circular dependency between "my-app" and "my-app" detected                     @nrwl/nx/enforce-module-boundaries

✖ 2 problems (2 errors, 0 warnings)

Lint errors found in the listed files.

nx lint my-app  192.34s user 10.69s system 112% cpu 3:00.16 total

Environment

>  NX  Report complete - copy this into the issue template

  @nrwl/angular : Not Found
  @nrwl/cli : 9.4.0-rc.8
  @nrwl/cypress : 9.4.0-rc.8
  @nrwl/eslint-plugin-nx : 9.4.0-rc.8
  @nrwl/express : 9.4.0-rc.8
  @nrwl/jest : 9.4.0-rc.8
  @nrwl/linter : 9.4.0-rc.8
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : 9.4.0-rc.8
  @nrwl/react : 9.4.0-rc.8
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.4.0-rc.8
  @nrwl/web : 9.4.0-rc.8
  @nrwl/workspace : 9.4.0-rc.8
  typescript : 3.8.3
community linter stale bug

Most helpful comment

Hm you must have a very deep dependency chain. We should probably memoize that function though.

Would you like to contribute a PR? Someone from the community is also welcome to try.

Do you happen to have a repo exhibiting the issue to verify if a fix really speeds things up?

All 2 comments

Hm you must have a very deep dependency chain. We should probably memoize that function though.

Would you like to contribute a PR? Someone from the community is also welcome to try.

Do you happen to have a repo exhibiting the issue to verify if a fix really speeds things up?

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

Was this page helpful?
0 / 5 - 0 ratings