Skip to content

Commit

Permalink
update webpack plugin to support module workers
Browse files Browse the repository at this point in the history
  • Loading branch information
RoccoC committed Nov 5, 2024
1 parent 9adbed1 commit ae5cab7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 8 additions & 1 deletion webpack-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit ae5cab7

Please sign in to comment.