-
Notifications
You must be signed in to change notification settings - Fork 786
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
WIP Don't merge. Basic Scala.js compilation #1412
Conversation
build.sbt
Outdated
// Ignore, tut is not supported in scala.js | ||
sources in (Compile,doc) := Seq.empty, | ||
// This is needed to support the TLS compiler and scala.js at the same time | ||
// Remove the dependency on the scalajs-compiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by what's going on here. Note that we reverted use of the TLS compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh really, Are we on LBS now? If so I can drop this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We weren't using any advanced features, and the binary compatibility isn't quite yet as we thought it would be when we adopted it. I'm interested in going back at some point, but for now, it's LBS.
@@ -0,0 +1,10 @@ | |||
package org.log4s | |||
|
|||
case class Logger(name: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no way to write to a console?
I still wonder whether the log4s project would be interested in cross-compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can write to console. This is only an interim to get things compiling
@@ -0,0 +1,91 @@ | |||
/** TODO fs2 port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop this entire file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is removed on master. Maybe a rebase is needed?
@@ -0,0 +1,77 @@ | |||
/** TODO fs2 port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And drop this one, too.
|
||
def error(t: Throwable)(s: => String): Unit = { | ||
t.printStackTrace() | ||
println(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably flip these two lines.
println(s) | ||
|
||
def debug(s: => String): Unit = | ||
println(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be extremely verbose. We might want to have a gasp global threshold.
See #1415 for something that will conflict with this. I took care to ensure we are publishing our fork of parboiled for scala.js. |
@rossabaker. Thanks for including parboiled support on the fork |
ba867fe
to
3d9dcb8
Compare
849b8fc
to
17409ce
Compare
this is awesome! |
…Version Fix Displayed Scala Version in Service Doc
…cation Add Partial unification for Clearer Documentation
Upgrade fs2 to 0.10.0-M7
… insensitive string and implement parser
Make TransferCoding immutable
Hey @cquiroz and everybody else :) I have really been wanting this as well, so i took your branch and ran with it to see how far along i would get. I certainly hope you won't mind a helping hand in this effort. So far I've rebased on master and (with a good pinch of hacks) gotten the tests to link and (mostly) run green. My branch is located at https://github.com/oyvindberg/http4s/tree/scala.js-continue. Would you mind having a look, and update this PR as you see fitting? Apologies in advance for the wall of text which follows as I have tried to summarize the current state of the port. There are a bunch of issues, including some which might be of interest for jvm code. Necessary snapshot dependencies to compile/run testsScala.jsYour Specs2A rabbit hole. It turns out that IssuesReflectionAs noted in #956 (comment), there is one instance of reflection in the codebase. For now I kept the overall structure of everything, but inlined the result of running that code: object HttpHeaderParser {
private val allParsers = new util.concurrent.ConcurrentHashMap[CaseInsensitiveString, HeaderParser]
addParser("ACCEPT-CHARSET".ci, ACCEPT_CHARSET)
addParser("ACCEPT".ci, ACCEPT)
addParser("ACCEPT-ENCODING".ci, ACCEPT_ENCODING)
...
} This obviously means that there is now a possibility of adding a header and forgetting to add it to the global mutable list. Better options should probably be explored. LocalesIn Scala.js we don't have access to Locale databases. That is mainly a problem because there are many usages of We also have problems show up as a test failure:
I have a feeling we will be stuck with whatever node/browser does here. Unimplemented APIs in Scala.js
|
@oyvindberg Wow, that's great. I've been trying to get the tests to run by removing/replacing the bits on http4s that cannot properly run on scala.js. Unfortunately I'm short on time so i'd be quite happy to accept your contributions Some comments:
In summary I really love this. Let's think about ways to move this forward |
Great! I guess we'll just have to follow your path and fix the outstanding issues one by one. Once we find a reasonable solution to an issue, we extract the changeset and submit a proper PR with that. How about I take the macro issue and the reflection issue for now? |
Alright, I was able to spend a bit more time on the macro issue, see the linked bug report in Scala.js above. You really did quite a job porting dates/locales to Scala.js, @cquiroz - well done! Even though we cannot currently reimplement |
@oyvindberg It would be hard I think. The reason is that you'd need to parse the rules from cldr and then implement the algorithm. I think it would be simpler to have an |
@rossabaker Hey there. I see your don't panic label, and just wanted to know: |
@oyvindberg I have been hard pressed for time to continue with this. I still want to keep an eye and contribute somehow but I have no issue if you want to continue progressing this. I'm not sure what's the best mechanic, perhaps build on top of my PR? I saw you got a bug fixed on scala.js, Do you need to wait for that? |
I have a support request in to GitHub to fix this (and other so-labelled) PRs. I'm still happy to see this work done. If this PR is still closed when you are ready to resume, please open a new one and link to this. If we can reopen it, we can continue here. |
GitHub can't help bring this ticket back, so we'll need to reopen. In the meantime, log4s just got preliminary scala.js support |
Do you mean send another PR from my branch? |
Yes, another PR from the branch will reopen this. And then just mention this ticket, because there's some good discussion here. |
Here is a first stab at getting http4s to run on scala.js. The final objective is to be able to run the http client on js but we are still several steps away from that
This PR updates the build to cross compile some of the subprojects including core, client and some dependencies
Some notes on the changes to the build
core
andtests
have been converted to full cross projects, This is needed to split the parts that contains references to classes not available in scala.js, in particularFile
ThusEntityEncoder/Decoder
andMultipart
have been split. This means the sources files have been moved from<project>/src
to<project>/shared/src
testing
,client
,circe
,jawn
andparboiled2
have been converted to Pure cross compiled projectsscala.js
have been added. It doesn't do anything at the moment but it lets us compileclient
depend on java only libraries so the tests were moved to a projectclientTesting
TODO:
[ ] Make the tests run on scala.js
[ ] Implement a scala.js based client
[ ] Example of a client on js
I'm posting this for comments but this certainly doesn't do anything useful at the moment. The main challenge is to come up with a client implementation on JS