Skip to content
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 scalacOptions for sourcemapping github paths #706

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions project/Smithy4sBuildPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import scala.scalanative.sbtplugin.ScalaNativePlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport.scalaJSLinkerConfig
import org.scalajs.linker.interface.ModuleKind
import org.scalajs.jsenv.nodejs.NodeJSEnv
import com.github.sbt.git.SbtGit.git

sealed trait Platform
case object JSPlatform extends Platform
Expand Down Expand Up @@ -390,6 +391,20 @@ object Smithy4sBuildPlugin extends AutoPlugin {
}

lazy val jsDimSettings = simpleJSLayout ++ Seq(
scalacOptions ++= {
// Map the sourcemaps to github paths instead of local directories
val flag =
if (scalaVersion.value.startsWith("3")) "-scalajs-mapSourceURI"
else "-P:scalajs:mapSourceURI"
val localSourcesPath = baseDirectory.value.toURI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're my hero.
I'll try to get a PR that fixes it today!

Copy link
Member

@kubukoz kubukoz Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @armanbilge <3

val headCommit = git.gitHeadCommit.value.get
scmInfo.value.map { info =>
val remoteSourcesPath =
s"${info.browseUrl.toString
.replace("github.com", "raw.githubusercontent.com")}/$headCommit"
s"${flag}:$localSourcesPath->$remoteSourcesPath"
zetashift marked this conversation as resolved.
Show resolved Hide resolved
}
},
Test / scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.CommonJSModule)
},
Expand Down