8000 Deprecate support for ECMAScript 5.1. by sjrd · Pull Request #5128 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Deprecate support for ECMAScript 5.1. #5128

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

8000
Merged
merged 1 commit into from
Mar 4, 2025

Conversation

sjrd
Copy link
Member
@sjrd sjrd commented Feb 8, 2025

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 Arrays instead of typed arrays for Scala Arrays of primitive types.
  • Using custom Java Maps 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 Symbols.
  • 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 classes. Notably, that means they cannot extend native ES classes, and they do not inherit static members.
  • Top-level exports are declared as vars instead of lets.

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.


I did a simulation of all the things we could drop if we indeed removed support for ES 5.1 in the future. It is visible in #5129.

@sjrd sjrd force-pushed the deprecate-es5.1-support branch from bf11623 to 4b42414 Compare February 8, 2025 10:12
@sjrd sjrd marked this pull request as ready for review March 3, 2025 16:42
@sjrd sjrd requested a review from gzm0 March 3, 2025 16:42
@sjrd
Copy link
Member Author
sjrd commented Mar 3, 2025

Looks like no one negatively reacted for 3 weeks, despite linking to this PR from all the usual places. @gzm0 Let's do it?

@sjrd sjrd changed the title RFC: Deprecate support for ECMAScript 5.1. Deprecate support for ECMAScript 5.1. Mar 4, 2025
Copy link
Contributor
@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed :) :shipit:

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so sad :((

Consider adding the full string ESVersion.ES5_1 in the comment for a bit better greppability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I also added a comment referring to here at the definition site of ES5_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.
@sjrd sjrd force-pushed the deprecate-es5.1-support branch from 4b42414 to a4cdc6 8B62 f Compare March 4, 2025 07:53
@sjrd sjrd merged commit 9104f7d into scala-js:main Mar 4, 2025
3 checks passed
@sjrd sjrd deleted the deprecate-es5.1-support branch March 4, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0