[w3c/ServiceWorker] Clarify dynamic-imported scripts are never installed (#1356)

Current spec seems to have no description about how to handle dynamic-imported scripts. 

We have 3 situations to install scripts:

1. Classic script + importScripts()
2. Module script + static import
3. Classic/Module script + dynamic import

In 1., a top-level script and all imported scripts are installed because we must guarantee that all scripts for ServiceWorker exist for offline support. Note that importScripts() is allowed to be called only on the initial script evaluation or the install event. See for details [#1319](https://github.com/w3c/ServiceWorker/issues/1319) and [Intent to Deprecate and Remove: importScripts() of new scripts after service worker installation](https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/a6P-niHWgF4).

In 2., a top-level script and all imported scripts are installed because of the same reason of 1..

However, in 3., we cannot ensure all imported scripts exist on installation because a service worker could use import() after installation.

My suggestion is we should clarify that a top-level script and static-imported scripts are installed but all dynamic-imported scripts are **NOT** installed in the spec because dynamic-import is a kind of networking APIs to fetch subresources such as fetch() or XMLHttpRequest that are never installed. If users want to use scripts offline, they should import them with static import. Or, they should explicitly store them in a storage like CacheStorage and dynamically import them as Data URL etc.


-- 
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/1356

Received on Wednesday, 26 September 2018 07:20:37 UTC