Closed alanpearce closed 2 weeks ago
I've been using this for a while and can't see anything else that needs adding at the moment.
I definitely think that using has!
will be the best solution for conditional worker usage, but from reading a discussion seems as if it's not quite ready for use with curl yet. Until then, it's not that hard to live without.
Hmm, I decided to try the CJSM loader with this. Definitely doesn't work, but I think I'll wait for it to stabilise before looking at it. I also tried the node.js
style of assigning module.exports as a function, which doesn't work when inside a worker.
At least rvalue require
works.
Hey @alanpearce!
Lots of other stuff bogging me down, atm. Looking forward to seeing what you've created and want WebWorker support sometime soon! Thanks for being patient. :)
-- John
Thanks for your suggestion @scothis. It's definitely a better idea than just using importScripts
, however I thought about it when I started and went with the simplest solution just to get it working. Initially it didn't seem like a big deal given that importScripts
only blocks the worker thread.
@unscriptable I see there is some XHR code in the text!
plugin. I'd like to use this in worker shim without duplicate code, but I'm not quite sure how you would want this organised. Let me know what you think and I'll get on it when I have time. :)
I created a plugin to load a module as a worker, and created a shim to enable curl to load scripts from inside a worker. The makefiles were updated to build a worker-specific version and add to the kitchen sink.
There isn't any detection for worker support right now and I'm not quite certain about the best way to implement that, or if that should be a concern of this code (and curl).
There are a few ways I thought of to do this:
require
the file as normal in the worker plugin, perhaps usingsetTimeout
to fake asynchronicity. This seems like a bad idea though—it might lock up the browser.Worker
shim could be added, to returnWorker
, whether it's fake or real. Kind of the same as the above.has!
, loading a non-worker module instead if the browser doesn't support Workers. This seems most reasonable.See #122 for more history.