Skip to content

mozilla-algiers/web-ext

 
 

Repository files navigation

Web-ext

This is a command line tool to help build, run, and test web extensions.

Ultimately, it aims to support web extensions in a standard, portable, cross-platform way. Initially, it will provide a streamlined experience for developing Firefox web extensions.

Installation

This tool is not yet ready for installation. Stay tuned.

Should I Use It?

This tool may require using a nightly build of Firefox and is initially intended to develop web extensions, a platform which is not yet stable in Firefox. If you are looking to develop an add-on that runs in older versions of Firefox, consider jpm.

Get Involved

Hi! This tool is under active development. To get involved you can watch the repo, file issues, create pull requests, or ask a question on dev-addons. Read on for how to develop new features.

Development of web-ext

You'll need:

To get started, clone the source and run npm install.

Develop all the things

Your one stop command to continuously build, run tests, check for syntax errors, and check for flow errors is this:

npm run develop

The other commands below are just variations on this.

Run all application tests

To run the complete suite of tests just how the CI server would, type npm run ci-test.

Run the test suite

Type npm test to run the test suite and check the code for syntax errors (lint).

If you are deep down some rabbit hole, you can skip lint checks temporarily by setting $SKIP_LINT in the environment like:

SKIP_LINT=1 npm test

Build web-ext

Type npm run build to build a new version of the ./bin/web-ext command.

Check for lint

Type npm run lint to make sure there are no syntax errors or other house keeping problems in the source code.

Check for Flow errors

This project relies on flow to ensure functions and classes are used correctly. Run all flow checks with npm run flow-check.

Fix the Flow config

Flow checks all dependencies in node_modules to catch usage errors. We made a hacky optimization where our config ignores unimported modules. This sped up the standalone Flow check by 2x. However, when you change package.json you may need to regenerate the ignore rules. Do so like this:

grunt fix-flow-config

After that, commit and push the new .flowconfig.

Some Questions and Answers

Why do we need a command line tool?

This is a great question and one that we will ask ourselves for each new web-ext feature. Most web extension functionality is baked into the browsers themselves but a complimentary command line tool will still be helpful. Here is a partial list of examples:

  • File watching.
    • When you edit a file, you may need to trigger certain commands (tests, installation, etc).
  • Integrating with services.
    • Mozilla offers some useful services such as linting and signing extensions.

Why not patch jpm for web extension support?

First, note that jpm is still actively maintained by Mozilla right now. We decided not to patch jpm for web extension support (See jpm issue 445, discussion). Here's why.

Mozilla built cfx then deprecated it for jpm and now we're proposing a new tool. I know this is frustrating for developers but web extensions mark a major turning point. It would be an arduous task to wedge its feature set and simplified development process into jpm.

Pros of creating a new tool:

  • By creating a new tool that focuses on the [emerging] web extension standard, we have a better chance of interoperating with other platforms, such as Google Chrome or Opera. It would be hard to do that while preserving compatibility in jpm.
  • Creating SDK-based add-ons was overly complicated. With web extensions you no longer need to convert your source into legacy artifacts and you won't need boostrapping scripts.
  • There are superior features in Firefox now for developing extensions such as loading from source code instead of a packaged XPI. It will be easier to reimagine a new tool around these work flows rather than adjust jpm's existing work flows.
  • jpm's functional tests are slow, brittle and hard to run. There are flaky time-outs and we've run out of low hanging fruit fixes at this point.
  • Most of jpm's code was not designed to be unit testable which makes it hard to maintain and refactor.
  • jpm's code was written in ES5 which is cumbersome after coming from the ES6 Firefox code base or from most other languages with modern conveniences (Python, Ruby, etc).
  • Some core functionality of jpm can be extracted and re-used in the new tool.

Cons of creating a new tool:

  • Firefox extension developers will have to interrupt and re-arrange their work flows.
  • Developers of existing add-ons will need to port to web extensions sooner rather than later.
  • The web-ext tool will require some ramp-up time for scaffolding.
  • The community of jpm contributors will need to shift focus to web-ext.

About

A command line tool to help build, run, and test web extensions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%