Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 29 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 15:31
    @sjrd banned @lerbatax
  • Jan 31 23:04
    sjrd commented #3555
  • Jan 31 22:56
    sjrd review_requested #3555
  • Jan 31 22:56
    sjrd opened #3555
  • Jan 31 21:06

    sjrd on 0.6.x

    Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)

  • Jan 31 21:06
    sjrd closed #3554
  • Jan 31 20:54
    erikvanoosten commented #2665
  • Jan 31 16:33
    sjrd commented #3538
  • Jan 31 15:54

    sjrd on master

    Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)

  • Jan 31 15:54
    sjrd closed #3552
  • Jan 31 15:54

    sjrd on master

    Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)

  • Jan 31 15:54
    sjrd closed #3553
  • Jan 31 15:33
    sjrd commented #2665
  • Jan 31 15:30
    erikvanoosten commented #2665
  • Jan 31 10:41
    sjrd review_requested #3554
  • Jan 31 10:41
    sjrd opened #3554
  • Jan 31 10:05
    gzm0 synchronize #3552
Sébastien Doeraene
@sjrd
The lack of release for scala-parallel-collection for 2.13 before the release of 2.13 prevented is from getting the tools ready in 0.6.28.
Ólafur Páll Geirsson
@olafurpg
Thanks for the update. I'm eagerly waiting for 0.6.29 then! :D
Sébastien Doeraene
@sjrd
Anyone wants to advance the support of Scala.js in dotty? I wrote up a tutorial to do so, linked from this meta good first issue: lampepfl/dotty#7113
Carlos Quiroz
@cquiroz
Are there specific tasks open to support dotty?
Sébastien Doeraene
@sjrd
Make it work, one test file at a time.
Carlos Quiroz
@cquiroz
:D
Sébastien Doeraene
@sjrd
Of course at some point there will be the big task of non-native JS classes (aka Scala.js-defined JS classes). But before getting there, there is a lot that can be addressed just by enabling shared tests (the ones that also work on the JVM)
Russ White
@russwyte

In a class Foo with a nested class Bar Is there are a way to create a js.constorOf[Bar] where Bar not a top level class?

When I try to do that now (in 0.6.28) I get: An undefined behavior was detected: [object Object…s not an instance of Foo at runtime - but no compile time error.

This is pretty bad for my application because the class I need the constructor for needs to be aware of it’s parent type. Any suggestions?

Russ White
@russwyte

I see this is supported in 1.0.0-M8:

https://www.scala-js.org/news/2019/06/03/announcing-scalajs-1.0.0-M8/

Is there any chance this could be applied to 0.6.x since many of my dependencies aren’t ready for 1.0.0-M8?

Sébastien Doeraene
@sjrd
No, you have to upgrade to 1.x, and encourage your dependencies to do the same.
If there was any we could have implemented it in 0.6.x, we would have done so already.
TATSUNO Yasuhiro
@exoego

I want to disable fastOptJS/fullOptJS in compile phase for a sbt sub project, something like skip in fastOptJS in Compile := true, but it seems no effect right now.
Are there any way to disable fastOptJS/fullOptJS in specific project?

Suppose we have sbt projects like this.

  • root project (just aggregate below)
    • common project X
    • project A, depends on X
    • project B, depends on X
    • project C, depends on X

Project X contains common source shared in project A, B, and C.
Project X should be tested (so fastOptJS in Test should be performed).
However, X's JS is not used production, so disabling f*OptJS in compile phase can reduce build time in (root/)fullOptJS.

Sébastien Doeraene
@sjrd
You can override fast and fullOptJS to be a no op, like any other task.
Or you could just not invoke it in the first place ...
TATSUNO Yasuhiro
@exoego
Thanks.
I override with below and it works.
.setings(
  fastOptJS in Compile := Attributed.blank(file("")),
  fullOptJS in Compile := Attributed.blank(file(""))
)
Mustafa Kuscu
@mcku

Also when compiling under dotty, BaseCharsetTest:

ClassType(Ljava_io_Serializable) expected but UndefType found for tree of type org.scalajs.ir.Trees$Undefined

this error when the case is empty

could not reproduce it in a minimal sense

adding expectedChars would get rid of those
See: https://github.com/scala-js/scala-js/pull/3756/files/9e0a1959e5a5d1d4f90b01bb70b7da071831a21c#diff-8e8b9776805c3c46a92816f342baf75dR225

Ntend7777
@Ntend7777
Hello
Sébastien Doeraene
@sjrd
@mcku looks like a dotty bug. It should infer Unit for the type of the match, instead of Serializable.
Mustafa Kuscu
@mcku
they ought to run the scalajs test case to reproduce the bug then, right?
Sébastien Doeraene
@sjrd
Yes.
But it's very possible that it won't reproduce on the JVM, because the JVM backend has a tendency to tolerate and fix things on the fly, whereas the Scala.js backend is more strict in what it accepts.
Eric K Richardson
@ekrich
Which versions of Scala.js emit ES5 or ES6?
For 1.0.0-M8 (Scala.js now emits ECMAScript 2015 code by default) is that ES5?
Sébastien Doeraene
@sjrd
2015 is 6
Eric K Richardson
@ekrich
So does 0.6.x also emit ES6?
Mustafa Kuscu
@mcku
yes, since 0.6.26 scalajs emits ES modules. Many people use ES/ES6 to mean ES2015 and newer.. ES5 is, roughly speaking, old, troublesome JS syntax which has no appeal..
Sébastien Doeraene
@sjrd
@ekrich 0.6.x can emit ES2015 if you ask it to. 1.x can also still emit ES5.1 if you ask it to. In both cases, you can ask them to emit scripts, CommonJS modules pour ES modules.
Eric K Richardson
@ekrich
Wow, ok thanks @sjrd and @mcku. Last time I did any serious web programming was in the IE8 era.
Moritz Bust
@Busti
Can I call a native function that is defined multiple times with a differently typed parameter using a union type variable?
class WebSocket {
  def send(data: String): Unit = js.native
  def send(data: Blob): Unit = js.native
  def send(data: ArrayBuffer): Unit = js.native
}

val myData: String | Blob | ArrayBuffer = ???
websocketInstance.send(myData) // Error
Do I have to pattern match?
Should I wrap my data in case classes for each type to avoid having unions in my application code?
Moritz Bust
@Busti
Also, I cannot seem to pattern match for that union.
[error]  found   : String
[error]  required: String | org.scalajs.dom.Blob | scala.scalajs.js.typedarray.ArrayBuffer
[error]     (which expands to)  String | org.scalajs.dom.raw.Blob | scala.scalajs.js.typedarray.ArrayBuffer
[error]             case d: String      => webSocket.send(d)
TATSUNO Yasuhiro
@exoego
IIUC, test uses fastOptJS-produced JS file by default. How to run test using fullOptJS? I need this to verify that full-optimied JS behave as same as fast-optimizes JS.
TATSUNO Yasuhiro
@exoego
I read this but not mentioned. https://www.scala-js.org/doc/project/testing.html
Sébastien Doeraene
@sjrd
set scalaJSStage in Global := FullOptStage before running test
TATSUNO Yasuhiro
@exoego
@sjrd Thanks !!
aappddeevv
@aappddeevv
@Busti For js functions that take complex arguments, in my definitions, I tend to break out methods with different argument types when the "js union" is too complex especially when js callback signatures are involved. But for unions with simple types, I often leave it as a union argument so you could have send above take a union type. You don't need to have myData be of type union for it to work, it could just be one of the union types. You have to widen the union result then test using js tests, it makes pattern matching much more verbose.
There is an example on stackoverflow.
mushtaq
@mushtaq

I am trying to write a facade for this npm module:
https://github.com/canjs/can-ndjson-stream/blob/master/can-ndjson-stream.js

as below:

@JSImport("can-ndjson-stream", JSImport.Namespace)
@js.native
object CanNdJsonStream extends js.Object {
  def ndjsonStream(response: ReadableStream[Uint8Array]): ReadableStream[js.Object] = js.native
}

But I get the following error:

scala.scalajs.js.JavaScriptException: TypeError: $i_can$002dndjson$002dstream.ndjsonStream is not a function

What am I missing?

Sébastien Doeraene
@sjrd
The function is exported as a default member, not under its name.
Moritz Bust
@Busti
@aappddeevv Do you happen to have a link to that example? I cannot find it.
mushtaq
@mushtaq

thanks @sjrd I changed JSImport.Namespace to JSImport.Default, now the error is:

scala.scalajs.js.JavaScriptException: TypeError: $moduleDefault(...).ndjsonStream is not a function

Not sure I interpreted your suggestion correctly.

ok, this seems to work:
@JSImport("can-ndjson-stream", JSImport.Namespace)
@js.native
class CanNdJsonStream extends ReadableStream[Uint8Array] {
  def this(response: ReadableStream[Uint8Array]) = this()
}
mushtaq
@mushtaq
sorry, it should be extends ReadableStream[js.Object]
aappddeevv
@aappddeevv
@Busti here
Li Haoyi
@lihaoyi-databricks
Anyone know what's the current status of new java.text.DecimalFormat(template).format in Scala.js?
It seems it isn't supported in javalib, but not sure if there's a similar API I can use that does the same thing, or some third-party shim
presumably some amount of formatting ability must be present to make Float#toString work
Li Haoyi
@lihaoyi-databricks
https://github.com/cquiroz/scala-java-locales seems to support it but the library doesn't seem to be published to maven central
at least not for scala 2.13