2

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
  • The particular URL at which you serve your .js file depends on your web server (Play!), not on Scala.js itself. This should be asked as a separate SO question with the playframework tag. Commented Jan 10, 2016 at 8:36

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.