New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module Tree output #903
Comments
👍, we should do this – would just be a case of adding a rollup.rollup( options ).then( bundle => {
bundle.modules.forEach( ({ id, dependencies }) => {
console.log( `${id} has ${dependencies.length} dependencies:`, dependencies );
});
}); This would only work via the JavaScript API, unless we added more logging to the CLI – #651. |
include dependencies in bundle.modules
Released in 0.35 |
In case it helps anyone, it looks like |
For anybody who comes here for the same reason I did, here's a handy little function for listing all of the modules which depend on another module: async function build() {
const bundle = await rollup.rollup(config);
const { modules } = bundle.cache;
printModulesWhichDependOn(modules, 'lodash');
}
/**
* Prints a list of modules which depend on `moduleName`, excluding the module itself.
* This is useful if you need to see every module which depends on eg. "lodash".
*
* @param {*} modules - a list of modules from the build (build.modules or build.cache.modules)
* @param {*} moduleName
*/
function printModulesWhichDependOn(modules, moduleName) {
console.log(`MODULES WHICH DEPEND ON "${moduleName}":`);
modules.forEach(({ id, dependencies }) => {
if (
id.indexOf(moduleName) === -1 &&
dependencies.find(d => d.indexOf(moduleName) > -1)
) {
console.log(` - ${id}`);
}
});
} |
Would it be possible for rollup to print out a tree of all the modules used and how they are related? Reason for the request is that I have a project where certain dependencies are still getting included, but having difficulty tracking down "why", and thought a module graph or tree would help pinpoint the culprit. Thanks
The text was updated successfully, but these errors were encountered: