I've recently mucked around the webworkers and tried to make that thing up and running. Even though I'd rather use the service workers, our clients don't have the latest browsers so we have to go with web workers. I've found that /support/workers module to be really great, but I've hit the wall once I've started using the modules in it and the problem is the sheer number of requests being pulled for the worker which was insane.
To put this into perspective, the following modules caused ~530 requests ( ! ) and that itself took around 20seconds to finish, which kind of beats the whole purpose of having a worker doing something quick. Once initialized, it worked a treat but that init time is shocking.
The task I was facing was a processor intensive process of querying a large number of geometries from the elevationSampler and that was blocking the UI. So I went through couple of stages
1) serialize the elevationSampler and provide it to worker. This didn't work as there was no way I could instantiate the ElevationSampler as its two provided classes cannot be easily instantiated and provided with the basic data.
2) so after step 1 proved to be a no-go, I've decided to provide the URL of the elevation layer to worker, and the worker loaded the ElevationLayer and created the sampler and do the calcs. This worked, but the problem is described above, the number of requests was way too large.
3) I've ended up querying the elevations in the main thread, but offset some further, non-esri calculations into the worker.
Is there a way to provide an esri bundle or how could I cut down the number of requests while still maintaining the number of modules I would like to pull?