Integrating Langium WebWorker to Angular #1096
-
Hello, I'm seeking assistance with integrating a Languium web worker into an Angular application. I have followed the documentation provided at https://langium.org/tutorials/langium_and_monaco/ to create a web worker and successfully integrated my own grammar. The application works flawlessly when launched on an Express server. Now, I'm facing challenges when trying to transfer the web worker to my Angular application. Defining the web worker in the same way as in Express did not work, as Angular seems to modify the provided JavaScript file, leading to an exception: var _asyncToGenerator = require("<path_to_project>/node_modules/@babel/runtime/helpers/asyncToGenerator").default; In an attempt to find a solution, I referred to the official Angular documentation at https://angular.io/guide/web-worker#adding-a-web-worker. However, I am unsure about how and where to define the MonacoEditorLanguageClientWrapper to be launched with the web worker. If anyone has experience with integrating a Languium web worker into an Angular application, I would greatly appreciate your help or any suggestions on how to proceed. Thank you in advance for your assistance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hey @Franz-Ritter, We have an example for an integration of @kaisalmen Any further recommendations? |
Beta Was this translation helpful? Give feedback.
-
Update in case someone has similar issues: So far, the Client and the communication with the web worker was not the problem. But thanks for the suggestions. I had trouble to launch the web worker itself in Angular. Based on the Documentation here I was able to create a javascript file which supports my grammar. Anyway, once I tried to launch the web worker with a relative path to the script in an Angular component, angular seemed to compile the web worker javascript again and tried to attach some babel features for await operations in the script:
This resolved in an error I was able to solve that Problem by putting the web worker file in the assets folder of the project and reference to it absolute to the project:
I still get small issues, such as |
Beta Was this translation helpful? Give feedback.
Update in case someone has similar issues:
So far, the Client and the communication with the web worker was not the problem. But thanks for the suggestions. I had trouble to launch the web worker itself in Angular.
Based on the Documentation here I was able to create a javascript file which supports my grammar. Anyway, once I tried to launch the web worker with a relative path to the script in an Angular component, angular seemed to compile the web worker javascript again and tried to attach some babel features for await operations in the script:
var _asyncToGenerator = require("<path_to_project>/node_modules/@babel/runtime/helpers/asyncToGenerator").default;
This resolved in an error
ang…