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

+9 -16
View File
@@ -8,7 +8,6 @@ import compat from 'core-js-compat';
import { EsbuildPlugin } from 'esbuild-loader';
import { DuplicatesPlugin } from 'inspectpack/plugin';
import ExtractCssPlugin from 'mini-css-extract-plugin';
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
import packageJson from 'package-json';
import { gt } from 'semver';
import webpack from 'webpack';
@@ -18,6 +17,8 @@ import WebpackBar from 'webpackbar';
import { version } from '../../package.json';
import root from '../utils/root';
const monacoPath = join(dirname(require.resolve('monaco-editor/editor.js')), '..', '..');
const {
list,
targets,
@@ -134,6 +135,10 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
extensions: ['.js', '.jsx', '.ts', '.tsx', '.cjs'],
alias: {
vj: root(),
'monaco-editor/esm/vs/editor/browser/editorExtensions': join(monacoPath, 'esm/vs/editor/browser/editorExtensions.js'),
'monaco-editor/esm/vs/editor/editor.worker.js': join(monacoPath, 'esm/vs/editor/editor.worker.js'),
'monaco-editor/esm/vs/platform/quickinput/common/quickInput': join(monacoPath, 'esm/vs/platform/quickinput/common/quickInput.js'),
'monaco-editor/esm/vs/base/browser/markdownRenderer': join(monacoPath, 'esm/vs/base/browser/markdownRenderer.js'),
'react/jsx-runtime': require.resolve('react/jsx-runtime'),
react: require.resolve('react'),
'react-dom/client': require.resolve('react-dom/client'),
@@ -282,7 +287,7 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
jQuery: 'jquery',
'window.jQuery': 'jquery',
React: 'react',
monaco: 'monaco-editor/esm/vs/editor/editor.api',
monaco: 'monaco-editor/editor',
}),
new ExtractCssPlugin({
filename: `[name]-${version}.css?[fullhash:6]`,
@@ -313,24 +318,12 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
new webpack.DefinePlugin({
'process.env.VERSION': JSON.stringify(require('@hydrooj/ui-default/package.json').version),
}),
new webpack.optimize.MinChunkSizePlugin({
minChunkSize: 128000,
}),
// MinChunkSizePlugin merges worker chunks into the main chunk and breaks
// the runtime id module (webpack#15416), do not re-enable it
new webpack.NormalModuleReplacementPlugin(/\/(vscode-)?nls\.js/, require.resolve('../../components/monaco/nls')),
new webpack.NormalModuleReplacementPlugin(/^prettier[$/]/, root('../../modules/nop.ts')),
new webpack.NormalModuleReplacementPlugin(/^highlightjs[$/]/, root('../../modules/nop.ts')),
new webpack.NormalModuleReplacementPlugin(/core-js\/stable/, root('__core-js.js')),
new MonacoWebpackPlugin({
filename: '[name].[hash:6].worker.js',
customLanguages: [{
label: 'yaml',
entry: require.resolve('monaco-yaml/index.js'),
worker: {
id: 'vs/language/yaml/yamlWorker',
entry: require.resolve('monaco-yaml/yaml.worker.js'),
},
}],
}),
...env.measure ? [
new BundleAnalyzerPlugin({ analyzerPort: 'auto' }),
new DuplicatesPlugin(),