fix: monaco-editor offline

This commit is contained in:
tao.chen
2026-08-20 19:23:42 +08:00
parent ae3b6d63e2
commit e4d010ec76
3 changed files with 13 additions and 4 deletions
+5
View File
@@ -9,6 +9,11 @@ import {
import type { Route } from "./+types/root"; import type { Route } from "./+types/root";
import { AuthProvider } from "./context/AuthContext"; import { AuthProvider } from "./context/AuthContext";
// Monaco 离线加载配置:必须在任何 <Editor> 挂载前执行,否则 loader 会默认
// 从 jsDelivr CDN 拉取 monaco,离线环境下编辑器初始化失败、永远 loading。
// `.client` 后缀:该模块只进客户端 bundle,SPA 构建的 server 预渲染阶段
// 会被替换成空桩,避免 monaco-editor ESM(依赖浏览器全局)在 Node 里崩掉。
import "./lib/monacoSetup.client";
import "./app.css"; import "./app.css";
export const links: Route.LinksFunction = () => []; export const links: Route.LinksFunction = () => [];
+1
View File
@@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@monaco-editor/react": "^4.7.0", "@monaco-editor/react": "^4.7.0",
"monaco-editor": "^0.56.0",
"@react-router/node": "^8", "@react-router/node": "^8",
"@react-router/serve": "^8", "@react-router/serve": "^8",
"isbot": "^5.1.36", "isbot": "^5.1.36",
+7 -4
View File
@@ -20,6 +20,9 @@ importers:
isbot: isbot:
specifier: ^5.1.36 specifier: ^5.1.36
version: 5.2.1 version: 5.2.1
monaco-editor:
specifier: ^0.56.0
version: 0.56.0
react: react:
specifier: ^19.2.7 specifier: ^19.2.7
version: 19.2.8 version: 19.2.8
@@ -47,7 +50,7 @@ importers:
version: 19.2.17 version: 19.2.17
'@types/react-dom': '@types/react-dom':
specifier: ^19.2.3 specifier: ^19.2.3
version: 19.2.3(@types/react@19.2.17) version: 19.2.4(@types/react@19.2.17)
tailwindcss: tailwindcss:
specifier: ^4.2.2 specifier: ^4.2.2
version: 4.3.3 version: 4.3.3
@@ -504,8 +507,8 @@ packages:
'@types/node@22.20.1': '@types/node@22.20.1':
resolution: {integrity: sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==} resolution: {integrity: sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==}
'@types/react-dom@19.2.3': '@types/react-dom@19.2.4':
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==} resolution: {integrity: sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==}
peerDependencies: peerDependencies:
'@types/react': ^19.2.0 '@types/react': ^19.2.0
@@ -1738,7 +1741,7 @@ snapshots:
dependencies: dependencies:
undici-types: 6.21.0 undici-types: 6.21.0
'@types/react-dom@19.2.3(@types/react@19.2.17)': '@types/react-dom@19.2.4(@types/react@19.2.17)':
dependencies: dependencies:
'@types/react': 19.2.17 '@types/react': 19.2.17