Probably the most important detail is that SDK no longer uses packages. This is an improvement for two reasons:
- once SDK is in Firefox we won’t be able to perform complicated module search at compile time and even more so at runtime.
- We also see it as great improvement to current ambiguous behavior of
require. Now SDK is just a
library of modules. Once it’s in Firefox, all addons will be able to load any SDK module without needing to convert completely to an SDK-style project.
- We also hope to empower other Mozilla projects with CommonJS so that new APIs & features can be authored in de facto standard CommonJS module format.
Going forward, the idiomatic way to require an SDK modules now is:
require("sdk/panel"). Low level and usually less stable APIs will have longer require paths:
To ensure that addons built using the old layout are not affected by this change we have analyzed all the module requirements of all AMO hosted addons and created a mapping that maps module requirements used to a new style. CFX - SDK’s CLI tool uses this mapping to allow backwards compatible behavior, while we have no plans on breaking backwards compatibility in a visible future, we still would like to encourage authoring new add-ons in idiamatic style this will make your code a lot more portable!
This new layout is currently on the Master branch and is scheduled to be released on December 11 as version 1.12.