Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 23 2021 09:24
    @sjrd banned @yensaoxuan_twitter
  • Apr 18 2021 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 2021 07:47
    @sjrd banned @quangs
  • Jan 23 2021 06:34
    @sjrd banned @Rebeka58_gitlab
  • Jun 08 2020 20:43
    @sjrd banned @sw7240614
  • Sep 29 2019 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 2019 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 2019 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 2019 15:31
    @sjrd banned @lerbatax
  • Jan 31 2019 23:04
    sjrd commented #3555
  • Jan 31 2019 22:56
    sjrd review_requested #3555
  • Jan 31 2019 22:56
    sjrd opened #3555
  • Jan 31 2019 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 2019 21:06
    sjrd closed #3554
  • Jan 31 2019 20:54
    erikvanoosten commented #2665
  • Jan 31 2019 16:33
    sjrd commented #3538
  • Jan 31 2019 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 2019 15:54
    sjrd closed #3552
  • Jan 31 2019 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 2019 15:54
    sjrd closed #3553
vovoks
@vovoks
I mean make JS Array that compatible Scala Array[Byte].
Sébastien Doeraene
@sjrd
JS Arrays and Scala's Array[Byte]s are not directly compatible with each other.
What is your use case?
vovoks
@vovoks
My function on Scala accepting input Array[Byte] I want to call it on JS.
Sébastien Doeraene
@sjrd
As @gzm0 said, either you can write a Scala.js function that would create the Array[Byte] and you export that function to JS; or you can declare your Scala function to accept an input of type js.Array[Byte] or js.typedarray.Int8Array instead.
vovoks
@vovoks
Thank you very much! I'll try it.
Objektwerks
@objektwerks
I haven't worked with Scalajs in a year or so (github.com/objektwerks/scalajs.pool). But I recall the build, package and deploy process was a bit challenging. Has that process improved? Or even evolved into a standard process? TIA!
yurique
@yurique:nowhere.chat
[m]

It might be a bit challenging to define your build if you're starting from scratch :)
After that, it's a matter of running fastLinkJS for development and fullLinkJS for a production build.

There's an option of using the scalajs-bundler which maintains a webpack configuration and runs it under the hood in order to produce bundles ready to be shipped into the browser.

I personally prefer to deal with webpack manually (or experiment with other tools), so I'm usually doing something like this: https://github.com/yurique/frontroute-example or this: https://github.com/tulz-app/laminext/tree/main/website (shameless plug :) ).

Having all this in place, I have one terminal tab with sbt ~fastLinkJS and another one with yarn dev running. And yarn build for production build (after sbt fullLinkJS).

Objektwerks
@objektwerks
@yurique:nowhere.chat Thanks!
August Nagro
@AugustNagro

Wonder if it would be worthwhile to replace js.UndefOr with Scala 3 union + extension methods:

extension [A] (a: A | Unit)

  def isEmpty: Boolean =
    a == ()

  def isDefined: Boolean =
    !a.isEmpty

  def map[B](f: A => B): B | Unit =
    if a.isEmpty then () else f(a.forceGet)

// etc

@main def main(): Unit =
  val a: Int | Unit = 21
  println(a.isDefined)
  println(a.isEmpty)
  println(a.map(_ + 1))

Doesn't seem possible w/ Null union unfortunately.

Sébastien Doeraene
@sjrd
js.UndefOr is a Scala 3 union + extension methods in Scala 3 (well, implicit conversion to value class, but all the same).
Martijn
@martijnhoekstra:matrix.org
[m]
I have a cargo-culted scalaJSLinkerConfig.withBatchMode(true). What does this do/change
Sébastien Doeraene
@sjrd
It prevents the linker from using its incremental mode.
That encourages it to release memory sooner, which is sometimes useful in a CI context.
But in a dev context, it's likely slowing you down.
Martijn
@martijnhoekstra:matrix.org
[m]
Ah, thanks
Objektwerks
@objektwerks
With scalajs 1.5, in a crossproject, using fullOptJS/fullLinkJS, is the former sharedjs-opt.js merged into js-opt.js? Using fastOptJS/fastLinkJS separate main.js files, in js and shared subprojects, are generated.
Sébastien Doeraene
@sjrd
@objektwerks Could you elaborate? There's no such thing as a "shared subproject" when just using a cross project. A cross project is only sugar for two projects: a JVM one and a JS one. There's a shared source directory, but no shared project.
Objektwerks
@objektwerks
@sjrd I've always used a shared subproject to share .js and .jvm js and classes between the js and jvm projects. Did that change recently? Here's an example project: github.com/objektwerks/scalajs.pool. Some time ago, js-opt.js and shared-opt.js files were generated from a fullOptJS. That has changed with 1.5 and the module linking feature.
Objektwerks
@objektwerks
I guess I've always viewed the shared crossproject as another subproject. That said, I was just curious why the shared/.js shared-opt.js file is now empty after a fullOptJS/fullLinkJS. Hence the merge shared/.js into js/js-opt.js question.
Sébastien Doeraene
@sjrd
If you have a non leaf project, its JS files are empty (except for boilerplate), and so calling any of the linking methods on them is useless.
This has always been true.
It's just that maybe because of aggregation, you were calling linking methods of the shared stuff without actually meaning to?
Objektwerks
@objektwerks
Ok. Because I used to specific both js files in my index.html file. So is ALL of the generated JS being placed in the js/js-sbt.js file?
Sébastien Doeraene
@sjrd
Yes.
There was never any reason for you to include both JS files in your html. The shared one contributed nothing useful.
Objektwerks
@objektwerks
Ok, great. I was thinking that - but wasn't sure. :) Thanks, Sebastien! Cheers!
Sébastien Doeraene
@sjrd
Graag gedaan.
Objektwerks
@objektwerks
Dutch, eh? Nice.
Sébastien Doeraene
@sjrd
I'm Belgian so I speak some Dutch, yes.
Joel Moberg
@joelmo
"starting from 45kB gzipped for a full application." 45kB gzipped is heavy but maybe alot of libraries are included? In haxe I can create libraries that start from ~7kB gz then I have IO function and http client and some more.
It's also before minified..
Sébastien Doeraene
@sjrd
I'm afraid the 45 KB don't include much of libraries. It's, unfortunately, mostly the Scala collections. It's the price to pay to get full Scala.
Haxe plays a different game.
Joel Moberg
@joelmo
I will stay with have then. Thanks for answering.
Objektwerks
@objektwerks
How can I modify the fast/fullLinkJS output directory name. For instance, in lieu of js-opt or js-fastopt, I might want to name both js for the sake of consistency. I've attempted to set scalaJSLinkerOutputDirectory, but with no success.
Sébastien Doeraene
@sjrd
It's that setting, but it needs to be scoped in Compile / or Test /
Objektwerks
@objektwerks
Ok, let me try that.
Sébastien Doeraene
@sjrd
That said, if you make both fastOpt and fullOpt point to the same location, you'll confuse sbt's change detection mechanisms, and things can go wrong (either recomputing things too often or not often enough).
Objektwerks
@objektwerks
Ok. I've tried this fastLinkJS / scalaJSLinkerOutputDirectory := file("js") with no success.
Sébastien Doeraene
@sjrd
Compile / fastLinkJS / scalaJSLinkerOutputDirectory := file("js")
Objektwerks
@objektwerks
Ok. I got this to work Compile / fastLinkJS / scalaJSLinkerOutputDirectory := target.value / public / "dev" I tried you way, but the linker got a bit lost in terms of directory location. All I can say is - sbt is an art. :)
Sébastien Doeraene
@sjrd
Once you learn to use show, inspect and above all inspect tree, a lot of things become much easier.
Objektwerks
@objektwerks
Ok, thanks for the tip, Sebastien!
Sébastien Doeraene
@sjrd
For example, inspect proj/fastLinkJS directly tells you that it depends on proj / Compile / fastLinkJS / scalaJSLinkerOutputDirectory, among other things.
Objektwerks
@objektwerks
@sjrd Yeah, sbt inspect and show provide a bit of info.:)
Carlos Quiroz
@cquiroz
Finally got around to use dynamic ES imports with scala.js
Works great, thanks @sjrd and the team for this awesome feature
Sébastien Doeraene
@sjrd
It's mostly @gzm0 in this case 😉
Martijn
@martijnhoekstra:matrix.org
[m]
Is there a way to get a stack trace from a running scalajs program on node a la jstack?
I see there is a way to connect a debugger, maybe that's a fruity approach. Is there anything already there in any of the usual tooling for attaching debuggers (maybe even with sourcemaps)?