langium
langium copied to clipboard
`yo langium` results in `"initialize" is not exported by "node_modules/vscode/extensions.js"`
Steps To Reproduce
- 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).
- 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
> [email protected] 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):
- The
package.jsonin the generatedhello-worldfolder states that the generated Langium project depends onvscode-languageclient ~9.0.1andmonaco-languageclient ~6.6.0. monaco-languageclient ~6.6.0seems to however depend onvscode-languageclient ~8.1.0.monaco-languageclient ~7.2.0seems to plan to get rid of the erroneous import of theinitializefunction fromvscode/extensions(possibly becausevscode-languageclient ~9.0.1doesn't provide it anymore or elsewhere).
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:
[email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
└── [email protected]
The expected behavior
Behave as described at https://langium.org/docs/getting-started after the successful execution of yo langium.
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.
cc @kaisalmen Any idea why this appears in the first place?
@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.
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 :-)
changed package.json config with "monaco-editor-wrapper": "~3.5.0", can work fine.
Do we have a workaround for this issue? I don't get it so far.
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?
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.
Hi @tobiashochguertel sorry I missed your question. The workaround sketched above ⬆️ should get it going.
This has been fixed with the 3.0 release.