Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
48 views

Generic way of array creation in Scala.js

I'm looking for a generic way of array creation in Scala.js. The following code works fine in JVM and Scala Native platforms: def newArray[A](fqcn: String, size: Int): Array[A] = { val clazz = Class....
Andriy Plokhotnyuk's user avatar
1 vote
1 answer
69 views

Referring to non-existent class while compiling to ScalaJS

I'm builing a ScalaJs & Scala3 application, when i run the npm run dev/build command I have the following error, and I'm not figuring out how to fix it: Referring to non-existent class scala....
Ghignatti Nicolò's user avatar
0 votes
0 answers
35 views

How can I share a resource file in a cross project

I am using the gRPC library in a cross project. My server implementation will be in the js part on nodejs and my client in the jvm So my question is how can I best share the .proto file between them. ...
user79074's user avatar
  • 5,402
2 votes
2 answers
114 views

How would I define a facade with for keyof syntax

I have the following syntax in a typescript definition file that I want to place in a scala facade form: type Properties<T> = { [P in keyof T]?: T[P] }; I have tried running this through the ...
user79074's user avatar
  • 5,402
0 votes
0 answers
36 views

Is there a mechanism to access a NodeJS app remotely

I have a third party TypeScript library that I would like to access from my Scala application. The library I want to use is dydx-v4-clients I have been able to access the library by creating a facade. ...
user79074's user avatar
  • 5,402
1 vote
1 answer
65 views

sbt-crossproject publishes jvm project with unexpected name

I'm trying to publish few scalamock modules for jvm and js simultaniously. I'm using sbt-crosspublish and sbt-ci-release. addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1....
Georgii Kovalev's user avatar
0 votes
1 answer
153 views

Hot Reloading Scala.js

How to hot reload in scala.js application while in development I am manually reloading the Scala.js application during development. However, I need the ability to reload and immediately reflect the ...
BALAJI's user avatar
  • 1
2 votes
0 answers
59 views

Saving date objects in MongoDb from Scala.js

I have a serverless application written in Scala.js that is writing to a MongoDb database. We wrote our own custom integration with the Node.js mongodb driver. Everything is working well except for ...
Oliver Payne's user avatar
0 votes
0 answers
53 views

Use a SBT task with different settings from one module

When testing locally, I do not care about code size, therefore I switch GCC off by using following line in my frontend and worker modules settings: Compile / fullLinkJS / scalaJSLinkerConfig ~= { _....
Suma's user avatar
  • 34.6k
2 votes
0 answers
46 views

How to allow dynamic interface for a native JS trait in Scala 3?

Following facade trait for three.js works fine with Scala 2: @js.native trait Uniforms extends js.Object with Dynamic { @JSBracketAccess def update(name: String, uniform: Uniform): Unit @...
Suma's user avatar
  • 34.6k
1 vote
1 answer
72 views

Why does Scala multi platform build fails with `Toplevel definition X is defined in ...`?

My multi platform build is failing with an error, that indicates that both JVM and JS dependencies are in the class path. How can this be? [error] |Toplevel definition EnableReflectiveInstantiation ...
Nabil A.'s user avatar
  • 3,400
0 votes
0 answers
160 views

Idiomatic way to talk to REST backend from a Scala.js frontend?

I wrote a SPA with Scala.js, where I use a library called RosHTTP in order to communicate with a REST backend. It helps me add query parameters, set headers, work with cookies and increase transfer ...
nondeterministic's user avatar
1 vote
2 answers
380 views

Are there any mill/scala-3/scala.js examples available?

Is there a guide or example somewhere for using mill build tool with scala-3 and scala.js? I saw that the same question had been asked, but implicitly for sbt, and the answer was essentially "it ...
user3416742's user avatar
0 votes
1 answer
54 views

Exception using scalajs-bundler Reference to undefined setting: client / npmDependencies

I get the following exception when i start sbt: [error] Reference to undefined setting: [error] [error] client / npmDependencies from client / npmDependencies (/home/sofoklis/workspace/playjs/...
Sofoklis's user avatar
0 votes
1 answer
83 views

sbt-crossproject default project has different scalaVersion than I set. Why?

I'm writing a cross-compiled library between JSPlatform and JVMPlatform using sbt-scalajs-crossproject. I've explicitly set scalaVersion in common settings and yet: sbt:oatlibxp> show scalaVersion ...
bwbecker's user avatar
  • 1,315
1 vote
1 answer
184 views

Scala.js - How to convert ArrayBuffer to Array[Byte]?

DOM API returns ArrayBuffer but what I need is Array[Byte]. How can I do a conversion? import scala.scalajs.js.typedarray.ArrayBuffer def toScalaArray(input: ArrayBuffer): Array[Byte] = { // code ...
R A's user avatar
  • 335
0 votes
1 answer
136 views

Scala.js - How to convert Array[Byte] to Blob?

DOM API requires Blob but all I have is Array[Byte]. How can I do the conversion? import org.scalajs.dom.Blob def toBlob(input: Array[Byte]): Blob = { // code in question }
R A's user avatar
  • 335
0 votes
1 answer
407 views

Decode JSON with Circe and Scala.js

I try to create veeery simple scala.js app. I was following this tutorial https://www.scala-js.org/doc/tutorial/scalajs-vite.html and I want to decode a json. Circe https://circe.github.io/circe/ says ...
LancerX's user avatar
  • 1,231
0 votes
2 answers
127 views

How to share data between Scala.js test suites?

I share data between ScalaTest suites using a common singleton Object. This works fine when running on JVM, but to my surprise it fails on Scala.js. It seems on Scala.js a fresh instance of the ...
Suma's user avatar
  • 34.6k
0 votes
1 answer
309 views

How to format / parse a Date in Scala and ScalaJS

I want to use Dates in shared code (JVM and JS). So I need the functionality to parse a Date from a Text and to format a Text from a Date. I found that ScalaJS supports java.util.Date and java.util....
pme's user avatar
  • 14.9k
1 vote
1 answer
65 views

Scala.js - How to convert Seq to js.Iterable lazily?

I have a Seq[Byte] that I need to convert to js.Iterable[Byte]. I have some code that does that task: import scala.scalajs.js import scalajs.js.JSConverters.iterableOnceConvertible2JSRichIterableOnce ...
R A's user avatar
  • 335
-1 votes
2 answers
228 views

How to create an Array for Tuples in Scala?

Im trying to create an empty Array to store coordinates of an object in an Tuple which is then stored in an Array. When I try: var walls = Array[Tuple2]() Im getting this error message: kinds of the ...
TamZ's user avatar
  • 27
0 votes
1 answer
106 views

How do I use a BigDecimal from Scala.js in my JavaScript application?

I have this Scala object: @JSExportTopLevel("Calculator") object Calculator { @JSExport def calculate(): BigDecimal = 3.14 } I can call the exported singleton method from my JavaScript ...
Big McLargeHuge's user avatar
0 votes
1 answer
127 views

Scala.js - How to show browser alert?

How to show a browser alert window in Scala.js? JavaScript version is as follows: alert() alert(message)
R A's user avatar
  • 335
0 votes
1 answer
48 views

Scala.js - Handling NaN

import scala.scalajs.js import scala.scalajs.js.Date import org.scalajs.dom.window.alert val num: Double = new Date("a").getTime alert((num + 1).toString) This code reports NaN as the ...
R A's user avatar
  • 335
7 votes
1 answer
6k views

How to use SBT's libraryDependencyScheme key

I'm in library dependency hell right now with the following error: [error] (server / update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible: [error] [...
bwbecker's user avatar
  • 1,315
3 votes
3 answers
529 views

Scala.js - Convert Uint8Array to Array[Byte]

How do I implement the following method in Scala.js? import scala.scalajs.js def toScalaArray(input: js.typedarray.Uint8Array): Array[Byte] = // code in question
R A's user avatar
  • 335
0 votes
1 answer
59 views

Is there a useState concept so I can create a service which holds data that is accessed in multiple components?

I have 2 components who want to access the same data. Instead of each doing an HTTP Request independantly, I wanted to keep the items in parity. When doing react, we can easily do: const [ data, ...
Fallenreaper's user avatar
  • 10.7k
2 votes
1 answer
212 views

Testing using scalatest for Scala.js and Slinky

I'm trying to create a react-native app using slinky and am trying to run tests using the scala.js port of scalatest. Simple situation where the deps look like this in build.sbt scalaVersion := "...
arinray's user avatar
  • 216
0 votes
1 answer
127 views

Async function called in a slinky/scalajs setup causes render to fail

I'm unsure if this is a question for the general scala.js world or specifically slinky/slinky-native/slinky-hot FYI, using libraryDependencies += "me.shadaj" %%% "slinky-native" % &...
arinray's user avatar
  • 216
0 votes
1 answer
173 views

importing static javascript functions into scala.js

In a third party library react-native-fbsdk-next I have a file FBAccessToken.ts The class below has a few ordinary members and a static member function. class FBAccessToken { accessToken: string; ...
arinray's user avatar
  • 216
1 vote
1 answer
660 views

Importing Settings.initializeSDK from react-native-fbsdk-next fails with TypeError: null is not an object

I'm a react/scala.js noob and am trying to create a slinky/react-native app that supports facebook login. I'm trying to initialise the facebook SDK by doing the following object FbSdkSettings { @js....
arinray's user avatar
  • 216
1 vote
1 answer
119 views

How to create frontend project from multiple scala.js projects?

My project is a game server with frontend for it. For the frontend I'm using scala.js. Project is a cross-build so I can share files between jvm (server) and js (client). Cross-build method: https://...
Onajk's user avatar
  • 21
6 votes
1 answer
675 views

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 ...
Shelby Moore III's user avatar
0 votes
0 answers
130 views

Scala scala.js cannot find module js script in sbt build

I'm trying to import a JS Script script.js into a scala program App.scala and use its methods add and divide. However on running the program, I keep getting the error, Cannot find module 'resources/...
Vakindu's user avatar
  • 867
1 vote
1 answer
791 views

Scala Scala.js importing JavaScript module gives 'There were linking errors, module support is disabled'

I'm trying to import a JavaScript class module script.js into a scala program main.scala and use its methods add and divide. I'm using scala.js for importing the JS script and SBT for build. However ...
Vakindu's user avatar
  • 867
0 votes
1 answer
375 views

Scala Scala.js importing JavaScript module gives error 'method value is not a member of'

I'm trying to import a JavaScript class module script.js into a scala program main.scala and use its methods add and divide. I'm using scala.js for importing the JS script and SBT for build. However ...
Vakindu's user avatar
  • 867
1 vote
1 answer
446 views

Scala.js import JS script gives error: expected start of definition

I have a JS script script.js which contains a class MyType. I would like to use the class' methods add() and divide inside a scala script App.scala. Using Scala.js and JSImport I import script.js into ...
Vakindu's user avatar
  • 867
1 vote
0 answers
30 views

How to hide Scala.JS types from JVM code?

I've been practicing leveraging as much JVM code as possible in Scala.JS in order to benefit from unit testing pure JVM logic, which is of course much faster. At some point though, you run into the ...
ecoe's user avatar
  • 5,402
1 vote
1 answer
128 views

How to fix the problem "Fatal error: java.lang.Object is missing called from core module analyzer" in ScalaJS Linking

I'm trying to defer ScalaJS Linking to runtime, which allows multi-stage compilation to be more flexible and less dependent on sbt. The setup looks like this: Instead of using scalajs-sbt plugin, I ...
tribbloid's user avatar
  • 3,992
1 vote
1 answer
209 views

How to use scala.js compiler as a compiler plugin, thus allowing it to integrate into Gradle or maven?

I have a Scala project that can only be compiled with Gradle, recently someone has asked it to be ported to Scala.js, ideally by cross-build. When I read the code of Scala.js, I realised that the bulk ...
tribbloid's user avatar
  • 3,992
3 votes
1 answer
431 views

In scala.js, what are the possible causes of "Error: Cannot find module 'jsdom'"?

I'm trying to compile and run the scala.js basic tutorial at: https://github.com/scala-js/scalajs-tutorial When I execute the main class by sbt run, I got the following error message: $ sbt run [info] ...
tribbloid's user avatar
  • 3,992
0 votes
0 answers
50 views

How do I post a non-string value in a Scala Http request?

From a Scala program, I need to send values with different primitive types to a Node server. Http("http://middleware-api:3000/createPromoCodeInCms?") .postForm .param("lifetime&...
papillon's user avatar
  • 2,088
2 votes
2 answers
738 views

Ajax.post --> dom.fetch

I'm trying to use the dom.fetch (or dom.Fetch.fetch) api instead of Ajax.post and have a few problems: Is this a correct translation from ajax to fetch? Ajax.post( url = "http://localhost:8080/...
Marc Grue's user avatar
  • 5,385
2 votes
0 answers
4k views

How to avoid "`this` has been rewritten to `undefined`" warning when bundling Scala.js file with rollup?

I'm using a Scala.js file with ECMAScript modules inside a Svelte project. When building the project with rollup I get the warning this has been rewritten to undefined With pointing at last line of ...
Corrl's user avatar
  • 7,931
-1 votes
1 answer
727 views

How to differentiate between mousedown and mousedrag

I am performing some actions on onMousedown event. But then they also get executed for drag as drag starts with mouse down. How can I ensure that actions on mouse-down don't happen for mouse drag? ...
Mandroid's user avatar
  • 7,736
0 votes
1 answer
67 views

Radiobutton click event invoking callback 2 times

I have a radio button defined as: <.label( ....styling ^.onClick ==> { event => event.stopPropagation() props.select }, <.input.radio( ...
Mandroid's user avatar
  • 7,736
0 votes
1 answer
155 views

Scala.js: How do I read the value using of an input element using Scala.js?

I am trying to do something like this: <input id="test">Hello!</input> import io.udash.wrappers.jquery.jQ // Read from Scala val x = jQ("#test").value().asIntanceOf[...
pathikrit's user avatar
  • 33.7k
0 votes
1 answer
53 views

Scalajs, js.Dictionary inconsistent behavior

I have an inconsistent error using ScalaJS. Here is a minimal example: the size and the content of a dictionary variable are inconsistent. def A(mapping: js.Dictionary[String]): Unit = { dom....
idwx's user avatar
  • 57
1 vote
0 answers
126 views

Does the Scala.js ecosystem offer any way(s) to augment or replace the auto-generated setter/mutator methods for property fields of scala classes?

Please consider a family of plain and case classes, cross-compiled to JVM and Scala.js, which make mixed use of properties with automatically and manually defined accessor methods. Many come from ...
Ben McKenneby's user avatar

1
2 3 4 5
18