update webpack plugin to support module workers

This commit is contained in:
RoccoC 2024-11-05 12:07:29 -08:00
parent 9adbed19a9
commit ae5cab77cb
2 changed files with 9 additions and 2 deletions

View file

@ -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);
}