'How can I use monaco yaml plugin with Monaco Webpack Loader Plugin?

I have ESM version of Monaco set up using the Webpack Loader plugin. I want to add monaco yaml plugin, and I struggle to understand how do I do that. I'm using the Integrating the ESM version of the Monaco Editor guide and Monaco Yam plugin README.

The documentation on yaml plugin says to set up getWorker function in MonacoEnvironment; however, the ESM documentation says to either use Webpack loader, or to set up getWorkerUrl` function, so three different ways to set this up in total.

  • The names of getWorker and getWorkerUrl functions hint that they are interchangeable — are they? Who calls these functions?
  • getWorkerUrl uses ./ts.worker.bundle.js for typescript, whereas getWorker uses monaco-editor/esm/vs/language/typescript/ts.worker url to create typescript worker. These urls seem very similar. Is there 1-to-1 relationship here, and what is it? If there is, where is the monaco-editor/esm/vs/language/typescript prefix added?
  • Monaco Yaml getWorker function source uses monaco-yaml/yaml.worker url for the plugin. If urls in getWorkerUrl are automatically added monaco-editor/... prefixes, how can I use getWorkerUrl function with this url?
  • Options for Monaco Webpack plugin aren't documented, so I'm trying to understand their meaning from types. There's IFeatureDefinition with label, entry, worker of type IWorkerDefinition, which in turn also has id and string. How do all of these properties relate to the getWorkerUrl parameters of moduleId and label (is that the label of a feature or a worker? What's the difference?) and the return value of url?
  • What's the easiest and most reliable way to check if monaco yaml plugin has been successfully loaded by the editor?

Overall, there's no proper information about exact contracts of all this configuration, just simple examples, and a lot of things that seem to be vaguely similar between all the three methods (getWorker, getWorkerUrl and MonacoWebpackPlugin) without any clarifications, so I just feel very confused by it. These questions are my best attempt at structuring all the information available to me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source