yaml-language-server
yaml-language-server copied to clipboard
Cannot load as ESM because it tries to use require
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)
Any idea on what I'm doing wrong? Has anyone managed to get this working with Angular 19?