code: private static ChunkOutput writeOutput(Compiler compiler, Flags flags) {
      ArrayList<File> outputFiles = new ArrayList<>();
      ChunkOutput output = new ChunkOutput();
  
      File file = new File();
      file.path = flags.jsOutputFile;
  
      String code = compiler.toSource();
      String prefix = "";
      String postfix = "";
      if (flags.outputWrapper != null) {
        String marker = null;
        int pos = flags.outputWrapper.indexOf(OUTPUT_MARKER_JS_STRING);
        if (pos != -1) {
          // With jsstring, run SourceCodeEscapers (as per AbstractCommandLineRunner).
          code = SourceCodeEscapers.javascriptEscaper().escape(code);
          marker = OUTPUT_MARKER_JS_STRING;
        } else {
          pos = flags.outputWrapper.indexOf(OUTPUT_MARKER);
          if (pos != -1) {
            marker = OUTPUT_MARKER;
          }
        }
  
        if (marker != null) {
          prefix = flags.outputWrapper.substring(0, pos);
          SourceMap sourceMap = compiler.getSourceMap();
          if (sourceMap != null) {
            sourceMap.setWrapperPrefix(prefix);
          }
        }
        postfix = flags.outputWrapper.substring(pos + marker.length());
      }
      if (flags.createSourceMap != null && !flags.createSourceMap.equals(false)) {
        StringBuilder b = new StringBuilder();
        try {
          compiler.getSourceMap().appendTo(b, flags.jsOutputFile);
        } catch (IOException e) {
          // ignore
        }
        file.sourceMap = b.toString();
      }
  
      file.src = prefix + code + postfix;
      outputFiles.add(file);
      output.compiledFiles = outputFiles.toArray(new File[0]);
      output.compiledCode = file.src;
      output.sourceMap = file.sourceMap;
      return output;
    }
docs: Generates the output code, taking into account the passed {@code flags}.