То, что я понял, на данный момент выглядит следующим образом:
Имея рабочий, как этот:
class LoginWorker
#worker with an awesome entry method
process: (message)=>
console.log "Processing #{message}"
Я создаю объект экспорта функция, которая использует метод convertToText от http://jsfiddle.net/numoccpk/1/
exportObject: (obj)->
# Gets the constructor implementation and then the prototype
ctor = convertToText obj
proto = convertToText obj.prototype
# Stitch them together, now it looks like a worker file
text = """
// Defines the bind function from Coffeescript in order
// to be able to use()=> functions.
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
var worker = #{ctor}
worker.prototype = #{proto}
var workerInstance = new worker;
self.addEventListener('message', function(e) {
workerInstance.process(e.data);
}, false);
"""
# Create a Blob and get its URL
blobUrl = window.URL.createObjectURL new Blob([text])
# Build the worker inline!
worker = new Worker(blobUrl)
Тогда вам просто необходимо вызвать exportObject(LoginWorker)
, убедившись, что LoginWorker
доступен в s- конечно, справиться.