The manifest v3 does indeed want a:
"background" : {
"service_worker" : "background.js"
}
On Safari, I don't see support for "type" : "module", so, a better approach to maintain module support is to use a bundler like esbuild to generate the background.js from a collection of source files like background_base.js, common.js, etc :
./node_modules/.bin/esbuild background_base.js --bundle --outfile=background.js
This allows one to keep module support, for say testing, while producing a single background.js that web extensions appear to cooperate better with. No need for a legacy like background.html with script hack. Javascript import works for test environments and allows one to incorporate various libraries easily. I've replace all my content.js, popup.js and similar with the same pattern. In my environment, I use WebStorm to do the majority of editing (working with modules) and let XCode to do the final build and packaging after the esbuild scripts run. This also simplifies the manifest.json and the number of files I have to keep track of in XCode.
Post
Replies
Boosts
Views
Activity
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";
Similarly, I just updated to 12.3 and XCode 13.3 . See the same as above.
see same