Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use JSON/CSS/HTML language without workers #793

Closed
neoncom opened this issue Mar 30, 2018 · 2 comments
Closed

Cannot use JSON/CSS/HTML language without workers #793

neoncom opened this issue Mar 30, 2018 · 2 comments
Labels
help wanted Issues identified as good community contribution opportunities

Comments

@neoncom
Copy link

neoncom commented Mar 30, 2018

monaco-editor version: 0.11.1
Browser: chrome latest
OS: win 10 64bit
Steps or JS usage snippet reproducing the issue:

Run browser-esm-webpack-small sample with following changes:

in index.js:

  • editor language "json"
  • enable (uncomment) " import 'monaco-editor/esm/vs/language/json/monaco.contribution';"

I also changed mode to delelopment in webpack config.

Result:

Error: self.require is not a function
    at eval (editorSimpleWorker.js:395)
    at new Promise_ctor (winjs.base.js:1660)
    at EditorSimpleWorkerImpl.BaseEditorSimpleWorker.loadForeignModule (editorSimpleWorker.js:393)
    at SimpleWorkerServer._handleMessage (simpleWorker.js:259)
    at Object.handleMessage (simpleWorker.js:245)
    at SimpleWorkerProtocol._handleMessage (simpleWorker.js:117)
    at SimpleWorkerProtocol.handleMessage (simpleWorker.js:89)
    at SimpleWorkerServer.onmessage (simpleWorker.js:249)
    at self.onmessage (editor.worker.js:23)

Why do i get this error?

It seems like the json worker is needed. But why? JSON syntax highlighting works perfectly without it. I don't want the this json worker :)

BTW, I am not running from "file://", i am using "npm run simpleserver". The standard language "python" (from that sample) works without issue.

This issue looks a bit like #759 but that issue requires a worker to fail due to some reason before it throws "self.require is not a function". This is not the case in this issue.

@alexdima alexdima added the help wanted Issues identified as good community contribution opportunities label Apr 27, 2018
@flash-me
Copy link

Did you set globalobject: self in your webpack config like here?

The webworkers are responsible for enhanced suggestions and syntax errors etcs. With setting the editor language to JSON everything is going to be loaded, not only the colors.

However you can customize the imports and decide yourself what should be loaded and what not. Example

@alexdima
Copy link
Member

I believe this now works.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

3 participants