Skip to content

Commit b616d0b

Browse files
committed
Update troubleshooting section in README
1 parent 4e111f8 commit b616d0b

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The examples not requiring a backend are now available [via GitHub Pages](https:
6262
- [Bad Polyfills](#bad-polyfills)
6363
- [buffer](#buffer)
6464
- [monaco-editor and react](#monaco-editor-and-react)
65+
- [webpack worker issues](#webpack-worker-issues)
6566
- [Licenses](#licenses)
6667

6768
## Changelogs, project history and compatibility
@@ -76,7 +77,18 @@ CHANGELOGs for each project are available from the linked location:
7677

7778
Important Project changes and notes about the project's history are found [here](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/versions-and-history.md#important-project-changes).
7879

79-
You find the `monaco-editor`, `vscode`, `@codingame/monaco-vscode-api` and `@codingame/monaco-vscode-editor-api` compatibility table [here](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/versions-and-history.md#monaco-editor--codingamemonaco-vscode-api-compatibility-table).
80+
These are the current versions of packages from this repository and their alignment with **@codingame/monaco-vscode-api** **monaco-editor** and **vscode**:
81+
82+
- **monaco-languageclient**: `9.6.0-next.0` (release date: 2025-04-0x)
83+
- **monaco-editor-wrapper**: `6.7.0-next.0` (release date: 2025-04-0x)
84+
- **@typefox/monaco-editor-react**: `6.7.0-next.0` (release date: 2025-04-0x)
85+
- Aligned with:
86+
- **@codingame/monaco-vscode-[editor]-api**: `15.0.3`
87+
- **vscode**: `1.98.2`
88+
- **monaco-editor**: `0.52.2`
89+
- **vscode-ws-jsonrpc**: `3.4.0` (release date: 2024-12-18)
90+
91+
You find the full compatibility table with all previous versions [here](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/versions-and-history.md#monaco-editor--codingamemonaco-vscode-api-compatibility-table).
8092

8193
[This article](https://www.typefox.io/blog/teaching-the-language-server-protocol-to-microsofts-monaco-editor/) describes the initial motivation for starting monaco-languageclient.
8294

@@ -330,6 +342,50 @@ import { loader } from "@monaco-editor/react";
330342
loader.config({ monaco });
331343
```
332344

345+
### webpack worker issues
346+
347+
When webpackk is used as bundler there are issues with utilizing the undbundled workers from `@codingame/monaco-vscode-api`. [jhk-mjolner](https://github.com/jhk-mjolner) provided a solution in the context of issue #853 [here](https://github.com/TypeFox/monaco-languageclient/issues/853#issuecomment-2709959822):
348+
349+
1. Npm install `webpack-cli` (or webpack will do it for you when you try running this later).
350+
2. Create a `bundle-monaco-workers.js` file with this content:
351+
352+
```js
353+
// solve: __dirname is not defined in ES module scope
354+
import { fileURLToPath } from 'url';
355+
import { dirname, resolve } from 'path';
356+
357+
const __filename = fileURLToPath(import.meta.url);
358+
const __dirname = dirname(__filename);
359+
360+
export default {
361+
entry: {
362+
editor: './node_modules/@codingame/monaco-vscode-editor-api/esm/vs/editor/editor.worker.js',
363+
textmate: './node_modules/@codingame/monaco-vscode-textmate-service-override/worker.js'
364+
},
365+
output: {
366+
filename: '[name].js',
367+
path: resolve(__dirname, './src/assets/monaco-workers'),
368+
// if this is true (default), webpack will produce code trying to access global `document` variable for the textmate worker, which will fail at runtime due to being a worker
369+
chunkLoading: false
370+
},
371+
mode: 'production',
372+
performance: {
373+
hints: false
374+
}
375+
};
376+
```
377+
378+
3. Add this line to your `packages.json` scripts section: `"bundle monaco workers": "webpack --config bundle-monaco-workers.js"`
379+
4. Run the script `npm run 'bundle monaco workers'`
380+
5. Configure the `workerLoaders` parameter for `useWorkerFactory` to point to the pre-bundled workers:
381+
382+
```js
383+
'TextEditorWorker': () => new Worker('/assets/monaco-workers/editor.js', {type: 'module'}),
384+
'TextMateWorker': () => new Worker('/assets/monaco-workers/textmate.js', {type: 'module'}),
385+
```
386+
387+
6. Enable `editor.experimental.asyncTokenization` in the monaco-wrapper config, if you want to use the textmate worker.
388+
333389
## Licenses
334390

335391
- monaco-languageclient: [MIT](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/client/LICENSE)

0 commit comments

Comments
 (0)