Skip to content
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

Support ESFeatures in Scala.js #1671

Merged
merged 8 commits into from
Jan 14, 2022

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Jan 12, 2022

ScalaJSModule currently supports the useECMAScript2015 settings.
Nowadays Scala.js offers support for multiple ESVersion.
In the official Sbt plugin they are set inside an object called ESFeatures that contains other settings.
This PR tries to mimic the Scala.js API.
It is a breaking change, since overriding the old useECMAScript2015 doesn't have any effect anymore.

How deprecate overriding useECMAScript2015

Since we can't derive ESFeatures from useECMAScript2015, I can't use the same deprecation mechanism as testFrameworks. What I did instead is to define a private boolean var in ScalaJSModule called overriddenUseECMAScript2015 that is first set to true. It is then set to false by the default implementation of useECMAScript2015 which calls back the new esFeatures. Before fastOpt and fullOpt I call a private checkDeprecations task, which calls useECMAScript2015() and then checks the overriddenUseECMAScript2015. If it was overridden then the value remains true and it fails the task with an error message; otherwise it finds false and continues with the build.

@lolgab lolgab force-pushed the support-esfeatures-in-scala-js branch from ab8be79 to 3b86356 Compare January 13, 2022 13:24
@lolgab lolgab marked this pull request as ready for review January 13, 2022 15:23
@lefou
Copy link
Member

lefou commented Jan 13, 2022

@lolgab You may want to look into JavaModule.bspCompileClassesPath, where I've implemented an override detection for the compile target.

if (compile.ctx.enclosing == s"${classOf[JavaModule].getName}#compile") {

Once we know we have an overridden deprecated target, we can issue a warning message and also use the value to derive the new target, otherwise we can just go with our defaults.

@lolgab lolgab requested a review from lefou January 13, 2022 17:21
scalajslib/src/ScalaJSModule.scala Outdated Show resolved Hide resolved
scalajslib/src/ScalaJSModule.scala Outdated Show resolved Hide resolved
@lolgab lolgab requested a review from lefou January 14, 2022 10:30
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@lefou lefou merged commit 9c818ae into com-lihaoyi:main Jan 14, 2022
@lefou lefou added this to the after 0.10.0-M5 milestone Jan 14, 2022
@lolgab lolgab deleted the support-esfeatures-in-scala-js branch January 14, 2022 12:32
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