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 {
292292 workerConstructor === 'Worker'
293293 ? `${ jsContent }
294294 const blob = typeof self !== "undefined" && self.Blob && new Blob([${
295+ // NOTE: Revoke the objURL after creating the worker, otherwise it breaks WebKit-based browsers
295296 workerType === 'classic'
296- ? ''
297+ ? `'(self.URL || self.webkitURL).revokeObjectURL(self.location.href);',`
297298 : // `URL` is always available, in `Worker[type="module"]`
298299 `'URL.revokeObjectURL(import.meta.url);',`
299300 } jsContent], { type: "text/javascript;charset=utf-8" });
@@ -312,14 +313,6 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
312313 'data:text/javascript;charset=utf-8,' + encodeURIComponent(jsContent),
313314 ${ workerTypeOption }
314315 );
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- : ''
323316 }
324317 }`
325318 : `${ jsContent }
You can’t perform that action at this time.
0 commit comments