Developing cross-browser extensions with web-ext 3.2.0

The web-ext tool was created at Mozilla to help you build browser extensions faster and more easily. Although our first launch focused on support for desktop Firefox, followed by Firefox for Android, our vision was always to support cross-browser development once we shipped Firefox support.

With the 3.2.0 release, you can use web-ext to truly build cross-browser extensions! Here is an example of developing an extension in Google Chrome using the run command:

$ web-ext run -t chromium

What’s even better is you can run your extension in both Firefox and Chrome at the same time:

$ web-ext run -t firefox-desktop -t chromium

As you’d expect, you can develop in any other Chromium-based browser such as Brave, Microsoft Edge, Opera or Vivaldi. Here’s an example of developing in Opera:

$ web-ext run -t chromium --chromium-binary /usr/bin/opera

Firefox’s WebExtensions API has always strived for Chrome API compatibility but several improvements have resulted in subtle differences, like how WebExtensions APIs always return promises. Mozilla already offers the webextensions-polyfill library to normalize promises and other things across both browser platforms.

And now, we are excited to offer a robust development solution for cross-browser extensions! Once you give it a try, let us know if you run into issues or have ideas for improvement.

Here is an example of launching an extension in Firefox and Chrome then editing a CSS file in the extension source to show off the automatic reloading feature.

 

Other new features in web-ext 3.2.0

Chromium browser support isn’t the only nice new feature. Thanks to parse-json 5.0.0, the parsing errors on the extension manifest and locale files will now include a code frame. This will make it a lot easier to track down and fix mistakes.

Detailed JSON parsing error logged from web-ext 3.2.0

About Luca Greco

More articles by Luca Greco…

About kumar303

Kumar hacks on Mozilla web services and tools for various projects, such as those supporting Firefox Add-ons. He hacks on lots of random open source projects too.

More articles by kumar303…


3 comments

  1. Scott Fortmann-Roe

    Great to see!

    I would also love to see externally_connectable support landed for Firefox extensions. It’s the biggest gap right now preventing us from porting our Chrome extension.

    October 16th, 2019 at 10:05

    1. kumar303

      The progress on this can be tracked at https://bugzilla.mozilla.org/show_bug.cgi?id=1319168 This API feature had a lower priority when we first worked on porting Chrome API features but its usage has grown since then.

      October 16th, 2019 at 10:23

  2. anonymous

    Web-ext requires node, bleh.

    Is there any Firefox web extension vanilla boilerplate which shows how you read/write configuration, do localization and maybe other stuff in a correct way?

    October 28th, 2019 at 09:04

Comments are closed for this article.