create-react-extension icon indicating copy to clipboard operation
create-react-extension copied to clipboard

Cannot import scripts in background script with importScripts (service worker)

Open Danscap opened this issue 2 years ago • 0 comments

As you can see here,

image

using self.importScripts('../pathtojavascriptfile.js') is broken. I'm not sure if this is a webpack issue, but using this normally in a background.js script without create-react-extension works.

Does anyone have a possible fix for this?

Edit

The reason this is so important is because in MV3 with the limitation of service workers, you cannot import files the way you would in another javascript or react file, you must use self.importScripts() to import local files.

This is the only way for services like Firebase to be integrated into your extension. And this is currently impossible because of this bug.

Danscap avatar Apr 18 '22 01:04 Danscap