Improve the algorithm to determine in which file a module should be

For example if module a is placed into bar.js, and a is the only module
that requires b, then b should also be placed in bar.js