<commit_before>package com.programmaticallyspeaking.ncd.javascript

import com.google.javascript.jscomp.CompilerOptions.LanguageMode
import com.google.javascript.jscomp.{CompilationLevel, Compiler, CompilerOptions, PropertyRenamingPolicy, SourceFile, VariableRenamingPolicy}

object Minifier {

  def minify(code: String): String = {
    val compiler = new Compiler

    val options = new CompilerOptions

//    options.setQuoteKeywordProperties(true)
//    options.setSkipNonTranspilationPasses(true)
//    options.setVariableRenaming(VariableRenamingPolicy.OFF)
//    options.setPropertyRenaming(PropertyRenamingPolicy.OFF)
//    options.setWrapGoogModulesForWhitespaceOnly(false)
//    options.setPrettyPrint(false)
//    options.setSourceMapOutputPath("/dev/null")
//    options.setSourceMapIncludeSourcesContent(true)
//    //    options.setWarningLevel(ES5_WARNINGS, CheckLevel.OFF)
//    options.setForceLibraryInjection(Iterable("mini_es6_runtime").asJava)

    CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options)

    // Due to transpilation, we shouldn't need any externs.
    val extern = SourceFile.fromCode("externs.js", "")

//    // Wrap the input so that we can read the expression result.
//    var extendedInput = s"var __ncdbg_retval = ($input);"

    // Errors will be reported for input.js
    val inputFile = SourceFile.fromCode("input.js", code)

    // compile() returns a Result, but it is not needed here.
    compiler.compile(extern, inputFile, options)

    // The surrounding IIFE sets 'this' to an anonymous object, so that polyfills (e.g. Symbol) don't pollute the
    // global object. The 'with' statement allows Symbol to be used as a free variable in the generated code.
//    val src = compiler.toSource
//    val output =
//      s"""
//         |(function() {with(this) {
//         |$src
//         |return __ncdbg_retval;
//         |}}).call({})
//         """.stripMargin
//    output
    compiler.toSource()
  }
}<commit_msg>Remove commented-out code in Minifier<commit_after>package com.programmaticallyspeaking.ncd.javascript

import com.google.javascript.jscomp.{CompilationLevel, Compiler, CompilerOptions, SourceFile}

object Minifier {

  def minify(code: String): String = {
    val compiler = new Compiler

    val options = new CompilerOptions

    CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options)

    // Due to transpilation, we shouldn't need any externs.
    val extern = SourceFile.fromCode("externs.js", "")

    // Errors will be reported for input.js
    val inputFile = SourceFile.fromCode("input.js", code)

    // compile() returns a Result, but it is not needed here.
    compiler.compile(extern, inputFile, options)

    compiler.toSource()
  }
}
{'fraction_non_alphanumeric': 0.10600578871201158, 'fraction_numerical': 0.000723589001447178, 'mean_word_length': 3.6864406779661016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '420609', 'n_tokens_mistral': 829, 'n_tokens_neox': 789, 'n_words': 198}