List<JSModule> modules = createClosureModules(program);
// Build the externs based on what we discovered building the modules.
List<JSSourceFile> externs = getClosureCompilerExterns();
Result result = compiler.compileModules(externs, modules, options);
if (result.success) {
int fragments = program.getFragmentCount();
for (int i = 0; i < fragments; i++) {
int module = mapFragmentIndexToModuleIndex(i);
js[i] = compiler.toSource(modules.get(module));