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
Prev Previous commit
Next Next commit
Remove support for ECMAScript 5.1.
In this commit, we do the minimum changes to remove
`ESVersion.ES5_1`. All the supporting code is still present
elsewhere. We will add separate commits for the various areas
that can be removed.
  • Loading branch information
sjrd committed Feb 8, 2025
commit cd2c89701ae8e04b1406bc1cf0927605f49b3085
15 changes: 6 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -278,27 +278,27 @@ def Tasks = [
setJavaVersion $java
npm install &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSStage in Global := FullOptStage' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= makeCompliant' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= makeCompliant' \
'set scalaJSStage in Global := FullOptStage' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= makeCompliant' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
++$scala $testSuite$v/test
Expand Down Expand Up @@ -542,7 +542,6 @@ def otherScalaVersions = [
def scala3Version = "3.6.3"

def allESVersions = [
"ES5_1",
"ES2015",
// "ES2016", // Technically we have the '**' operator dependent on ES2016, but it's not enough to justify testing this version
"ES2017",
Expand All @@ -561,11 +560,9 @@ mainScalaVersions.each { scalaVersion ->
}
quickMatrix.add([task: "test-suite-default-esversion", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-default-esversion", scala: scalaVersion, java: mainJavaVersion, testMinify: "true", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-custom-esversion", scala: scalaVersion, java: mainJavaVersion, esVersion: "ES5_1", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-webassembly", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-webassembly", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "testSuiteEx"])
quickMatrix.add([task: "test-suite-default-esversion", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "scalaTestSuite"])
quickMatrix.add([task: "test-suite-custom-esversion", scala: scalaVersion, java: mainJavaVersion, esVersion: "ES5_1", testSuite: "scalaTestSuite"])
quickMatrix.add([task: "test-suite-webassembly", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "scalaTestSuite"])
quickMatrix.add([task: "bootstrap", scala: scalaVersion, java: mainJavaVersion])
quickMatrix.add([task: "partest-fastopt", scala: scalaVersion, java: mainJavaVersion, partestopts: ""])
Expand Down
5 changes: 4 additions & 1 deletion library/src/main/scala/scala/scalajs/LinkingInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ object LinkingInfo {

/** Constants for the value of `esVersion`. */
object ESVersion {
/** ECMAScrîpt 5.1. */
/** ECMAScript 5.1. */
@deprecated(
"ECMAScript 2015 is not supported anymore; LinkingInfo.esVersion will never be equal to ES5_1.",
since = "future")
final val ES5_1 = 5

/** ECMAScript 2015 (6th edition). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

package org.scalajs.linker.interface

import scala.annotation.compileTimeOnly

import Fing 8000 erprint.FingerprintBuilder

/** ECMAScript features to use when linking to JavaScript.
Expand Down Expand Up @@ -75,13 +77,8 @@ final class ESFeatures private (

/** Use the ECMAScript 2015 semantics of Scala.js language features.
*
* Default: `true`
*
* As of Scala.js 1.6.0, this is `true` if and only if
* `esVersion >= ESVersion.ES2015`. In the future, it might become
* independently configurable.
*
* When `true`, the following behaviors are guaranteed:
* Since "the future", this is always true. That means that the following
* behaviors are always guaranteed:
*
* - JavaScript classes are true `class`'es, therefore a) they can extend
* native JavaScript `class`'es and b) they inherit static members from
Expand All @@ -92,22 +89,8 @@ final class ESFeatures private (
* - Throwable classes are proper JavaScript error classes, recognized as
* such by debuggers (only with the JavaScript backend; not in Wasm).
* - In Script (`NoModule`) mode, top-level exports are defined as `let`s.
*
* When `false`, the following behaviors apply instead:
*
* - All classes defined in Scala.js are `function`s instead of `class`'es.
* Non-native JS classes cannot extend native JS `class`'es and they do
* not inherit static members from their parent class.
* - All lambdas for `js.Function`s are `function`s.
* - Throwable classes have JavaScript's `Error.prototype` in their
* prototype chain, but they are not considered proper error classes.
* - In Script (`NoModule`) mode, top-level exports are defined as `var`s.
*
* Prefer reading this value instead of `esVersion` to determine which
* semantics apply. Doing so will be future-proof if and when this setting
* becomes configurable independently from `esVersion`.
*/
val useECMAScript2015Semantics = esVersion >= ESVersion.ES2015
val useECMAScript2015Semantics: Boolean = true

/** Use ECMAScript 2015 features.
*
Expand Down Expand Up @@ -191,14 +174,9 @@ final class ESFeatures private (
* Otherwise, if `esVersion` was below `ES2015`, it sets it to `ES2015`.
* Otherwise, it returns the same configuration of `ESFeatures`.
*/
@deprecated(
"use withESVersion(ESVersion.ES5_1) or withESVersion(ESVersion.ES2015) instead",
"1.6.0")
def withUseECMAScript2015(useECMAScript2015: Boolean): ESFeatures = {
if (!useECMAScript2015) withESVersion(ESVersion.ES5_1)
else if (esVersion == ESVersion.ES5_1) withESVersion(ESVersion.ES2015)
else this
}
@compileTimeOnly("ECMAScript 5.1 is not supported anymore.")
def withUseECMAScript2015(useECMAScript2015: Boolean): ESFeatures =
this

def withAllowBigIntsForLongs(allowBigIntsForLongs: Boolean): ESFeatures =
copy(allowBigIntsForLongs = allowBigIntsForLongs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

package org.scalajs.linker.interface

import scala.annotation.compileTimeOnly

import Fingerprint.FingerprintBuilder

final class ESVersion private (val edition: Int, val name: String)
Expand All @@ -30,15 +32,13 @@ final class ESVersion private (val edition: Int, val name: String)
}

object ESVersion {
/** 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). */
val ES2015: ESVersion = new ESVersion(6, "ECMAScript 2015")

/** ECMAScript 5.1. */
@compileTimeOnly("ECMAScript 5.1 is not supported anymore.")
val ES5_1: ESVersion = ES2015

/** ECMAScript 2016 (7th edition).
*
* Contains the following notable features:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ 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
30 changes: 0 additions & 30 deletions linker/shared/src/test/scala/org/scalajs/linker/AnalyzerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -654,36 +654,6 @@ class AnalyzerTest {
}
}

@deprecated("test deprecated features", "forever")
@Test
def newTargetWithoutES2015(): AsyncResult = await {
val classDefs = Seq(
mainTestClassDef(LoadJSConstructor("A")),
classDef("A",
kind = ClassKind.JSClass,
superClass = Some(JSObjectLikeClass),
jsConstructor = Some(
JSConstructorDef(JSCtorFlags, Nil, None, JSConstructorBody(
Nil,
JSSuperConstructorCall(Nil),
JSNewTarget() :: Nil
))(EOH, UNV)
)
),
JSObjectLikeClassDef
)

val moduleInitializer = MainTestModuleInitializers

val analysis = computeAnalysis(classDefs,
moduleInitializers = MainTestModuleInitializers,
config = StandardConfig().withESFeatures(_.withESVersion(ESVersion.ES5_1)))

assertContainsError("NewTargetWithoutES2015Support", analysis) {
case NewTargetWithoutES2015Support(_) => true
}
}

@Test
def importMetaWithoutESModule(): AsyncResult = await {
val classDefs = Seq(
Expand Down
0