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
Adam Warski
@adamw
ok, thx :) I'll disable the scala3-js for now - it will be in a comment
Daniel Schoepe
@dschoepe

If you really need the JS library, then you can use any serialization library that cross-compiles for Scala/JVM and Scala.js (most do). What you'll need in addition is how to spawn a process with the JS lib, and how to communicate with it. There, any mechanism to handle IPC would work fine. I can mention https://github.com/scala-js/scala-js-js-envs which is what we use in sbt-scalajs, although it might be overkill for your use case, since it abstracts over several JS engines.

Thanks, that looks exactly like what I was looking for actually!

fromscalatohaskell
@fromscalatohaskell_gitlab
JS noob question - how can we refer to require('path/to/image.png') in ScalaJS so that webpack can see my images and not complain? They are seen by my SCSS and transformer to some hash-file thing?
Tobias Schlatter
@gzm0
object A {
  @js.native
  @JSImport('path/to/image.png', JSImport.Namespace)
  val image = js.native
}
2 replies
Chris Kipp
@ckipp:matrix.org
[m]
Can I get some input on some ScalaJS stuff. I recently was given the keys to scoverage so I'm trying to push forward a release, however I'm a bit consued by the sjs1 vs _sjs1.5 versioning scheme for artifacts, and I'm unsure what this should be here: https://github.com/scoverage/scalac-scoverage-plugin/pull/311#discussion_r621883170
it's an odd situation where both the compiler plugin and the runtime is being fully cross released, so the sbt crossproject doesn't include the normal _sjs. So it's being done manually, but am unsure if we actually want the sjs1.5 instead of sjs1
however I'm unsure if that's just a bi-product of the full cross and if that's needed in this scenario
it works int he sbt plugin, but that's because there is some hacky stuff to do a take(3) and add it to the artifact that the sbt plugin is including in the build
Sébastien Doeraene
@sjrd
It should be _sjs1. There's no such thing as _sjs1.5.
2 replies
Naftoli Gugenheim
@nafg
This message was deleted
How can I get source maps to go to some custom uri?
I want to add a handler in the backend but it should be under some custom path, like /_source_maps/...
Right now they're just 404
In the .js.map they're like /../../../../...
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
@nafg I saw there was a flag for that. Here's an example PR: https://github.com/raquo/Laminar/pull/91/files
Naftoli Gugenheim
@nafg
There's no API in the sbt plugin?
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
🤷‍♂️ right now it seems to be a scalac flag.
Naftoli Gugenheim
@nafg
All the stuff in scalaJSLinkerConfig is irrelevant?
This message was deleted
Tobias Schlatter
@gzm0
no, that can also be useful (that stuff is very old, and I don't think we have given it an awful lot of thought).
Basically, the compiler options can be useful per compilation unit, the linker config is for everything.
Sorry, I don't have an awful lot of time right now :-/
Naftoli Gugenheim
@nafg
nm, the closest thing is relativizeSourceMapBase which only determines how many dots to put in
ok thanks
vovoks
@vovoks
Hello, guys! Please, tell me how I make Scala Array[Byte] on JS?
Tobias Schlatter
@gzm0
From JavaScript code you mean? You cannot.
(you can create a Scala.js function that creates one, but you cannot do anything with it except for passing it back to Scala.js code).
have a look at js.Array and maybe Int8Array?
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.