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
0
votes
0 answers

Adding Provided JS (under a directory) in SBT causing unexpected token

Invalid character is coming in the generated *-js-deps.js, when I am trying to add a ProvidedJS build.sbt I tried with 0.6.9 & 0.6.11 addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.11") jsDependencies += ProvidedJS /…
Justin Patel
  • 1,323
  • 10
  • 5
0
votes
1 answer

Jquery plugin with Scala

Any one knows how to use a jquery plugin bootstrap-multiselect in scala js code. Scala.js has library which wrapped a jquery, I want to use similar statitically type code for jquery plugin finally I want to create a react component for multiselect…
Justin Patel
  • 1,323
  • 10
  • 5
0
votes
1 answer

How to access an HTML form element as Scala.js "HTMLFormElement" (in order to call "post()" on it)?

There's a form in an HTML page:
and I can address that form in scala.js just fine via dom.document.getElementById("mainForm") Next I want to call .send() on the form to submit it.…
Hannes
  • 3
  • 2
0
votes
1 answer

Scala.js, typed facade for wavesurfer.js

I'm implementing a facade for wavesurfer.js library. I have read the official docs and these questions. It should be an easy task, however I'm experiencing some problems. What I have so far: @js.native trait WaveSurferOpts extends js.Object { val…
ars
  • 1,509
  • 3
  • 18
  • 29
0
votes
1 answer

Folding union-types into Either/Coproducts

Given a pseudo-union type in Scala.js, how would I fold it into an Either[A, B] (or a coproduct)?
Reactormonk
  • 21,472
  • 14
  • 74
  • 123
0
votes
1 answer

µPickle Couldn't derive type error on write

I'm trying to use µPickle in Scala.js to produce Json for Ajax request. Here is my code: import upickle._ import upickle.default._ case class FmData(name: String, comment: String) val data = write(FmData("name", "comment")) And I…
sergeda
  • 2,061
  • 3
  • 20
  • 43
0
votes
1 answer

Scala.js jQuery: Getting the text from a html input

I am "somewhat" new to Scala, and am learning some Scala.js. I have a html form and am trying to take the strings from the fields and do some pattern matching to see if they meet basic criteria. The problem I'm having refers to the method of…
Patrick S.
  • 275
  • 1
  • 5
  • 19
0
votes
2 answers

upickle: invalid string value during deserialization

I am quite new in scala.js world so I decided to try it out on some small examples and one of them is quite simple get request with parsing of returning json back into scala entity. Please find code which does it below: def…
tkachuko
  • 1,956
  • 1
  • 13
  • 20
0
votes
1 answer

List of Scala.js classes actually linked into fastOpt.js/ fullOpt.js?

I'm writing an sbt plugin that creates a JS file from a specific StaticAnnotation type; instead of including all annotations found on the classpath, I would prefer to only emit annotations on classes that were actually linked by fastOptJS /…
jokade
  • 197
  • 5
0
votes
1 answer

scalajs prototype propery on js object

I'm trying to convert the js: // var XComponent = document.registerElement('x-component', { // prototype: Object.create(HTMLElement.prototype, { // createdCallback: { // value: function() { // var root =…
ses
  • 13,174
  • 31
  • 123
  • 226
0
votes
1 answer

Using scala-js-env-selenium for crossbrowser testing

I am using https://github.com/scala-js/scala-js-env-selenium for in-browser testing, so far tests are running fine in local browser. Now i want to run my tests in remote browsers (https://app.crossbrowsertesting.com) I created new…
invariant
  • 8,758
  • 9
  • 47
  • 61
0
votes
1 answer

scalajs facade unable to access native js method

I'm trying to use the facade for createjs https://github.com/scalawarrior/scalajs-createjs In createjs, display objects have a 'clone' method that is used for making quick duplicates of sprites and bitmaps. But I get a compiler error when I try to…
user2241515
  • 121
  • 2
  • 8
0
votes
1 answer

Scala-js - Navigator.oscpu

Can you advice me how to get Navigator.oscpu using Scala-js? Mapping to native Navigator does not seems to have the oscpu. https://developer.mozilla.org/en-US/docs/Web/API/Navigator/oscpu
Skoky
  • 849
  • 1
  • 9
  • 15
0
votes
1 answer

org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2

I am using scalatest as my testing framework, here is my test code : import org.scalatest.FunSuite class SampleTest extends FunSuite{ test("hello") { println(s"sdfsf") } } build.sbt settings val scalatestJS = libraryDependencies +=…
invariant
  • 8,758
  • 9
  • 47
  • 61
0
votes
1 answer

Avoid repeating package names in Scala.js calls from HTML

I use many calls like this in the HTML page to call my Scala.js code: