Skip to content

Commit 4ef059b

Browse files
authored
Merge pull request #539 from sjrd/scalajs-1.5.0
Announcing Scala.js 1.5.0.
2 parents ee152d3 + e89eac5 commit 4ef059b

File tree

6 files changed

+155
-1
lines changed

6 files changed

+155
-1
lines changed

_config.yml

+1-1
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: 1.4.0
60+
scalaJS: 1.5.0
6161
scalaJSBinary: 1
6262
scalaJS06x: 0.6.33
6363
scalaJS06xBinary: 0.6

_data/library/versions.yml

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
- 1.2.0
2626
- 1.3.0
2727
- 1.4.0
28+
- 1.5.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 1.5.0
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2021/02/12/announcing-scalajs-1.5.0/
7+
---
8+
9+
10+
We are excited to announce the release of Scala.js 1.5.0!
11+
12+
This is mostly a bugfix release, including fixes for some important bugs related to dynamic module loading, which was introduced in 1.4.0.
13+
14+
The main non-bug fix improvement is the introduction of custom JS function types.
15+
It is now possible to declare custom subtraits of `js.Function` with arbitrary `apply` signatures.
16+
Notably, this allows to declare types for JS functions with varargs.
17+
18+
Scala.js 1.5.0 adds support for the imminent Scala 2.13.5.
19+
**Previous versions of Scala.js, including Scala.js 0.6.x, will not work with Scala 2.13.5+.**
20+
21+
Finally, due to [the announcement by JFrog to discontinue Bintray](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/), we are now publishing the `sbt-scalajs` sbt plugin to Maven Central, like all our other artifacts.
22+
Discussions are in progress with key actors of the Scala ecosystem about how to preserve all the previously published sbt plugins (sbt-scalajs being just one of many).
23+
24+
Read on for more details.
25+
26+
<!--more-->
27+
28+
## Getting started
29+
30+
If you are new to Scala.js, head over to [the tutorial]({{ BASE_PATH }}/tutorial/).
31+
32+
If you need help with anything related to Scala.js, you may find our community [on Gitter](https://gitter.im/scala-js/scala-js) and [on Stack Overflow](https://stackoverflow.com/questions/tagged/scala.js).
33+
34+
Bug reports can be filed [on GitHub](https://github.com/scala-js/scala-js/issues).
35+
36+
## Release notes
37+
38+
If upgrading from Scala.js 0.6.x, make sure to read [the release notes of Scala.js 1.0.0]({{ BASE_PATH }}/news/2020/02/25/announcing-scalajs-1.0.0/) first, as they contain a host of important information, including breaking changes.
39+
40+
This is a **minor** release:
41+
42+
* It is backward binary compatible with all earlier versions in the 1.x series: libraries compiled with 1.0.x through 1.4.x can be used with 1.5.0 without change.
43+
* It is *not* forward binary compatible with 1.4.x: libraries compiled with 1.5.0 cannot be used with 1.4.x or earlier.
44+
* It is *not* entirely backward source compatible: it is not guaranteed that a codebase will compile *as is* when upgrading from 1.4.x (in particular in the presence of `-Xfatal-warnings`).
45+
46+
As a reminder, libraries compiled with 0.6.x cannot be used with Scala.js 1.x; they must be republished with 1.x first.
47+
48+
## Fixes with compatibility concerns
49+
50+
### Inner classes and objects in non-native JS traits
51+
52+
Until Scala.js 1.4.x, the compiler allowed the declaration of inner classes and objects in non-native JS traits, as in
53+
54+
{% highlight scala %}
55+
trait Outer extends js.Object {
56+
object InnerObject extends js.Object
57+
58+
class InnerClass extends js.Object
59+
}
60+
{% endhighlight %}
61+
62+
While the above definition would be allowed by the compiler, any attempt to actually extend `Outer` would result in broken code.
63+
64+
Scala.js 1.5.0 will therefore reject this definition at compile-time.
65+
This may cause code that compiled before to be rejected, which constitutes a backward source incompatible change.
66+
67+
If you have actual, working code using that pattern (for example, where you receive instances of `Outer` from JavaScript code, instead of extending it yourself), it is likely that you can fix the code by adding `@js.native` both to the outer trait and the inner classes and objects:
68+
69+
{% highlight scala %}
70+
@js.native
71+
trait Outer extends js.Object {
72+
@js.native
73+
object InnerObject extends js.Object
74+
75+
@js.native
76+
class InnerClass extends js.Object
77+
}
78+
{% endhighlight %}
79+
80+
## Custom JS function types
81+
82+
**Scala 2.11 note:** With Scala 2.11, this feature requires the `-Xexperimental` flag, which adds SAM support to the Scala compiler.
83+
84+
For interoperability with JavaScript code that manipulates function values, Scala.js has always had a set of `js.FunctionN` and `js.ThisFunctionN` types.
85+
Since they are SAM types, they can be created with anonymous functions, for example:
86+
87+
{% highlight scala %}
88+
val jsFun: js.Function1[Int, String] = arg => arg.toString()
89+
{% endhighlight %}
90+
91+
The built-in JS function types can accomodate any function with a fixed number of parameters, up to 22.
92+
However, they are not enough for more specialized use cases:
93+
94+
* Function values with variadic arguments (varargs)
95+
* Function values of more than 22 arguments
96+
97+
To address such advanced use cases, Scala.js 1.5.0 now allows to define custom JS function types with arbitrary `apply` signatures.
98+
For example, if you need to represent a function value with one `Int` parameter and varargs of type `String`, you can define a custom JS function type for it:
99+
100+
{% highlight scala %}
101+
trait SpecialJSFunction extends js.Function {
102+
def apply(first: Int, rest: String*): Any
103+
}
104+
{% endhighlight %}
105+
106+
and create values of that type as expected:
107+
108+
{% highlight scala %}
109+
val specialJSFun: SpecialJSFunction = { (first, rest) =>
110+
s"$first, ${rest.size}"
111+
}
112+
{% endhighlight %}
113+
114+
A custom JS function type is any `trait` whose parent class is `js.Function`, and which has a single abstract method named `apply`.
115+
If a custom JS function type extends the special trait `js.ThisFunction`, its first argument on the Scala.js side maps to the `this` value in JavaScript.
116+
117+
Note that the built-in `js.FunctionN` and `js.ThisFunctionN` types fit those definitions, and are therefore "custom" JS function types themselves, that happen to be defined in the Scala.js standard library.
118+
119+
## Miscellaneous
120+
121+
### New JDK APIs
122+
123+
The following JDK APIs were added:
124+
125+
* `java.util.concurrent.Semaphore` (except the methods that require blocking)
126+
127+
## Bug fixes
128+
129+
Among others, the following bugs have been fixed in 1.5.0:
130+
131+
* [#4386](https://github.com/scala-js/scala-js/issues/4386) `js.dynamicImport` and `ModuleSplitStyle.FewestModules` may cause public modules to be imported by Scala.js code
132+
* [#4385](https://github.com/scala-js/scala-js/issues/4385) Desugaring for `ApplyImportDynamic` nodes captures variables too aggressively
133+
* [#4416](https://github.com/scala-js/scala-js/issues/4416) Incremental runs lead to GCC reporting a JSC_UNDEFINED_VARIABLE
134+
* [#4370](https://github.com/scala-js/scala-js/issues/4370) Scala.js 1.4.0 breaks linking of fields with type `Nothing`
135+
* [#4375](https://github.com/scala-js/scala-js/issues/4375) Compiler crash with overriding type members in JS types
136+
* [#4413](https://github.com/scala-js/scala-js/issues/4413) `hashCode()` and `identityHashCode()` don't work for JS `symbol`s and `bigint`s
137+
* [#4351](https://github.com/scala-js/scala-js/issues/4351) `j.u.Formatter` octal and hex conversion do not support `+ (` flags for BigIntegers
138+
* [#4353](https://github.com/scala-js/scala-js/issues/4353) `j.u.Formatter` 'g' conversion is not JVM-compliant for 0.0
139+
* [#4402](https://github.com/scala-js/scala-js/issues/4402) Extending a native inner class complains that it has no JS native load spec
140+
* [#4401](https://github.com/scala-js/scala-js/issues/4401) Inner classes and objects wrongly allowed in non-native JS traits
141+
142+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av1.5.0+is%3Aclosed).

assets/badges/scalajs-1.5.0.svg

+1
Loading

doc/all-api.md

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ title: All previous versions of the Scala.js API
55

66
## All previous versions of the API
77

8+
### Scala.js 1.5.0
9+
* [1.5.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.5.0/scala/scalajs/js/index.html)
10+
* [1.5.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.5.0/)
11+
* [1.5.0 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/1.5.0/org/scalajs/ir/index.html)
12+
* [1.5.0 scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/1.5.0/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/1.5.0/org/scalajs/linker/interface/index.html))
13+
* [1.5.0 scalajs-linker]({{ site.production_url }}/api/scalajs-linker/1.5.0/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/1.5.0/org/scalajs/linker/index.html))
14+
* [1.5.0 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/1.5.0/org/scalajs/testing/adapter/index.html)
15+
* [1.5.0 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/1.5.0/#org.scalajs.sbtplugin.package)
16+
817
### Scala.js 1.4.0
918
* [1.4.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.4.0/scala/scalajs/js/index.html)
1019
* [1.4.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.4.0/)

doc/internals/version-history.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Version history
55

66
## Version history of Scala.js
77

8+
- [1.5.0](/news/2021/02/12/announcing-scalajs-1.5.0/)
89
- [1.4.0](/news/2021/01/12/announcing-scalajs-1.4.0/)
910
- [1.3.1](/news/2020/11/16/announcing-scalajs-1.3.1/)
1011
- [1.3.0](/news/2020/10/16/announcing-scalajs-1.3.0/)

0 commit comments

Comments
 (0)