From a0dd922fde3897cddc9e44d2de93dd0919c9a723 Mon Sep 17 00:00:00 2001 From: syimyuzya Date: Sun, 8 Sep 2024 13:42:45 +0800 Subject: [PATCH] Fix Monaco worker unable to start Problem due to cross-origin loading of the worker script. The worker script is now bundled as inline data, at the expense of the bundle size, which increased from 8MB to 10MB. PS This is only a quick fix, NOT definitive. There is probably a better way to do it. --- .eslintrc.json | 2 +- src/editor/initialize.ts | 2 +- vite.config.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index fd26c6d..bd64534 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -57,6 +57,6 @@ "alphabetize": { "order": "asc", "caseInsensitive": true } } ], - "import/no-unresolved": ["error", { "ignore": ["\\?(?:worker|raw)$"] }] + "import/no-unresolved": ["error", { "ignore": ["\\?(?:worker(&inline)?|raw)$"] }] } } diff --git a/src/editor/initialize.ts b/src/editor/initialize.ts index 51cf4f7..3a0bf2b 100644 --- a/src/editor/initialize.ts +++ b/src/editor/initialize.ts @@ -1,5 +1,5 @@ import { languages } from "monaco-editor"; -import TSWorker from "monaco-editor/esm/vs/language/typescript/ts.worker.js?worker"; +import TSWorker from "monaco-editor/esm/vs/language/typescript/ts.worker.js?worker&inline"; import { SuggestAdapter } from "monaco-editor/esm/vs/language/typescript/tsMode"; declare global { diff --git a/vite.config.ts b/vite.config.ts index a5c5ef6..d181571 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -22,7 +22,7 @@ export function makeConfig(assetLocation = base) { __APP_VERSION__: JSON.stringify(process.env.npm_package_version), }, build: { - chunkSizeWarningLimit: 8192, + chunkSizeWarningLimit: 10240, outDir: "build", }, experimental: {