As of Chrome 80, you can create module type workers with new Worker("worker.js", { type: "module" }), and then use module features like import in the worker script. However other browsers are still working on support for this, so using it needs feature detection and a fallback.
Is there a convenient and simple way to feature detect module support for workers?
Note on some platforms (e.g. Cordova) creating workers is actually non-trivial and involves a bunch of workarounds, so something that works in pure JS would be ideal.