Reputation: 341
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.
Upvotes: 2
Views: 800
Reputation: 1
Had the same or similar issue with manifest v3 and safari 16.1. First, be sure that all the code (.js, .html, .css) are included in the build for code signing on "Build Phases"::
Next, I was trying to use module support. In the manifest.json, i removed the :
"background": {
"service_worker": "background.js",
"type" : "module"
},
and replaced it with:
"background": {
"page" : "background.html"
},
the background.html then is a simple:
<script type="module" src="background.js"></script>
the background.js then uses an import on the first line as:
import * as common from "./common.js";
Upvotes: 0