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
5
votes
1 answer

Scala.JS configuration for Scala 3?

I tried posting this question to Scala Users but no reply yet. How does one go about working with the new experimental Scala 3 with Scala.JS? I can’t find cogent instructions. Shockingly there’s nothing I can find on this topic on the Internet. For…
Shelby Moore III
  • 6,063
  • 1
  • 33
  • 36
5
votes
2 answers

How to change the entry point to something other than the default 'src/main.js' using Vite?

I want to point to a different location and file name and deviate from the Vite standard. Let's say my js file is in out/frontend/../../out.js. I got it working when I rename it to main.js and copy it in the root of my project where index.html and…
user3350744
  • 449
  • 1
  • 5
  • 12
5
votes
2 answers

Scalajs & scala ZIO

Does scala.js work with scala ZIO? I'm looking to use scala ZIO with scala.js I only know how to use scala ZIO in normal apps does anyone know how to use it with scala.js?
NaseemMahasneh
  • 485
  • 5
  • 19
5
votes
0 answers

scalajs-bundler choking on source map URLs prefixed with local path, e.g. './http...' source files when running fastOptJS::startWebpackDevServer

I have a ScalaJS project and running the sbt command fastOptJS::startWebpackDevServer in Windows 10 yields errors like in the following snippet: [error] (Emitted value instead of an instance of Error) Cannot find source file…
Zachary Albia
  • 71
  • 2
  • 7
5
votes
1 answer

Sleep inside Future in Scala.js

Is it possible to sleep inside a Future in Scala.js ? Something like: Future { Thread.sleep(1000) println("ready") } If I try this then I get an exception saying that sleep method does not exist. It seems like that it is possible to sleep in…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
5
votes
1 answer

In Scala.js, how to best create an object conforming to a trait from a JS façade?

Suppose I have this definition in Scala.js for the return type of a function of some library I'm using: @native trait Link extends Object { val href: String = native val title: String = native } What's the best, typesafe way, in Scala code, to…
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
5
votes
0 answers

Cannot preserve state in Scala.js

I am trying to write a simple scala.js application. The problem I now have is that I can't figure out why I fail to save data which I get from the server / user. To be more concrete, here are code snippets: