Closed Quafadas closed 1 year ago
Yup, you want to do what the sbt-typelevel plugin is doing here.
So I'll try to put up a PR for this.
The solution being to pass an appropiate scalacOptions
setting for sourcemaps:
From sbt-typelevel
:
scalacOptions ++= {
val flag = if (tlIsScala3.value) "-scalajs-mapSourceURI:" else "-P:scalajs:mapSourceURI:"
val tagOrHash =
GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
val l = (LocalRootProject / baseDirectory).value.toURI.toString
tagOrHash.flatMap { v =>
scmInfo.value.map { info =>
val g =
s"${info.browseUrl.toString.replace("github.com", "raw.githubusercontent.com")}/$v/"
s"$flag$l->$g"
}
}
},
Note that this assumes that you are setting scmInfo
correctly :)
@zetashift Go ahead, yes! this will be great.
One thing to note that might trip you up is that smithy4s' build uses sbt-projectmatrix, which specifically changes the baseDirectory
of the project to something like target/.matrix/...
So if you see weird values - don't be alarmed and you might have to go through paths relative to ThisBuild / baseDirectory
which should be unaffected
One thing to note that might trip you up is that smithy4s' build uses sbt-projectmatrix, which specifically changes the
baseDirectory
of the project to something liketarget/.matrix/...
I don't think that should matter, crossProject
does similar shenanigans depending on whether its pure or not.
Is there a way to get the tag or hash without involving a sbt plugin?
In sbt typelevel, there are helpers of this:
val tagOrHash = GitHelper.getTagOrHash(git.gitCurrentTags.value, git.gitHeadCommit.value)
Browsing through the sbt docs I can't seem to find anything about getting git values(which makes sense for a build tool :P).
Currently sketching out adding these options to jsDimSettings
:
lazy val jsDimSettings = simpleJSLayout ++ Seq(
scalacOptions ++ {
val flag =
if (scalaVersion.value.startsWith("3")) "-scalajs-mapSourceURI:"
else "-P:scalajs:mapSourceURI:"
},
EDIT: the plugin mentioned would be https://github.com/sbt/sbt-git
yes, I'd suggest sbt-git. If we don't have that, it can probably be added
yes, I'd suggest sbt-git. If we don't have that, it can probably be added
Yes, sbt-git is already in there...I forgot to sync my fork and thus was modifying a very old version 🤦
I think the sourcemaps still aren't working:
(the picture should actually be pointing to a github url instead of /home/runner.../
The problem is that the "local" path doesn't point to sources... I think it has something to do with the fact that the project uses /modules/project_dir
thus the "baseDirectory" might not be correct.
Maybe sourceDirectory
should have been used instead of baseDirectory
?
This is the difference between sourceDirectory
and baseDirectory
I am unsure which one is the right path, because of sbt-projectmatrix
and if it even matters.
(the picture should actually be pointing to a github url instead of
/home/runner.../
So I haven't been able to look into this in depth, but the fact that the source maps didn't change at all suggests something more fundamental is wrong, than the path is wrong.
If it was working, even if the path was wrong, at least the sourcemaps would be pointed to a wrong GitHub URL, instead of to the runner directory.
Sorry, I take that all back 😅 I guess it's the localSourcesPath
that's wrong, which is why the sourcemap transformation is not applying? Edit: figured it out, see https://github.com/disneystreaming/smithy4s/pull/706/files#r1072602594
In my pet project, vite complains about source map errors. I believe one of the culprits to be smithy.
Here's a sample .js.map file.
I think the important part, is the home/runner/work/smithy4s/etc/etc line, which obviously doesn't exist, in my local environment. Because I aggressively lurk discord, I believe the solution may look something like this;
https://discord.com/channels/632150470000902164/635668814956068864/1060561961810677760
https://github.com/typelevel/sbt-typelevel/blob/4da726ca021ea2c6459e8286d9ec49ab7c79a883/github/src/main/scala/org/typelevel/sbt/TypelevelScalaJSGitHubPlugin.scala#L35
I believe there to be a compiler flag, which could potentially point this back to this repository, for example. I will openly admit, that my understanding of this, is somewhat superficial...