From 0660f588d7e4056ae3240ee9635abb43e061c66e Mon Sep 17 00:00:00 2001 From: Lera24 Date: Wed, 3 Jan 2024 15:12:29 +0200 Subject: [PATCH 1/2] fix: error in codeEditor component --- src/app/components/utils/code-editor.vue | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/app/components/utils/code-editor.vue b/src/app/components/utils/code-editor.vue index 31afda3e8..77ba47343 100644 --- a/src/app/components/utils/code-editor.vue +++ b/src/app/components/utils/code-editor.vue @@ -27,7 +27,29 @@ import { editor, languages } from 'monaco-editor'; import { markRaw } from 'vue'; import { mapState } from 'vuex'; +import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' +import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' +import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker' +import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker' +import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker' +self.MonacoEnvironment = { + getWorker(_, label) { + if (label === 'json') { + return new jsonWorker() + } + if (label === 'css' || label === 'scss' || label === 'less') { + return new cssWorker() + } + if (label === 'html' || label === 'handlebars' || label === 'razor') { + return new htmlWorker() + } + if (label === 'typescript' || label === 'javascript') { + return new tsWorker() + } + return new editorWorker() + } +} // https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditorconstructionoptions.html const defaultSizeConfig = { From 9b273c163eb3302e2c18778d78f0ac38057f14dc Mon Sep 17 00:00:00 2001 From: Lera24 Date: Wed, 3 Jan 2024 15:18:15 +0200 Subject: [PATCH 2/2] feature: add comment --- src/app/components/utils/code-editor.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/components/utils/code-editor.vue b/src/app/components/utils/code-editor.vue index 77ba47343..89a34cde0 100644 --- a/src/app/components/utils/code-editor.vue +++ b/src/app/components/utils/code-editor.vue @@ -27,11 +27,14 @@ import { editor, languages } from 'monaco-editor'; import { markRaw } from 'vue'; import { mapState } from 'vuex'; -import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' -import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' -import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker' -import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker' -import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker' +import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'; +import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'; +import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'; +import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'; +import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'; + +// Fix error: Unexpected usage at fd.loadForeignModule +// https://github.com/vitejs/vite/discussions/1791 self.MonacoEnvironment = { getWorker(_, label) {