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

Point source maps to generated sources #13

Closed
raquo opened this issue Mar 18, 2021 · 0 comments · Fixed by #14
Closed

Point source maps to generated sources #13

raquo opened this issue Mar 18, 2021 · 0 comments · Fixed by #14

Comments

@raquo
Copy link
Contributor

raquo commented Mar 18, 2021

As described in raquo/Laminar#91, Scala.js sjsir files contain the path & name of the original .scala file. My understanding is that these file names are then used to display the content of .scala files when debugging with source maps.

The problem for libraries is, by default the file paths in sjsir files are local to the machine on which the compilation happens, which is not the user machine where source maps are actually needed. The way to fix that is to use github URLs for raw files for file paths. I'd like to do that for Laminar and all of its dependencies, but the problem with tuplez is that it doesn't commit the generated .scala files to git, so there is nowhere we could point the source maps to.

To solve this, I propose that tuplez commits all of its generated files to git similar to how Airstream does it. I think it will be beneficial to users exploring the source code too. I'm not 100% sure about all the things you're generating but this approach seems like it should work. After you have the files, you need something like this in build.sbt:

scalacOptions ++= {
    val sourcesUrl = s"https://raw.githubusercontent.com/raquo/scala-dom-types/${git.gitHeadCommit.value.get}"
    val sourcesOptionName = if (scalaVersion.value.startsWith("2.")) "-P:scalajs:mapSourceURI" else "-scalajs-mapSourceURI"
    Seq(
      s"${sourcesOptionName}:${file("js").toURI}->$sourcesUrl/js/",
      s"${sourcesOptionName}:${file("shared").toURI}->$sourcesUrl/shared/"
    )
  }

and this in turn requires

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")

Note: the js and shared paths are copy-pasta from scala dom types, you'll need something else depending on where you put the generated files. You can easily check that your .sjsir files link to the correct github URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant