3 ms·
Amazing work - thanks for putting it out there. In your live coding presentation, you mentioned that the output from compiling scala to js is several files. I
by apo 10y ago
Amazing work - thanks for putting it out there.
In your live coding presentation, you mentioned that the output from compiling scala to js is several files.
I'm interested in generating one file that exposed JavaScript functions that can be easily called from a js runtime.
In other words, I'd like to write a JavaScript library in Scala - not a full-blown application.
What are some good resources showing how to do this?
- lihaoyi 10y agoThe live coding presentation is two years out of date; Scala.js now compiles to a single JS blob Everything function marked with @JSExport will be exposed to Javascript. There's no concrete difference between an application with one `@JSExport def main` method that you call to initialize it, and a library with multiple `@JSExport`ed methods. It all works the same way: the `@JSExport`ed functions are exposed, and people can call them. This repo shows how to make a NPM library using Scala.js - https://github.com/rockymadden/scala-node/ https://github.com/rockymadden/scala-node/ If you want to learn how to use `@JSExport` properly, the [core documentation](http://www.scala-js.org/tutorial/basic/ http://www.scala-js.org/tutorial/basic/) and [Hands-on Scala.js](http://www.lihaoyi.com/hands-on-scala-js/ http://www.lihaoyi.com/hands-on-scala-js/) are great.