Search code examples
javascriptmodulebrowserifyweb-worker

Combine browserify and WebWorker


I'm using browserify to pack my app and use js files as modules.

Now I want to use a webworker to upload a very big file on the background.

The problem I have is that to create this worker the instruction

new Worker('./worker.js')

must receive the name of a js file. So that this file cannot be a module. I think that this makes my app much more complicated, because now I have to combine two ways of using js files.

On the other hand, I'm interested in accessing a browserify module from this worker too.

So the question is, Which is the best way of using browserify and web workers together?


Solution

  • You can use webworkify to handle this