firefox-addonjpm

How to add a file other than index.js to a Firefox add-on using jpm


I am building a Firefox add-on and like to include code that is used in the index.js, as well as in the worker script. Instead of copying the function, I would like to add it in a file next to the index.js if possible.


Solution

  • for addon modules you use require("./relative/path.js"), for the worker you specify it through the contentScriptFile parameter. You will have to feature-detect whether CommonJS features (require/exports) are available.