[Feature] Enabling `tide-mode` workflow with TS *monorepo* (React)
david-alvarez-rosa opened this issue · comments
Hi Emacs wizards -- wanted to ask about how can work in a monorepo, were multiple teams have each their own package (repo).
Let pkg-1
, ..., pkg-n
be the packages corresponding to team-1
, ..., team-n
, respectively.
At compile-time, those directories are (symbolically) linked to pkg-main
pkg-main/
.gitignore
tsconfig.json
packages/
pkg-1 -> ../pkg-1
...
pkg-n -> ../pkg-n
pkg-1/
.gitignore
...
pkg-n/
.gitignore
Any tips on how can this be handled by tide-mode
?
--
PS Why not enabling repo sponsorship? I'd be happy to contribute :)
When you open any .ts file, tide walks up the directory till it finds a directory with tsconfig.json file and it will start tsserver with that directory as the project root. https://github.com/ananthakumaran/tide/blob/master/tide.el#L323 You can override the logic by setting the tide-project-root
buffer local variable. I am not sure whether you want tide to work at individual project level or whole repo level. Individual project level is usually straightforward, just need to have a tsconfig.json at the project root directory.
Thanks @ananthakumaran —- unfortunately for me this doesn't really work as expected with projectile
.
What I do is to force tide-project-root
to be the project root and I fill typescript project references in my tsconfig.json. This way I have a single tsserver managing my whole monorepo, works like a charm.
I use pnpm to manage the monorepo and meta-updater to maintain the typescript project references.
The only thing that doesn't work is tide-project-errors are the response from tsserver seems to big to process, but I'm not surprised, it's a really large monorepo.