ui: monaco: upgrade to 0.57, drop monaco-editor-webpack-plugin

- Migrate entry points to the 0.57 exports scheme (monaco-editor/editor,
  languages/features/typescript/register)
- Wire workers via the official MonacoEnvironment.getWorker +
  new Worker(new URL(...)) integration; webpack emits them as shared-chunk
  classic workers (chrome 70 compatible), total assets -21%
- Keep css/html/json language features (register.all) and route their
  worker labels; json is used by the cmeditor textareas
- Replace removed esm/vs/nls.messages with an inline implementation in the
  nls shim
- Drop MinChunkSizePlugin: it merged worker chunks into the main chunk and
  broke the runtime id module (webpack#15416)
- Remove monaco-editor-webpack-plugin dependency
- loadMonaco() now returns the loaded feature module exports, e.g.
  loadMonaco(['typescript']).typescript.javascriptDefaults
This commit is contained in:
undefined committed 2026-10-09 16:26:44 +00:00
1 parent 80638bf9ab
commit 489b2dbeec
11 files changed
+103 -42

No files matched your search

+28 -1
View File
@@ -1,8 +1,11 @@
import './monaco.styl';
import 'monaco-editor/features/register.all.js';
import 'monaco-editor/languages/definitions/register.all.js';
import 'monaco-editor/languages/features/register.all.js';
import $ from 'jquery';
import * as monaco from 'monaco-editor/editor';
import { EditorAction, registerEditorAction } from 'monaco-editor/esm/vs/editor/browser/editorExtensions';
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import { IQuickInputService } from 'monaco-editor/esm/vs/platform/quickinput/common/quickInput';
import list from 'monaco-themes/themes/themelist.json';
import { nanoid } from 'nanoid';
@@ -10,6 +13,30 @@ import { i18n, request } from 'vj/utils';
export { renderMarkdown } from 'monaco-editor/esm/vs/base/browser/markdownRenderer';
self.MonacoEnvironment = {
getWorker(workerId: string, label: string): Worker {
if (label === 'editorWorkerService') {
return new Worker(new URL('monaco-editor/editor/editor.worker.js', import.meta.url), { type: 'module' });
}
if (label === 'yaml') {
return new Worker(new URL('monaco-yaml/yaml.worker.js', import.meta.url), { type: 'module' });
}
if (label === 'typescript' || label === 'javascript') {
return new Worker(new URL('monaco-editor/languages/features/typescript/ts.worker.js', import.meta.url), { type: 'module' });
}
if (['css', 'scss', 'less'].includes(label)) {
return new Worker(new URL('monaco-editor/languages/features/css/css.worker.js', import.meta.url), { type: 'module' });
}
if (['html', 'handlebars', 'razor'].includes(label)) {
return new Worker(new URL('monaco-editor/languages/features/html/html.worker.js', import.meta.url), { type: 'module' });
}
if (label === 'json') {
return new Worker(new URL('monaco-editor/languages/features/json/json.worker.js', import.meta.url), { type: 'module' });
}
throw new Error(`Unknown monaco worker label: ${label}`);
},
} as monaco.Environment;
export default monaco;
export const customOptions: monaco.editor.IStandaloneDiffEditorConstructionOptions = JSON.parse(localStorage.getItem('editor.config') || '{}');
export function saveCustomOptions() {