Closed Hotell closed 3 years ago
I have also experienced this error and finally came up with a solution. The problem origin from how TypeScript and ESLint works together, providing the files to lint.
When creating a new workspace with Nx everything works, since there are limited number of files to lint. As the code base grows this will eventually become a problem.
To support enterprise workspaces I did the following:
Created a new file tsconfig.eslint.json
containing a reference to tsconfig.base.json
and the paths that should support linting. For a default Nx workspace, paths would be apps
and libs
.
{
"extends": "./tsconfig.base.json",
"include": [
"./apps/**/*",
"./libs/**/*"
]
}
Then change parserOptions
in .eslintrc
to point to the new file.
{
...
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.eslint.json"
}
...
}
The lint block in angular.json
should also look something like this.
{
...
"lint": {
"builder": "@nrwl/linter:lint",
"options": {
"linter": "eslint",
"tsConfig": [
"libs/shared/ui/loading-message/tsconfig.lib.json",
"libs/shared/ui/loading-message/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**",
"!libs/shared/ui/loading-message/**/*"
]
}
...
}
Now everything should work as expected. Hopefully it will help someone else struggling getting it to work.
Nx version 10.0.12
.
Angular CLI: 10.0.6
Node: 12.17.0
OS: darwin x64
Angular: 10.0.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1000.5
@angular-devkit/build-angular 0.1000.6
@angular-devkit/build-optimizer 0.1000.6
@angular-devkit/build-webpack 0.1000.6
@angular-devkit/core 10.0.6
@angular-devkit/schematics 10.0.6
@angular/cdk 10.1.3
@angular/cli 10.0.6
@angular/flex-layout 10.0.0-beta.32
@angular/material 10.1.3
@angular/material-moment-adapter 10.1.3
@ngtools/webpack 10.0.6
@schematics/angular 10.0.6
@schematics/update 0.1000.6
rxjs 6.6.2
typescript 3.9.7
webpack 4.43.0
Kudos to this issue that got me on track by explaining the problem in more detail.
This situation should be greatly helped by the new builder coming in https://github.com/nrwl/nx/pull/3763
FYI this OOM error is mainly caused by nx error boundaries rule rather than current linter builder implementation.
that didn't help much. I upgraded to @nrwl/*: 11.0.2
and I'm still experiencing the same issue, although my project is significantly smaller than the project the OP is describing. It only has ~350 files in total, but the linting always crashes on my e2e module with ~40 TS files in it and like 5 JSON files.
As I mentioned, what is slowing things down by huge amount is implementation of nx module boundaries eslint plugin. Try to turn that rule off @kamiljano βοΈ. There were no changes in the implementation in v11.
Regarding new eslint builder, while the implementation is better than the old builder, there are no real perf improvements ( we migrated 180 projects nx workspace ).
As a workaround we increased the memory limit: export NODE_OPTIONS=--max_old_space_size=8000
But after enabling additional checks we still ran into OOM issues.
Now we changed our scripts in package.json
:
"lint:nx-workspace": "./node_modules/.bin/nx workspace-lint",
"lint:nx": "./node_modules/.bin/nx run-many --all --target=lint",
"lint": "run-s lint:nx-workspace lint:nx",
AFAIK, run-many will start a separate node-process to lint each project (--all
)
Now the execution is slower, but it seems to work.
I have also experienced this error and finally came up with a solution. The problem origin from how TypeScript and ESLint works together, providing the files to lint.
When creating a new workspace with Nx everything works, since there are limited number of files to lint. As the code base grows this will eventually become a problem.
Suggested fix
To support enterprise workspaces I did the following:
Created a new file
tsconfig.eslint.json
containing a reference totsconfig.base.json
and the paths that should support linting. For a default Nx workspace, paths would beapps
andlibs
.{ "extends": "./tsconfig.base.json", "include": [ "./apps/**/*", "./libs/**/*" ] }
Then change
parserOptions
in.eslintrc
to point to the new file.{ ... "parserOptions": { "ecmaVersion": 2020, "sourceType": "module", "project": "./tsconfig.eslint.json" } ... }
The lint block in
angular.json
should also look something like this.{ ... "lint": { "builder": "@nrwl/linter:lint", "options": { "linter": "eslint", "tsConfig": [ "libs/shared/ui/loading-message/tsconfig.lib.json", "libs/shared/ui/loading-message/tsconfig.spec.json" ], "exclude": [ "**/node_modules/**", "!libs/shared/ui/loading-message/**/*" ] } ... }
Now everything should work as expected. Hopefully it will help someone else struggling getting it to work.
Context
Nx version
10.0.12
.Angular CLI: 10.0.6 Node: 12.17.0 OS: darwin x64 Angular: 10.0.9 ... animations, common, compiler, compiler-cli, core, forms ... platform-browser, platform-browser-dynamic, platform-server ... router, service-worker Ivy Workspace: Yes Package Version ------------------------------------------------------------ @angular-devkit/architect 0.1000.5 @angular-devkit/build-angular 0.1000.6 @angular-devkit/build-optimizer 0.1000.6 @angular-devkit/build-webpack 0.1000.6 @angular-devkit/core 10.0.6 @angular-devkit/schematics 10.0.6 @angular/cdk 10.1.3 @angular/cli 10.0.6 @angular/flex-layout 10.0.0-beta.32 @angular/material 10.1.3 @angular/material-moment-adapter 10.1.3 @ngtools/webpack 10.0.6 @schematics/angular 10.0.6 @schematics/update 0.1000.6 rxjs 6.6.2 typescript 3.9.7 webpack 4.43.0
Finally
Kudos to this issue that got me on track by explaining the problem in more detail.
Since I upgraded to Nx 11 I'm no longer using my own workaround. tsconfig.eslint.json
is removed and the setup is as suggested by the Nrwl team.
This might not help you guys still struggling but since I suggested a workaround I just want to let you know my status. Still though, performance hasn't improved.
I am going to close this one for now, the tooling and configuration has changed quite a bit since this was originally opened, and it is no longer a good foundation for clear discussion on any current issues because of that.
If you encounter performance issues with your ESLint setup in the latest version of Nx, please have a read of: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#my-linting-feels-really-slow
This will give you a better understanding of the moving pieces involved in using TypeScript and ESLint together. If, on top of that, Nx is causing issues/has bugs we can work on those on a case by case basis.
If that last point applies to you, please open a fresh issue with as much information about your setup as possible: versions of packages, configuration files, folder structures etc. Naturally the best possible submissions include links to repos which reproduce the issues.
Thanks all π
Please do not +1 or "me too" performance issue reports - we need to be able investigate specific setups
@JamesHenry the link you posted lead to a 404 page, can you provide an updated link?
@daton89 sorry, we transitioned from github docs to a full website: https://typescript-eslint.io/docs/linting/troubleshooting#my-linting-feels-really-slow
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.
Expected Behavior
lint should work consistently no matter if executed via linter builder or directly via eslint cli
Current Behavior
with following workspace configuration
yarn nx run pb-legacy:lint-broken
throw error because of out of memoryfew debug logs from builder:
yarn nx run pb-legacy:lint
properly lints codebaseContext