greggman/unzipit

Workers in the browser

valentinoli opened this issue · 5 comments

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?

it works just fine in web workers. See example in the repo.

I tried but it relies on a Node module worker_threads

Moreover, the example is titled "Workers in Node"

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!