[Bug] `createWebWorker` is broken in minimal distributions
Reproducible in vscode.dev or in VS Code Desktop?
- [x] Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- [x] Not reproducible in the monaco editor playground
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
Reproduction Steps
Create a minimal distribution of Monaco Editor (following e.g. https://github.com/microsoft/monaco-editor/tree/main/samples/browser-esm-webpack-small).
Specifically, don't import "monaco", but just import "monaco-editor/esm/vs/editor/editor.api.js" and any features you wish to support.
Actual (Problematic) Behavior
Calling monaco.editor.createWebWorker({ moduleId: "..." }) doesn't work any more due to https://github.com/microsoft/vscode/pull/244117 and https://github.com/microsoft/monaco-editor/pull/4950.
This breaks monaco-yaml: https://github.com/remcohaszing/monaco-yaml/issues/272.
import "monaco" replaces the createWebWorker function with a wrapper that converts the old IWebWorkerOptions to the new IInternalWebWorkerOptions.
However, it's not possible to import this wrapper function without importing the entirety of Monaco Editor because it is bundled into monaco-editor/esm/vs/editor/editor.main.js.
Expected Behavior
It's possible to only import the parts of Monaco Editor that you need and still have a working monaco.editor.createWebWorker function.
Additional Context
No response
Hi — I was looking at this to see if a small monaco-editor-side change would help.
As I understand it, vscode editor.createWebWorker now correctly requires IInternalWebWorkerOptions.worker (vscode PR 244117), and the old moduleId/createData helper already lives in this repo as src/internal/common/workers.ts (used by the JSON/HTML/CSS/TS worker managers). That helper is just not re-exported from the tree-shakeable entries, so an editor.api.js import still sees only the core function. That also matches what broke monaco-yaml issue 272.
I would not change vscode or overlay editor.api.js. If it would be welcome, I can send a monaco-editor PR that:
- Re-exports
createWebWorker/IWebWorkerOptionsfrommonaco-editor/editorand the package root (the 0.56 tree-shake path from PR 5155), and - Dual-dispatches
editor.createWebWorkeron those same monaco-owned modules (workerin opts goes to core, else the existing wrapper).
That would keep editor.api.js as monaco-editor-core. Apps on the supported monaco-editor/editor import would get a working helper without pulling editor.main.js.
I saw issue 5148 (and draft PR 5156) as the longer-term worker direction — happy to stand down if you would rather not restore this compatibility. Thank you for any guidance.