Announcing Scala.js 1.6.0
Jun 9, 2021.
We are excited to announce the release of Scala.js 1.6.0!
This release fixes a number of bugs and brings new interoperability features, notably
It also brings new facades for
js.FinalizationRegistry, while proper implementations of
java.lang.ref.* are moved to separate libraries.
The Scala standard library was upgraded to versions 2.12.13 and 2.13.5.
Read on for more details.
If you are new to Scala.js, head over to the tutorial.
Bug reports can be filed on GitHub.
If upgrading from Scala.js 0.6.x, make sure to read the release notes of Scala.js 1.0.0 first, as they contain a host of important information, including breaking changes.
This is a minor release:
- It is backward binary compatible with all earlier versions in the 1.x series: libraries compiled with 1.0.x through 1.5.x can be used with 1.6.0 without change.
- It is not forward binary compatible with 1.5.x: libraries compiled with 1.6.0 cannot be used with 1.5.x or earlier.
- It is not entirely backward source compatible: it is not guaranteed that a codebase will compile as is when upgrading from 1.5.x (in particular in the presence of
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.
Fixes with compatibility concerns
java.lang.ref.* have been moved to separate libraries
Until Scala.js 1.5.x, the core library contained stub implementations of the classes in
java.lang.ref.*, such as
These implementations did not respect the weak semantics, and instead held strong references.
Despite linking and successfully running, code using
WeakReference et al. was therefore stubtly wrong.
Since this goes against our policy for the standard library that linking code must be correct, we have removed those stubs from the core library. To preserve binary compatibility, we introduce two variants of a library that provides the removed pieces:
scalajs-fake-weakreferencesis an exact copy of what used to ship in Scala.js core; it can be used as a drop-in replacement when upgrading to Scala.js 1.6.0.
scalajs-weakreferencesprovides a correct implementation of
ReferenceQueueinstead, but relies on ECMAScript 2021’s built-in
FinalizationRegistry; it can be used for new code.
Due to the removal from the core library, you may encounter linking errors when upgrading to Scala.js 1.6.0, such as:
You may fix these linking errors by adding the following dependency to your
We encourage you to try and get rid of that dependency when you get the chance, since it is (intentionally) broken.
ECMAScript 2020 introduced the meta-property
import.meta, which provides host-dependent information about the enclosed module.
Until Scala.js 1.5.x, there was no way to access that meta-property.
Scala.js 1.6.0 introduces a new primitive to address that shortcoming:
import.meta is only valid in an ES module, using
js.import.meta requires to emit the Scala.js code as an
Failing to do so will result in a linking error such as
The following definitions for ECMAScript 2021 library features were added:
Upgrade to JUnit 4.13.2
The Scala.js version of JUnit has been updated to match the API of JUnit 4.13.2.
The most important change is the addition of
New configuration for the target ECMAScript version
Until Scala.js 1.5.x, one could only choose between targeting ECMAScript 5.1 or ECMAScript 2015, based on the following setting:
It is now possible to choose any known ECMAScript version since 5.1, using the following setting:
Possible values are
We will add further choices in the future, as new versions of ECMAScript are released.
The Scala.js linker and libraries may choose to optimize the resulting code, or offer more features, based on the target ECMAScript version.
As of Scala.js 1.6.0, choices greater than
ES2015 are only used for optimizations.
Upgrade to GCC v20210406
We upgraded to the Google Closure Compiler v20210406.
Among others, the following bugs have been fixed in 1.6.0:
- #4466 1 ULP error when toFloat is called for some long values
- #4499 FewestModules can result in filenames that are greater than 255 Characters
You can find the full list on GitHub.