yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Cannot load as ESM because it tries to use require

Open arobinson opened this issue 9 months ago • 5 comments

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 avatar Jan 29 '25 19:01 arobinson