How to install service workers for erpnext, using firebase?

I have a problem like this. I’m trying to create “Services workers” using a js file then add it to the hooks section of the customs app. However, I encountered a problem when importing the library. After I created the js file and added the init file to the hooks, I was told, the above import can only be used in the module? Is there any workaround?

importScripts('https://www.gstatic.com/firebasejs/9.0.0/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/9.0.0/firebase-messaging-compat.js');