Workers in the browser
valentinoli opened this issue · 5 comments
valentinoli commented
Currently, this module only supports workers in Node.js
Would it be difficult to add support for unzipping in parallel with Web Workers in the browser?
greggman commented
it works just fine in web workers. See example in the repo.
valentinoli commented
I tried but it relies on a Node module worker_threads
valentinoli commented
Moreover, the example is titled "Workers in Node"
valentinoli commented
Ah, I was getting a webpack error:
This dependency was not found:
* worker_threads in ./node_modules/unzipit/dist/unzipit-worker.module.js
To install it, you can run: npm install --save worker_threads
Solved it by using the webpack file-loader
{
test: /unzipit-worker.module.js$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[contenthash:7].[ext]'
}
}
]
}
import workerURL from 'unzipit/dist/unzipit-worker.module.js'
setOptions({
workerURL,
numWorkers: 2
})
Thanks!