Skip to content

Commit 495d075

Browse files
authored
Merge pull request #4742 from RoccoC/webpack-plugin-esm
Update webpack plugin to support module workers
2 parents e03e965 + d2205cb commit 495d075

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

webpack-plugin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monaco-editor-webpack-plugin",
3-
"version": "7.1.0",
3+
"version": "7.1.1",
44
"description": "A webpack plugin for the Monaco Editor",
55
"main": "out/index.js",
66
"typings": "./out/index.d.ts",

webpack-plugin/src/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,14 @@ function createLoaderRules(
296296
if(/^(\\/\\/)/.test(result)) {
297297
result = window.location.protocol + result
298298
}
299-
var js = '/*' + label + '*/importScripts("' + result + '");';
299+
var js = '/*' + label + '*/';
300+
if (typeof import.meta !== 'undefined') {
301+
// module worker
302+
js += 'import "' + result + '";';
303+
} else {
304+
// classic worker
305+
js += 'importScripts("' + result + '");';
306+
}
300307
var blob = new Blob([js], { type: 'application/javascript' });
301308
return URL.createObjectURL(blob);
302309
}

0 commit comments

Comments
 (0)