Skip to content

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Feb 11, 2020

And update the website to use 1.x by default everywhere.

The tutorial is duplicated, with one version for 1.x (the default), and a legacy version for 0.6.x.


Not to be merged yet, but review welcome :)

@sjrd sjrd requested a review from gzm0 February 11, 2020 18:56
After 7 years of development, including 5 years of stability within the 0.6.x series, we are finally ready to present Scala.js 1.0.0.
Quoting Antoine de Saint-Exupéry,

> Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
Copy link

Choose a reason for hiding this comment

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

👍 ❤️ Rigor and obsession in the Scala.js development process is an example for all of us emulate! Thank you!

@sjrd sjrd force-pushed the scalajs-1.0.0 branch 6 times, most recently from fa167be to bf828c9 Compare February 13, 2020 17:04
doc/api.md Outdated
* [scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/latest/org/scalajs/testadapter/index.html)
* [sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/latest/#org.scalajs.sbtplugin.package)
* [sbt-scalajs-env-phantomjs]({{ site.production_url }}/api/sbt-scalajs-env-phantomjs/latest/#org.scalajs.jsenv.phantomjs.sbtplugin.package)
* [sbt-jsdependencies]({{ site.production_url }}/api/sbt-jsdependencies/latest/#org.scalajs.jsdependencies.sbtplugin.package)
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered removing the projects that are not in the core repo from this list? Since they will observe a different release schedule, they might best be put elsewhere? Just like the DOM and jQuery API below?

org.scalajs.jsenv.Input.Script(file("./jquery.js").toPath)
Compile / jsEnvInput := jQueryScript +: (Compile / jsEnvInput).value
Test / jsEnvInput := jQueryScript +: (Test / jsEnvInput).value
{% endhighlight %}
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 a bit problematic IMO. We really don't want anybody to think this is a good way to use Scala.js, do we?

How hard would it be to:

  • Not rely on a bare JS library.
  • Use scala-js-bundler in the tutorial.

Note that I haven't reviewed in detail yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

It highlights a limitation of how we set up the jsEnvInput setting. We should initialize it to Nil in the no-configuration scope, and add the linked file in each configuration. That way we would only have to write

jsEnvInput += Input.Script(file("./jquery.js").toPath)

in this build.

We can improve that in 1.0.1, but for 1.0.0 we're stuck with this suboptimal config :(

Copy link
Member Author

Choose a reason for hiding this comment

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

Not rely on a bare JS library.

That would defeat the purpose of that entire section. Of course we can remove all the section about jQuery, and keep using the DOM until the end. Maybe that would be better?

Use scala-js-bundler in the tutorial.

That's probably going a step too far for this tutorial, which in my opinion lays the ground knowledge of how Scala.js work, and which every Scala.js user needs to know.

But I can write an alternative story where we do that, for comparison.

Copy link
Contributor

Choose a reason for hiding this comment

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

keep using the DOM until the end. Maybe that would be better?

That was my thinking as well. It would avoid some of the boilerplate of dealing with native JS libs. We should defer to the scalajs-bundler documentation for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have pushed a commit that changes the tutorial to stick to standard DOM, rather than using jQuery. It goes with the following branch of the scalajs-tutorial repo: https://github.com/scala-js/scalajs-tutorial/commits/develop-1.x-no-jquery

Looking at it now, I actually think it's much better overall :)

* `relativeSourceMaps`
* `scalaJSOptimizerOptions`

Finally, if you are still using sbt 0.13.x, you will have to upgrade to sbt 1.2.1 or later (as of this writing, the latest release is 1.3.4).
Copy link
Contributor

Choose a reason for hiding this comment

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

1.3.8? (taken from below).


You will not be able to use Scala.js 1.0.0 with sbt 0.13.x.
You will have to upgrade to sbt 1.2.1 or later.
As of this writing, the latest version is 1.3.8.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put this to the bottom since it was already mentioned?


* Scala 2.10.x is not supported at all,
* Only 2.11.12 is still supported in the 2.11.x series, and
* 2.12.1 and following are supported in the 2.12.x series, but not 2.12.0.
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a useful thing to mention in "before you upgrade": Upgrading the Scala version can (and should) be done before upgrading Scala.js to minimize simultaneous changes.


Scala.js 1.x consolidates all of that into one simple task key `jsEnvInput` of type `Seq[org.scalajs.jsenv.Input]`, where an `Input` is an ADT with the following possible alternatives:

* `Input.Scripts(script)`: a JavaScript file to load as a script
Copy link
Contributor

Choose a reason for hiding this comment

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

Input.Script?

gzm0 added a commit to gzm0/scala-js that referenced this pull request Feb 14, 2020
This allows users to simply write jsEnvInput += Input.Script(myJSLibrary) in their build. Discovered while writing the tutorial: scala-js/scala-js-website#478 (comment)
@sjrd sjrd force-pushed the scalajs-1.0.0 branch 2 times, most recently from a3202b5 to 882bc2c Compare February 14, 2020 12:29
@sjrd sjrd requested a review from gzm0 February 14, 2020 15:36
@sjrd
Copy link
Member Author

sjrd commented Feb 14, 2020

@gzm0 I believe I have addressed all your comments.

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.

We can avoid this issue by building the UI directly from the Scala.js code.

In your `build.sbt`, set:
Instead of prepare the button in the HTML, we can add the following code to the `main` method in Scala.js:
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of preparing


val button = jQuery("button:contains('Click me!')")
assert(button.length == 1)
val button = document.querySelector("button")
Copy link
Contributor

Choose a reason for hiding this comment

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

Cast this to HTMLElement (or HTMLButtonElement) so you can call click()?

jsDependencies +=
"org.webjars" % "jquery" % "2.2.1" / "jquery.js" minified "jquery.min.js"
val button = document.createElement("button")
button.textContent = "Click me!"
Copy link
Contributor

Choose a reason for hiding this comment

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

In appendPar we seem to use document.createTextNode (which seems unnecessarily verbose). Is this inconsistency deliberate?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it was not intended. The code in appendPar is much older, and perhaps at the time textContent did not exist yet. I have changed appendPar to use textContent a well.

@sjrd
Copy link
Member Author

sjrd commented Feb 14, 2020

Updated to address the nits, and squashed all in one commit.

gzm0 added a commit to gzm0/scala-js that referenced this pull request Feb 17, 2020
This allows users to simply write jsEnvInput += Input.Script(myJSLibrary) in their build. Discovered while writing the tutorial: scala-js/scala-js-website#478 (comment)
gzm0 added a commit to gzm0/scala-js that referenced this pull request Feb 17, 2020
This allows users to simply write jsEnvInput += Input.Script(myJSLibrary) in their build. Discovered while writing the tutorial: scala-js/scala-js-website#478 (comment)
gzm0 added a commit to gzm0/scala-js that referenced this pull request Feb 17, 2020
This allows users to simply write jsEnvInput += Input.Script(myJSLibrary) in their build. Discovered while writing the tutorial: scala-js/scala-js-website#478 (comment)
And update the website to use 1.x by default everywhere. The tutorial is duplicated, with one version for 1.x (the default), and a legacy version for 0.6.x.
@sjrd sjrd changed the title DO NOT MERGE Announcing Scala.js 1.0.0. Announcing Scala.js 1.0.0. Feb 25, 2020
@sjrd sjrd merged commit b9d3f79 into scala-js:master Feb 25, 2020
@sjrd sjrd deleted the scalajs-1.0.0 branch February 25, 2020 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants