The easiet implementation of the tool is to leverage rjs build time hooks, in our case we are leveraging done as added in the grunt-contrib-requirejs plugin. r.js build analysis leverages the format of manifest of build.txt that r.js provides in the case of the plugin we use the contents of that file provided directly via stdio. You could read the build.txt and invoke the analysis on that as well.
{
done: function(done, response) {
var status = true;
var duplicates = analyzer.duplicates(response, {
exclude: ['publications/public/app.js']
});
grunt.util._.each(duplicates, function(parents, child) {
grunt.log.subhead('The file "'+child+'" was built into the following multiple bundles: ');
grunt.util._.each(parents, function(parent) {
grunt.log.warn(parent);
});
grunt.log.writeln();
});
if (!grunt.util._.isEmpty(duplicates)) {
status = false;
}
if (status === true) {
grunt.log.writeln();
grunt.log.writeln('No duplicates found in bundles.');
}
done(status);
}
})
}
As recently introduced I think building a tool on top of new hook is probably the right way to go.