Questions tagged [scala.js]

Scala.js is a Scala to JavaScript compiler deemed production-ready as of version 0.6.0.

Scala.js compiles Scala code to JavaScript, allowing you to write your Web application entirely in Scala!

Noteworthy features:

  • Support all of Scala, modulo a few semantic differences
  • Very good interoperability with JavaScript code. For example, use jQuery and HTML5 from your Scala.js code, either in a typed or untyped way. Or create Scala.js objects and call their methods from JavaScript.
  • Integrated with sbt (including support for dependency management and incremental compilation)
  • Can be used with your favorite IDE for Scala
  • Generates Source Maps for a smooth debugging experience (step through your Scala code from within your browser supporting source maps)
  • Integrates Google Closure Compiler for producing minimal code for production.

Find out more at scala-js.org

845 questions
7
votes
1 answer

Check if call result is undefined

how can I check if the result to call a JavaScript function is undefined? I tried with if( s.getNode(id1) != js.undefined) but fastOptJS say: scala.scalajs.js.Dynamic and scala.scalajs.js.UndefOr[Nothing] are unrelated: they will most likely…
gilcu2
  • 343
  • 3
  • 13
7
votes
2 answers

How to use scala.js from maven

Is there any way to use scala.js with Maven. I want to use scala.js in maven based project, and AFAIU, it's hard to integrate sbt with maven.
Konstantin Solomatov
  • 10,252
  • 8
  • 58
  • 88
7
votes
2 answers

Scala.js: Using addEventListener to add events to objects

In JavaScript, the addEventListener() method is used like this: object.addEventListener("click", myScript); In Scala.js: I have a canvas, and I want to listen to clicks only on the canvas, not the entire document. In the Scala.js.dom library,…
user3025403
  • 1,070
  • 3
  • 21
  • 33
7
votes
1 answer

Scala.js vs Scala GWT for client web development?

I am planning to write a web application. However, I want to write both the client and server side in Scala. Should I choose Scala.js? or should I go for GWT. What are the cases where I have to choose one over the other? Also, are there any other…
user1980875
6
votes
1 answer

Can Scala.js generate TypeScript d.ts type bindings?

I'd like to use Scala.js to write libraries to then use in web applications written in TypeScript. This requires TypeScript type bindings (*.d.ts file) to be generated by Scala.js for my library. Does Scala.js support this?
6
votes
1 answer

ScalaJS plugin 0.6.23: "value %%% is not a member of String"

After migrating to ScalaJS 0.6.23 from 0.6.21: (addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.23")) My sbt-build throws the following exception: ... [error] /Users/mpa/dev/Github/pme123/scala-adapters/project/Settings.scala:88:20: value %%% is…
pme
  • 14,156
  • 3
  • 52
  • 95
6
votes
1 answer

Will Scala.js ever produce small bundles?

While I love Scala the language, and Scala.js the project, I'm a little put-off by the size of the eventual JS bundle, even in fullOptJS mode. My immediate need is to create a small-ish library for use in the browser. >150kb is a big ask, and…
vivri
  • 885
  • 2
  • 12
  • 23
6
votes
1 answer

Scala.js stacktraces

I'm frustrated by unintelligible stacktraces when my Scala.js code throws an exception. I thought I had a solution using a Javascript library (see Getting a scala stacktrace) but it breaks too often. How do you extract meaning (where the program…
bwbecker
  • 1,031
  • 9
  • 21
6
votes
1 answer

Using DependsOn between two ScalaJS SBT projects

(Long question ahead. Simplified tl;dr at the bottom). I have two ScalaJS projects built with SBT - "myapp" and "mylib", in the following directory…
James Davies
  • 9,602
  • 5
  • 38
  • 42
6
votes
2 answers

scala.js — getting complex objects from JavaScript

I'm trying scala.js and I must say that it's completely impressed! However, I try to introduce it into our production little-by-little, working side-by-side with existing JavaScript code. One thing I'm struggling with is passing complex structures…
Maguro
  • 61
  • 4
6
votes
1 answer

How can I copy Scala.js source maps using resourceGenerators?

I'm using resourceGenerators sbt key to copy fastOptJs-generated .js files when using products, like this: (resourceGenerators in Compile) <+= (fastOptJS in Compile in frontend, packageScalaJSLauncher in Compile in frontend,…
Patryk Koryzna
  • 475
  • 4
  • 13
6
votes
1 answer

How to combine crossProject and dependsOn

I have a multi-project definition something like the following: lazy val commonSettings = settings( libraryDependencies ++= Seq( "ch.qos.logback" % "logback-classic" % "1.1.2", ... ) lazy val core = (project in file(".")). …
user79074
  • 4,937
  • 5
  • 29
  • 57
6
votes
1 answer

Working with opaque types (Char and Long)

I'm trying to export a Scala implementation of an algorithm for use in JavaScript. I'm using @JSExport. The algorithm works with Scala Char and Long values which are marked as opaque in the interoperability guide. I'd like to know (a) what this…
Richard Dallaway
  • 4,250
  • 1
  • 28
  • 39
6
votes
1 answer

How to convert Scala.js application to CommonJS module?

Is there any standard way to use Scala.js application as a libriary in CommonJS environment? And if not, can I patch generated js file for that purpose?
AIring
  • 63
  • 5
6
votes
2 answers

ScalaJS: How to convert String to String?

Let's assume I have a list of Strings: List[String]. And I want to convert it to the interoperable JavaScript array of JavaScript Strings: js.Array[js.String]. How to do that?
Ilya Lakhin
  • 1,904
  • 1
  • 16
  • 31
1 2
3
56 57