Skip to content

Commit cd7a9dd

Browse files
authored
Merge pull request #649 from sjrd/scalajs-1.18.0
Announcing Scala.js 1.18.1.
2 parents a426a40 + d98945c commit cd7a9dd

File tree

7 files changed

+190
-4
lines changed

7 files changed

+190
-4
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.17.0
67+
scalaJS: 1.18.1
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
@@ -34,3 +34,4 @@
3434
- 1.13.0
3535
- 1.16.0
3636
- 1.17.0
37+
- 1.18.0
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 1.18.1
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2025/01/09/announcing-scalajs-1.18.1/
7+
---
8+
9+
10+
We are pleased to announce the release of Scala.js 1.18.1!
11+
12+
This is technically a hotfix patch release for 1.18.0, which was discovered to be [severely broken](https://github.com/scala-js/scala-js/issues/5107), and was therefore never announced.
13+
These release notes therefore present it as a "minor release" compared to 1.17.0.
14+
15+
This release drops support for Scala 2.12.{2-5} and 2.13.{0-2}.
16+
Other than that, it is mostly a bugfix release.
17+
18+
It also contains a number of internal changes to the intermediate representation and linker.
19+
These are not externally visible, except for users who directly manipulate the IR and/or linker.
20+
They pave the way for upcoming changes that are still ongoing work.
21+
22+
Read on for more details.
23+
24+
<!--more-->
25+
26+
## Getting started
27+
28+
If you are new to Scala.js, head over to [the tutorial]({{ BASE_PATH }}/tutorial/).
29+
30+
If you need help with anything related to Scala.js, you may find our community [in `#scala-js` on Discord](https://discord.com/invite/scala) and [on Stack Overflow](https://stackoverflow.com/questions/tagged/scala.js).
31+
32+
Bug reports can be filed [on GitHub](https://github.com/scala-js/scala-js/issues).
33+
34+
## Release notes
35+
36+
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.
37+
38+
This is a **minor** release, compared to 1.17.0:
39+
40+
* It is backward binary compatible with all earlier versions in the 1.x series: libraries compiled with 1.0.x through 1.17.x can be used with 1.18.0 without change.
41+
* It is *not* forward binary compatible with 1.17.x: libraries compiled with 1.18.0 cannot be used with 1.17.x or earlier.
42+
* It is *not* entirely backward source compatible: it is not guaranteed that a codebase will compile *as is* when upgrading from 1.17.x (in particular in the presence of `-Xfatal-warnings`).
43+
44+
Technically 1.18.1 is a patch release with respect to 1.18.0.
45+
Our usual patch version guarantees do apply, despite the retraction of 1.18.0.
46+
47+
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.
48+
49+
## Changes with compatibility concerns
50+
51+
### Enforce stricter rules on the use of `this` in the IR of constructors
52+
53+
Exceptionally, **this is theoretically a binary-breaking change**.
54+
It is possible for previously valid IR (Intermediate Representation, as published in binaries on Maven Central) to be rejected by Scala.js 1.18.x.
55+
56+
We now enforce, during IR checking (by default, only enabled in `fullLink` builds), that constructors abide by stricter rules.
57+
Before calling their `super` constructor (or delegate `this()` constructor), they may not refer to the `this` instance.
58+
The only exception is to *assign* a field, as in `this.foo = bar`.
59+
This restriction is in line with a similar rule in JVM bytecode.
60+
61+
Unfortunately, the Scala.js compiler for Scala 2.x was previously generating IR that is invalid according to the new rule in one corner case situation.
62+
If there is a `try..catch` expression inside an argument to the `super` constructor, the compiler may lift it to a separate method.
63+
We compiled that method as an *instance* method, using the `this` value, instead of compiling it as a *static* method.
64+
65+
Here is an example:
66+
67+
{% highlight scala %}
68+
class Parent(val i: Int)
69+
70+
class Child extends Parent({
71+
val p = try Integer.parseInt("foo") catch { case _: NumberFormatException => 42 }
72+
p
73+
})
74+
75+
object Test {
76+
def main(args: Array[String]): Unit =
77+
println(new Child().i)
78+
}
79+
{% endhighlight %}
80+
81+
If your application depends on a library that contained such a code shape, you may hit the following IR checking error at link time in Scala.js 1.18.0.
82+
83+
{% highlight none %}
84+
[error] ...: Restricted use of `this` before the super constructor call
85+
[error] There were 1 ClassDef checking errors.
86+
{% endhighlight %}
87+
88+
If that is the case, the library needs to be recompiled with Scala.js 1.18.x or later to be usable again.
89+
Make sure to [tell us on the relevant PR](https://github.com/scala-js/scala-js/pull/5019) if that happens.
90+
91+
In order to mitigate the impact of this change, we conducted an audit of (the latest version of) all Scala.js libraries published to Maven Central.
92+
We did not find any library that violated the new rule.
93+
You may still run into the issue if you depend on a private library.
94+
95+
As a temporary, stop-gap measure, you may silence the error with the following setting:
96+
97+
{% highlight scala %}
98+
Compile/fullLinkJS/scalaJSLinkerConfig ~= { _.withCheckIR(false) }
99+
{% endhighlight %}
100+
101+
However that will start causing real issues once we leverage the new restriction for better optimizations.
102+
103+
### Drop support for Scala 2.12.2 to 2.12.5 and 2.13.0 to 2.13.2
104+
105+
In order to reduce our maintenance burden and ease further development, Scala.js 1.18.1 drops support for Scala 2.12.2 to 2.12.5 and 2.13.0 to 2.13.2.
106+
Scala 2.12.6+ and 2.13.3+ are still supported.
107+
108+
We still had a number of dedicated code paths, special cases and exceptions for these versions in our codebase.
109+
Moreover, we occasionally hit compiler bugs in early 2.12.x versions, which imposed constraints on how we wrote our code.
110+
111+
### The Wasm backend now requires full support of `try_table` (notably Node.js 23)
112+
113+
If you are using the WebAssembly backend, you now need at least Node.js 23 to run and test.
114+
115+
In Scala.js 1.17.0, the WebAssembly backend worked around some issues in Wasm engines regarding the `try_table` instruction.
116+
Our main blocker was the version of V8 shipped with Node.js 22.
117+
Now that Node.js 23 has been released with the correct behavior, we removed the workaround.
118+
119+
### Improved internal checks after optimizations
120+
121+
We improved "IR checking", our internal consistency checks in the linker.
122+
Previously, we only performed IR checking before optimizations.
123+
Now, we also check the IR after the optimizer if one of the following conditions hold:
124+
125+
* you are using the Wasm backend, or
126+
* you are using the `bigint` encoding of `Long`s, through the setting `withESFeatures(_.withAllowBigIntsForLongs(true))`.
127+
128+
This may surface internal bugs that we are unaware of.
129+
If that happens, please report an issue, as prompted by the error message.
130+
131+
By default, IR checking is only performed during `fullLink`.
132+
You may disable it with the following setting:
133+
134+
{% highlight scala %}
135+
Compile/fullLinkJS/scalaJSLinkerConfig ~= { _.withCheckIR(false) }
136+
{% endhighlight %}
137+
138+
### Changes to the IR and linker APIs
139+
140+
For tooling authors who directly manipulate the IR and linker APIs, there have been some breaking changes in that area.
141+
This is in line with our versioning policy for the linker APIs.
142+
143+
The changes you are most likely to hit are:
144+
145+
* We renamed `NoType` to `VoidType`, which represents the IR type `void`.
146+
`void` is now generally handled more regularly.
147+
* `VarRef` now directly contains a `LocalName`, rather than a `LocalIdent` itself containing a `LocalName`.
148+
* `This` is not a separate IR node anymore; instead it is a `VarRef` with the special name `LocalName.This`.
149+
* `ArrayLength`, `Throw`, and a number of more obscure IR nodes have been merged into `UnaryOp`.
150+
* `JSLinkingInfo` was removed as a "bag of options"; it was replaced by `LinkTimeProperty` for individual properties.
151+
* `Transformers` does not make the distinction between "statement" and "expression" anymore.
152+
This follows from handling `void` more uniformly.
153+
154+
## Miscellaneous
155+
156+
### New JDK APIs
157+
158+
This release adds shell definitions for the following JDK 21 interfaces, but without any method:
159+
160+
* `java.util.SequencedCollection`, `SequencedMap` and `SequencedSet`
161+
162+
## Bug fixes
163+
164+
Among others, the following bugs have been fixed since 1.17.0:
165+
166+
* [#5107](https://github.com/scala-js/scala-js/issues/5107) IR checking error for IR coming from Scala.js < 1.11 through deserialization hack
167+
* [#5085](https://github.com/scala-js/scala-js/issues/5085) `java.math.BigDecimal.valueOf(0, 9).stripTrailingZeros.scale` returns 9 instead of 0.
168+
* [#5069](https://github.com/scala-js/scala-js/issues/5069) Linking errors with `java.util.SequencedCollection` on JDK 21+ (considered a bug because they surfaced even in code that did not mention that new interface).
169+
* [#5048](https://github.com/scala-js/scala-js/issues/5048) Wasm backend fails when no modules are defined.
170+
* [#4947](https://github.com/scala-js/scala-js/issues/4947) Wrong optimization of `@inline` classes with several private fields of the same name in the class hierarchy.
171+
172+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av1.18.0+is%3Aclosed).

assets/badges/scalajs-1.18.0.svg

Lines changed: 1 addition & 0 deletions
Loading

doc/all-api.md

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

66
## All previous versions of the API
77

8+
### Scala.js 1.18.1
9+
* [1.18.1 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.18.1/scala/scalajs/js/index.html)
10+
* [1.18.1 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.18.1/)
11+
* [1.18.1 scalajs-javalib-intf]({{ site.production_url }}/api/scalajs-javalib-intf/1.18.1/)
12+
* [1.18.1 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/1.18.1/org/scalajs/ir/index.html)
13+
* [1.18.1 scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/1.18.1/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/1.18.1/org/scalajs/linker/interface/index.html))
14+
* [1.18.1 scalajs-linker]({{ site.production_url }}/api/scalajs-linker/1.18.1/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/1.18.1/org/scalajs/linker/index.html))
15+
* [1.18.1 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/1.18.1/org/scalajs/testing/adapter/index.html)
16+
* [1.18.1 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/1.18.1/#org.scalajs.sbtplugin.package)
17+
818
### Scala.js 1.17.0
919
* [1.17.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.17.0/scala/scalajs/js/index.html)
1020
* [1.17.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.17.0/)

doc/internals/version-history.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Version history
55

66
## Version history of Scala.js
77

8+
- [1.18.1](/news/2025/01/09/announcing-scalajs-1.18.1/)
9+
- ~~1.18.0~~ ([severely broken](https://github.com/scala-js/scala-js/issues/5107) and therefore never announced)
810
- [1.17.0](/news/2024/09/28/announcing-scalajs-1.17.0/)
911
- [1.16.0](/news/2024/03/19/announcing-scalajs-1.16.0/)
1012
- [1.15.0](/news/2023/12/29/announcing-scalajs-1.15.0/)

doc/project/webassembly.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ We expect to lift that limitation in the future.
6161

6262
## Minimal setup
6363

64-
The following sbt setup enables the Wasm backend and configures flags for Node.js 22.
64+
The following sbt setup enables the Wasm backend and configures flags for Node.js 23.
6565

6666
{% highlight scala %}
6767
// Emit ES modules with the Wasm backend
@@ -71,7 +71,7 @@ scalaJSLinkerConfig := {
7171
.withModuleKind(ModuleKind.ESModule) // required by the Wasm backend
7272
},
7373

74-
// Configure Node.js (at least v22) to support the required Wasm features
74+
// Configure Node.js (at least v23) to support the required Wasm features
7575
jsEnv := {
7676
val config = NodeJSEnv.Config()
7777
.withArgs(List(
@@ -92,7 +92,7 @@ Here are some engines known to support enough Wasm features.
9292

9393
### Node.js 22
9494

95-
As mentioned above, Node.js 22 and above requires the following flags:
95+
As mentioned above, Node.js 23 and above requires the following flags:
9696

9797
* `--experimental-wasm-exnref`: required
9898
* `--experimental-wasm-imported-strings`: optional (good for performance)

0 commit comments

Comments
 (0)