Skip to content

Conversation

@rebeccaalpert
Copy link
Member

@rebeccaalpert rebeccaalpert commented Oct 29, 2025

The @patternfly/react-code-editor library uses a CDN to load some Monaco stuff by default. This doesn't work for all consumers. Adjusting so we can do without the CDN.

Found this in the docs for @patternfly/react-code-editor:

To use monaco-editor as an npm package and avoid using CDN
The @monaco-editor/react package is built on the monaco-editor package, which will fetch some additional files using CDN by default. To avoid this, include monaco-editor as a dependency and insert the following into your code:

import * as monaco from 'monaco-editor';
import { loader } from '@monaco-editor/react';

loader.config({ monaco });
This may require the additonal webpack plugins such as monaco-editor-webpack-plugin. To properly install the library monaco-editor-webpack-plugin be sure to follow the plugin instructions

Doing this seems to get us off the CDN network calls, but I'm seeing some grumpy console warnings from Monaco:

hook.js:608 Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq
overrideMethod @ hook.js:608
hook.js:608 You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker

The editor does seem to work though? I don't see a webpack config we can plug into either.

You can see an example of Monaco usage here: https://chatbot-pr-chatbot-743.surge.sh/patternfly-ai/chatbot/messages/#editable-attachments

@patternfly-build
Copy link

patternfly-build commented Oct 29, 2025

The @patternfly/react-code-editor library uses a CDN to load some Monaco stuff by default. This doesn't work for all consumers. Adjusting so we can do without the CDN.
Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be how it's supposed to be set up, and I'm not seeing the warning on the surge (though it could be getting obfuscated by two minified react errors that are in the console). I'm not 100% though, it may just needs some testing to make sure the code editor is still functioning and not freezing.

@karthikjeeyar
Copy link
Contributor

With this PR changes, I can now see the monaco-editor is loading from node_modules instead of cdn, this should fix our issue. Thanks @rebeccaalpert for fixing this issue!

image

@rebeccaalpert
Copy link
Member Author

Awesome! Thanks @karthikjeeyar.

@rebeccaalpert rebeccaalpert marked this pull request as ready for review October 30, 2025 13:23
@rebeccaalpert rebeccaalpert merged commit 7b6db94 into patternfly:main Oct 31, 2025
7 checks passed
@github-actions
Copy link

🎉 This PR is included in version 6.5.0-prerelease.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

react-code-editor uses cdn to load monaco-editor by default which is not allowed in RHDH

5 participants