by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 08 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
  • Jan 31 2019 15:33
    sjrd commented #2665
  • Jan 31 2019 15:30
    erikvanoosten commented #2665
  • Jan 31 2019 10:41
    sjrd review_requested #3554
  • Jan 31 2019 10:41
    sjrd opened #3554
Daniel Spiewak
@djspiewak
I'll give that a shot and see how much it improves
Sébastien Doeraene
@sjrd
Otherwise, make sure that you don't disable parallel execution of tests by sbt.
Daniel Spiewak
@djspiewak
yeah parallel execution is on; it's actually one test suite that is responsible for the majority of that time
I could probably split it into several to get a quick win there
Sébastien Doeraene
@sjrd
Other than that, I'm afraid I don't have more advice to offer.
Daniel Spiewak
@djspiewak
sometimes I wonder about the amount of carbon we collectively produce, running and re-running and re-re-running our test suites…
Sébastien Doeraene
@sjrd
If you can isolate one test suite that runs much slower on JS than on JVM, it might make for a good benchmark, to see if there's something important we're missing in our optimizer.
Yeah me too 🤔
Daniel Spiewak
@djspiewak

If you can isolate one test suite that runs much slower on JS than on JVM, it might make for a good benchmark, to see if there's something important we're missing in our optimizer

I think that would be interesting. I can definitely give you a starting point, but it's anything but minimal: https://github.com/typelevel/cats-effect/blob/series/3.x/laws/shared/src/test/scala/cats/effect/PureConcSpec.scala#L48-L51

which in turn makes me suspect that something about FreeT is absurdly slow in ScalaJS
since there aren't a lot of other commonalities between the two suites
but… that's not very minimized :-)
Sébastien Doeraene
@sjrd
Right 😅
Daniel Spiewak
@djspiewak
if I'm right with my guess though, then https://github.com/typelevel/cats/blob/master/free/src/test/scala/cats/free/FreeTSuite.scala should exhibit at least similar behavior
I haven't checked
frankly, given the amount of indirection and wrapping which occurs during Free evaluation, it doesn't really surprise me that it's slow
perhaps I should be more surprised that the JVM is as fast as it is
Daniel Spiewak
@djspiewak
btw, for posterity… using optimized semantics appears to produce only a marginal improvement in runtime (less than 5%) in this exact case
Li Haoyi
@lihaoyi
Javascript JIT optimizers are famously fragile, so I wouldn’t be surprised by some usage pattern accidentally causing them to bail out. Not sure what the current state is, but when I used to do frontend work the “perf best practices” changed on remarkably short time scales
if you can minimize the pathological code, it’s probably worth running on a few browsers to see if it’s uniformly pathological
Stefan Wachter
@swachter
I want to ease the configuration of the ScalaTsPlugin in case of JS/JVM cross projects. I would like to offer a sequence seq of common settings that can be used in crossProject(...).settings(seq). That sequence should contain a libraryDependency that is specified using the %%% combinator . Unfortunately, the %%% can only be used inside settings and tasks (and build.sbt itself) but not for defining vals in a plugin. Is there a solution?
Sébastien Doeraene
@sjrd
There's no need for anything special. Writing val mySeq = Def.settings(libraryDependencies += "..." %%% "..." % "...") will work.
Stefan Wachter
@swachter
Thanks!
Anton Sviridov
@keynmol
It's probably a silly question, but is there an example somewhere for simulating onchange events on inputs? I got my tests working for a checkbox input with .click(), but struggling to find a minimal example on how to do it with a change event
        testApp.searchBox.value = "bla"
        testApp.searchBox.dispatchEvent(new Event("onchange"))
typechecks, but doesn't do anything
Anton Sviridov
@keynmol
worth pointing out I'm trying to run tests using jsdom
Nikita Gazarov
@raquo
@keynmol I think you need the same but with new Event("change") (w/o "on" prefix)
Might also want to provide bubbles=true param to Event to match native browser behaviour
Anton Sviridov
@keynmol

I've tried so many things :D

        println(testApp.searchBox.dispatchEvent(new Event("change", new EventInit{
          bubbles = true
        })))

does print out true, but the app doesn't get triggered (it's Laminar btw ;-))

I attempted also to create the event through dom.document.createEvent("HTMLEvents") but then I'm not sure how to initialise it from Scala, as the parameter is private (can't dispatch without init)

I also attempted to use TextEvent and TextEventInit but then it just says TextEvent not found at runtime, which I assume is just jsdom not having this?

It seems like I'm missing something with regards to how to properly test Scala.js applications.

Nikita Gazarov
@raquo
I don't think it has to do with Scala.js to be honest. This is more likely to be a jsdom issue since there is no real DOM environment in node.js, jsdom is but an emulator. My suggestion is to set up a plain, non-Scala node.js project with jsdom and try to get onchange event simulation to work there. Then if that works, translate that snippet to scala.js and see if it still works. I would expect it to, but if it doesn't we could try to figure it out.
Also if you're going to test this, use text inputs with explicitly specified type="text" just to be sure, and definitely don't use checkboxes, those have... non-inuitive timing (long story short)
Nikita Gazarov
@raquo

Also

  • to rule out Laminar misconfiguration, call yourInputElement.ref.addEventListener("change", _ => println("yo")) to register an event handler by native JS means
  • and make sure that the input element that you're rendering is actually present in the DOM, that it's mounted. Unmounted elements don't get most events. You can check that by println(dom.document.body.innerHtml) and making sure your input is there.
  • and of course check timing, first set up all the elements and event listeners, then trigger the event

If you believe this is Laminar related don't hesitate to ask in our room too

Anton Sviridov
@keynmol

to rule out Laminar misconfiguration

huh, that is a good idea. I added a test where I can see dispatch working when used directly: https://github.com/keynmol/http4s-laminar-stack/pull/1/commits/ba5b2725a4ef2ee7f6ff26364ba39c10a3706a55

Only difference I can see is that I use .ref to get the element in the direct example, but use getElementById in the actuall app testing.

but it's a good start - I'll see if it's somehow related to Laminar or the error of my ways

Matthew de Detrich
@mdedetrich
So I am using Circe 0.13.0 with scala-java-time 2.0.0 in a scala.js subproject and I am getting the following error
[error] Referring to non-existent method java.time.format.DateTimeFormatter$.ofPattern(java.lang.String)java.time.format.DateTimeFormatter
[error]   called from de.zalando.logistics.common.itemtrace.model.DeployedCirceImplicits.$$init$()scala.Unit
[error]   called from de.zalando.logistics.common.DeployedGlobalCirceImplicits$.<init>()
[error]   called from states.States$.<init>()
[error]   called from components.Header$.$$anonfun$component$2(japgolly.scalajs.react.CompScope$DuringCallbackU,components.HeaderProps,scala.runtime.BoxedUnit)japgolly.scalajs.react.ReactElement
[error]   called from components.Header$.<init>()
[error]   called from components.Content$.$$anonfun$component$2(japgolly.scalajs.react.CompScope$DuringCallbackU,components.ContentProps,scala.runtime.BoxedUnit)japgolly.scalajs.react.ReactElement
[error]   called from components.Content$.<init>()
[error]   called from components.backend.Backend.render(components.MainProps,states.States$MainObject)japgolly.scalajs.react.ReactElement
[error]   called from components.MainComponent$.$$anonfun$App$3(japgolly.scalajs.react.CompScope$DuringCallbackU)japgolly.scalajs.react.ReactElement
[error]   called from components.MainComponent$.<init>()
[error]   called from components.KeyCapture$Backend.render(components.KCInput)japgolly.scalajs.react.ReactComponentU
[error]   called from components.KeyCapture$.$$anonfun$component$3(japgolly.scalajs.react.CompScope$DuringCallbackU)japgolly.scalajs.react.ReactComponentU
[error]   called from components.KeyCapture$.<init>()
[error]   called from Main$.main([java.lang.String)scala.Unit
[error]   called from core module module initializers
I am explicitly including scala-java-time 2.0.0 in my library dependencies
Scala-java-time is referring to https://github.com/cquiroz/scala-java-time btw
@cquiroz From Scala-java-time says that the scala.js linker gets very confused if there are two packages providing the same set of classes
Any ideas on how to resolve this?
Anton Sviridov
@keynmol
I've just had this error with circe and shapeless because of %% instead of %%% in dependecy specification - any chance it could be that?
Matthew de Detrich
@mdedetrich
This actually happened when updating an project to a newer version of Circe (and the project worked fine before that)
Anton Sviridov
@keynmol
gotcha
Matthew de Detrich
@mdedetrich
I tried adding "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeV to a couple of places where. js libraries are defined, but as you can see I am using %%%
Anton Sviridov
@keynmol

@raquo seems like it was my fault - wrong event, I was using onInput in client code :-/ Which I switched to because onChange for some reason was uber-slow in the browser... but either way

        testApp.searchBox.dispatchEvent(new Event("input", new EventInit {
          bubbles = true
        }))

works with laminar elements now :)

Matthew de Detrich
@mdedetrich
Figured out my issue
Assuming you have a shared frontend/backend project (where you have js/shared/jvm), putting scala-java-time in both shared and js caused the issue
Putting it in only shared fixed the problem
Nikita Gazarov
@raquo
@keynmol Makes sense. I see you already got the answer in Laminar room already but for everyone else here: The change browser event only fires after the input element that you typed in loses focus, whereas the input event fires on every keystroke live. This is standard browser behavior, see MDN for reference. I know that React for example fires the change event on every keystroke but it's just a React thing, not standard.
Roberto Leibman
@rleibman

I want to write an internationalization library that works with scala and the following properties

  • Can be used both in the server and on the client (scala.js) with minimum differences
  • Language string files are independent of the scala files, so I can send them to a translator who may not know how to code
  • Works with string interpolation
  • In scala.js you can get the whole bundle from the server at a time, or get strings as you need them, both through ajax
  • Support for .po files or resource bundles (MyResource_en.properties)

Does anybody want to help, offer suggestions or have additional requirements? Am I missing a project that already does this? I looked at scalingua but it doesn’t support scala.js, and the ability to download only one language at a time I think is important

Roberto Leibman
@rleibman
Nikita Gazarov
@raquo

I haven't used it but I don't like the approach that scalajs-i18n-rx takes. It creates reactive variables for every translated string in your UI which is gross overkill unless you actually need to change the language dynamically. For most applications a page reload when switching languages would be totally fine, and would avoid wasting memory on all those RX variables. Also it's tied to ScalaTags, so if you're using a different DOM library you can't use it.

A good i18n library would be agnostic of the DOM and as you said, only load one language file from a non-Scala text file. A great i18n library would support template strings such s "we have %s users", comments for translators, and the ability to translate the same string in several ways depending on context provided in the comment (e.g. "home" as in home page vs "home" as in building)

Eric Peters
@er1c
I have a fairly ambitious port of Apache Lang3 in progress at https://github.com/er1c/scala-apache-commons-lang3 could really use some help porting the java tests and fixing implementations. Basis of the .scala files are the IntelliJ java converter and tweaking.