microsoft / microsoft/monaco-editor
[Bug] [Vite] Worker error when call 'setCompilerOptions()'
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Very minimal reproduction repository: https://github.com/wirekang/vite-monaco-reproduce
Monaco Editor Playground Code
No response
Reproduction Steps
- Run
npm run buildornpm run dev - Open
index.htmlin browser
Actual (Problematic) Behavior
Worker not loaded with error:
tsMode-GQNSSG2P.js?v=9237fbed:383 Uncaught (in promise) Error: Could not find source file: 'inmemory://model/1'.
at getValidSourceFile (ts.worker.js?type=module&worker_file:112883:23)
at Object.getSyntacticDiagnostics (ts.worker.js?type=module&worker_file:113110:46)
at TypeScriptWorker.getSyntacticDiagnostics (ts.worker.js?type=module&worker_file:171181:47)
at EditorSimpleWorker.fmr (editorSimpleWorker.js?v=9237fbed:501:64)
at SimpleWorkerServer._handleMessage (simpleWorker.js?v=9237fbed:358:65)
at Object.handleMessage (simpleWorker.js?v=9237fbed:343:51)
at SimpleWorkerProtocol._handleRequestMessage (simpleWorker.js?v=9237fbed:149:38)
at SimpleWorkerProtocol._handleMessage (simpleWorker.js?v=9237fbed:118:29)
at SimpleWorkerProtocol.handleMessage (simpleWorker.js?v=9237fbed:111:14)
Expected Behavior
No response
Additional Context
monaco: 0.45.0
vite: 5.0.8
If you comment out the setCompilerOptions(), tsWorker works well.
Since the reproduction is very simple, I thought I forgot something, but I can't find out what did I wrong.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproduction repository and run npm run build or npm run dev, then open index.html in a browser. Compare the behavior with and without setCompilerOptions() and inspect the TypeScript worker error for the missing inmemory://model/1 source file. Done means the worker loads and operates with setCompilerOptions() enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript, vite
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100