scala-js/scala-js — pull request #334 by sjrd (2014-03-07 08:32:37+00:00)
Title: Future-proofing tests with preoptimizeJS and optimizeJS

This PR does not yet really add support for running unit tests with `preoptimizeJS` and `optimizeJS`. The problem is that Rhino will crash with files that are too large (in terms of generated bytecode, not in bytes), and for non-trivial codebases the results of `preoptimizeJS` and `optimizeJS` are already too large.

However, it basically works, and we are able to run unit tests for the `testing` example both with `preoptimizeJS` and `optimizeJS`, because that example is mostly trivial. The incantations to enable this are either one of:

```scala
set sources in (exampleTesting, Test, ScalaJSKeys.scalaJSEnvironment) :=
Seq((ScalaJSKeys.preoptimizeJS in (exampleTesting, Test)).value)
set sources in (exampleTesting, Test, ScalaJSKeys.scalaJSEnvironment) :=
Seq((ScalaJSKeys.optimizeJS in (exampleTesting, Test)).value)
```

(not both, they override each other)

So this PR future-proofs later support of out-of-the box unit testing with optimizations. In particular, further improvements should not require binary-incompatible changes, but only changes in the sbt plugin, so we'll be able to introduce that support in point releases.