diff --git a/webpack-plugin/package.json b/webpack-plugin/package.json index 48e5e1350a..07ac8fed6f 100644 --- a/webpack-plugin/package.json +++ b/webpack-plugin/package.json @@ -1,6 +1,6 @@ { "name": "monaco-editor-webpack-plugin", - "version": "7.1.0", + "version": "7.1.1", "description": "A webpack plugin for the Monaco Editor", "main": "out/index.js", "typings": "./out/index.d.ts", diff --git a/webpack-plugin/src/index.ts b/webpack-plugin/src/index.ts index 529dd044c5..ea8ca29313 100644 --- a/webpack-plugin/src/index.ts +++ b/webpack-plugin/src/index.ts @@ -296,7 +296,14 @@ function createLoaderRules( if(/^(\\/\\/)/.test(result)) { result = window.location.protocol + result } - var js = '/*' + label + '*/importScripts("' + result + '");'; + var js = '/*' + label + '*/'; + if (typeof import.meta !== 'undefined') { + // module worker + js += 'import "' + result + '";'; + } else { + // classic worker + js += 'importScripts("' + result + '");'; + } var blob = new Blob([js], { type: 'application/javascript' }); return URL.createObjectURL(blob); }