microsoft / monaco-editor

A browser based code editor
https://microsoft.github.io/monaco-editor/
MIT License
40.56k stars 3.61k forks source link

[Bug] Update to angular 18.2.3 gives importScripts error #4675

Open Dlankheet opened 2 months ago

Dlankheet commented 2 months ago

Reproducible in vscode.dev or in VS Code Desktop?

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Reproduction Steps

Have the following dependencies: "@angular/core": "18.2.3" "monaco-editor": "^0.51.0" "typescript": "^5.5.4"

Run npm install.

Import a monaco editor in to your project and add it to your dom:

Actual (Problematic) Behavior

e7ea2d78-e839-48eb-963c-a52acac188d7:1 Uncaught SyntaxError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL 'assets/monaco-editor/min/vs/base/worker/workerMain.js#editorWorkerService' is invalid. at e7ea2d78-e839-48eb-9…-a52acac188d7:1:337

Uncaught DOMException SyntaxError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL 'assets/monaco-editor/min/vs/base/worker/workerMain.js#editorWorkerService' is invalid. at

image

Expected Behavior

No errors.

Additional Context

No response

Jobvdb commented 2 months ago

Not sure if it helps, but when downgrading to monaco 0.50.0, this behavior is gone.

bitofsky commented 2 months ago

I have also been experiencing a similar error since version 0.51.0. When I downgrade to 0.50.0, the error disappears. The issue can be easily reproduced. If you create an editor using a language that utilizes workers, you can see the error immediately.

<!DOCTYPE html>
<html>
<head>
  <script src="monaco-editor/min/vs/loader.js"></script>
  <script>
    require.config({ paths: { vs: 'monaco-editor/min/vs' } });
  </script>
</head>

<body>
  <div id="container" style="width: 500px; height: 500px;"></div>
  <script>
    require(['vs/editor/editor.main'], function () {
      monaco.editor.create(document.getElementById('container'), {
        value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
        language: 'typescript'
      });
    });
  </script>
</body>
</html>

image

tczkqq commented 2 months ago

I have the same issue, only downgrading helps

niwolf commented 2 months ago

I have the same issue after updating to v0.51.0 of monaco-editor. My Angular version is still on v17.3.0. Downgrading to v0.50.0 of monaco-editor should not be the solution 😃

JMGomes commented 2 months ago

same issue here. I was getting issues with the diff editor. I could fix it by downgrading to v0.50.0 😞

I'm using angular with the config

{
  "glob": "**/*",
  "input": "node_modules/monaco-editor",
  "output": "/assets/monaco/"
},
niwolf commented 2 months ago

Related to: https://github.com/microsoft/monaco-editor/issues/4654

kaisnb commented 1 month ago

I've experienced the same error when I updated from v50 to v51. After updating now from v51 to v52, the stacktrace changed but I guess the problem is the same:

Screenshot 2024-10-03 at 22 56 59