Earlier quoted context omitted.
If you can find a good Javascript library for doing it you can build it into your Worker with Webpack.
It's not finding a parser that I find problematic, it's the dataset needed. My understanding is that the workers are limited to 128MB of ram and that they may be 'restarted' at any time. Datasets for accurate browser detection would be really tight in fitting into that amount of RAM when combined with whatever else you may be doing and you have to deal with load / parse time whenever a worker is restarted. This seems…
I think you might be overestimating that. Bundling the aforementioned https://github.com/faisalman/ua-parser-js wouldn't be significant - maybe hundreds of KB as a script (distinct from memory!) - at most.