'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
getWorkerandgetWorkerUrlfunctions hint that they are interchangeable — are they? Who calls these functions? getWorkerUrluses./ts.worker.bundle.jsfor typescript, whereasgetWorkerusesmonaco-editor/esm/vs/language/typescript/ts.workerurl 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 themonaco-editor/esm/vs/language/typescriptprefix added?- Monaco Yaml
getWorkerfunction source usesmonaco-yaml/yaml.workerurl for the plugin. If urls ingetWorkerUrlare automatically addedmonaco-editor/...prefixes, how can I usegetWorkerUrlfunction with this url? - Options for Monaco Webpack plugin aren't documented, so I'm trying to understand their meaning from types. There's
IFeatureDefinitionwithlabel,entry,workerof typeIWorkerDefinition, which in turn also hasidandstring. How do all of these properties relate to thegetWorkerUrlparameters ofmoduleIdandlabel(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 |
|---|
