Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a VS Code web extension entrypoint #1724

Open
TiemenSch opened this issue Sep 7, 2023 · 4 comments
Open

Provide a VS Code web extension entrypoint #1724

TiemenSch opened this issue Sep 7, 2023 · 4 comments

Comments

@TiemenSch
Copy link

Since the VS Code extension already uses WASM compilation of the Rust language server, I believe it should be possible to add a browser entrypoint to the extension. That would mean that users could use it on https://vscode.dev or similar web-based environments.

Their migration instructions are listed here:
https://code.visualstudio.com/api/extension-guides/web-extensions#migrate-extension-with-code

@TiemenSch
Copy link
Author

I'm currently trying this out with a custom language server I'm building with a similar setup and think I'm well underway to figuring it out. Will report back today or tomorrow!

@TiemenSch
Copy link
Author

TiemenSch commented Sep 12, 2023

So I have a proof-of-concept working in my own extension's repo. I'm by no means an esbuild/bundling/extension expert, so I would love to hear any good suggestions/improvements on that front. It works for both the node and browser entrypoint. Some caveats, though:

  • the Worker of each client (webworker) doesn't seem to be cleaned up properly if workspace folders change and clients are stopped and restarted in the browser. This can result in duplication of errors. I had to change the path handling to use VS Code's internal Uri type. This gets rid of the dependencies on the path:node and friends, but might be the culprit. Or the worker should be cached somewhere and properly .terminate()d on client stop.
  • the WASM is encoded inline in both the JS output files for the servers because I don't know how to bundle it as a single static file properly. For small language servers I think this shouldn't be much of a problem, but it's not quite as elegant as having the plain WASM file in your ./out tree.

Any constructive suggestions are highly appreciated :)
https://gitlab.com/ratio-case-os/rust/esl-compiler/-/tree/main/vsx

@wiiznokes
Copy link

Sorry for asking this here, but do you know why their server doesn't use another process instead of js binding?

@TiemenSch
Copy link
Author

There are many different ways to run a language server and connect to it with a client such as VS Code, but this issue goes about rather making it "more JS like" such that it also works fluently in the browser version of VS Code. (like https://vscode.dev). On such web targets, spinning up a process isn't the same thing as on a local desktop environment.

With VS Code being an electron application, it makes sense to keep things in JS land for both desktop and web.

I'm exploring the route of compiling to Rust code to a WASM file and using that on every platform with preferably minimal JS code to glue things together. When properly setup, that should keep the setup simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants