mozilla / web-ext

A command line tool to help build, run, and test web extensions
Mozilla Public License 2.0
2.72k stars 339 forks source link

Support enable-background-service-worker option #2916

Open Robot-Inventor opened 1 year ago

Robot-Inventor commented 1 year ago

Is this a feature request or a bug?

Feature request

addons-linter supports the --enable-background-service-worker option on the command line. I would like to see this option supported in the web-ext lint command as well. This option is especially important when developing extensions for multiple browsers.

Rob--W commented 1 year ago

What is the purpose of running web-ext lint on manifest.json files targeting non-Firefox browsers?

rpl commented 1 year ago

Besides Rob question (which we are still interested in), we agreed that we would be willing to extend the --firefox-prefix option to support this use case (at the moment we enable mv3 addons-linter option by default, and we could add an opt-in one to enable the background service worker support as well).

Rob--W commented 1 year ago

(...) to extend the --firefox-prefix option

--firefox-preview= option*

Robot-Inventor commented 1 year ago

Thank you for agreeing to expand the option.

As for why use web-ext lint, in my project, manifest.json and some code are different for Firefox and Chrome (most are the same). In addition to manual checks, web-ext lint can be a useful way to prevent simple mistakes in the manifest and code for each browser.

ximex commented 8 months ago

Firefox 121+ allows now background.server_worker. See: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background#browser_support Also minimum_chrome_version should be allowed in the manifest.json for easier cross browser support

Rob--W commented 8 months ago

Firefox 121 does not support service_worker. The difference in 121 is that it loads the background script as expected even if the service_worker key is present. This was https://bugzilla.mozilla.org/show_bug.cgi?id=1860304

ximex commented 8 months ago

This is what i mean. Firefox 121 doesn't have a problem now if the service_worker key is there. not that Firefox supports it. So web-ext shouldn't complain about it

xuhdev commented 2 weeks ago

I agree with @ximex . It's not uncommon to share a single manifest.json file across browsers.

However, now it returns a warning (https://github.com/mozilla/addons-linter/issues/5152), which is in line with the behavior of Firefox.

Rob--W commented 2 weeks ago

We should accept manifest.json files that specify both service_worker and scripts (https://github.com/mozilla/addons-linter/issues/5252 and https://github.com/mozilla/web-ext/issues/3101).