0

I have a Scala.js jar, foo_sjs0.6_2.11-0.1-SNAPSHOT.jar, which contains javascript for my web server, and a separated Play project for controlers/views/etc.

Is there any way to compile and load .js files at runtime when I run the Play project, given it has foo_sjs0.6_2.11-0.1-SNAPSHOT.jar as a dependency?

P/S: I'm well aware of Play-Scala.js multi-project settings https://github.com/vmunier/play-with-scalajs-example, and I don't want that.

1 Answers1

1

It's possible. You just have to use the Scala.js Tools API programmatically to link the .sjsir files in the jars into a .js file. Look at how the CLI linker does it for inspiration.

sjrd
  • 21,805
  • 2
  • 61
  • 91
  • So in the end I'm still gonna create a js/jvm cross project, aren't I? – user1503000 Dec 02 '15 at 04:18
  • Probably, unless you also want to compile at runtime by invoking scalac like it's done in https://github.com/lihaoyi/scala-js-fiddle/blob/master/server/src/main/scala/fiddle/Compiler.scala But that's not the common case at all. What's the problem with a cross project? Maybe you want to elaborate on that in your question. – sjrd Dec 02 '15 at 07:27
  • Well I have another problem with sbt aggregation which makes me use sbt's default empty root project. Now I see I should pay more attention to sbt instead of working around. Thank you very much. – user1503000 Dec 02 '15 at 10:44