Can webworker build together not in a separate js file?
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.
Most helpful comment
Instantiating several workers at once from the same script will fetch the script several times. The
Blobtechnique 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.