Spawning a service worker in a safari web extension in the background

new Worker(browser.runtime.getURL('source/worker.js'))

throws an error:

Error: This script should only be loaded in a browser extension.

I have a hefty background processing operation that I need to pass off to a web worker, but the script I try to execute causes this error.

Is there a standard way of spawning a web worker in a background script for a safari web extension?

Spawning a service worker in a safari web extension in the background
 
 
Q