I’m currently working on a browser extension for both Chrome and Firefox that shares much of the same code.
However, the extension requires a background script, and starting with manifest v3, Chrome and Firefox now handle these in a mutually incompatible way. In manifest.json
‘s background
entry, Chrome requires the use of service_worker
while Firefox still requires using scripts
. Consequently, I can’t create a manifest that works with both apps.
Is there a convenient way I can get both browsers to load an unpacked extension, where each uses a different manifest, but while still loading the same code?
The only idea I can think of is to create two folders for both browsers, each with a separate manifest, and then symlinking to the scripts themselves. But that strikes me as being problematic for a number of reasons, one being the need to maintain the symlinks when files move or change, and the other is for Windows users who would try to check out the extension’s git repository given Windows’ poor support for symlinks. I’m hoping there’s a better method.