'NuxtJS Firebase V9 modular in service worker

Firebase documentation says to use this code inside service worker:

import { initializeApp } from 'firebase/app'
import { getMessaging } from 'firebase/messaging/sw'

But I get this error:

Token error: FirebaseError: Messaging: We are unable to register the default service worker.

I assume that this is because WebPack under NuxtJS configuration ignores "import" inside service worker files.

Is there any way to fix this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source