vdesjs / vite-plugin-monaco-editor

A vite plugin for the Monaco Editor
MIT License
206 stars 36 forks source link

More sophisticated handling of custom language plugins #41

Open caghand opened 1 year ago

caghand commented 1 year ago

The existing customWorkers functionality is great. However, it does not cover more advanced cases, where a custom language handler must be "initialized" before its worker can be used. monaco-editor-webpack-plugin has an undocumented feature called customLanguages, which makes it possible to inject a language initializer into monaco-editor, in addition to the worker registration. For example, monaco-yaml needs to be registered like this: https://github.com/remcohaszing/monaco-yaml#using-monaco-webpack-loader-plugin Please note the entry: 'monaco-yaml' property there. It will inject this code snippet into monaco-editor: https://github.com/remcohaszing/monaco-yaml/blob/main/src/index.ts If this is not done, then getWorkerUrl() never gets called for "yaml", so yaml.worker never gets loaded. Is it possible to extend vite-plugin-monaco-editor to support this functionality?