Open MikaelMayer opened 9 years ago
+1 (if that's an acceptable way to promote an issue-report which is also a bugfix-proposal). Agree with the ebook sentiment - as a Scala.js learner, the hands-on ebook is great - still, the book could mention here the appJVM/run
"magic spell"-command - i got stuck looking for the right incantation until asked on Gitter https://gitter.im/scala-js/scala-js , where someone kindly pointed it out. And thanks Mikael for pointing out the minor bug in specifying the correct -fastopt.js
file in Page.scala, applying your fix was the solution to get the app running.
+1. Wasted hours on the various issues in the client-server tutorial, a big detraction from an otherwise great resource. Thank you Mikael for devoting the time to hunt down all the solutions.
I'm stilling having trouble executing the code of the client-server tutorial. Here's what I tried so far:
cd hands-on-scala-js
sbt
clientserver/run
and appJVM/run
This yielded:
[warn] No main class detected java.lang.RuntimeException: No main class detected. at scala.sys.package$.error(package.scala:27)
Any help is much appreciated.
Edit:
Never mind, I took Li Haoyi's example and overhauled it: https://github.com/mb720/scalajsClientServer
The project includes instructions on how to start the server (it's easy, though). Also, I used the most recent version of all dependencies (except for spray-can 1.3.3 where I noticed a constant and significant CPU load after the first request from the client). I modified the code a bit when I could make things simpler and when APIs changed or were deprecated.
Feedback is very welcome! :-)
Before I create a pull request for fixing the issues I encountered while reading this wonderful book, I will put them there so that I can obtain your confirmation they are real issues.
A Client-Server Setup
Add a file
project/build.properties
containingsbt.version=0.13.7
to ensure that the SBT version is high enough. My sbt version by default is 0.13.0There is a missing plugin in
project/build.sbt
which should be added at the end of the file.Replace in the file
Page.scala
the first line by the secondAdd this to the file
Page.scala
just before the other script (dependencies)State the command required to run the server (it took me four hours to figure out, between
run
,re-start
,app/re-start
,app/run
which had missing main classes, or evenstart
etc., until I figured out I could start sub-projects)Any remarks, or other ways to make this work?
edit; How to integrate sbt resolver:
After some time, I figured out how to configure sbt resolver thanks to your project
scala-js-fiddle/blob/master/project/Build.scala
.In the file
project/build.sbt
, include the following:In the file
/build.sbt
, do the following:Now the application can be started using
re-start
in sbt directly. I think it can be a valuable point to include in the tutorial.