如何使用 jpm 将 index.js 以外的文件添加到 Firefox 附加组件

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

我正在构建一个 Firefox 附加组件,并希望包含在 index.js 以及工作脚本中使用的代码。如果可能的话,我不想复制函数,而是想将它添加到 index.js 旁边的文件中。

对于插件模块,您使用 require("./relative/path.js"), for the worker you specify it through the contentScriptFile 参数。您将必须 feature-detect CommonJS 功能 (require/exports) 是否可用。