Skip to content

Commit 774e877

Browse files
authored
Merge pull request #549 from sjrd/scalajs-1.6.0
Announcing Scala.js 1.6.0.
2 parents 2b8d3b0 + 467545c commit 774e877

File tree

6 files changed

+157
-1
lines changed

6 files changed

+157
-1
lines changed

_config.yml

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

6565
### VERSIONS ###
6666
versions:
67-
scalaJS: 1.5.1
67+
scalaJS: 1.6.0
6868
scalaJSBinary: 1
6969
scalaJS06x: 0.6.33
7070
scalaJS06xBinary: 0.6

_data/library/versions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
- 1.3.0
2727
- 1.4.0
2828
- 1.5.0
29+
- 1.6.0
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 1.6.0
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2021/06/09/announcing-scalajs-1.6.0/
7+
---
8+
9+
10+
We are excited to announce the release of Scala.js 1.6.0!
11+
12+
This release fixes a number of bugs and brings new interoperability features, notably `js.import.meta`.
13+
It also brings new facades for `js.WeakRef` and `js.FinalizationRegistry`, while proper implementations of `java.lang.ref.*` are moved to separate libraries.
14+
15+
The Scala standard library was upgraded to versions 2.12.13 and 2.13.5.
16+
17+
Read on for more details.
18+
19+
<!--more-->
20+
21+
## Getting started
22+
23+
If you are new to Scala.js, head over to [the tutorial]({{ BASE_PATH }}/tutorial/).
24+
25+
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).
26+
27+
Bug reports can be filed [on GitHub](https://github.com/scala-js/scala-js/issues).
28+
29+
## Release notes
30+
31+
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.
32+
33+
This is a **minor** release:
34+
35+
* 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.
36+
* 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.
37+
* 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 `-Xfatal-warnings`).
38+
39+
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.
40+
41+
## Fixes with compatibility concerns
42+
43+
### Classes in `java.lang.ref.*` have been moved to separate libraries
44+
45+
Until Scala.js 1.5.x, the core library contained stub implementations of the classes in `java.lang.ref.*`, such as `WeakReference`.
46+
These implementations did not respect the weak semantics, and instead held *strong* references.
47+
Despite linking and successfully running, code using `WeakReference` et al. was therefore stubtly wrong.
48+
49+
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.
50+
To preserve binary compatibility, we introduce two variants of a library that provides the removed pieces:
51+
52+
* [`scalajs-fake-weakreferences`](https://github.com/scala-js/scala-js-fake-weakreferences) is 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.
53+
* [`scalajs-weakreferences`](https://github.com/scala-js/scala-js-weakreferences) provides a *correct* implementation of `WeakReference` and `ReferenceQueue` instead, but relies on ECMAScript 2021's built-in `WeakRef` and `FinalizationRegistry`; it can be used for new code.
54+
55+
Due to the removal from the core library, you may encounter linking errors when upgrading to Scala.js 1.6.0, such as:
56+
57+
{% highlight text %}
58+
[error] Referring to non-existent class java.lang.ref.WeakReference
59+
[error] called from helloworld.HelloWorld$.main([java.lang.String)void
60+
[error] called from static helloworld.HelloWorld.main([java.lang.String)void
61+
[error] called from core module module initializers
62+
[error] involving instantiated classes:
63+
[error] helloworld.HelloWorld$
64+
{% endhighlight %}
65+
66+
You may fix these linking errors by adding the following dependency to your `libraryDependencies`:
67+
68+
{% highlight scala %}
69+
"org.scala-js" %%% "scalajs-fake-weakreferences" % "1.0.0"
70+
{% endhighlight %}
71+
72+
We encourage you to try and get rid of that dependency when you get the chance, since it is (intentionally) broken.
73+
74+
## `js.import.meta`
75+
76+
ECMAScript 2020 introduced the meta-property `import.meta`, which provides host-dependent information about the enclosed module.
77+
Until Scala.js 1.5.x, there was no way to access that meta-property.
78+
Scala.js 1.6.0 introduces a new primitive to address that shortcoming:
79+
80+
{% highlight scala %}
81+
import scala.scalajs.js
82+
83+
val moduleMetaInfo: js.Dynamic = js.`import`.meta
84+
println(moduleMetaInfo.url) // Node.js-specific
85+
{% endhighlight %}
86+
87+
Since `import.meta` is only valid in an ES module, using `js.import.meta` requires to [emit the Scala.js code as an `ESModule`]({{ BASE_PATH }}/doc/project/module.html).
88+
Failing to do so will result in a linking error such as
89+
90+
{% highlight text %}
91+
[error] Uses import.meta with a module kind other than ESModule
92+
[error] called from helloworld.HelloWorld$.main([java.lang.String)void
93+
[error] called from static helloworld.HelloWorld.main([java.lang.String)void
94+
[error] called from core module module initializers
95+
[error] involving instantiated classes:
96+
[error] helloworld.HelloWorld$
97+
{% endhighlight %}
98+
99+
## Miscellaneous
100+
101+
### New facades for the JavaScript standard library
102+
103+
The following definitions for ECMAScript 2021 library features were added:
104+
105+
* `js.WeakRef`
106+
* `js.FinalizationRegistry`
107+
108+
### Upgrade to JUnit 4.13.2
109+
110+
The Scala.js version of JUnit has been updated to match the API of JUnit 4.13.2.
111+
The most important change is the addition of `org.junit.Assert.assertThrows`.
112+
113+
### New configuration for the target ECMAScript version
114+
115+
Until Scala.js 1.5.x, one could only choose between targeting ECMAScript 5.1 or ECMAScript 2015, based on the following setting:
116+
117+
{% highlight scala %}
118+
scalaJSLinkerConfig ~= { _.withESFeatures(_.withUseECMAScript2015(false)) } // default true
119+
{% endhighlight %}
120+
121+
It is now possible to choose any known ECMAScript version since 5.1, using the following setting:
122+
123+
{% highlight scala %}
124+
scalaJSLinkerConfig ~= (_.withESFeatures(_.withESVersion(ESVersion.ES2018))) // default ES2015
125+
{% endhighlight %}
126+
127+
Possible values are `ES5_1` and `ES2015` through `ES2020`.
128+
We will add further choices in the future, as new versions of ECMAScript are released.
129+
130+
The Scala.js linker and libraries may choose to optimize the resulting code, or offer more features, based on the target ECMAScript version.
131+
As of Scala.js 1.6.0, choices greater than `ES2015` are only used for optimizations.
132+
133+
### Upgrade to GCC v20210406
134+
135+
We upgraded to the Google Closure Compiler v20210406.
136+
137+
## Bug fixes
138+
139+
Among others, the following bugs have been fixed in 1.6.0:
140+
141+
* [#4466](https://github.com/scala-js/scala-js/issues/4466) 1 ULP error when toFloat is called for some long values
142+
* [#4499](https://github.com/scala-js/scala-js/issues/4499) FewestModules can result in filenames that are greater than 255 Characters
143+
144+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av1.6.0+is%3Aclosed).

assets/badges/scalajs-1.6.0.svg

Lines changed: 1 addition & 0 deletions
Loading

doc/all-api.md

Lines changed: 9 additions & 0 deletions
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.6.0
9+
* [1.6.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.6.0/scala/scalajs/js/index.html)
10+
* [1.6.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.6.0/)
11+
* [1.6.0 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/1.6.0/org/scalajs/ir/index.html)
12+
* [1.6.0 scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/1.6.0/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/1.6.0/org/scalajs/linker/interface/index.html))
13+
* [1.6.0 scalajs-linker]({{ site.production_url }}/api/scalajs-linker/1.6.0/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/1.6.0/org/scalajs/linker/index.html))
14+
* [1.6.0 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/1.6.0/org/scalajs/testing/adapter/index.html)
15+
* [1.6.0 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/1.6.0/#org.scalajs.sbtplugin.package)
16+
817
### Scala.js 1.5.1
918
* [1.5.1 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.5.1/scala/scalajs/js/index.html)
1019
* [1.5.1 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.5.1/)

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+
- [1.6.0](/news/2021/06/09/announcing-scalajs-1.6.0/)
89
- [1.5.1](/news/2021/04/01/announcing-scalajs-1.5.1/)
910
- [1.5.0](/news/2021/02/12/announcing-scalajs-1.5.0/)
1011
- [1.4.0](/news/2021/01/12/announcing-scalajs-1.4.0/)

0 commit comments

Comments
 (0)