Bundle Monaco through the Angular build (ESM) - #5651
Merged
norman-abramovitz merged 2 commits intoJul 18, 2026
Conversation
Monaco previously loaded through its own AMD loader from a wholesale copy of the vs/ distribution in assets — unversioned URLs that can never be served immutable (the cache-policy blocker cloudfoundry#5561 records), a serialized loader -> editor.main.js -> css load sequence, and a peer-dependency conflict: @cfstratos/monaco-yaml 2.5.0 pins monaco ^0.20 while the repo ships 0.52, breaking plain npm install. The editor is now a hashed lazy chunk (673 kB wire vs 966 kB over three unversioned requests), loaded by dynamic import on first use; the copied asset tree is gone. Language workers are bundled from relative new Worker(new URL(...)) references via one-line wrapper modules (the builder does not resolve bare specifiers there) — only the languages Stratos edits get one (json, yaml; every editor surface is json/yaml/plaintext), everything else falls back to the basic editor worker. The codicon font needs an explicit .ttf loader entry, and the dynamic import uses the concrete esm file path because the package publishes only a module field, which vitest's resolver rejects as a bare specifier (typed by a local ambient declaration). @cfstratos/monaco-yaml is replaced by upstream monaco-yaml 5.5.1 (peers >=0.36): registered once by the loader, schemas applied through its update() handle via configureYaml() — same global last-writer semantics as the old yamlDefaults surface. The chart values editor drops its AMD contribution load (init now completes without window.require, which no longer exists) and surfaces schema registration failures instead of losing them as unhandled rejections. Stale AMD-era mocks and the completed-migration guide are removed; follow-on candidate: a tree-shaken feature subset via editor.api instead of full editor.main.
Monaco had no e2e coverage at all — nothing would have caught a broken loader path. The smoke drives the variable edit dialog on a real app: the editor must render from the lazily imported chunk, a typed keystroke must round-trip, and an invalid yaml model must produce diagnostics from the monaco-yaml worker (polling that model's own markers — the global marker event fires for any model and races unrelated traffic).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5561.
What changes
Monaco previously loaded through its own AMD loader from a wholesale copy of the
vs/distribution in assets: unversioned URLs that can never be servedcache-control: immutable(one of the two cache-policy blockers the issue records), a serialized loader → editor.main.js → css sequence, and a peer conflict —@cfstratos/monaco-yaml2.5.0 pins monaco ^0.20 while the repo ships 0.52, which breaks plainnpm install.vs/asset tree is retired. Initial bundle is unchanged — Monaco stays off the critical path (perf(core): lazy-load monaco, right-size assets; add load diagnostics #5560's lazy-load behavior preserved).new Worker(new URL(...))references via one-line wrapper modules (the builder doesn't resolve bare package specifiers there). Only the languages Stratos actually edits get a worker — json and yaml; every editor surface in the repo is json/yaml/plaintext (verified by census of allapp-monaco-editorusages andcreateModel/setModelLanguagecall sites). Other labels fall back to the basic editor worker: syntax highlighting is main-thread and unaffected, workers only add validation/completion.@cfstratos/monaco-yaml→ upstreammonaco-yaml5.5.1 (peersmonaco-editor >= 0.36, actively maintained). Registered once by the ESM loader; schema registration goes through aconfigureYaml()helper wrapping the v5update()handle — same global last-writer semantics as the oldyamlDefaultssurface. The Helm chart-values editor drops its AMD contribution load and now surfaces schema-registration failures instead of losing them as unhandled rejections..ttffile-loader entry inangular.json, and the dynamic import uses the concreteesm/vs/editor/editor.main.jspath because the package publishes only amodulefield — esbuild accepts the bare specifier but vitest's vite resolver does not (typed by a small local ambient declaration).Verification
window.require— exactly the k8s surface the CF-side smoke doesn't reach.Follow-on candidate (noted, not done here): import a tree-shaken feature subset via
editor.apiinstead of fulleditor.mainto shrink the editor chunk further.Net −231 lines.