ESM build evaluates in one ~250 ms long task; the AMD build splits it up

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

Maintainers usually reply within 1 day

@hediet is already working on this.

Since Oct 11, 2026.

Assessment

This issue has not been assessed yet.

Description

Moving from the deprecated AMD build to the ESM build (0.57.0, webpack 5) made our docs site's desktop Total Blocking Time worse. The total JS work is about the same in both builds. The difference is how it's scheduled. min/vs is built as about 10 chunks, and they evaluate in several smaller tasks. A bundled import('monaco-editor') evaluates everything in a single ~220–270 ms task.

Measurements are Lighthouse desktop with observed timing, median of 7, on a page with one editor:

Build TBT
AMD from CDN 221 ms
ESM, import('monaco-editor') ~380 ms
ESM, staged (below) 293 ms

Staging the 0.56 entry points, with a setTimeout yield between each, recovers most of the gap:

await import('monaco-editor/editor');
await yieldToMain();
await import('monaco-editor/features/register.all');
await yieldToMain();
const monaco = await import('monaco-editor');

The largest task left is monaco-editor/editor itself, at about 140 ms. There is no smaller supported entry point that would let us split it further.

Ask:

  • Could the editor core expose finer-grained supported entry points, or register its contributions lazily?
  • Alternatively, could Monaco document (or ship) a staged entry like the one above as the recommended way to load the ESM build without a long task?

Either would let sites drop the AMD build without a main-thread regression.

Dominant language
JavaScript
Stars
47k
Forks
4.2k
Avg merge
3d 13h
Merged PRs (30d)
13

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from microsoft/monaco-editor

All issues in microsoft/monaco-editor

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.