Re: [w3c/ServiceWorker] Feature detection for type="module" support (#1582)

If https://github.com/w3c/ServiceWorker/issues/1585 is resolved, and dynamic `import()` comes to service workers, it would introduce one more capability that would be important to know prior to service worker registration.

You could theoretically create four different versions of a service worker script—`importScripts()` vs. static module imports, and dynamic `import()`s vs. no dynamic support—to cover all the possible variations, and registering them one at a time until you find the one that doesn't throw isn't a good model. (Though I doubt it's likely that a browser will support dynamic import() but not static module imports...)

Exposing some combination of `['classic', 'dynamic', 'static']` as a new `importSupport` property on the `ServiceWorkerContainer`, reflecting the set of capabilities of the current browser, would address this expanded use case. Browsers that don't have an `importSupport` property on `ServiceWorkerContainer` could be assumed to only support classic `importScripts()`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1582#issuecomment-825837154

Received on Friday, 23 April 2021 18:20:06 UTC