I have converted a web extension originally made for chrome to safari, using the tool documented at https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari
The project is created, builds, and launches successfully. I have added a service worker however and am unable to get it to load properly.
"The service_worker script failed to load due to an error."
I have no idea what to do with this error, as it provides no information at all. The option to access the background page process is disabled in the Safari Develop menu with the message "service worker failed to load".
Here is my "manifest.json"
{
"manifest_version": 3,
"name": "My Extension",
"version": "3.6",
"description": "__MSG_extDesc__",
"default_locale": "en_US",
"options_ui": {
"page": "options.html",
"open_in_tab": false
},
"action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"icons": {
"128" : "icon.png"
},
"permissions": [
"activeTab",
"storage",
"scripting",
"clipboardWrite"
],
"host_permissions": [
"https://ajax.googleapis.com/",
"http://myServer.com/*",
"http://lists.w3.org/",
"https://www.pinterest.com/*"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content-script.js"]
}
],
"background": {
"service_worker": "background.js",
"type": "module"
}
}
Does anyone have any good suggestions/knowledge on how to debug why the service worker doesn't load? The extension works without any errors or warnings in Google Chrome. I understand a similar question has been asked before but my situation is different. I completely commented out my backgroung.js script and am still unable to load my service worker making it difficult to pin point the issue. Thanks in advance!
I had added the background script after the chrome to Safari conversion. As such it was not included in the Build Phases. Adding it to the build phases fixed my issue. reference: https://developer.apple.com/forums/thread/710164