This code, cut from the --list handler in the Browserify bin/cmd.js script , will provide you with a flat list of files:
// Your setup: var scripts = [ 'a.js', 'b.js' ]; //a & b require a lot of other scripts var b = browserify({ entries: scripts }); // Logging out each of the filenames: b.pipeline.get('deps').push(require('through2').obj( function (row, enc, next) { console.log(row.file || row.id); next(); } )); // Bundle as normal: b.bundle().pipe(fs.createWriteStream('bundle.js'));
(Note: you will need through2 package installed for the above to work out of the box.)
The tree can be built using the code from the --deps handler next to it , but all this code displays a list of JSON drops, each of which contains a list of other files on which it depends; you need to build a tree yourself.
source share