fix(ui): bundle Monaco workers into production build - #6627
Open
ajuijas wants to merge 1 commit into
Open
Conversation
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.
What
Fixes the
Could not create web worker(s)... You must define MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorkererror in the production Docker image, where the CEL editor falls back to synchronous mode because no Monaco worker files exist anywhere in the image.Fixes #6580
Why
Two things were missing in production:
scripts/build-monaco-workers-turbopack.js(which bundles the workers intopublic/monaco-workers/) was only wired into thedevscript, so production builds never emitted the worker files —docker/Dockerfile.uicopiespublic/into the image, but the directory was never populated.MonacoCel.tsx) never setMonacoEnvironment, so even with workers present Monaco wouldn't know where to load them from. (The dev/turbopack variants already handle this.)How
package.json:buildnow runsnpm run build-monaco-workers && ./next_build.sh, mirroring the existingdevscript.MonacoCel.tsx: setsself.MonacoEnvironment.getWorkerUrlto the pre-built/monaco-workers/{json,yaml,editor}.worker.jsfiles, matching the exact filenames the build script emits (webpack entries{editor,json,yaml}.workerwithfilename: "[name].js").This is the same approach the issue thread converged on.
How it was tested
npm run build-monaco-workerslocally: webpack compiled successfully and emittededitor.worker.js,json.worker.js,yaml.worker.jsintokeep-ui/public/monaco-workers/— confirming thegetWorkerUrlpaths match the real output filenames.npm run build/ Docker image build was not run locally. The wiring mirrors the existingdevscript, andDockerfile.uialready copiespublic/into the runner stage, but I'd appreciate a maintainer sanity-check of the production image.