language-tools
language-tools copied to clipboard
Allow esm URL imports
Description
I'm working on getting svelte working with deno/vite and I have a fully working demo, and typescript works near perfectly, except for URL imports. Since URL imports are an esm standard and work in the browser already, the LSP should have support for this.
Proposed solution
A deno-lsp-like way of caching and using imports through URLs
Alternatives
Somehow plugging in the deno LSP instead of the typescript LSP into svelte
Additional Information, eg. Screenshots
demo of URL imports working:https://github.com/Suyashtnt/svelte-deno-ssr-demo/
What exactly is it that you mean by "support"? The error diagnostics ("cannot find module..") going away? This working at runtime? In other words, is this an editor feature request or Svelte feature request?
What exactly is it that you mean by "support"? The error diagnostics ("cannot find module..") going away? This working at runtime? In other words, is this an editor feature request or Svelte feature request?
The ability to have types from URL imports and cannot find module
to go away
Is TypeScript able to handle this somehow? Is there some Deno TS plugin that enables support for this? Trying to find out how this works in regular .ts
files
Hi @dummdidumm, Bartek from the Deno here. AFAIK TypeScript itself doesn't have support for this - we have a custom plugin (https://github.com/denoland/vscode_deno/tree/main/typescript-deno-plugin), but it doesn't seem to handle logic for resolution, from my understanding all requests are sent to Deno's LSP that does the resolution. That said, we have some plugins for eg. ESBuild that implement this logic, so it shouldn't be a hard lift from our side to provide an npm package that provides this resolution. We also have deno_cache
which provides the same logic as Deno binary in terms of obtaining and caching of these sources. I'm sure we could provide an npm version for it as well.
I'll try having a crack at it, inspired by the work in esbuild_deno_loader, which I've used in a small Deno + Svelte project.
I think the place to look is https://github.com/sveltejs/language-tools/blob/master/packages/language-server/src/plugins/typescript/module-loader.ts