Files
OmniRoute/src/shared/components/MonacoEditor.tsx
diegosouzapw 1c4d850441 fix(build): import Monaco ESM API to fix webpack nls.messages-loader error
Replace import("monaco-editor") with import("monaco-editor/esm/vs/editor/editor.api")
in MonacoEditor.tsx. The root package entry resolves to the minified bundle
(min/vs/editor/editor.main.js) which requires the monaco-editor-webpack-plugin
loader "vs/nls.messages-loader". The ESM API module has no such dependency and
satisfies loader.config({ monaco }) identically.
2026-05-18 19:40:10 -03:00

24 lines
760 B
TypeScript

"use client";
import dynamic from "next/dynamic";
import type { EditorProps } from "@monaco-editor/react";
// Self-hosted Monaco. Configures @monaco-editor/react to use the bundled
// `monaco-editor` package instead of the default jsdelivr CDN, which is
// blocked by our CSP (script-src 'self'). Keep all Editor imports going
// through this wrapper so the loader is configured exactly once.
const MonacoEditor = dynamic<EditorProps>(
async () => {
const [{ default: Editor, loader }, monaco] = await Promise.all([
import("@monaco-editor/react"),
import("monaco-editor/esm/vs/editor/editor.api"),
]);
loader.config({ monaco });
return Editor;
},
{ ssr: false }
);
export type { EditorProps };
export default MonacoEditor;