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 09:24
    @sjrd banned @yensaoxuan_twitter
  • Apr 18 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 07:47
    @sjrd banned @quangs
  • Jan 23 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
Ulugbek Abdullaev
@ulugbekna
I discovered sbt-crossproject and see that it's updated some time ago. I wonder whether it is still used/maintained and what its primary purpose is since it seems just sbt itself can compile to both jvm and js?
Anton Sviridov
@velvetbaldmime:matrix.org
[m]

sbt itself can compile to both jvm and js

crossproject helps generating those project - one can do it manually like you did, or with crossproject/projectmatrix plugins.

If you have a ton of cross-built projects, manual creation can become tedious quickly :)

1 reply
Rich
@Rich2
What does io.Source.fromResource do when running Scala.js in a browser?
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
I think it breaks during linking
[error] Referring to non-existent class java.io.FileNotFoundException 
[error]   called from scala.io.Source$.fromResource(java.lang.String,j
ava.lang.ClassLoader,scala.io.Codec)scala.io.BufferedSource
Rich
@Rich2
Ah OK I tried compiling under Scala.js. Thanks.
I'll make sure any methods that call it are in a Java only source folder.
Dave Smith
@davesmith00000
Slightly odd question maybe. Indigo (game engine) is using inheritance where it occasionally needs to - for reasons lost to the mists of time - but there are a few places where I've been considering for ages switching to typeclasses. With the move to Scala 3 complete, now seems like a good time to make use of the nice new syntax for typeclasses.
The question I've got is: Can anyone offer any intuition for how typeclasses stack up in terms of performance, versus straight up inheritance in relatively simple cases performed many many times a second? (On a JS engine, not the JVM.)
I should and would [attempt to] measure it, but I just wondered if anyone had any gut feelings or words of wisdom on the subject?
Sébastien Doeraene
@sjrd
AFAICT, it should be more or less the same. In both cases, I believe the dominating time loss is in the megamorphic dispatch.
Dave Smith
@davesmith00000
Good to know, thanks. 👍
Dan Di Spaltro
@dispalt
So is it not possible at the moment to use dynamicImports with closure compiler?
Sébastien Doeraene
@sjrd
dynamicImports per se are fine. It's ESModule that Closure does not support.
Ah no you're right. Emitting multiple modules is not supported by Closure either.
1 reply
dang, that kind of hurts the feature right? For our app we're talking 2.4mb of uncompressed vs 7mb fullopt with no closure. I was really hoping to use this...
Sébastien Doeraene
@sjrd
Yeah well, there's not much we can do about it...
Dan Di Spaltro
@dispalt
got it, I guess it kind of operates on the whole app. I guess the other option is to create another "app" , or really lean in and split everything on dynamicImport boundaries and take the hit in total, but have each piece feel like snappier
Tobias Schlatter
@gzm0
Just to give some context: I have interacted quite closely with the GCC team regarding multiple modules: Essentially GCC does not support "keeping" our module splits. It might support creating multiple files on its own, but then we're talking about way deeper integration from a build tool perspective. My hope was that webpack (via scalajs-bundler) allows similar compression.
But yes, the whole splitting feature is not really usable on its own without a post bundler if code size is a concern (which it probably always is :-/)
Carlos Quiroz
@cquiroz
I decided to accept a larger js output with es modules
7 replies
But would be great to find a way to compress it
Brian P. Holt
@bpholt

It is possible to mark an object annotated with @JSImport as “used” or something, so it’s not pruned by the optimizer?

I’m importing cross-fetch/polyfill so I can create WHATWG Fetch API response objects in unit tests for Cloudflare Workers. I can do something like

@js.native
@JSImport("cross-fetch/polyfill", JSImport.Default)
object FetchPolyfill extends js.Any

// inside a test class
val throwaway = FetchPolyfill

but that’s kind of inelegant, so I was hoping there’s a better solution.

(The stubs for the classes themselves are defined by scalajs-dom so AFAICT there’s not an easy way to move the @JSImport somewhere where it would more naturally be used.)

Carlos Quiroz
@cquiroz
Could you use a js.native val?
nafg
@nafg
Does anyone know if sbt-web-scalajs 1.2.0 works with scalajs-bundler?
N.S. Cutler
@godenji

Ah no you're right. Emitting multiple modules is not supported by Closure either.

I don't mean to be overly critical, but what benefit does dynamicImport have wrt to code size, worse than none? Looks like a very promising feature, one that really helps in the JS/TS world where lazy loading is a significant performance improvement.

Maybe I'm misunderstanding the performance/code size tradeoff here. Perhaps lazy loading helps on the performance front but status quo of large initial bundle size remains?

Brian P. Holt
@bpholt
Using a js.native val didn’t seem to help—I still had to reference the val somewhere to see it included
Eric Peters
@er1c
inside of an sbt task, is there a way to get the platform suffix (e.g. _sjs_1)
Eric Peters
@er1c
oh maybe projectID.value.crossVersion
Jacob Bogers
@Jacob_Bogers_twitter
hi
scala.js, I am blown away
can you make it work with react or svelte?
Antoine Doeraene
@sherpal
For react there is at least two different ways : slinky and scala-js-react. For svelte I don't know anything existing
Jacob Bogers
@Jacob_Bogers_twitter
maybe someone made a framework in scala.js itself
Antoine Doeraene
@sherpal
For frameworks in scala js itself there are at least laminar and outwatch0fw
Outwatch*. There is also scala tags although I'm not sure where people consider it to be a framework
Ulugbek Abdullaev
@ulugbekna
Hi! I have two text files that I want to use in scala-jvm and scala-js (separate) code. In scala-jvm code, I can just read the files, what's a good way to get those files in scala-js? Maybe sbt can load them as variables on compilation or I can somehow embed them in the html? (sorry if the question is not very scala-js specific)
Antoine Doeraene
@sherpal
If you're talking about html, I'm assuming you want to get some text file from the server, or perhaps embedded inside the scala-js compiled file (which, depending on the size of your files, might be bad). (In case you are on node.js, you should simply use the fs module.) if you don't want to deal with a server, then probably the best is to embed in the html, for example in a hidden div with a unique id, and you get it using dom.document.getElementById(myId).innerText (and yes, you can tweak the fastOptJS task to copy paste from your resources, for example). If you want to get it from a server instead, you can simply make an http request. Note, however, that there will be no way to do that synchronously (which is not a bad thing)
3 replies
Dan Di Spaltro
@dispalt
@gzm0 there are options to compress things more in these plugins like terser and friends, the big one for SJS would be mangle properties, however, without some sort of guidance on how to do it, it's too aggressive and the app breaks. I noticed in the GCC linker you have some settings and I wonder if we could come up with some way to enable some lite mangling while respecting some scalajs rules, like don't touch $classData
Tobias Schlatter
@gzm0
hmmm... probably :) I'm quite sure we could extend / change the linker to JS in a different shape. But the specifics would really depend on what plugins we would want to target and what they need. I'm afraid I will not have the cycles to look into the plugins specifically. But if this is important to you, you could have a look at how GCCs advanced optimizations (what we target) compare to the modes of the plugins you'd like. That would be helpful for us so we can better assess whether adjusting the linker would be feasible.
Sébastien Doeraene
@sjrd
I'm slowly starting to think that we might want to build our own minifier for global names (class names, property names, function names). If we do that, then hopefully any local-only JS minifier could be applied to individual .js files to finish the job. It might not be as good as GCC applied to an entire .js file, but it might be able to go a long way in the right direction.
1 reply
Tobias Schlatter
@gzm0
Would that mean ditching GCC entirely?
Sébastien Doeraene
@sjrd
At least as an option, yes. Or we could use GCC in SIMPLE mode on each file separately (after our global name minify phase).
Dan Di Spaltro
@dispalt

I'm slowly starting to think that we might want to build our own minifier for global names (class names, property names, function names). If we do that, then hopefully any local-only JS minifier could be applied to individual .js files to finish the job. It might not be as good as GCC applied to an entire .js file, but it might be able to go a long way in the right direction.

Yeah honestly, if we just shrink some of the property names, I think the bundle would be quite a bit smaller. Right now terser takes 13MB -> 5.6mb for us, incorrectly mangling properties (FWIW) goes from 5.66 -> 2.8MB then gzip is like 500kb

Carlos Quiroz
@cquiroz
Agreed an internal name mangling would go a long way, if you look at the produced js you can see the original names taking a lot of space
After that things like terser could do a bit more
nafg
@nafg
What's the status of getting npmDependencies decoupled from webpacking (as in scalajs-bundler)? Has it happened? Is there any chance of npmDependencies becoming part of scala.js?
Sébastien Doeraene
@sjrd
I don't think anyone has worked on that.
In any case, they would become two separate sbt plugins. We won't add anything to sbt-scalajs (why would we?).
nafg
@nafg
Yeah that's not important. But the convention of the way it records npmDependencies in jar files so they propagate transitively should be documented as a standard that transcends a particular sbt plugin. Also, it needs to be supported in Mill.
Mathieu
@mathieuleclaire
Hi,
I have a question concerning jsDependencies.
I have a facade for plotly.js, but webpacking this library is terrible, so that I have given up using scalajs-bundler to deal with the js sources. So I now use jsDependencies plugin in my facade build. The result is a wrap of the plotly.min.js in my facade jar output as expected.
My question is: how to get this js resource (conained in the jar facade) from a project depending on this facade (so that I could copy it to the right place to render it accessible in my html) ?
I guess it is a trivial use case, but I didn't find the right methods to achieve that.