851 questions
0
votes
2
answers
346
views
What determines the output javascript file name generated by scalajs sbt plugin?
In this project:
https://github.com/tribbloid/scalajs-cli-demo
I defined a scalajs project using a combination of npm and sbt, inside npm package file I declare sbt as a prepublish script:
"...
4
votes
0
answers
113
views
Is sbt the only option when it comes to scala.js and IntelliJ IDE?
I'm writing a scala library that can be compiled into both JVM bytebodes and javascript minified npm package (through scalajs).
It will be released on both maven central and npm public repositories, ...
8
votes
2
answers
10k
views
leaflet map does not appear correctly until resize
I am using Leaflet with scalajs-leaflet facade on Binding.scala, and the map initializes/appears incorrectly.
In order to reproduce the issue, i have prepared a lihaoyi/workbench page similar to ...
0
votes
1
answer
115
views
LinkingErrors when updating from Scala.rx 0.3.2 to 0.4.0
In my project I use Scala.rx 0.3.2. When I upgraded to version 0.4.0 - without changing any code - I suddenly get a lot of LinkingErrors for even simple code like:
private val pageVisibility: Var[...
0
votes
1
answer
268
views
React Simple Global Entity Cache instead of Flux/React/etc
I am writing a little "fun" Scala/Scala.js project.
On my server I have Entities which are referenced by uuid-s
(inside Ref-s).
For the sake of "fun", I don't want to use flux/redux architecture ...
1
vote
1
answer
382
views
Binding.scala: how to define checked in a Checkbox
I want to define a checkbox in Binding.scala, like:
<input type="checkbox"
checked={elem.checked}
/>
elem.checked can have any String value (even an empty):the ...
2
votes
1
answer
548
views
Poll a Future in Scala.js
I have a Future in a cross-platform JVM / JS application. The future is polled following way in JVM:
val load = Future(loadSometing())
if (load.isCompleted) {
val loaded = Await.result(load, ...
0
votes
1
answer
62
views
Overloaded method value trigger with alternatives for '=> Unit' parameter
I just upgraded Scala.rx version 0.3.2 to 0.4.0 and suddenly I get the following errors on my triggers:
overloaded method value trigger with alternatives:
[error] (f: Boolean => Unit)(implicit ...
0
votes
2
answers
108
views
Asynchronous Computation in scalajs Diode
I have an user interface and provide a button to the user, which executes the function longComputation(x: A): A and updates then the user interface (particularly the model) with the new result. This ...
0
votes
0
answers
159
views
Scala JVM calling Scala JS
Is it possible to call a scala JS function directly from scala JVM with parameter passing ?
I want to execute some javascript code in the browser, for example a plotting javascript library that ...
1
vote
0
answers
53
views
Scala.js @JSGlobal - cannot perform run sbt
I'm struggling with an error and I cannot think of good solution.
I have class:
@JSGlobal("THREE.Scene")
class Scene extends js.Object {
def add(obj: js.Object): Unit = ???
}
and main:
[...]
...
1
vote
0
answers
455
views
SBT plugin is added as a dependency in my published library
I recently released my first Scala & Scala.js cross-building library to Sonatype. Now I want to use the Scala.js lib in one of my applications, however if I want to add a dependency to my lib ...
2
votes
1
answer
152
views
Scala and Scala.js version included in artifact id
I just successfully released my first Scala & Scala.js cross-building library to Sonatype and can now use the following two artifacts in my applicatons:
https://search.maven.org/artifact/com....
-1
votes
1
answer
141
views
binding.scala component to string conversion
I have a binding.scala component and a third party scalajs library that takes html string as input. How can the b.s component can be passed to the library method as an argument?
Specifics:
import ...
2
votes
1
answer
339
views
Setup a scala.js cross compiled library
I have a small Scala library that I want to make use of in a Scala.js application: https://github.com/fbaierl/scala-tarjan
For that reason, I have decided to create a cross-compiled library that ...
1
vote
1
answer
686
views
String interpolation like java.text.MessageFormat for scala.js
I need a string interpolation like java.text.MessageFormat for scala.js. Specifically I need something that lets me chose the order in which my parameters are printed (like '{0}', '{1}') for our ...
3
votes
2
answers
733
views
Scala.js: CSS styled console logs
With javascript I can print styled logs on the console like e.g. this:
console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
which will result in:
Is there any way I can do the same ...
0
votes
1
answer
80
views
extending js.native class yields TypeError: Class constructor cannot be invoked without 'new'
I get a TypeError when extending a @js.native class in scala.js and running in node.
object MainApp {
def main(args: Array[String]): Unit = {
println(new B())
}
}
class B extends A
@js....
0
votes
1
answer
360
views
Sessions in Scala.JS (and Play)
I want to get a very simple user authentification going in a web-app that is written in Scala.JS and whose backend is implemented in Play 2.6.
Using the Scala.JS RosHTTP-library, my user-client ...
3
votes
1
answer
214
views
Making a JVM scala library available in Scala.js
What is the standard/easiest way to make a normal scala library (sbt) available for scala.js (also sbt)? Do I just copy/fork the source files into a scala.js project and build that or is there any ...
1
vote
1
answer
211
views
Simulacrum in Scalafiddle: exception during macro expansion
I wanted to use Simulacrum in Scalafiddle, like:
import simulacrum._
@typeclass trait Ordering[T] {
def compare(x: T, y: T): Int
@op("<") def lt(x: T, y: T): Boolean = compare(x, y) < ...
0
votes
1
answer
134
views
Binding.scala: Get current value of a Binding
It seems it is not possible to get the current value of a Binding like we can do for a Var(using method value). I looked at the source and this method is declared as being private for Binding class, ...
1
vote
2
answers
727
views
What to import in Scala.js to use a simple "ProvidedJS" module?
I have very simple local module exporting a class. I would like to use this module locally, using ProvidedJS. No matter what I have tried, each time I do run or test in sbt, the compiler complains ...
1
vote
0
answers
656
views
React-Table Filter not receiving value after onChange triggered
I'm using ScalaJs and ReactJs with React-Table. I've run into an odd issue where the Filter object in react-table is missing the filter value when I set a custom Filter component for a specific column....
2
votes
1
answer
125
views
How to convince Scala.js to use Javascript defined method equals for comparison?
Background: the real projects uses Three.js with a facade. Both Three.js and the facade define the equals method for many types, including Vector3. This is a small sample demonstrating the equals ...
1
vote
1
answer
33
views
Let Play! dynamically insert data for Scala.js script
I have a project using Play Framework as a server and the client written in Scala.js and inserted into the page delivered via scalajs-scripts. There also is a shared sub-project used by both server ...
1
vote
1
answer
1k
views
scalajs and webpack4 config settings issues
I am using webpack 4.20.2 and scalajs ("0.6.24") , scalajs bundler(0.13.1)
when i am building bundle file i am getting below webpack exceptions. I am attaching build.sbt which uses webpack.config....
0
votes
2
answers
610
views
Dynamic access to named objects in Scala.js
There are some objects in my Scala.js project I would like to access dynamically. I think I might be able to get this working using Dynamic, however currently the fastOptJS / fullOptJS step is ...
0
votes
1
answer
661
views
How can I use Material UI in Scala JS?
My team works with Scala.js and I wanna use Material-UI. But those two's code types look very different. Most of the examples in Material-UI seem to be based on regular Javascript.
I've tried to ...
2
votes
1
answer
395
views
In Play, how to copy js files from ScalaJS client to server?
I'm trying to write an app that's part ScalaJS and part Play framework. I'm using the ScalaJS bundler. It's bundling my JavaScript fine and I can see the resulting files where they are supposed to go.
...
2
votes
2
answers
98
views
IntelliJ shows error using scalatags with boolean attributes
Does anyone now why IntelliJ is showing an error here even though sbt compiles and everything works correctly:
*Edit: "stopEnabled" is a Boolean.
As I understand, to not show an error here, I would ...
0
votes
2
answers
479
views
Using bootstraptoggle's onclick event in a scala-js application
In my scala-js application I want to use the bootstraptoggle library to create a nice looking switch button.
So far I am creating the toggle button by a method looking somewhat like this:
import ...
0
votes
1
answer
305
views
How to change or add a value to an existing BlobPropertyBag
Some JavaScript functions take an options parameter that can be created in Scala.js like this:
js.Dynamic
.literal(
"onload" -> onloadHandler _,
"filename" -> s"myFileName.txt"
)
....
1
vote
1
answer
527
views
Add table row after creating table body using scalatags
Using scalatags, normally I create a table like this:
table(
thead(
tr(
th("A"),
th("B")
)
),
tbody(
tr(
td("HELLO"),
td("WORLD")
),
tr(
td("FOO"),
...
2
votes
1
answer
141
views
scalajs getCause on Ajax.post onFailure
Try to get the cause for an Ajax.post failure (using Scala.Js) but get only the class name:
Ajax.post(
url = "...",
data = "...",
headers = Map("Content-Type"->"application/json; charset=utf-...
0
votes
1
answer
43
views
Representing js.Dynamic in an object or class
Say I want to produce the following javascript:
var myObj = { x: 'a', y: 'b' }
I can do this by callaing js.Dynamic.literal:
val myObj = js.Dynamic.literal(x = "a", y = "b")
But I can also represent ...
1
vote
0
answers
127
views
Can Nashorn viably port JavaScript libraries to the JVM side of cross-built Scala.js projects?
This question addresses the flip side of another question: Can JSweet viably port Java libraries for use in cross-built Scala.js projects?
Imagine making a Scala.js facade for a JavaScript library, ...
2
votes
1
answer
236
views
Use case class parameter in scalajs method from play framework template
Get an UndefinedBehaviorError when using a parameter of type case class in an scalajs method which I handover from a play framework Scala/Twirl template view/notify.scala.html:
@(note: Notification, ....
1
vote
1
answer
400
views
Pass function from Scala.js to Javascript function?
I've defined function in Scala.js like this:
val myFunction: js.Function1[js.Array[String], Boolean] = (data: js.Array[String]) => true
And also defined Javascript function on the page:
function ...
4
votes
1
answer
390
views
How to work around broken transitive jsDependencies?
The webjar ecosystem has recently been broken.
See https://github.com/webjars/webjars/issues/1789
org.webjars.npm:react:16.2.0 depends on org.webjars.npm:loose-envify:[1.1.0,2) which now includes ...
1
vote
1
answer
78
views
In Scala.js, modifying svg.Stylable.style
Working with Scala.js, I have created some SVG elements like Text, Line, Rect, and now I am trying to set the style attribute with code like this, where element is of type svg.Stylable:
element.style....
0
votes
1
answer
268
views
scalajs-react router. How to perform ajax request inside conditional route
I am trying to make some conditional routes. The condition resolves on the serverside.
Route rule example:
| (dynamicRouteCT("#user" / long.caseClass[User]) ~> dynRender((page: User) => <....
-1
votes
1
answer
157
views
scalajs with d3 facade giving errors
I'm working on this example in scalajs but getting error at
val mm: js.Function2[Bin[Double], Double, Double] = { (x: Bin[Double], y: Double) => x.y }
val yMax = d3.max(data, mm)
d3.max does ...
1
vote
1
answer
247
views
call twirl template from ScalaJs
The play framework documentation says (https://www.playframework.com/documentation/2.6.x/ScalaTemplates): You can then call this from any Scala code as you would normally call a method on a class:
...
2
votes
2
answers
400
views
Can JSweet viably port Java libraries for use in cross-built Scala.js projects?
In the search for ways to make Java libraries accessible to both the JavaScript and JVM sides of Scala.js cross-built projects, please consider the following experiment:
Imagine that a Scala.js ...
2
votes
1
answer
404
views
How can I print all the settings in Test configuration for a project build using SBT?
I have a scala-js project, adding a particular library dependency, is affecting the way project test cases are running. Without the library dependency everything's fine, the moment I add them, tests ...
1
vote
0
answers
161
views
Extend XMLHttpRequest in Scala.js
I'm extending XMLHttpRequest in Scala.js:
class ReasonerHttpRequest(val reasonerId: String) extends XMLHttpRequest {}
Then, I try to create:
val http = new ReasonerHttpRequest(reasonerId)
This ...
4
votes
2
answers
574
views
How to break down the size of scala.js JS output
There exist a few webpack bundle analysis scripts that show a list of included modules along with their sizes. However, Scala.js emits one big module for all the Scala code, so those tools can't look ...
0
votes
1
answer
144
views
ComponentDidMount actions with timeout
I am trying to perform some actions when my component did mount, but not immediately. My component looks like something this:
object MyComponent {
def apply = compopnent()
class Backend($: ...
7
votes
1
answer
2k
views
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-...