
A webpack loader that moves a module and its dependencies into a Web Worker, automatically reflecting exported functions as asynchronous proxies.
Worker
npm install -D workerize-loader
worker.js:
// block for `time` ms, then return the number of loops we could run in that time:
export function expensive(time) {
    let start = Date.now(),
        count = 0
    while (Date.now() - start < time) count++
    return count
}
 index.js: (our demo)
import worker from 'workerize-loader!./worker'
let instance = worker()  // `new` is optional
instance.expensive(1000).then( count => {
    console.log(`Ran ${count} loops`)
})
 The inner workings here are heavily inspired by worker-loader. It's worth a read!
    © JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
    https://webpack.js.org/loaders/workerize-loader