eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
750 stars 68 forks source link

Support the VSCode extension on the web #1487

Open Yokozuna59 opened 6 months ago

Yokozuna59 commented 6 months ago

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.

msujew commented 6 months ago

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.

Yokozuna59 commented 6 months ago

@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?

msujew commented 6 months ago

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.

Yokozuna59 commented 6 months ago

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.

msujew commented 6 months ago

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 commented 6 months ago

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