Skip to content

Misc improvements #61

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

Merged
merged 3 commits into from
Jul 9, 2014
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ author :
twitter : sjrdoeraene
feedburner : feedname

scalaJSVersion: 0.5.1
scalaJSBinaryVersion: 0.5

# The production_url is only used when full-domain names are needed
# such as sitemap.txt
# Most places will/should use BASE_PATH to make the urls
Expand Down
2 changes: 1 addition & 1 deletion doc/sbt/cross-building.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Starting from sbt 0.13, you can write a multi-project build in a `.sbt` file. Th
You now have separate projects to compile towards Scala.js and Scala JVM. Note the same name given to both projects, this allows them to be published with corresponding artifact names:

- `foo_2.10-0.1-SNAPSHOT.jar`
- `foo_sjs0.5.0-RC2_2.10-0.1-SNAPSHOT.jar`
- `foo_sjs{{ site.scalaJSBinaryVersion }}_2.10-0.1-SNAPSHOT.jar`

If you do not publish the artifacts, you may choose different names for the projects.

Expand Down
6 changes: 5 additions & 1 deletion doc/sbt/depending.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ This will fetch the required JAR containing jQuery. However, it will not include

The Scala.js sbt plugin has `jsDependencies` for this purpose. You can write:

ScalaJSKeys.jsDependencies += "org.webjars" % "jquery" % "1.10.2" / "jquery.js"

or, with `import ScalaJSKeys._`:

jsDependencies += "org.webjars" % "jquery" % "1.10.2" / "jquery.js"

This will make your project depend on the respective WebJar and include a file named `jquery.js` in the said WebJar when your project is run or tested. We are trying to make the semantics of "include" to be as close as possible to writing:
Expand Down Expand Up @@ -62,6 +66,6 @@ This will look for `myJSLibrary.js` in the resources and include it. It is an er

If you want all JavaScript dependencies to be concatenated to a single file (for easy inclusion into a HTML file for example), you can set:

skip in packageJSDependencies := false
skip in ScalaJSKeys.packageJSDependencies := false

in your project settings. The resulting file in the target folder will have the suffix `-jsdeps.js`.
8 changes: 4 additions & 4 deletions doc/sbt/js-envs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ title: JavaScript Environments

In order to decide how to run JavaScript code, the Scala.js sbt plugin uses the following two setting keys:

- `preLinkJSEnv` the JavaScript Environment (i.e. virtual machine) used to run unlinked `.sjsir` files (defaults to Rhino)
- `postLinkJSEnv` the JavaScript Environment used to run linked JavaScript (defaults to Node.js if DOM is not required, otherwise PhantomJS)
- `ScalaJSKeys.preLinkJSEnv` the JavaScript Environment (i.e. virtual machine) used to run unlinked `.sjsir` files (defaults to Rhino)
- `ScalaJSKeys.postLinkJSEnv` the JavaScript Environment used to run linked JavaScript (defaults to Node.js if DOM is not required, otherwise PhantomJS)

You may change these environments at your discretion. However, note that running Rhino on linked JavaScript and Node.js or PhantomJS on unlinked JavaScript is unlikely to work or at least slow.

For example, to switch to PhantomJS, you can set:

postLinkJSEnv := new scala.scalajs.sbtplugin.env.phantomjs.PhantomJSEnv
ScalaJSKeys.postLinkJSEnv := new scala.scalajs.sbtplugin.env.phantomjs.PhantomJSEnv

We'd like to stress here again, that you need to separately install Node.js and PhantomJS if you would like to use these environments.

Expand All @@ -25,5 +25,5 @@ You have two options to solve this:
1. Install [nodejs-legacy](http://packages.ubuntu.com/utopic/nodejs-legacy) which will add an alias called `node`
2. Explicitly tell the Node.js environment the name of the command:

postLinkJSEnv := new scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv("nodejs")
ScalaJSKeys.postLinkJSEnv := new scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv("nodejs")

6 changes: 3 additions & 3 deletions doc/sbt/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ You now can run your application already by using the `run` task:

sbt> run

This will detect and run classes that extend `scala.scalajs.js.JSApp`, while optionally prompting the user to choose a class if multiple such classes exist (fails with multiple classes if `persistLauncher := true`, see section below for details).
This will detect and run classes that extend `scala.scalajs.js.JSApp`, while optionally prompting the user to choose a class if multiple such classes exist (fails with multiple classes if `ScalaJSKeys.persistLauncher := true`, see section below for details).

To run the `.sjsir` files, we invoke the Rhino JavaScript interpreter with a special scope that lazily reads and loads required `.sjsir` files on the fly (much like Java class loading). Note that by default, this environment doesn't have a DOM. If you need it set `requiresDOM := true` in your settings.
To run the `.sjsir` files, we invoke the Rhino JavaScript interpreter with a special scope that lazily reads and loads required `.sjsir` files on the fly (much like Java class loading). Note that by default, this environment doesn't have a DOM. If you need it set `ScalaJSKeys.requiresDOM := true` in your settings.

## Fast-Optimize

Expand Down Expand Up @@ -51,4 +51,4 @@ The same stage commands can be applied to the command `test` (have a look at the

## Writing Launcher Code

If you want the code which is used to run the main class to be written to a file, you can set `persistLauncher := true`. Note that this will require your main class to be either unique or explicitly set (`mainClass := Some(<name>)`). The resulting file in the target folder will have the suffix `-launcher.js`.
If you want the code which is used to run the main class to be written to a file, you can set `ScalaJSKeys.persistLauncher := true`. Note that this will require your main class to be either unique or explicitly set (`mainClass := Some(<name>)`). The resulting file in the target folder will have the suffix `-launcher.js`.
11 changes: 7 additions & 4 deletions doc/sbt/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ title: Scala.js sbt Setup

Load the sbt plugin (`project/plugins.sbt`)

addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.0")
addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "{{ site.scalaJSVersion }}")

Add Scala.js settings (`build.sbt`):

scalaJSSettings

There is also a list of settings that doesn't change the `run` and `test` tasks (`build.sbt`):
If you are using a `Build.scala` definition, import the following:

scalaJSBuildSettings
import scala.scalajs.sbtplugin.ScalaJSPlugin._

Note that `scalaJSSettings` contains all these settings, so don't use both of them.
Either way, you might want to add the following import for some of the keys
specific to Scala.js to be available in the scope of your build:

import ScalaJSKeys._
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To setup Scala.js in a new sbt project, we need to do two things:

Adding the Scala.js sbt plugin is a one-liner in `project/plugins.sbt` (all file names we write in this tutorial are relative to the project root):

addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.1")
addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "{{ site.scalaJSVersion }}")

We also setup basic project settings and Scala.js settings in the sbt build file (`build.sbt`, in the project root directory):

Expand Down