scala.js

How can scala-js integrate with sbt-web?

本秂侑毒 提交于 2019-12-03 15:21:41
I would like to use scala-js with sbt-web in such a way that it can be compiled to produce javascript assets that are added to the asset pipeline (e.g. gzip, digest). I am aware of lihaoyi's workbench project but I do not believe this affects the asset pipeline. How can these two projects be integrated as an sbt-web plugin? Scala-js produces js files from Scala files. The sbt-web documentation calls this a Source file task . The result would look something like this: val compileWithScalaJs = taskKey[Seq[File]]("Compiles with Scala js") compileWithScalaJs := { // call the correct compilation

Scala.js compilation destination

我怕爱的太早我们不能终老 提交于 2019-12-03 11:51:02
问题 I'm working on a Scala.js cross project where the jvm folder represents my server application and js represents my scala.js code. Whenever i compile my scala.js code via sbt crossJS/fastOptJS the compiled JS ends up in ./js/target/scala-2.11/web-fastopt.js . I need to have this compiled JS file accessible in the resources of the server project in the jvm folder, so i can server it through my web application. I think i have to do something with artifactPath but i can't seem to get any results

What is the difference between scala.js vs jscala?

落爺英雄遲暮 提交于 2019-12-03 11:13:03
问题 There are two tools to compile Scala code right in the JavaScript: Scala.js and JScala. Both of them look great, and can work with non-trivial Scala code. What is the technical difference between them? 回答1: Actually there are more than two tools, but Scala.js and JScala are indeed the 2 tools still under active development. The difference is fundamental: Scala.js is a compiler from Scala to JavaScript, whereas JScala is a macro-based DSL for generating snippets of JavaScript code. As @Gaurav

How do I port an existing Scala library to scalajs?

大憨熊 提交于 2019-12-03 05:29:36
I'm new to Scala.js. I'd like to use the Argonaut json library. https://github.com/argonaut-io/argonaut Its only dependencies appear to be Monocle and Scalaz which both have versions compiled for Scala.js. I'd be happy to work on porting Argonaut to Scala.js, but don't have a firm idea on how to begin. Does anyone have any pointers? Thanks. sjrd Quick proof-of-concept The first thing to try is to convert the build so that the JVM projects become Scala.js projects. The basis for this is pretty easy: In project/plugins.sbt , add the dependency to the Scala.js sbt plugin: addSbtPlugin("org.scala

Scala.js compilation destination

做~自己de王妃 提交于 2019-12-03 03:13:09
I'm working on a Scala.js cross project where the jvm folder represents my server application and js represents my scala.js code. Whenever i compile my scala.js code via sbt crossJS/fastOptJS the compiled JS ends up in ./js/target/scala-2.11/web-fastopt.js . I need to have this compiled JS file accessible in the resources of the server project in the jvm folder, so i can server it through my web application. I think i have to do something with artifactPath but i can't seem to get any results from my experiments thus far. You can simply set the artifactPath of the fastOptJS task (or the

What is the difference between scala.js vs jscala?

懵懂的女人 提交于 2019-12-03 02:42:46
There are two tools to compile Scala code right in the JavaScript: Scala.js and JScala . Both of them look great, and can work with non-trivial Scala code. What is the technical difference between them? Actually there are more than two tools, but Scala.js and JScala are indeed the 2 tools still under active development. The difference is fundamental: Scala.js is a compiler from Scala to JavaScript, whereas JScala is a macro-based DSL for generating snippets of JavaScript code. As @Gaurav explained in his answer, Scala.js is the regular Scala compiler, but it emits JavaScript code instead of

Scala-JS for real web project [closed]

走远了吗. 提交于 2019-12-02 17:10:37
Has someone used Scala-JS in real web project but not only for plain JavaScript replacement in isolated env ? I would like to use Scala as much as possible (I wish I could). And seems Scala-JS claims to be that lib I could use (now) or in the future. That's why I'm interested in small working solution to look at, to bootstrap (like PlayFramework app where Scala-JS ). The solution/example that could demonstrate that Scala-JS can be used in real web-development work. I'm asking because what I found about Scala-JS so far is hardly real usage of it. Q: some examples / proves that It is ready to

Creating custom DOM events with scalajs

為{幸葍}努か 提交于 2019-12-02 02:46:20
问题 I can't find a way to create custom events with scala-js. For instance, with js you can create a custom event like the following (taken from here): var event = new CustomEvent('build', { 'detail': elem.dataset.time }); However, there is no constructor for CustomerEvent or Event in scala-js that accept arguments. Also, subclassing either such as: class DrawEvent extends Event { override def `type` = "draw" } leads to Uncaught TypeError: undefined is not a function when trying to construct via

Cannot get uTest to see my tests

随声附和 提交于 2019-12-01 19:58:13
问题 I'm trying to get uTest to work with ScalaJS and SBT. SBT is compiling the files, and uTest is running, but it simply ignores my tests. Try as I might I cannot find any difference between my code and the tutorial examples. build.sbt: enablePlugins(ScalaJSPlugin) name := "Scala.js Stuff" scalaVersion := "2.11.5" // or any other Scala version >= 2.10.2 scalaJSStage in Global := FastOptStage libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0" testFrameworks += new TestFramework("utest

How to read a resource file in Scala.js?

点点圈 提交于 2019-12-01 19:42:40
Let's say I have a map.csv file at the same level (or some other webapp-accessible place) as index-{dev,opt}.html , e.g.: key1,value1 key2,value2 ... keyN,valueN I want to read in that CSV file and end up with a Map[String,String] . I know how to do that in Scala, but how would I do that in Scala.js? I'm trying not to hard-code the keys and values. The parsing is basically identical to how you would do it in conventional Scala -- it's the same language, after all. So the real issue is fetching the file. There's no one-size-fits-all solution there; it depends on what you're using as the web