Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load as ESM because it tries to use require #1014

Open
arobinson opened this issue Jan 29, 2025 · 1 comment
Open

Cannot load as ESM because it tries to use require #1014

arobinson opened this issue Jan 29, 2025 · 1 comment

Comments

@arobinson
Copy link

Summary

I cannot load the yaml-language-server in Angular 19 in a worker (serving using ng serve which uses Vite). No matter if I import it myself or if I try to use the monaco-yaml library, the same thing happens. Somehow the UMD code is being loaded, not the ESM code, as a result I get the error:

Uncaught Error: Dynamic require of "jsonc-parser" is not supported

Relevant information

I've tried both:

import { getLanguageService } from 'yaml-language-server/lib/esm/languageservice/yamlLanguageService';

and

import { getLanguageService } from 'yaml-language-server';

As you can see in the screen shot, the UMD library is being loaded, not the ESM library as expected (see the cb in the upper right's path, it is coming from umd)

Image

Any idea on what I'm doing wrong?
Has anyone managed to get this working with Angular 19?

@arobinson
Copy link
Author

Is there a way to force the vscode-json-languageservice to be loaded from ESM not from UMD in an ESM environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant