Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev service worker on Firefox is not working #95

Open
fkrauthan opened this issue Dec 29, 2024 · 7 comments
Open

Dev service worker on Firefox is not working #95

fkrauthan opened this issue Dec 29, 2024 · 7 comments

Comments

@fkrauthan
Copy link

I've configured the service worker to use strategies: "injectManifest", and created the minimal service worker code required. My dev section looks as follow:

			devOptions: {
				enabled: true,
				type: "module",
			},

However when running my sveltekit app in dev mode (pnpm run dev) and opening the page on Firefox I get a SW registration error TypeError: ServiceWorker script at http://localhost:5173/dev-sw.js?dev-sw for scope http://localhost:5173/ threw an exception during script evaluation. [PWA.svelte:23:18](http://localhost:5173/src/lib/components/PWA.svelte) error (without any additonal errors displayed in the console).

Opening the same page in for example Chrome registers the service worker correctly.

You can use this repository https://github.com/fkrauthan/sveltekit-pwa-issue to see this issue yourself.

@userquin
Copy link
Member

You cannot use custom sw with type module in Firefox, it is not supported.

@fkrauthan
Copy link
Author

Hmm but changing type to classic produces the same error?

@userquin
Copy link
Member

Because cannot use import statements, the custom sw in dev is "compiled" via esbuild just removing the ts annotations:

Check the source code in the network or source tab.

@fkrauthan
Copy link
Author

fkrauthan commented Dec 29, 2024

Ah so in general dev mode for service workers does not work right now for firefox. Might be worth pointing out in the docs (as it only calls out that type module is only supported on chromium.

@userquin
Copy link
Member

You can write your custom service worker using importScripts, it should work.

@userquin
Copy link
Member

Ah so in general dev mode for service workers does not work right now for firefox. Might be worth pointing out in the docs (as it only calls out that type module is only supported on chromium.

https://vite-pwa-org.netlify.app/guide/development.html#injectmanifest-strategy

@fkrauthan
Copy link
Author

fkrauthan commented Dec 29, 2024

Yeah to me that reads as I can use type module on chrome (especially since the box just below it talks about that classic is used for prod builds all the time and works on all browsers), and I can use classic on all browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants