最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Firefox Service Worker import module giving TypeError - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question asked Mar 30 at 0:57 McMurphyMcMurphy 1,3061 gold badge17 silver badges51 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Firefox doesn't support module ServiceWorkers, yet. Here's the issue Implement "module" service workers.

发布评论

评论列表(0)

  1. 暂无评论