microsoft / microsoft/monaco-editor

[Bug] Using workers with the deprecated AMD build

Open
#5,111 6 comments 0 reactions 1 assignee View on GitHub

@hediet is already working on this.

Since Nov 13, 2025.

bug editor-core
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

No response

Monaco Editor Playground Code

Reproduction Steps

No response

Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

Let me preface this with I understand that you want to move forward to ESM builds, and I understand deprecation of the AMD build, and I'm thankful that is still included for now. However, I can't just switch to ESM with everything implied by that especially bundler integration into a bigger project etc. without allocating a long and dedicated period of time to do so which is just not possible right now or the near future 🙁 Furthermore, as long as AMD is still included I'd like to at least keep up-to-date especially with regards to the TS version which hasn't been updated for a long while now. So I'd like to ask for some help here. This is for Monaco version 0.54.0 because I want to get at least this sorted out before the even more breaking-changes coming in 0.55.0 regarding language integration.

My integration of the Monaco editor relies on a worker running ESLint, that was built as an AMD module and then loaded using monaco.editor.createWebWorker, and makes use of the mirror models. The changelog states "Custom AMD workers don't work anymore out of the box.". I was able to at least figure out that I can compile the worker code as a normal script, create the Worker myself and then call the method like

const worker = new Worker(window.location.origin + "/worker/eslint-worker.js");
this.webWorker = monaco.editor.createWebWorker<IEsLintWorker>({
	worker,
	// moduleId: window.location.origin + "/worker/eslint-worker",
	// label: this.owner,
	// createData: { config: this.createEsLintCompatibleConfig() } as IWorkerCreateData
});
return this.webWorker.getProxy();

where the commented lines were the API used before. However, I can't figure out what I need to do for plumbing, so that the create function is still called and provides a) the worker context (monaco.worker.IWorkerContext) for the mirror models, and b) the createData. Can I make this work without completely switching to ESM? What code can I consult? The only messages I receive inside the worker are -please-ignore- and $initialize, after which the promise returned by the call to getProxy() never resolves and no further messages arrive. What's the protocol here? Debugging all those tangled event handlers and figuring out what to do when and where when my worker isn't the only one loaded is pretty hard...

Do I really have to resort back to a custom build worker integration without mirror model support? 🙁

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.