question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EditorSimpleWorker.loadForeignModule

See original GitHub issue

same problem at https://github.com/microsoft/monaco-editor/issues/1690#issue-532479802 my code: this.editor = monaco.editor.create(document.getElementById("monaco"), { value: "", language: "javascript", theme:"vs-dark" }); the error meets :

Uncaught Error: Unexpected usage

Error: Unexpected usage at EditorSimpleWorker.loadForeignModule (editorSimpleWorker.js?ccf6:540) at eval (webWorker.js?af50:54) at eval (errors.js?fdcc:12)

when i delete the props language is ok,why?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
realwugangcommented, Aug 13, 2021

resolved

//package.json
"vite": "^2.4.4"
// vite.config.js
import { defineConfig } from 'vite';
const prefix = `monaco-editor/esm/vs`;
export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          jsonWorker: [`${prefix}/language/json/json.worker`],
          cssWorker: [`${prefix}/language/css/css.worker`],
          htmlWorker: [`${prefix}/language/html/html.worker`],
          tsWorker: [`${prefix}/language/typescript/ts.worker`],
          editorWorker: [`${prefix}/editor/editor.worker`],
        },
      },
    },
  },
});
//my editor component file
import 'monaco-editor/esm/vs/basic-languages/css/css.contribution'
import 'monaco-editor/esm/vs/basic-languages/xml/xml.contribution'
import 'monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution'


import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.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'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window.MonacoEnvironment = {
  getWorker (_: string, label: string) {
    if (label === 'typescript' || label === 'javascript') return new TsWorker()
    if (label === 'json') return new JsonWorker()
    if (label === 'css') return new CssWorker()
    if (label === 'html') return new HtmlWorker()
    return new EditorWorker()
  }
}
export default Xxx

https://github.com/vitejs/vite/issues/1927 https://github.com/vitejs/vite/discussions/1791

3reactions
alexdimacommented, May 11, 2021

I’m sorry it doesn’t seem to be working, but with so many requests that we get here and in the VS Code issue tracker, we just cannot provide the support we would like to offer.

That said, if you can track down your issue to a specific problem of the Monaco editor, we are more than welcoming a PR by the community!

I’ll close this issue, but if you have specific follow up questions, we’ll try to help as good as we can given the limited resources that we have.

Thanks for your understanding!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected usage loading foreign module for monaco editor ...
loadForeignModule (editorSimpleWorker.js?ccf6:540) at eval (webWorker.js?af50:54). Here is my vue.config.js file:
Read more >
Unexpected usage at EditorSimpleWorker.loadForeignModule
vue+webpack/vue3+vite使用monaco editor时报错Unexpected usage at EditorSimpleWorker.loadForeignModule解决,react同理.
Read more >
Accessing Monaco from Theia
I am just wondering whether it is possible at all too get at the underlying Monaco editor, specifically the typescript language so that...
Read more >
冬久久的博客-程序员宅基地_unexpected usage at ...
vue+webpack/vue3+vite使用monaco editor时报错Unexpected usage at EditorSimpleWorker.loadForeignModule解决,react同理.
Read more >
monaco-yaml - npm Package Health Analysis - Snyk
loadForeignModule (editorSimpleWorker.js) at webWorker.js. As a workaround, create a file named yaml.worker.js in your own project with the following ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found