8000 Deprecate support for ECMAScript 5.1. · scala-js/scala-js@a4cdc6f · GitHub
[go: up one dir, main page]

Skip to content

Commit a4cdc6f

Browse files
committed
Deprecate support for ECMAScript 5.1.
That support is the biggest source of alternative code paths and polyfills in our codebase. The polyfills and other alternative implementations we need to support ES 5.1 include: * `Math.fround` to support `Float` operations (in `CoreJSLib`). * Other bit manipulation magic for floating-point numbers (in `FloatingPointBits`). * Using dynamic JS `Array`s instead of typed arrays for Scala `Array`s of primitive types. * Using custom Java `Map`s instead of `js.Map`. * Various implementations of math methods in `jl.Math` (although these may come back for a Wasm-only target, along with more of them). * Using run-time generated random property names instead of `Symbol`s. * Very complex code to handle surrogate pairs in `ju.regex.*`. * (Imperfect) desugaring of `...rest` parameters and `...spread` operators. Moreover, the ES 5.1 output does not even have exactly the same semantics as later versions: * JS classes are not true `class`es. Notably, that means they cannot extend native ES classes, and they do not inherit static members. * Top-level exports are declared as `var`s instead of `let`s. 10 years after the instruction of ECMAScript 2015, I believe it is time to deprecate the support for Es 5.1, so that we can eventually remove it.
1 parent cf05126 commit a4cdc6f

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

linker-interface/shared/src/main/scala/org/scalajs/linker/interface/ESVersion.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ final class ESVersion private (val edition: Int, val name: String)
3030
}
3131

3232
object ESVersion {
33-
/** ECMAScrîpt 5.1. */
33+
// !!! When we actually remove this, remove the code mentioning it in ClosureLinkerBackend.scala
34+
/** ECMAScript 5.1. */
35+
@deprecated(
36+
"Support for ECMAScript 5.1 is deprecated and will eventually be removed.",
37+
since = "1.19.0")
3438
val ES5_1: ESVersion = new ESVersion(5, "ECMAScript 5.1")
3539

3640
/** ECMAScript 2015 (6th edition). */

linker-interface/shared/src/test/scala/org/scalajs/linker/interface/StandardConfigFingerprintTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class StandardConfigFingerprintTest {
4242
@Test
4343
def noFingerprintCollisionESFeatures(): Unit = {
4444
val sc1 = StandardConfig().withESFeatures(_.withESVersion(ESVersion.ES2015))
45-
val sc2 = StandardConfig().withESFeatures(_.withESVersion(ESVersion.ES5_1))
45+
val sc2 = StandardConfig().withESFeatures(_.withESVersion(ESVersion.ES2016))
4646
assertFingerprintsNotEquals(sc1, sc2)
4747
}
4848

linker/jvm/src/main/scala/org/scalajs/linker/backend/closure/ClosureLinkerBackend.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ final class ClosureLinkerBackend(config: LinkerBackendImpl.Config)
7878
import ClosureOptions.LanguageMode._
7979

8080
esFeatures.esVersion match {
81-
case ESVersion.ES5_1 => ECMASCRIPT5_STRICT
8281
case ESVersion.ES2015 => ECMASCRIPT_2015
8382
case ESVersion.ES2016 => ECMASCRIPT_2016
8483
case ESVersion.ES2017 => ECMASCRIPT_2017
@@ -87,6 +86,10 @@ final class ClosureLinkerBackend(config: LinkerBackendImpl.Config)
8786
case ESVersion.ES2020 => ECMASCRIPT_2020
8887
case ESVersion.ES2021 => ECMASCRIPT_2021
8988

89+
// Test for ESVersion.ES5_1 without triggering the deprecation warning
90+
case esVersion if esVersion.edition == 5 =>
91+
ECMASCRIPT5_STRICT
92+
9093
case _ =>
9194
throw new AssertionError(s"Unknown ES version ${esFeatures.esVersion}")
9295
}

linker/shared/src/test/scala/org/scalajs/linker/AnalyzerTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ class AnalyzerTest {
654654
}
655655
}
656656

657+
@deprecated("test deprecated features", "forever")
657658
@Test
658659
def newTargetWithoutES2015(): AsyncResult = await {
659660
val classDefs = Seq(

0 commit comments

Comments
 (0)
0