Skip to content

Instantly share code, notes, and snippets.

@kfranqueiro
Last active March 1, 2016 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfranqueiro/4238675 to your computer and use it in GitHub Desktop.
Save kfranqueiro/4238675 to your computer and use it in GitHub Desktop.
Functions to find what's depending on a loaded Dojo module or what a module depends on (uses ES5 methods)
function findDep(depid) {
return Object.keys(require.modules).map(function(mid) {
return require.modules[mid];
}).filter(function(m) {
return m.deps && m.deps.map(function(dep) {
return dep.mid;
}).indexOf(depid) > -1;
}).map(function(m) {
return m.mid;
});
}
function getDeps(mid, depsMap) {
depsMap = depsMap || {};
depsMap[mid] = true;
var module = require.modules[mid];
if (module.deps) {
module.deps.forEach(function (module) {
getDeps(module.mid, depsMap);
});
}
return Object.keys(depsMap);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment