File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -416,10 +416,17 @@ import { createWorker } from '${WORKER_HELPER_ID}';
416
416
export const workerName = '${ workerName } ';
417
417
export const workerMsgId = '${ workerMsgId } ';
418
418
export const workerPath = /*@__PURE__*/import.meta.ROLLUP_FILE_URL_${ referenceId } ;
419
- const blob = new Blob(['importScripts("' + workerPath + '")'], { type: 'text/javascript' });
420
- const url = URL.createObjectURL(blob);
421
- export const worker = /*@__PURE__*/createWorker(url, workerName, workerMsgId);
422
- URL.revokeObjectURL(url);
419
+ export let worker;
420
+ try {
421
+ // first try directly starting the worker with the URL
422
+ worker = /*@__PURE__*/createWorker(workerPath, workerName, workerMsgId);
423
+ } catch(e) {
424
+ // probably a cross-origin issue, try using a Blob instead
425
+ const blob = new Blob(['importScripts("' + workerPath + '")'], { type: 'text/javascript' });
426
+ const url = URL.createObjectURL(blob);
427
+ worker = /*@__PURE__*/createWorker(url, workerName, workerMsgId);
428
+ URL.revokeObjectURL(url);
429
+ }
423
430
` ;
424
431
} ;
425
432
You can’t perform that action at this time.
0 commit comments