surma / rollup-plugin-loadz0r

An ill-named rollup plugin that makes code splitting “just work”, even with workers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Async importScripts() in SW is problematic

jeffposnick opened this issue · comments

As per the SW spec, and summarized at w3c/ServiceWorker#1319 (comment), calls to importScripts() are allowed either during the initial, synchronous, top-level SW execution or during the install event handler.

Chrome doesn't currently follow the spec and allows arbitrary, async importScripts(), but this is a bug that needs to be fixed.

Using this library could lead to folks to inadvertently calls importScripts() in a way that is meant to be disallowed, and (if they only test on Chrome) erroneously thinking that everything works fine because Chrome isn't throwing an exception.

commented

Hm...

Good that you file this. I’ll leave it like this for now as the only alternative would be fetch() + eval(), which is not CSP compliant. I’ll add a note to the README.

commented

On second thought, I’ll leave this open and think a bit more on what the right course of action is

commented

Fixed in 8cb54b7 by providing an option.