-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Add Scala.js source map compiler flag #432
Conversation
This now compiles locally for me, so I guess it would have some chance of working. If it was possible to let it run through the CI, it may (?) to test, whether this change worked or not ... |
Hi @Quafadas and thank you for your contribution! Having proper sourceMap links is a great addition to the com-lihaoyi ecosystem.
Also checking sbt-typelevel they don't do anything specific for Scala 2.12 and 2.11 so you can just check if it's scala3 or not.
So this lacks a trailing private def sourceMapOption = T.task {
val remoteSourcesPath = s"https://raw.githubusercontent.com/com-lihaoyi/upickle/${publishVersion()}/"
val sourcesOptionName = if(isScala3(crossScalaVersion)) "-scalajs-mapSourceURI" else "-P:scalajs:mapSourceURI"
s"$sourcesOptionName:${T.workspace}/->$remoteSourcesPath"
}
override def scalacOptions = super.scalacOptions() ++ Seq(sourceMapOption()) which outputs this:
Now, if you wanna be fancy and have some code that is portable to other repositories as well, you can derive the URL from private def sourceMapOption = T.task {
val baseUrl = pomSettings().url.replace("github.com", "raw.githubusercontent.com")
val sourcesOptionName = if(isScala3(crossScalaVersion)) "-scalajs-mapSourceURI" else "-P:scalajs:mapSourceURI"
s"$sourcesOptionName:${T.workspace}/->$baseUrl/${publishVersion()}/"
}
override def scalacOptions = super.scalacOptions() ++ Seq(sourceMapOption()) This is the final draft. |
@lolgab Oh wow - that is amazing feedback! Thankyou for taking the time - wonderfully educational too. As soon as I get a chance, I'll be taking another look... |
@lolgab Is this good to merge? |
The format needs to be a URI like `file:/home/user/upickle` Moreover, it doesn't make sense to add the option for untagged commits, since URLs don't dereference. Also scala-js-dom skips Snapshot versions: https://github.com/scala-js/scala-js-dom/blob/51a807cc04ea134ece030d6d4005a8ce30c1de99/project/Lib.scala#L82
@lefou There were some problems that I fixed in the last commits. Let's wait for the CI and then I think we can merge. |
@lolgab Thankyou so much again for your time. |
Very nice, thank you! It would be great to test this manually once we tagged and released |
I would be very happy to pick up the manual test once the release is out and will report back here. |
@lefou @lolgab I think this can be left safely closed. I added upickle 3.0.0-M2 to a toy app and did two checks;
That "Api.scala", is from upickle, and clicks right through to the sources on GitHub. So I conclude this works great - thank you both for your time! |
@Quafadas Thanks for reporting back! |
My attempt to fix #431
I haven't been able to test this at all. I think the solution is "spiritually" correct, but getting upickle to build in my environment, is not a trivial undertaking. I'll try it on a home computer once I get the chance. I'm also not sure, if this should be a very different place in upickle or mill itself - making it a bit of a shot in the dark to debug through CI right now.
The idea is stolen from here;
https://github.com/raquo/Laminar/blob/739cc0dbab319c685f28be30a1592b7d04347842/build.sbt#L78