sbt-dynscalajs icon indicating copy to clipboard operation
sbt-dynscalajs copied to clipboard

Add a friendly API to customize the `scalaJSLinkerConfig`

Open sjrd opened this issue 8 years ago • 0 comments

scalaJSLinkerConfig describes the configuration of the Scala.js linker. In sbt-scalajs, this a setting of type StandardLinker.Config, which is easily manipulatable. In sbt-dynscalajs, however, it is an Any, because it needs to be an instance of the StandardLinker.Config loaded from the ClassLoader in dynScalaJSClassLoader. This makes it very hard to manipulate, as can be seen here.

This could be improved using one of two approaches:

  • either give it a named abstract type, and pimp the API of StandardLinker.Config on it using an implicit class, whose implementations would perform the necessary reflection,
  • or give scalaJSLinkerConfig the static type StandardLinker.Config of the tools loaded in the classpath of sbt, and convert that to a Config from the class loader in the definition of scalaJSLinker.

The latter might be more pretty, but ties this sbt plugin to forever statically depend on the Scala.js linker artifacts, even if/when in the future that artifact will be decoupled from the js-envs artifacts.

sjrd avatar Sep 25 '17 21:09 sjrd