SW Registration failed with TypeError: ServiceWorker script at http://localhost/Vanilla/CacheManager.js for scope http://localhost/Vanilla/ threw an exception during script evaluation.
I'm getting the above TypeError when trying to register a ServiceWorker with FireFox (Works on Chrome, Wsdge, Opera) -
if ("serviceWorker" in navigator) {
await navigator.serviceWorker.register('/Vanilla/CacheManager.js', { scope: '/Vanilla/', type: 'module' })
.then(reg => {
console.log('SW Registered');
})
.catch(err => {
console.log('SW Registration failed with ' + err)
});
CacheManager.js (reduced to) -
*import config from "/Vanilla/config.js"* **// The problem**
console.log("Hello")
//const CACHE_NAME = config.cacheName
Config.js
export const config =
{
"cacheName": "VanillaV1.1"
}
I have no idea what TypeError FireFox is complaining about. CONST?
Firefox doesn't support module ServiceWorker
s, yet. Here's the issue Implement "module" service workers.