phenomnomnominal / betterer

betterer makes it easier to make incremental improvements to your codebase
MIT License
582 stars 39 forks source link

Extension: When working with typescript, use existing `tsserver` or create new one #694

Open abrenneke opened 3 years ago

abrenneke commented 3 years ago

Basically, the idea is instead of spinning up a typescript compiler for every single rule run, there's a single tsserver running in the extension that is reused for all typescript operations, the same way that the internal syntax checking in VS Code works.

In theory this would speed up any typescript operations by a lot, because the tsserver instance could cache everything and use a Watch compiler, but is also means a lot more development work on the betterer extension server side for a single use-case of betterer.

I suppose in theory, running betterer on the command line could spin up a single tsserver for all typescript operations too. We're probably an edge case for having more than one typescript rule in our .betterer file, but I think that would still improve times if the two rules could use the same server.

Just an idea!

phenomnomnominal commented 3 years ago

This would be great, but I have no idea how to make this happen in VS Code. I've explored their docs a bit, but it's unclear if it's even possible!

abrenneke commented 3 years ago

yeah I was looking at the code for svelte-language-server as a reference, looks like it's a whole lot of boilerplate to get a server process being reused.

phenomnomnominal commented 3 years ago

Ooh that could be okay though, the extension is already pretty wild so a bit more doesn't make much difference. Could you point me to the bit in their code that does it?

abrenneke commented 3 years ago

It seems like svelte has its own language server that then wraps tsserver et al.

Looks like

Overall pretty dang complicated

phenomnomnominal commented 3 years ago

Oof. Scary 😅 . Might come back to this on a rainy day!