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

Getting started is challenging #228

Open
davesmith00000 opened this issue Nov 7, 2021 · 3 comments
Open

Getting started is challenging #228

davesmith00000 opened this issue Nov 7, 2021 · 3 comments

Comments

@davesmith00000
Copy link

Hello!

This looks like a great project ...but I found it difficult getting something simple up and running and gave up. The details in the readme seem to be inadequate and the arrangement of the demos/examples is too involved for a quick start.

Examples:

  1. The readme does not include a simple build.sbt arrangement.
  2. How to run it - I went for fastOptJS and a local http server but is that right?
  3. It doesn't mention @JSExportTopLevel("main") - I should have known about that one but I still tripped over it.

Doing the prescribed minimum for me produces:

image

Should I be exporting modules? The HTML file examples suggest not?

I'll have another go some other time, just thought the feedback might be useful as it may be a barrier to adoption. This is what I did (nothing clever, just followed/interpreted the readme):

PurpleKingdomGames/indigo@ea622ea

All the best,

Dave

@davesmith00000
Copy link
Author

I wrote this issue up rather quickly yesterday, and today I'm feeling paranoid that it reads as rather blunt/abrupt, or that I'm expecting you to do something. I'm not expecting anything, just trying to be helpful - apologies if the original description doesn't come across that way. :-)

@japgolly
Copy link
Owner

Hi! Firstly thank you for the clarification message. I've no problem with your original but I really appreciate the kindness and know exactly what you mean in feeling how you felt. Text always seems to be a bit more ambiguous without a tone of voice bundled with it.

Unfortunately I don't have the time to spend making a nice getting started guide (at least for a while). I was kind of hoping that having the real working demo project and the examples in the readme would be enough, but I can see how that actually relies on quite a bit of implicit knowledge.

Which is a perfect segue to the issue you're seeing and the questions you're asking about. The implicit knowledge required there is pure Scala.js knowledge, and not scalajs-benchmark specific. I think you'd have the same problems with any other lilbrary... which I'm sure provides exactly zero comfort to you now haha. Let me do my best:

How to run it - I went for fastOptJS and a local http server but is that right?

There's no One Way for running Scala.js stuff. For short and sweet projects like this demo (and the scalajs-react ghpages site for another example), I just have a few static html files, and a little python server to serve both those files and the Scala.js-generated JS files. For larger projects I use something like http4s, or even a servlet + Jetty. There are some sbt plugins to make it nice and pleasant, (sbt-revolver is simple and awesome, for example).

It doesn't mention @JSExportTopLevel("main") - I should have known about that one but I still tripped over it.

Yeah you've got to expose some kind of function, which you then call from a little inline <script> tag in your html. Scala.js used to have the ability to add a little code to your generated JS, so that it calls your function as well; I just can't remember if that's still present or it's been removed. Either way, I personally don't use it but it's probably an option!

Should I be exporting modules? The HTML file examples suggest not?

Nah no need to export a module. You're gonna laugh when I tell you this but I think the problem you're having is that your def main is asking for a Array[String], where as when you call it from your html, you're calling main(), which is like calling main(undefined) 😅. Try using def main(): Unit instead and I think you'll be in business.

Now all of that aside, not to be rude or anything but I've got tons on so I can be a bit infrequent in checking in on OSS issues. If you don't mind a delay then np, but you'd be able to get immediate feedback if you check out the Scala.js gitter. From what I've seen they're pretty nice and friendly, and pretty quick to respond too.

I hope that helps!

davesmith00000 added a commit to davesmith00000/scalajs-benchmark that referenced this issue Nov 10, 2021
In response to japgolly#228.

I got it working and thought I'd try and help the next person. :-)
@davesmith00000
Copy link
Author

Hi,

There were two problems:

  1. As you said, calling main() with the wrong args.
  2. Requires the inclusion of the charts lib.

I've submitted a PR for your consideration that may help the next person: #229

Thanks again,

Dave

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

No branches or pull requests

2 participants