ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
822 stars 71 forks source link

optim(watch): don't reset `DocumentRegistry` b/t watch cycles #388

Closed agilgur5 closed 2 years ago

agilgur5 commented 2 years ago

Summary

Keep the DocumentRegistry b/t watch cycles instead of resetting it

Details

Potential Further Optimizations

  1. DocumentRegistry can actually be shared between multiple LSes for #177. Per the TS LS Wiki, sharing DocumentRegistry is actually recommended, as, minimally, lib.d.ts could be shared between projects.
    • But to do that we'd probably have to expose an option for it and users would have to opt-in. On second thought, this might not even be useful for #177 since those are separate processes that don't share variables 😕
      • Thinking about it one step further... we could actually create the DocumentRegistry as a top-level var, before the plugin is instantiated... that would make DocumentRegistry shared between all imports of rpt2... but it would still be limited to only the same Node process... so guess that's probably not useful either in this case 😕
        • And the top-level instantiation could be a bit hacky since tsModule isn't set till plugin instantiation (as visible in this PR, where the DocumentRegistry is only instantiated after tsModule is set)...
      • Leaving it as is here, as a result then
  2. It's possible we can avoid recreating the LS itself between watch cycles. That would be optimal. I believe we'd be able to do that if the parsedConfig hasn't changed between watch cycles, which is probably the most common usage of watch anyway, i.e. changing source files and not config