8000 DO NOT MERGE Simulation: What if we dropped support for ES 5.1. by sjrd · Pull Request #5129 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

DO NOT MERGE Simulation: What if we dropped support for ES 5.1. #5129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
sjrd committed Feb 8, 2025
commit 4b42414874955b46e28e12530746af9f4eb088db
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ final class ESVersion private (val edition: Int, val name: String)
}

object ESVersion {
/** ECMAScrîpt 5.1. */
/** ECMAScript 5.1. */
@deprecated(
"Support for ECMAScript 5.1 is deprecated and will eventually be removed.",
since = "1.19.0")
val ES5_1: ESVersion = new ESVersion(5, "ECMAScript 5.1")

/** ECMAScript 2015 (6th edition). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class StandardConfigFingerprintTest {
@Test
def noFingerprintCollisionESFeatures(): Unit = {
val sc1 = StandardConfig().withESFeatures(_.withESVersion(ESVersion.ES2015))
val sc2 = StandardConfig().withESFeatures(_.withESVersion(ESVersion.ES5_1))
val sc2 = StandardConfig().withESFeatures(_.withESVersion(ESVersion.ES2016))
assertFingerprintsNotEquals(sc1, sc2)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ final class ClosureLinkerBackend(config: LinkerBackendImpl.Config)
import ClosureOptions.LanguageMode._

esFeatures.esVersion match {
case ESVersion.ES5_1 => ECMASCRIPT5_STRICT
case ESVersion.ES2015 => ECMASCRIPT_2015
case ESVersion.ES2016 => ECMASCRIPT_2016
case ESVersion.ES2017 => ECMASCRIPT_2017
Expand All @@ -87,6 +86,10 @@ final class ClosureLinkerBackend(config: LinkerBackendImpl.Config)
case ESVersion.ES2020 => ECMASCRIPT_2020
case ESVersion.ES2021 => ECMASCRIPT_2021

// Test for ES5_1 without triggering the deprecation warning
case esVersion if esVersion.edition == 5 =>
ECMASCRIPT5_STRICT

case _ =>
throw new AssertionError(s"Unknown ES version ${esFeatures.esVersion}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ class AnalyzerTest {
}
}

@deprecated("test deprecated features", "forever")
@Test
def newTargetWithoutES2015(): AsyncResult = await {
val classDefs = Seq(
Expand Down
0