Chrome 61+ supports dynamic import() within Classic Workers. We can use this to polyfill Module Workers to a reasonable degree of accuracy.
The only trick is that we need to queue up any messages received while we wait for the module tree to load in the Worker, since Module Workers load the entire dependency graph before flushing messages queued during Worker instantiation.
This polyfill comes in two versions:
module-workers-polyfill-inline.js
is a single-file polyfill, but creates Workers with an Opaque Origin. If you're only loading dependencies from absolute URLs and not relying on storage like IndexedDB, this option is fine.
module-workers-polyfill.js
is a polyfill that depends on an external JS file to do its work. This allows it to be instantiated on the same origin as your page, avoiding the limitations present in the inline version.