shama / workerify

Transform web workers into browserified inline Blobs with browserify.
MIT License
112 stars 17 forks source link

SharedWorker support #8

Open rektide opened 10 years ago

rektide commented 10 years ago

SharedWorkers aren't much different in terms of creation than Workers; would be great to have. http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#shared-workers-and-the-sharedworker-interface

rynomad commented 10 years ago

I'm not shama, but as I've grown to depend on this project for my own work and have done some thinking on the subject, it's not as simple as it seems:

To the best of my knowledge, shared workers are identified across tabs by their urls, which of course is broken by creating a unique objectURL dynamically with workerify. HOWEVER...

On a lark, I tested to see if an object URL created in one tab would resolve if evaluated from another tab on the same domain, and it worked, so hope is not lost. cross domain message channels might offer a solution to pass the object url around, or you could use the server as a quick relay to pass the string, but it would be highly context specific, and depend on the lineage of pages/tabs, so methinks it might be a bit outside the scope of this module.

deathcap commented 10 years ago

"filesystem:" URLs are another option, they persist across page reloads and are predictable so they wouldn't necessarily have to be passed around (unlike blob object URLs). References:

http://www.w3.org/TR/file-system-api/ https://github.com/deathcap/url4data https://github.com/deathcap/rtc-signaller-sw