fix(monaco): Ensure monaco loader uses the bundled ESM instance instead of CDN

This commit is contained in:
Slinetrac
2025-12-21 21:08:57 +08:00
parent 2515deefed
commit 45193e017f
2 changed files with 6 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
- 修复 macOS 有线网络 DNS 劫持失败
- 修复 Monaco 编辑器内右键菜单显示异常
- 修复设置代理端口时检查端口占用
- 修复 Monaco 编辑器初始化卡 Loading
<details>
<summary><strong> ✨ 新增功能 </strong></summary>

View File

@@ -1,3 +1,5 @@
import { loader } from "@monaco-editor/react";
import * as monaco from "monaco-editor";
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker";
@@ -5,6 +7,9 @@ import yamlWorker from "monaco-yaml/yaml.worker?worker";
type WorkerConstructor = new () => Worker;
// Ensure monaco loader uses the bundled ESM instance instead of CDN.
loader.config({ monaco });
// Align with the former plugin mapping so Monaco can resolve its background workers.
const workerConstructors: Record<string, WorkerConstructor> = {
editorWorkerService: editorWorker,