use of com.google.javascript.jscomp.JSChunkGraph.ChunkDependenceException in project closure-compiler by google.
the class Compiler method initModules.
/**
* Initializes the instance state needed for a compile job if the sources are in modules.
*/
public void initModules(List<SourceFile> externs, List<JSChunk> modules, CompilerOptions options) {
initOptions(options);
checkFirstModule(modules);
this.externs.clear();
for (SourceFile file : externs) {
this.externs.add(new CompilerInput(file, /* isExtern */
true));
}
// Generate the module graph, and report any errors in the module specification as errors.
try {
this.moduleGraph = new JSChunkGraph(modules);
} catch (ChunkDependenceException e) {
// problems with the module format. Report as an error. The
// message gives all details.
report(JSError.make(MODULE_DEPENDENCY_ERROR, e.getChunk().getName(), e.getDependentChunk().getName()));
return;
}
// Creating the module graph can move weak source around, and end up with empty modules.
fillEmptyModules(getModules());
this.commentsPerFile = new ConcurrentHashMap<>(moduleGraph.getInputCount());
initBasedOnOptions();
initInputsByIdMap();
initAST();
// `dot -Tpng graph_file.dot > graph_file.png` will render an image.
try (LogFile moduleGraphLog = createOrReopenLog(this.getClass(), "chunk_graph.dot")) {
moduleGraphLog.log(DotFormatter.toDot(moduleGraph.toGraphvizGraph()));
}
}
Aggregations