code: @GwtIncompatible("com.google.gson")
    JsonArray toJson() {
      JsonArray modules = new JsonArray();
      for (JSModule module : getAllModules()) {
        JsonObject node = new JsonObject();
          node.add("name", new JsonPrimitive(module.getName()));
          JsonArray deps = new JsonArray();
          node.add("dependencies", deps);
          for (JSModule m : module.getDependencies()) {
            deps.add(new JsonPrimitive(m.getName()));
          }
          JsonArray transitiveDeps = new JsonArray();
          node.add("transitive-dependencies", transitiveDeps);
          for (JSModule m : getTransitiveDepsDeepestFirst(module)) {
            transitiveDeps.add(new JsonPrimitive(m.getName()));
          }
          JsonArray inputs = new JsonArray();
          node.add("inputs", inputs);
          for (CompilerInput input : module.getInputs()) {
            inputs.add(new JsonPrimitive(
                input.getSourceFile().getOriginalPath()));
          }
          modules.add(node);
      }
      return modules;
    }
docs: Returns a JSON representation of the JSModuleGraph. Specifically a
  JsonArray of "Modules" where each module has a
  - "name"
  - "dependencies" (list of module names)
  - "transitive-dependencies" (list of module names, deepest first)
  - "inputs" (list of file names)
  @return List of module JSONObjects.