mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
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.
24 lines
760 B
TypeScript
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;
|