Re: [ServiceWorker] Support module service workers, and update for ES6 (#831)

> I don't see why we'd treat es6 modules any different from importScripts when it comes to updates, caching etc.

Because they executes in a different way. With importScripts(urls), the network fetches for the imported scripts are always triggered when the main service worker script is run. So I guess the major concern was the scenario where the UA is offline and Run Service Worker fails while loading such imported scripts again from the network. Some related discussion was here: https://github.com/slightlyoff/ServiceWorker/issues/106.

But with the module script, loading imported scripts is separate from running them. For SW, we actually invoke them from two separate call sites: Update and Run Service Worker. That is, when Run Service Worker invokes "run the module script" algorithm, the most update-to-date imported scripts (by Update) in the module map can be used. So unless otherwise we had any other reason not to allow the updates to the imported scripts, relying on the ES6 module behavior seems more reasonable to me.


---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/831#issuecomment-188068896

Received on Wednesday, 24 February 2016 04:55:43 UTC