Parcel: Can webworker build together not in a separate js file?

Created on 17 Jan 2018  路  4Comments  路  Source: parcel-bundler/parcel

Can webworker build together not in a separate js file?

Most helpful comment

Instantiating several workers at once from the same script will fetch the script several times. The Blob technique results in worker code only being loaded once (and also eagerly, rather than on Worker instantiation).

I think it would be a nice feature in Parcel.

All 4 comments

I'm pretty sure that is impossible as web workers are js files being executed seperate from the main js code

var blob = new Blob(['worker code'], { type: 'text/javascript' });
var workerUrl = URL.createObjectURL(blob);
var worker = new Worker(workerUrl);

https://github.com/browserify/webworkify Does this make any help?

Closing this. I'm not sure why you'd want to inline it.

Instantiating several workers at once from the same script will fetch the script several times. The Blob technique results in worker code only being loaded once (and also eagerly, rather than on Worker instantiation).

I think it would be a nice feature in Parcel.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

algebraic-brain picture algebraic-brain  路  3Comments

donaldallen picture donaldallen  路  3Comments

medhatdawoud picture medhatdawoud  路  3Comments

davidnagli picture davidnagli  路  3Comments

mnn picture mnn  路  3Comments