4141import com .google .errorprone .annotations .CanIgnoreReturnValue ;
4242import com .google .errorprone .annotations .FormatMethod ;
4343import com .google .errorprone .annotations .MustBeClosed ;
44+ import com .google .gson .GsonBuilder ;
4445import com .google .javascript .jscomp .CodePrinter .LicenseTracker ;
4546import com .google .javascript .jscomp .CompilerInput .ModuleType ;
4647import com .google .javascript .jscomp .CompilerOptions .DevMode ;
@@ -497,13 +498,9 @@ public void printConfig() {
497498 if (this .isDebugLoggingEnabled ()) {
498499 // Log to separate files for convenience.
499500 logToFile ("externs.log" , externs ::toString );
500- // To get a pretty-printed JSON chunk graph, change the string generation expression to
501- //
502- // new GsonBuilder().setPrettyPrinting().create().toJson(chunkGraph.toJson())
503- //
504- // TODO(bradfordcsmith): Come up with a JSON-printing version that will work when this code is
505- // compiled with J2CL, so we can permanently improve this.
506- logToFile ("inputs.json" , () -> Iterables .toString (chunkGraph .getAllInputs ()));
501+ logToFile (
502+ "inputs.json" ,
503+ new GsonBuilder ().setPrettyPrinting ().create ().toJson (chunkGraph .toJson ())::toString );
507504 logToFile ("options.log" , () -> options .toString ());
508505 logToFile ("warningsGuard.log" , () -> warningsGuard .toString ());
509506 } else {
@@ -512,21 +509,22 @@ public void printConfig() {
512509 err .println ("==== Externs ====" );
513510 err .println (externs );
514511 err .println ("==== Inputs ====" );
515- // To get a pretty-printed JSON chunk graph, change this line to
516- //
517- // err.println(
518- // new GsonBuilder().setPrettyPrinting().create().toJson(chunkGraph.toJson()));
519- //
520- // TODO(bradfordcsmith): Come up with a JSON-printing version that will work when this code is
521- // compiled with J2CL, so we can permanently improve this.
522- err .println (Iterables .toString (chunkGraph .getAllInputs ()));
512+ err .println (new GsonBuilder ().setPrettyPrinting ().create ().toJson (chunkGraph .toJson ()));
523513 err .println ("==== CompilerOptions ====" );
524514 err .println (options );
525515 err .println ("==== WarningsGuard ====" );
526516 err .println (warningsGuard );
527517 }
528518 }
529519
520+ private void maybeLogPrunedInputs () {
521+ if (this .isDebugLoggingEnabled ()) {
522+ logToFile (
523+ "inputs_pruned.json" ,
524+ new GsonBuilder ().setPrettyPrinting ().create ().toJson (chunkGraph .toJson ())::toString );
525+ }
526+ }
527+
530528 private void logToFile (String logFileName , Supplier <String > logStringSupplier ) {
531529 try (LogFile log = this .createOrReopenLog (this .getClass (), logFileName )) {
532530 log .log (logStringSupplier );
@@ -2290,6 +2288,7 @@ void orderInputs() {
22902288 if (staleInputs ) {
22912289 repartitionInputs ();
22922290 }
2291+ maybeLogPrunedInputs ();
22932292 }
22942293
22952294 /**
0 commit comments