monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

[Bug] Update to angular 18.2.3 gives importScripts error

Open Dlankheet opened this issue 1 year ago • 7 comments

Reproducible in vscode.dev or in VS Code Desktop?

  • [X] Not reproducible in vscode.dev or 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

Dlankheet avatar Sep 10 '24 09:09 Dlankheet

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

Jobvdb avatar Sep 11 '24 14:09 Jobvdb

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

bitofsky avatar Sep 12 '24 00:09 bitofsky

I have the same issue, only downgrading helps

tczkqq avatar Sep 12 '24 13:09 tczkqq

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 😃

niwolf avatar Sep 19 '24 09:09 niwolf

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/"
},

JMGomes avatar Sep 19 '24 16:09 JMGomes

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

niwolf avatar Sep 23 '24 07:09 niwolf

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

kaisnb avatar Oct 03 '24 15:10 kaisnb

Same problem with 0.52.0

x-etienne avatar Nov 28 '24 06:11 x-etienne

use full url,see link

gozeon avatar Nov 29 '24 02:11 gozeon

paths: { vs: `${location.origin}/vendors/monaco-editor/${ PRODUCTION ? 'min' : 'dev' }/vs` }

ShenHongFei avatar Nov 29 '24 02:11 ShenHongFei