Skip to content

Commit 43ce9a1

Browse files
committed
Announcing Scala.js 0.6.20.
1 parent 4f63abe commit 43ce9a1

File tree

9 files changed

+239
-27
lines changed

9 files changed

+239
-27
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ colors: #in hex code if not noted else
5757

5858
### VERSIONS ###
5959
versions:
60-
scalaJS: 0.6.19
60+
scalaJS: 0.6.20
6161
scalaJSBinary: 0.6
6262
scalaJSDev: 1.0.0-M1
6363
scalaJSDevBinary: 1.0.0-M1
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 0.6.20
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2017/09/01/announcing-scalajs-0.6.20/
7+
---
8+
9+
10+
We are pleased to announce the release of Scala.js 0.6.20!
11+
12+
This release is mostly intended to bridge the gap between the 0.6.x and 1.x branches, to make it easier to cross-compile and/or migrate.
13+
14+
Read on for more details.
15+
16+
<!--more-->
17+
18+
## Getting started
19+
20+
If you are new to Scala.js, head over to
21+
[the tutorial]({{ BASE_PATH }}/tutorial/).
22+
23+
## Release notes
24+
25+
If upgrading from Scala.js 0.6.14 or earlier, make sure to read [the release notes of 0.6.15]({{ BASE_PATH }}/news/2017/03/21/announcing-scalajs-0.6.15/), which contain important migration information.
26+
27+
As a minor release, 0.6.20 is backward source and binary compatible with previous releases in the 0.6.x series.
28+
Libraries compiled with earlier versions can be used with 0.6.20 without change.
29+
0.6.20 is also forward binary compatible with 0.6.{17-19}, but not with earlier releases: libraries compiled with 0.6.20 cannot be used by projects using 0.6.{0-16}.
30+
31+
Please report any issues [on GitHub](https://github.com/scala-js/scala-js/issues).
32+
33+
## Breaking changes
34+
35+
### sbt 0.13.16 or above is required (or sbt 1.x)
36+
37+
The sbt plugin of Scala.js 0.6.20 starts using features of sbt 0.13.16.
38+
If you are using an older version of sbt 0.13.x, you will have to upgrade to 0.13.16 or later.
39+
40+
Since 0.6.19, Scala.js also supports sbt 1.0.0+.
41+
42+
### `scalajs-env-selenium` has to be upgraded to 0.2.0
43+
44+
Scala.js 0.6.20 contains internal changes to improve the so-called test adapter, which is the mechanism used by sbt to communicate with testing frameworks.
45+
These changes are invisible to you, but they broke [`scalajs-env-selenium`](https://github.com/scala-js/scala-js-env-selenium) 0.1.x.
46+
If you use it, you will have to upgrade it to 0.2.0.
47+
48+
## Deprecations
49+
50+
Scala.js 0.6.20 introduces more aggressive deprecations for features that will disappear in 1.x.
51+
Note that those features have already had better replacements since Scala.js 0.6.18; we are just making it more obvious that these new features should be used to be compatible with 1.x.
52+
53+
### `@ScalaJSDefined`
54+
55+
This annotation is now deprecated.
56+
Instead of using it, you should add the following to your project settings:
57+
58+
{% highlight scala %}
59+
scalacOptions += "-P:scalajs:sjsDefinedByDefault"
60+
{% endhighlight %}
61+
62+
and remove the `@ScalaJSDefined` annotations everywhere in your codebase.
63+
The semantics of your codebase will be unchanged.
64+
65+
### `js.JSApp`
66+
67+
`js.JSApp` has traditionally provided two services to an `object Foo` that extends it.
68+
These two services are replaced by two different features.
69+
70+
#### Discoverability by sbt as main object
71+
72+
Since Scala.js 0.6.18, the sbt plugin can recognize "standard" `main` methods of the form
73+
74+
{% highlight scala %}
75+
def main(args: Array[String]): Unit = ...
76+
{% endhighlight %}
77+
78+
in objects, even if they do not extend `js.JSApp`.
79+
Use such a main method to replace `js.JSApp` in the context of discoverability by sbt.
80+
81+
To enable it as main method, make sure you also set
82+
83+
{% highlight scala %}
84+
scalaJSUseMainModuleInitializer := true
85+
{% endhighlight %}
86+
87+
in your project settings.
88+
89+
#### Automatic export to JavaScript
90+
91+
Given
92+
93+
{% highlight scala %}
94+
package bar
95+
96+
object Foo extends js.JSApp {
97+
def main(): Unit = println("Hello world!")
98+
}
99+
{% endhighlight %}
100+
101+
the object `Foo` and its `main` method are automatically exported such that JavaScript code can call
102+
103+
{% highlight javascript %}
104+
bar.Foo().main();
105+
{% endhighlight %}
106+
107+
To achieve exactly the same behavior without `js.JSApp`, define `Foo` as
108+
109+
{% highlight scala %}
110+
package bar
111+
112+
object Foo {
113+
@JSExportTopLevel("bar.Foo")
114+
protected def getInstance(): this.type = this
115+
116+
@JSExport
117+
def main(): Unit = println("Hello world!")
118+
}
119+
{% endhighlight %}
120+
121+
Alternatively, you can define it as
122+
123+
{% highlight scala %}
124+
package bar
125+
126+
object Foo {
127+
@JSExportTopLevel("bar.Foo.main")
128+
def main(): Unit = println("Hello world!")
129+
}
130+
{% endhighlight %}
131+
132+
but in that case, the JavaScript code will have to be changed to
133+
134+
{% highlight javascript %}
135+
bar.Foo.main();
136+
{% endhighlight %}
137+
138+
### `jsDependencies += RuntimeDOM` and `requiresDOM := true`
139+
140+
These settings will not be supported by [`sbt-jsdependencies`](https://github.com/scala-js/jsdependencies) 1.x, the new home of `jsDependencies` and related features.
141+
142+
Instead of relying on them to configure a JS environment equipped with the DOM, you should explicitly do so.
143+
For example, to use Node.js with jsdom, use:
144+
145+
{% highlight scala %}
146+
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()
147+
{% endhighlight %}
148+
149+
## New features
150+
151+
### Improved support for cross-compilation with 1.x and `jsDependencies`
152+
153+
[The release notes of Scala.js 1.0.0-M1]({{ BASE_PATH }}/news/2017/07/03/announcing-scalajs-1.0.0-M1/) detail how to cross-compile between 0.6.x and 1.x.
154+
One aspect of it was particularly painful: handling the new `JSDependenciesPlugin`.
155+
Scala.js 0.6.20 makes this easier by introducing a shim of `JSDependenciesPlugin` inside sbt-scalajs.
156+
It is now sufficient to add the following to your `project/plugins.sbt`:
157+
158+
{% highlight scala %}
159+
// For jsDependencies
160+
{
161+
if (scalaJSVersion.startsWith("0.6.")) Nil
162+
else Seq(addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.0-M1"))
163+
}
164+
{% endhighlight %}
165+
166+
and add `enablePlugins(JSDependenciesPlugin)` to the projects that require it.
167+
There is no need for the hacky `project/JSDependenciesCompat.scala` anymore.
168+
169+
### JDK APIs
170+
171+
The following JDK API class has been added:
172+
173+
* `java.util.SplittableRandom`
174+
175+
## Bug fixes
176+
177+
The following bugs have been fixed in 0.6.20:
178+
179+
* [#3107](https://github.com/scala-js/scala-js/issues/3107) `ByteArrayOutputStream` (and in general all `Closeable`s) should be an `AutoCloseable`
180+
* [#3082](https://github.com/scala-js/scala-js/issues/3082) Incorrect handling of main generates broken code
181+
182+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av0.6.20+is%3Aclosed).

doc/all-api.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ title: All previous versions of the Scala.js API
55

66
## All previous versions of the API
77

8+
### Scala.js 0.6.20
9+
* [0.6.20 scalajs-library]({{ site.production_url }}/api/scalajs-library/0.6.20/#scala.scalajs.js.package)
10+
* [0.6.20 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/0.6.20/)
11+
* [0.6.20 scalajs-stubs]({{ site.production_url }}/api/scalajs-stubs/0.6.20/)
12+
* [0.6.20 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/0.6.20/#org.scalajs.core.ir.package)
13+
* [0.6.20 scalajs-tools]({{ site.production_url }}/api/scalajs-tools/0.6.20/#org.scalajs.core.tools.package) ([Scala.js version]({{ site.production_url }}/api/scalajs-tools-js/0.6.20/#org.scalajs.core.tools.package))
14+
* [0.6.20 scalajs-js-envs]({{ site.production_url }}/api/scalajs-js-envs/0.6.20/#org.scalajs.jsenv.package)
15+
* [0.6.20 scalajs-js-envs-test-kit]({{ site.production_url }}/api/scalajs-js-envs-test-kit/0.6.20/#org.scalajs.jsenv.test.package)
16+
* [0.6.20 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/0.6.20/#org.scalajs.testadapter.package)
17+
* [0.6.20 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/0.6.20/#org.scalajs.sbtplugin.package)
18+
819
### Scala.js 0.6.19
920
* [0.6.19 scalajs-library]({{ site.production_url }}/api/scalajs-library/0.6.19/#scala.scalajs.js.package)
1021
* [0.6.19 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/0.6.19/)

doc/internals/downloads.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ We strongly recommend using the SBT plugin, as shown in the [bootstrapping skele
77

88
The CLI distribution requires `scala` and `scalac` (of the right major version) to be on the execution path. Unpack it wherever you like and add the `bin/` folder to your execution path.
99

10+
#### Scala.js 0.6.20
11+
* [0.6.20, Scala 2.12 (tgz, 17MB)]({{ site.production_url }}/files/scalajs_2.12-0.6.20.tgz)
12+
* [0.6.20, Scala 2.12 (zip, 17MB)]({{ site.production_url }}/files/scalajs_2.12-0.6.20.zip)
13+
* [0.6.20, Scala 2.11 (tgz, 29MB)]({{ site.production_url }}/files/scalajs_2.11-0.6.20.tgz)
14+
* [0.6.20, Scala 2.11 (zip, 29MB)]({{ site.production_url }}/files/scalajs_2.11-0.6.20.zip)
15+
* [0.6.20, Scala 2.10 (tgz, 23MB)]({{ site.production_url }}/files/scalajs_2.10-0.6.20.tgz)
16+
* [0.6.20, Scala 2.10 (zip, 23MB)]({{ site.production_url }}/files/scalajs_2.10-0.6.20.zip)
17+
1018
#### Scala.js 0.6.19
1119
* [0.6.19, Scala 2.12 (tgz, 16MB)]({{ site.production_url }}/files/scalajs_2.12-0.6.19.tgz)
1220
* [0.6.19, Scala 2.12 (zip, 16MB)]({{ site.production_url }}/files/scalajs_2.12-0.6.19.zip)

doc/internals/version-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Version history
55

66
## Version history of Scala.js
77

8+
- [0.6.20](/news/2017/09/01/announcing-scalajs-0.6.20/)
89
- [0.6.19](/news/2017/07/29/announcing-scalajs-0.6.19/)
910
- [1.0.0-M1](/news/2017/07/03/announcing-scalajs-1.0.0-M1/)
1011
- [0.6.18](/news/2017/06/28/announcing-scalajs-0.6.18/)

doc/project/building.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ Now, the .js file produced by `fastOptJS` will print `"Hello world!"`.
4444
Note that this will require that there is a *unique* such object or that the one to use be explicitly set with `mainClass in Compile := Some(<name>)`.
4545
If you explicitly set `mainClass`, note that it needs to be set on a per-configuration basis (i.e. the part `in Compile` is essential, otherwise the setting will be ignored). For further information see the Stack Overflow entry ['How to set mainClass in ScalaJS build.sbt?'](http://stackoverflow.com/questions/34965072/how-to-set-mainclass-in-scalajs-build-sbt) (specific to Scala.js) and the Stack Overflow entry ['How to set main class in build?'](http://stackoverflow.com/questions/6467423/how-to-set-main-class-in-build) (not specific to Scala.js).
4646

47-
**Note for Scala.js 0.6.17 and earlier:** in Scala.js 0.6.17 and earlier, the main object was required to extend the special trait [`js.JSApp`]({{ site.production_url }}/api/scalajs-library/0.6.18/#scala.scalajs.js.JSApp).
47+
**Note for Scala.js 0.6.17 and earlier:** in Scala.js 0.6.17 and earlier, the main object was required to extend the special trait [`js.JSApp`]({{ site.production_url }}/api/scalajs-library/0.6.20/#scala.scalajs.js.JSApp).
4848
Since 0.6.18, any object with a standard `main` method will be recognized.
49-
`js.JSApp` is not recommended for new code.
49+
`js.JSApp` is now deprecated.
50+
See [the Scaladoc of `js.JSApp`]({{ site.production_url }}/api/scalajs-library/0.6.20/#scala.scalajs.js.JSApp) for migration tips.
5051

5152
## Running in the console
5253

@@ -58,7 +59,7 @@ This will run the `-fastopt.js` file right inside of your sbt console.
5859
By default, the file is run with [Node.js](http://nodejs.org/), which you need to install separately.
5960

6061
**Scala.js 0.6.x only:** If your application or one of its libraries requires a DOM (which can be specified with `jsDependencies += RuntimeDOM`), you will also need to install [`jsdom`](https://github.com/tmpvar/jsdom) with `npm install jsdom`.
61-
`jsDependencies += RuntimeDOM` is not recommended for new code, and should be replaced by `jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()`.
62+
`jsDependencies += RuntimeDOM` is now deprecated, and should be replaced by `jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()`.
6263

6364
There are alternative JavaScript interpreters that are available.
6465
See [JavaScript environments](./js-environments.html) for more details.

doc/project/js-environments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.0.0-M1"
4646
{% endhighlight %}
4747

4848
**Scala.js 0.6.x:** This environment is selected by default if your application or one of its libraries declares a dependency on the DOM, with `jsDependencies += RuntimeDOM`.
49+
Note that this is deprecated, so you should use `jsEnv := ...` anyway.
4950

5051
## PhantomJS
5152

doc/project/testing.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Testing
44
---
55

66
In this section we will discuss how to test Scala.js code managed as [Full cross project](./cross-build.html). All names
7-
for example subproject name such as `fooJVM` are taken from
7+
for example subproject name such as `fooJVM` are taken from
88
[cross compile example](https://github.com/scala-js/scalajs-cross-compile-example).
99

1010
## Directory Structure
@@ -30,28 +30,39 @@ parts, so when calling `sbt> test` will effectively run both `fooJVM/test` and `
3030

3131
## Integration testing
3232

33-
Configuring a regular non-Scala.js sbt project to have `it:test` is a well described task, see
34-
[documentation](http://www.scala-sbt.org/0.13/docs/Testing.html#Integration+Tests) for more details.
35-
In a `CrossProject` it won't work out-of-the-box because of 2 reasons. First reason is that by default Scala JVM and
36-
Scala.js `it` configurations won't be aware of `shared/src/it/scala` folder. Second is that Scala.js `it` configuration
37-
by default does not contain `ScalaJSClassLoader` definition required for running Scala.js tests. To fix that you need to
38-
add the following settings to the crossProject definition along with `IntegrationTest` settings:
33+
Configuring a regular non-Scala.js sbt project to have `it:test` is
34+
[documented in sbt](http://www.scala-sbt.org/0.13/docs/Testing.html#Integration+Tests).
35+
For a Scala.js project, you will also need to install the Scala.js-specific settings and tasks to the `it` configuration, as follows:
3936

4037
{% highlight scala %}
41-
lazy val cross = crossProject.in(file(".")).
38+
lazy val myProject = project.in(file(".")).
39+
enablePlugins(ScalaJSPlugin).
40+
// add the `it` configuration
41+
configs(IntegrationTest).
42+
// add `it` tasks
43+
settings(Defaults.itSettings: _*).
44+
// add Scala.js-specific settings and tasks to the `it` configuration
45+
settings(inConfig(IntegrationTest)(ScalaJSPlugin.testConfigSettings): _*).
4246
...
43-
// adding the `it` configuration
47+
{% endhighlight %}
48+
49+
For a `crossProject`, you also need to setup the `shared/src/it/scala` source directory.
50+
The complete setup is as follows:
51+
52+
{% highlight scala %}
53+
lazy val cross = crossProject.in(file(".")).
54+
// add the `it` configuration
4455
configs(IntegrationTest).
45-
// adding `it` tasks
46-
settings(Defaults.itSettings:_*).
47-
// add `shared` folder to `jvm` source directories
48-
jvmSettings(unmanagedSourceDirectories in IntegrationTest ++=
49-
CrossType.Full.sharedSrcDir(baseDirectory.value, "it").toSeq).
50-
// add `shared` folder to `js` source directories
51-
jsSettings(unmanagedSourceDirectories in IntegrationTest ++=
52-
CrossType.Full.sharedSrcDir(baseDirectory.value, "it").toSeq).
53-
// adding ScalaJSClassLoader to `js` configuration
54-
jsSettings(inConfig(IntegrationTest)(ScalaJSPluginInternal.scalaJSTestSettings):_*)
56+
// add `it` tasks
57+
settings(Defaults.itSettings: _*).
58+
// add Scala.js-specific settings and tasks to the `it` configuration
59+
jsSettings(inConfig(IntegrationTest)(ScalaJSPlugin.testConfigSettings): _*).
60+
// add the `shared` folder to source directories
61+
settings(
62+
unmanagedSourceDirectories in IntegrationTest ++=
63+
CrossType.Full.sharedSrcDir(baseDirectory.value, "it").toSeq
64+
).
65+
...
5566
{% endhighlight %}
5667

5768
Now you can put tests in `{shared|jvm|js}/src/it/scala` and they will run when you call `sbt> it:test`. Similarly to

tutorial/basic/index.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ What basically happens here is that jQuery (which is automatically included beca
379379
To make the DOM available, add the following to your `build.sbt`:
380380

381381
{% highlight scala %}
382-
jsDependencies += RuntimeDOM
382+
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()
383383
{% endhighlight %}
384384

385385
This will use the [`jsdom`](https://github.com/tmpvar/jsdom) library to simulate a DOM in Node.js.
@@ -393,9 +393,6 @@ After reloading, you can invoke `run` successfully:
393393
[info] Running tutorial.webapp.TutorialApp
394394
[success] (...)
395395

396-
Just like other library dependencies, `jsDependencies += RuntimeDOM` applies transitively: if you depend on a library that depends on the
397-
DOM, then you depend on the DOM as well.
398-
399396
Alternatively to Node.js with jsdom, you can use [PhantomJS](http://phantomjs.org/) or even [Selenium](http://docs.seleniumhq.org/).
400397
You can find more information about this in the [documentation about JavaScript environments]({{ BASE_PATH }}/doc/project/js-environments.html).
401398

0 commit comments

Comments
 (0)