Comments (1)
This is not a big deal to run it through esm.sh
import * as Monaco from 'https://esm.sh/[email protected]?bundle';
import EditorWorker from 'https://esm.sh/[email protected]/esm/vs/editor/editor.worker?worker';
import JsonWorker from 'https://esm.sh/[email protected]/esm/vs/language/json/json.worker?worker';
import CssWorker from 'https://esm.sh/[email protected]/esm/vs/language/css/css.worker?worker';
import HtmlWorker from 'https://esm.sh/[email protected]/esm/vs/language/html/html.worker?worker';
import TSWorker from 'https://esm.sh/[email protected]/esm/vs/language/typescript/ts.worker?worker';
async function loadCSS() {
const css = await fetch(`https://esm.sh/[email protected]?css`).then(response => response.text());
const style = document.createElement('style');
style.id = 'monaco-css';
style.innerHTML = css;
document.getElementById('monaco-css')?.remove();
document.head.appendChild(style);
}
self.monaco = monaco;
self.MonacoEnvironment = {
getWorker(_, label) {
if (label === 'json') {
return new JsonWorker();
}
if (label === 'css' || label === 'scss' || label === 'less') {
return new CssWorker();
}
if (label === 'html') {
return new HtmlWorker();
}
if (label === 'typescript' || label === 'javascript') {
return TSWorker();
}
return new EditorWorker();
}
};
loadCSS();
monaco.editor.create(document.getElementById("container"), {
value: `function x() {\n\tconsole.log("Hello world!");\n}`,
language: "javascript",
});
But yes, it's really strange that Microsoft recommends using that silly require loader instead of ESM.
from monaco-editor.
Related Issues (20)
- [Bug] Error: The parameters in nameBuiltin from elixir.js are globally replaced, causing compilation errors. HOT 1
- [Feature Request] monaco-esbuild-plugin
- [Bug] Vite5+electron+monaco, load ts worker exception: Editor.vue:34 Uncaught TypeError: require2 is not a function HOT 1
- Add Touch Selection Support to Monaco Editor HOT 1
- [Bug] Create two editors on the same page, set different themes, and the themes are overwritten
- NVDA screen reader is announcing unnecessary information as "press ALT + F1 key to expand accessibility option" but nothing is happening when we hit these keys:A11y_MonacoEditor_Screenreader
- [Bug] Cannot find JS module imported from TS file (2307)
- [Bug] - Viewport scrolling doesn't keep in perfect sync when Monaco editor has a small fixed height
- [Bug] Position sticky effect does not get honored for scrollbar backgrounds
- [mobx] There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`
- [Bug] css error
- [Bug] `Error`: cpp: an 'include' attribute must be a string at: tokenizer.root
- [Bug] Getting not iterable error, when key press HOT 1
- [Bug] `CompletionItem.range` has a default but is marked as required in the typings
- [Bug] ThirdPartyNotices.txt licensing error for Web Background Synchronization
- [Bug] Adding backtick to close open string adds two backticks instead of one
- [Bug] set 'diffEditor.insertedTextBackground': '#e1ffdd' and diff text Foreground missed
- [Bug] use side by side mode,delete texts are not high light
- [Bug] Cursor becomes misaligned when using custom font
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monaco-editor.