Actually, content
is supported in bootstrapped add-ons since quite some time (first in Gecko 8 and starting with Gecko 10, it will auto load manifests, IIRC).
You can load js code modules from chrome://yourpackage/content/...
not just from resource-URIs (since Gecko 4, IIRC). So there is nothing holding you back from using mozilla-style code modules.
Also, a couple of add-ons manually add resource
substitutions.
The stuff that Erik wrote uses a custom include
function, implemented in the corresponding bootstrap.js using loadSubScript
. That's an option, too. This scheme was invented when it wasn't yet possible to use js code modules from bootstrapped add-ons properly, e.g. because there was no Cu.unload
yet.
Using content
+ Cu.import
+ Cu.unload
is likely the easiest approach.
Real world example in one of my own add-ons (Desktop + Android) (the rest of the add-on is written using a custom commonjs-style require
loader, so don't get distracted by that).
chrome.manifest
- usingcontent
bootstrap.js
- usingCu.import
with acontent
chrome-URI.