Is there a more appropriate way to set the languag

2020-07-23 06:06发布

问题:

I had to configure the language_in option in the closure compiler to ECMASCRIPT5 to compile the libs Ember, Angular and others it's require ES5... There must be a better way, but I implemented this way:

  // Build.scala

  val root = new java.io.File(".")
  val defaultOptions = new CompilerOptions()
  defaultOptions.closurePass = true
  defaultOptions.setProcessCommonJSModules(true)
  defaultOptions.setCommonJSModulePathPrefix(root.getCanonicalPath + "/app/assets/javascripts/")
  defaultOptions.setLanguageIn(CompilerOptions.LanguageMode.ECMASCRIPT5)

  CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(defaultOptions)

  val main = play.Project(appName, appVersion, appDependencies).settings(
    (Seq(requireJs += "main.js", requireJsShim += "main.js") ++ closureCompilerSettings(defaultOptions)): _*
  )

Is there a more appropriate way to do this?