How can I create a JS library in scala-js? I am using standard Play/Scala server + scala-js client with shared objects. I want my library to be on URI /api/mylib.js. I don't know how make scala-js client project without main method. Also how to generate scala-js code to the specific URL I need.
1 Answer
To write a JS library, you need to export the public API to JavaScript.
You will also likely want to disable the generation of the "launcher", which looks for a JSApp in your classpath and calls its main method. Otherwise fastOptJS will complain that it cannot find any JSApp. You can do this with the following sbt setting:
persistLauncher := false
Edit: See also the blog post How to make an idiomatic Javascript library with Scala.js
playframeworktag.