You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to repro, you'll need a project depending on monaco-editor@>=0.52.0 and [email protected]. The plugin should be configured to load the workers from a different origin than the host.
Actual (Problematic) Behavior
I'm running into an issue in my project after upgrading to [email protected] where the language workers fail to load:
This appears to be caused by the monaco-editor-webpack-plugin, which falls back to using importScripts() when loading these workers cross-origin (in my case, the host origin is localhost:8100, and scripts are served by webpack-dev-server on localhost:8105). importScripts() is only supported for "classic" workers and fails when workers are initialized with type: "module" (https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts#typeerror).
Looks like this was caused by recent changes to the monaco-editor core as part of the ESM migration (here), where workers are now instantiated as module workers.
I believe the fix for this is to update the webpack plugin's getWorkerUrl function (here) to support ESM environments.
Expected Behavior
The worker should successfully load and not result in a TypeError.
Additional Context
I've raised #4742 to update the plugin to support ESM workers.
The text was updated successfully, but these errors were encountered:
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Link
N/A
Monaco Editor Playground Code
N/A
Reproduction Steps
In order to repro, you'll need a project depending on
monaco-editor@>=0.52.0
and[email protected]
. The plugin should be configured to load the workers from a different origin than the host.Actual (Problematic) Behavior
I'm running into an issue in my project after upgrading to
[email protected]
where the language workers fail to load:This appears to be caused by the
monaco-editor-webpack-plugin
, which falls back to usingimportScripts()
when loading these workers cross-origin (in my case, the host origin islocalhost:8100
, and scripts are served bywebpack-dev-server
onlocalhost:8105
).importScripts()
is only supported for "classic" workers and fails when workers are initialized withtype: "module"
(https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts#typeerror).Looks like this was caused by recent changes to the
monaco-editor
core as part of the ESM migration (here), where workers are now instantiated as module workers.I believe the fix for this is to update the webpack plugin's
getWorkerUrl
function (here) to support ESM environments.Expected Behavior
The worker should successfully load and not result in a
TypeError
.Additional Context
I've raised #4742 to update the plugin to support ESM workers.
The text was updated successfully, but these errors were encountered: