[英]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. 我正在构建一个Firefox附加组件,并且喜欢包含在index.js和worker脚本中使用的代码。 Instead of copying the function, I would like to add it in a file next to the index.js if possible. 如果可能的话,我想将它添加到index.js旁边的文件中,而不是复制函数。
for addon modules you use require("./relative/path.js") , for the worker you specify it through the contentScriptFile parameter. 对于您通过contentScriptFile参数指定它的worker所使用的addon模块(“./ relative / path.js”) 。 You will have to feature-detect whether CommonJS features (require/exports) are available. 您必须使用功能检测CommonJS功能(需要/导出)是否可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.