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:
See #122 for more history.
Add worker plugin to load modules as workers
Create worker shim to allow curl to be loaded inside a worker
Add make rule for worker shim support and create initial build
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.
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. :)
importScripts will load each script synchronously, somewhat defeating the benefits of AMD. Using XHR + eval would allow async loading.
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. :)