val-town / codemirror-ts

lint, hover, and autocomplete extensions for CodeMirror + TypeScript
https://val-town.github.io/codemirror-ts/
ISC License
145 stars 12 forks source link

Feature: Support Async Loading Extension? #38

Closed xianshenglu closed 1 week ago

xianshenglu commented 2 weeks ago

Problems:

When I'm trying to integrate this library I found the typescript is huge around 2.9mb.

And codemirror@6 doesn't support add extensions async.

Feature:

So, I'm wondering if we can support loading async or not.

Proposal:

For example,

tsFacet.of({ env, path }),

If the env is Promise<env> in that case, we can do nothing until env is loaded.

What do you think?

tmcw commented 1 week ago

I would consider this, though I think there are two pretty viable ways around it that are potentially better:

xianshenglu commented 1 week ago

@tmcw Really thanks for the reminder. I found StateEffect.appendConfig from your link which can solve my use case like below

function injectExtension(view, extension) {
  view.dispatch({
    effects: StateEffect.appendConfig.of(extension)
  })
}
xianshenglu commented 1 week ago

For sure the worker version is a nicer way. I tried that in my angular project. It seems that there're some issues to make it work. More likely package issue.

If possible I'll try to raise the issues regarding worker in angular.