Re: [w3c/ServiceWorker] Top-level await integration for ServiceWorkers running modules (#1407)

Dynamic module loading can be done with:

```js
const modulePromise = import(useFoo ? './foo' : './bar');

addEventListener('fetch', event => {
  event.respondWith(async function() {
    const { whatever } = await modulePromise;
    // …
  }());
});
```

This feels better all round, as you won't be blocked on the import if your code doesn't use it. 

-- 
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/1407#issuecomment-493989834

Received on Monday, 20 May 2019 13:35:24 UTC