So, for our major (full site) project we are using the Dojo Toolkit. We have a build script that is condensing and compressing the JavaScript files using the Dojo build architecture. Each site page uses a global set of scripts for general utilities and ui, and then usually has another set of script for specific widgets and such.
It took me a while to find how to write the build script to omit duplicate dependencies included in the global but required by the page-specific scripts. For instance, we have a custom form handler called MyProject.form and is extended by page-specific classes. So, with the original build this class was included in the Global layer and the page-specific layer resulting in the MyProject.form class being in both .js files in the built page.
The answer is: layerDependencies in the build script.
dependencies = {
resourceName: "MyProject",
layers: [
{
name: "../../MyProject/Global.js",
dependencies: ["MyProject", "MyProject.Global"]
},
{
name: "../../MyProject/CategoryPage.js",
dependencies: ["MyProject.CategoryPage"],
layerDependencies: ["../../MyProject/Global.js"]
}
]
};So, if a class in dojo.required (and therefore included) in Global.js it will be not be copied into CategoryPage.js if it is required there, also.


Wow, thanks. I was just looking for this. Definitely will help me greatly.