typescript-plugin-css-modules icon indicating copy to clipboard operation
typescript-plugin-css-modules copied to clipboard

VSCode Intellisense with version 5 is very slow

Open francesco-caveglia-deltatre opened this issue 2 years ago • 7 comments

VSCode Intellisense with version 5 is very slow

typescrpt@5 and typescript-plugin-css-modules@5: ~50'' typescrpt@4 and typescript-plugin-css-modules@4: ~2''

same issue 👀

"typescript": "^4.9.5", "typescript-plugin-css-modules": "^5.0.0"

itibbers avatar Apr 03 '23 06:04 itibbers

Hi there,

I've been digging into this today. With the move to TypeScript 5.x, the previous methods we used were deprecated (at least, we could no longer extend them).

As a result, we now need to provide a fresh script snapshot every time TypeScript requests one. As CSS modules often rely on imports, and we're using different renderers (Less, Sass, etc), caching becomes more complicated.

I think a quick fix here would be to add some kind of caching. I'm thinking:

  1. Make it opt-in.
  2. Use a short, time-based cache. Maybe 2-5 seconds.

Do you (@francescocaveglia or @itibbers) have an example project you could share, or something you could simply create with dummy data?

mrmckeb avatar Apr 10 '23 09:04 mrmckeb

same issue

"typescript": "^4.9.5", "typescript-plugin-css-modules": "^5.0.1"

vaakian avatar Apr 17 '23 08:04 vaakian

In my project it takes a couple of seconds for every completion (we use scss, but it shouldn't matter). This means things like console. completions just don't work.

Here's a repro with lots of dummy css modules: https://github.com/nulladdict/typescript-plugin-css-modules-repro-215

Unfortunate thing is that it affects every single completion even if the entire module graph was reused (in logs updateGraphWorker says structureChanged: false structureIsReused:: Completely while still taking a couple of seconds to complete)

I don't think short time-based caching would solve the issue, instead it would make completions periodically take long time, which is still not usable. Ideally we would need to update the cache only if files known to TS change.

I'm not sure if it's possible, but we can also try to skip snapshotting if we're autocompleting something unrelated to css module.

nulladdict avatar Jun 09 '23 12:06 nulladdict

I've labelled this with "help wanted" and it's open for contribution, but haven't found time to dig into this yet sorry.

mrmckeb avatar Sep 22 '23 05:09 mrmckeb

Any progress on this, guys?

ezze avatar Oct 12 '23 11:10 ezze