importScripts fails for Safari web extension

Viewed 88

I'm porting a working v3 chrome extension to Safari on MacOS. In my background (service worker) script I call

self.importScripts("Platform.js");

which should load said JavaScript file. It's in the same folder as the script that calls it.

But this fails in Safari (not chrome) with the error:

Failed to load resource: unsupported URL safari-web-extension://FE580C4D-9931-4639-ABF9-...../Platform.js

(dots substituted for the last hex digits). In the manifest I have the lines:

"web_accessible_resources": [
    {
      "resources": ["Platform.js"],
      "matches": ["<all_urls>"]
    },...

I'm following the instructions for converting a web extension to Safari. I'm running MacOS Monterey, Safari 15.5.

Any pointers as to what I might need to try would be appreciated. I thought of statically importing the code but it's not a JavaScript module.

0 Answers
Related