eclipse-langium / langium

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

`yo langium` results in `"initialize" is not exported by "node_modules/vscode/extensions.js"` #1315

Closed frademacher closed 5 months ago

frademacher commented 10 months ago

Steps To Reproduce

  1. Install Langium as described at https://langium.org/docs/getting-started (my node version is v20.10.0 and my npm version is 10.2.5).
  2. Run yo langium, and use default "Hello World" values for extension name, language name, and file extensions. Also, reply Yes to the questions for VSCode extension, CLI inclusion, and web worker inclusion.

The current behavior

During the execution of yo langium, and more precisely at the following step

> hello-world@0.0.1 build:bundle
> vite --config ./vite.bundle.config.ts build

vite v4.4.12 building for production...

I run into the following error:

"initialize" is not exported by "node_modules/vscode/extensions.js", imported by "node_modules/monaco-languageclient/lib/monaco-vscode-api-services.js".
file: /home/florian/Downloads/hello-world/node_modules/monaco-languageclient/lib/monaco-vscode-api-services.js:6:9
4:  * ------------------------------------------------------------------------------------------ */
5: import { ILogService, initialize, StandaloneServices } from 'vscode/services';
6: import { initialize as initializeVscodeExtensions } from 'vscode/extensions';
            ^
7: import getLanguagesServiceOverride from '@codingame/monaco-vscode-languages-service-override';
8: import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override';
...
An error occured while running langium:app#install
Error langium 

Command failed with exit code 1: npm run build:web

Unfortunately, I'm not very familiar with Node.js but could find the following oddities (at least they seem odd to me):

Could it be that yo langium should generate a dependency on vscode-languageclient ~8.1.0 rather than vscode-languageclient ~9.0.1 to be compatible with monaco-languageclient ~6.6.0; or, alternatively, have generated projects depend on (the upcoming?) monaco-languageclient ~7.2.0 in case vscode-languageclient ~9.0.1 is required?

If you could use the generated hello-world Langium project please let me know. However, as stated above, I just invoke yo langium following https://langium.org/docs/getting-started to run into the above error (this behavior is repeatable).

As a side note: When executing npm list langium in the generated hello-world folder I get the following response:

hello-world@0.0.1
├─┬ langium-cli@2.1.0
│ ├─┬ langium-railroad@2.1.0
│ │ └── langium@2.1.3 deduped
│ └── langium@2.1.3 deduped
└── langium@2.1.3

The expected behavior

Behave as described at https://langium.org/docs/getting-started after the successful execution of yo langium.

msujew commented 10 months ago

Note that this is only relevant for developers answering the web worker question with yes. We cannot downgrade the vscode-languageserver dependency, as Langium depends on that itself.

msujew commented 10 months ago

cc @kaisalmen Any idea why this appears in the first place?

kaisalmen commented 10 months ago

@msujew was just writing something. 🙂 @frademacher the template needs to be adjusted. I simply forgot that. A PR will come very soon. v7 of monaco-languageclient uses the newer vscode-languageclient as well.

And we need to prevent that incompatible version of @codingame/monaco-vscode-api are installed. Its versions are coupled to vscode versioning and therefore patch versions are not what they seem to be. We should change that, too. I will open an issue there as well.

frademacher commented 10 months ago

Thanks a lot for your prompt responses and technical clarifications @msujew @kaisalmen. I can confirm that the issue is not existent when responding with No to yo langium's question for web worker inclusion (as pointed out by Mark in https://github.com/eclipse-langium/langium/issues/1315#issuecomment-1845776962). For my current endeavors, this workaround is perfectly fine, thanks :-)

hyphappy011 commented 9 months ago

changed package.json config with "monaco-editor-wrapper": "~3.5.0", can work fine.

tobiashochguertel commented 9 months ago

Do we have a workaround for this issue? I don't get it so far.

medihack commented 8 months ago

As a new Langium user, I also stumbled across this problem. I am especially interested in the web worker integration. I already used Monaco with Chevrotain in a web worker before, but have some hopes that Langium could make some things easier. Is a fix planned for the web worker integration, or is it dependent on some 3rd party package that the Langium project doesn't have any influence on?

kaisalmen commented 8 months ago

Hi @medihack this has been fixed with #1317 but there was not official release after 2.1.3. v3 got delayed a bit.

As a workaround you can apply the changes from the PR locally. Only the template adjustments are required. And then run the generator. A new official release should become available before the end of January.

kaisalmen commented 8 months ago

Hi @tobiashochguertel sorry I missed your question. The workaround sketched above ⬆️ should get it going.

msujew commented 5 months ago

This has been fixed with the 3.0 release.