Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Scala.js module config docs #1938

Merged
merged 4 commits into from
Jul 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions docs/antora/modules/ROOT/pages/Common_Project_Layouts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,16 @@ version lives in `src-x.y`.
----
import mill._
import mill.scalajslib._
import mill.scalajslib.api._

object foo extends ScalaJSModule {
def scalaVersion = "2.12.4"
def scalaJSVersion = "0.6.22"
def scalaVersion = "2.13.8"
def scalaJSVersion = "1.10.1"
def ivyDeps = Agg(ivy"org.scala-js::scalajs-dom::2.2.0")
carlosedp marked this conversation as resolved.
Show resolved Hide resolved

object test extends Tests with TestModule.Utest {
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.8.0")
}
}
----

Expand All @@ -103,6 +109,11 @@ latter of which runs your code on Node.js, which must be pre-installed)
`ScalaJSModule` also exposes the `foo.fastOpt` and `foo.fullOpt` tasks for
generating the optimized Javascript file.

ScalaJSModule requires declaring it's dependencies as third party
libraries (don't forget to use double-colons `::` between the library name and the version for Scala.js dependencies).

If you are following the https://www.scala-js.org/doc/tutorial/basic/[Scala.js Tutorial], in the section where you test the code, it's mentioned that you need to make the DOM available to Node.js. Install the `jsdom` node library as instructed then add `def jsEnvConfig = T(JsEnvConfig.JsDom())` to your `build.sc` object. In Scala 3, the "scalajs-env-jsdom-nodejs" mentioned in the tutorial is no longer required.

== Scala Native Modules

.`build.sc`
Expand Down Expand Up @@ -402,4 +413,4 @@ A relatively complex build with numerous submodules, some cross-built across
Scala major versions while others are cross-built against Scala minor versions.

Also demonstrates how to pass one module's compiled artifacts to the
`run`/`test` commands of another, via their `forkEnv`.
`run`/`test` commands of another, via their `forkEnv`.