The Jetpack project released Addon SDK version 1.4 yesterday; this release is likely the most significant release of the SDK since 1.0 in June, and includes a number of improvements. One of the improvements was a change to simplify the internal file & folder structure of the xpi packages the SDK creates. This work was tracked in bug 660629.
One side-effect of this change is that the resource urls for files in the data folder of an add-on have changed. If you have created an add-on and for some reason hard-coded a resource url into your code, you will need to change your code in order for your add-on to work when packaged with SDK version 1.4.
While the release notes go into this issue in detail, I would like to highlight here the two main examples we are seeing in the wild of hard coded resource uris, with strategies for working around each.
1. Hard coded resource uris in main.js
Addon authors occasionally reference html and javascript files in the addon’s data directory directly via a hard-coded string:
var myPanel = require("panel").Panel({
contentURL: "resource://jid1-294x0ji6mesjag-at-jetpack-example-data/my-file.html",
contentScriptFile: "resource://jid1-294x0ji6mesjag-at-jetpack-example-data/my-script.js"
});
You should always use the method self.data.url instead:
var data = require("self").data;
var myPanel = require("panel").Panel({
contentURL: data.url("my-file.html"),
contentScriptFile: data.url("my-script.js")
});
2. Hard coded resource uris in html or css files inside the data directory.
Referencing a css or image file from an html or css file in the addon’s data directory does not require the entire resource uri path because these resources can be referenced with relative paths. Instead of doing this:
…all you need to do is this:
If you have created an SDK-based addon and have included some hard-coded resource uris in your code, you will only need to make changes to address this issue if you re-package your addon with 1.4. As we are not re-packing addons on AMO automatically for this release, there is no immediate need to update your code.
It is possible 6 weeks from now that we will re-pack all addons to use SDK 1.5, and at this point any remaining addons using hard-coded resource uris will stop working. To mitigate this we are working with the AMO team to identify all affected addons and contact addon authors directly to encourage them to update and use the best practices I demonstrated above.
Aris wrote on
Jeff Griffiths wrote on
Asi wrote on
Jeff Griffiths wrote on
John Nagle, Silicon Valley, CA wrote on
Jeff Griffiths wrote on