File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -292,8 +292,9 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
292
292
workerConstructor === 'Worker'
293
293
? `${ jsContent }
294
294
const blob = typeof self !== "undefined" && self.Blob && new Blob([${
295
+ // NOTE: Revoke the objURL after creating the worker, otherwise it breaks WebKit-based browsers
295
296
workerType === 'classic'
296
- ? ''
297
+ ? `'(self.URL || self.webkitURL).revokeObjectURL(self.location.href);',`
297
298
: // `URL` is always available, in `Worker[type="module"]`
298
299
`'URL.revokeObjectURL(import.meta.url);',`
299
300
} jsContent], { type: "text/javascript;charset=utf-8" });
@@ -312,14 +313,6 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
312
313
'data:text/javascript;charset=utf-8,' + encodeURIComponent(jsContent),
313
314
${ workerTypeOption }
314
315
);
315
- }${
316
- // For module workers, we should not revoke the URL until the worker runs,
317
- // otherwise the worker fails to run
318
- workerType === 'classic'
319
- ? ` finally {
320
- objURL && (self.URL || self.webkitURL).revokeObjectURL(objURL);
321
- }`
322
- : ''
323
316
}
324
317
}`
325
318
: `${ jsContent }
You can’t perform that action at this time.
0 commit comments