fix(dashboard): bundle Monaco editor instead of fetching from CDN - #4247
Conversation
@monaco-editor/react defaults to loading Monaco's AMD bundle from
cdn.jsdelivr.net at runtime, which breaks the editor in air-gapped or
restricted-network self-hosted deployments.
Adds monaco-editor as a direct dependency and configures Vite's native
?worker imports for the editor/json workers plus loader.config({ monaco })
so @monaco-editor/react resolves the bundled instance instead of injecting
a CDN script tag.
Fixes hatchet-dev#3703
|
@koushik717 is attempting to deploy a commit to the Hatchet Team on Vercel. A member of the Team first needs to authorize it. |
…itor types @monaco-editor/react's Monaco type resolves through monaco-editor/esm/vs/editor/editor.api. Before monaco-editor was a real dependency, that import was unresolvable and TS silently treated downstream usages as untyped, masking an implicit-any on this filter callback. Now that monaco-editor is bundled, the real types apply and the implicit-any needs an explicit annotation.
gregfurman
left a comment
There was a problem hiding this comment.
Thanks for the changes here @koushik717! I verified this locally on mac with a sandboxed firefox process without network access and it worked like a charm ✨
Once CI is 🟢 this looks good to ship!
@gregfurman The cypress failure appears to be a pre-existing flaky test it's also failing on unrelated PRs (mk/durable-tasks-as-operator, belanger/operators) at the same time with no overlap with this change. All other 25 CI checks are green. Happy to have someone re-run cypress or merge if the flakiness is known. |
|
Hi @koushik717 - FYI that we needed to revert this change here because it unfortunately broke JSON schema preview / autocomplete in the trigger runs form in production. I think this likely has to do with how assets are served in our production environments, but I didn't dig too deeply. Feel free to put up a re-apply of the PR with a fix if you'd like to investigate, and sorry for the churn here! |
|
@mrkaye97 Thanks for the heads up and sorry for the breakage! The root cause was Vite's |
Fixes #3703
@monaco-editor/reactdefaults to loading Monaco's AMD bundle fromcdn.jsdelivr.netat runtime, which breaks the editor in air-gapped or restricted-network self-hosted deployments.What changed
monaco-editoras a direct dependency.frontend/app/src/lib/monaco-environment.ts, imported once fromcode-editor.tsx, which:MonacoEnvironment.getWorkerusing Vite's native?workerimport for the editor and JSON workers (the only language currently wired up viaconfigureJsonSchema), andloader.config({ monaco })so@monaco-editor/reactresolves the bundled instance instead of injecting a CDN<script>tag.Notes for reviewers
@monaco-editor/loader's default config object, never reached onceloader.config({ monaco })runs. Confirmed via build inspection and network monitoring that this is dead code, not a live network call.monaco-editorpackage auto-registers a few language workers we don't currently use (css/html/ts) alongside json/editor — expected behavior of the package itself, not something this PR controls. Can follow up with trimming if bundle size is a concern.?workersuffix, which needs no extra plugin.Testing
pnpm run typecheck— no new errors (pre-existing failures are unrelated missing-codegen files, confirmed againstmain).vite build—editor.workerandjson.workerare emitted as separate chunks;loader.config({ monaco })runs at build time.jsdelivrandcdn.*) — zero matches. No console errors beyond standard dev-mode noise.AI disclosure (per AI_POLICY.md): I used an AI coding assistant for parts of this change and reviewed/tested everything above myself before opening this PR.