File tree 1 file changed +6
-5
lines changed
packages/vite/src/node/plugins
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -296,7 +296,10 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
296
296
chunk . code ,
297
297
) . toString ( 'base64' ) } ";`
298
298
299
- const blobCode = `${ encodedJs }
299
+ const code =
300
+ // Using blob URL for SharedWorker results in multiple instances of a same worker
301
+ workerConstructor === 'Worker'
302
+ ? `${ encodedJs }
300
303
const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
301
304
export default function WorkerWrapper() {
302
305
let objURL;
@@ -310,16 +313,14 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
310
313
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
311
314
}
312
315
}`
313
-
314
- const base64Code = `${ encodedJs }
316
+ : `${ encodedJs }
315
317
export default function WorkerWrapper() {
316
318
return new ${ workerConstructor } ("data:application/javascript;base64," + encodedJs${ workerOptions } );
317
319
}
318
320
`
319
321
320
322
return {
321
- // Using blob URL for SharedWorker results in multiple instances of a same worker
322
- code : workerConstructor === 'Worker' ? blobCode : base64Code ,
323
+ code,
323
324
// Empty sourcemap to suppress Rollup warning
324
325
map : { mappings : '' } ,
325
326
}
You can’t perform that action at this time.
0 commit comments