-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce the impact of MimeDB on JS size #30
Comments
/cc @rpiaggio |
Thanks for raising this issue and for testing this stuff! @ChristopherDavenport also identified this problem while testing the initial PR.
Before we resort to this, I'd like to understand why the Scala.js static linker is unable to dead-code-eliminate the Do you have any ideas about this? I think I remember seeing similar issues on some of your SJS projects which you resolved by e.g. using |
Right
Note this is with ES enabled which disables GCC |
Can you explain more about this? Or provide a pointer to a reference, not sure what this is or why you'd want to do this.
This comment in Scala.js explains how the DCE works I think: https://github.com/scala-js/scala-js/blob/master/javalanglib/src/main/scala/java/lang/System.scala#L24-L35 |
Ok, I looked into this a bit. There are a few pathways that can cause the entire Add I don't think there's any way around this. So, the only solution as @cquiroz proposes would be to reduce However, while this makes sense for the browser, I would prefer that this does not affect the Node.js runtime which should ideally have feature-parity with the JVM. I have no idea how to do this without publishing separate artifacts. |
I suppose it maybe worthwhile to check if making the vals in MimeDB lazy helps. Maybe there are other parts as well that could be optimized that way |
I'm pretty sure it won't. Even if lazyness defers initialization at runtime, the initialization code will be statically linked in the
This is definitely possible. |
I guess a related question is how do we get to |
It used in some of the methods in
That could work 🤔 |
At any rate, I recall investigating this same sort of problems with |
@cquiroz what is your target JS size? |
Our largest application is a whopping 16MB with scala.js |
phew! 😅 That number looks about right, I was |
Yeah. I noted this on my very old attempt to do |
Btw, |
We alrready have |
A basic fetch/circe app generates a 1.8 mb JS in #29 (comment). I'm hoping a strategy like http4s/http4s#5273 may help with this. |
See https://armanbilge.github.io/http4s-dom/sme.html for a helpful visual. |
Cool, how did you generate that graph? |
@cquiroz https://www.npmjs.com/package/source-map-explorer Will you use it for your 18 mb app? 😆 |
Yeah, thanks for this. The stupid large MimeDB that we get from http4s is the source of lots of problems including #119. So, yeah, time to fix this. |
I've PRed a fix upstream in http4s/http4s#6211. Please try the snapshot (instructions in PR :) |
We are testing http4s for our scala.js browser app and it seems to produce a fairly big increase on the scala.js produced by scala.js. One of the contributors is the very large
MimeDB
which maybe not needed on the typical frontend appShould we split
MimeDB
into jvm and js versions, with the latter having a minimal or empty set of mime types?The text was updated successfully, but these errors were encountered: