langium icon indicating copy to clipboard operation
langium copied to clipboard

Support the VSCode extension on the web

Open Yokozuna59 opened this issue 1 year ago • 6 comments

The current Langium VSCode extension doesn't work on the web (https://vscode.dev):

IMG_0104

I think it would be nice to have the extension runnable on the web.

I think this could be applied to both langium and langium-generator.


I used langium-sql as a reference to make my extension runnable on both.

Yokozuna59 avatar May 06 '24 10:05 Yokozuna59

I've also thought about this, but didn't have the time yet to look into this. The main issue is that the grammar language features imports which are a bit difficult to deal with in a web extension.

Any contribution for this is appreciated though.

msujew avatar May 06 '24 10:05 msujew

@msujew I think another issue would be the conflict in the generator-langium package between the web and VSCode extension templates. Both of them have common files but are stored in different directories.

Could you share some guidance pointing me in the correct direction so I may be able to work on this?

Yokozuna59 avatar May 07 '24 08:05 Yokozuna59

I don't think that these files should be in conflict. The VSCode web extension only needs 4 things:

  1. A browser entry point in the package.json of the extension
  2. A corresponding JavaScript bundle that is generated from a extension-browser.ts file.
  3. A main-browser.ts file that represents the browser based language server.
  4. A corresponding entry in the bundler script (esbuild.mjs) for the extension-browser.ts and main-browser.ts file.

There is no overlap between these 4 points and the web template AFAIK.

msujew avatar May 07 '24 10:05 msujew

The web template also uses an identical main-browser.ts file. And since the extension template has a separate extension folder, there will be two main-browser.ts, unless we store both of them in src/language.

Yokozuna59 avatar May 07 '24 11:05 Yokozuna59

Ah, right. We can probably solve that using some logic in the generator. We use that to merge the package.json in the end for example. Alternatively, this would be a good reason to start generating a npm workspace from the yeoman generator. But that would be a larger refactoring that might be out of scope for this change.

msujew avatar May 07 '24 11:05 msujew

I've created https://github.com/eclipse-langium/langium/issues/1495 to track the yeoman generator refactoring.

msujew avatar May 14 '24 14:05 msujew