Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
best ts eslint setup for large monorepo?#8506
-
Our monorepo is quite massive, and I wanted to share some statistics from the tsc to give you an idea of the scale:
|
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 7 replies
-
Context: in my day job work on a repo with >90k TS files. At that scale it's unfortunately a physical impossibility to use the ESLint CLI out-of-the-box.
You can make it all work - however you will need to build out some infra based on your company's setup. For example you can build a layer on top of ESLint that runs each "package" in its own thread to isolate it and its memory from one another. At Canva we don't use type-aware linting from the CLI because our repo doesn't have a nice "package" structure that would lend itself to clean isolation across threads. Instead we lint our files by roughly partitioning files across We do have some type-aware lint rules turned on via a custom TypeScript Language Server Plugin whose code is forked fromthis project. But we don't enforce type-aware rules at CI/CLI lint time. |
BetaWas this translation helpful?Give feedback.
All reactions
👀 2
-
Have you also experienced the issue of unresponsiveness in the tsserver and constant loading in the IDE as our TypeScript codebase grows larger? It seems that IntelliSense functionality is also not working most of the time. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes - typescript IDE performance scales horribly with the size of the codebase. In particular it's the size of the dependency graph of the currently opened file(s) that impacts the performance. There's no way around this either because the TS server is single-threaded and it relies on the The best bet is to try and architect your codebase to keep dep graphs shallow where possible. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
-
I can't remember where I saw this, but I saw a tip that the root tsconfig.json should NOT include all files of a monorepo, because it will suffer. It should only include the root TS files you need to lint (if any), and should explicitly exclude any of the packages that will extend the root tsconfig.json. So:
I can confirm this makes a HUGE difference in monorepos, and a lot of monorepo guides will not mention this. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
To clarify, is this aligned withthe TS docs on project structure or suggesting something different? I am personally running into issues along the lines of this discussion so I'm curious what concretely you've found to be beneficial |
BetaWas this translation helpful?Give feedback.
All reactions
-
Another reference on this topic:nx's guide |
BetaWas this translation helpful?Give feedback.