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

Source maps and external libraries, wrong sources. #993

Closed
artursoler opened this issue Aug 31, 2014 · 9 comments
Closed

Source maps and external libraries, wrong sources. #993

artursoler opened this issue Aug 31, 2014 · 9 comments
Labels
invalid Contains a factual error which makes the report invalid. Closed.

Comments

@artursoler
Copy link

When using source maps with external libraries (it has happened to me both with scalatags and with scalajs-react), it seems like the file paths of the computer where the library build was done are being leaked.

Example of paths I'm finding when browsing the generated map file:

1: "file:///home/golly/projects/scalajs-react/core/src/main/scala/japgolly/scalajs/react/vdom/ReactTags.scala"
2: "file:///home/golly/projects/scalajs-react/core/src/main/scala/japgolly/scalajs/react/vdom/ReactVDom.scala"
3: "file:///Users/haoyi/Dropbox%20(Personal)/Workspace/scalatags/js/../shared/main/scala/scalatags/generic/Util.scala"
4: "file:///Users/haoyi/Dropbox%20(Personal)/Workspace/scalatags/js/../shared/main/scala/scalatags/generic/Attrs.scala"
5: "file:///Users/haoyi/Dropbox%20(Personal)/Workspace/scalatags/js/../shared/main/scala/scalatags/generic/Styles.scala"
6: "file:///Users/haoyi/Dropbox%20(Personal)/Workspace/scalatags/js/../shared/main/scala/scalatags/generic/Core.scala" ```
@sjrd
Copy link
Member

sjrd commented Aug 31, 2014

That's the given libraries' fault ;-) They should use the -P:scalajs:mapSourceURI option in scalacOptions to tell the compiler a public URI where sources can be found (typically a GitHub raw URL).

-P:scalajs:mapSourceURI:FROM_URI[->TO_URI]
change the location the source URIs in the emitted IR point to

  • strips away the prefix FROM_URI (if it matches)
  • optionally prefixes the TO_URI, where stripping has been performed
  • any number of occurences are allowed. Processing is done on a first match basis.

@artursoler
Copy link
Author

Thanks for the fast response, Sébastien.

I'll close this issue and open one in each of the libraries.

@vendethiel
Copy link

Maybe this should be mentioned in the docs (not only the API)? I spent some time looking for that exact options

@sjrd
Copy link
Member

sjrd commented Sep 14, 2014

@Nami-Doc Sure! Where do you think it would be best to put it?

@vendethiel
Copy link

I first looked in the sbt plugin doc, so I'd say there. I'm not sure with what it'd go, though. Maybe there are other options you want to cover

@sjrd
Copy link
Member

sjrd commented Sep 14, 2014

Maybe an additional section in sbt plugin doc for "Publishing libraries"?

@vendethiel
Copy link

I'm not sure this should be cornered to library publishing? I'm hitting this issue on a local project, myself

@sjrd
Copy link
Member

sjrd commented Sep 14, 2014

Ah? But for a local project, the source maps pointing to your local files should work, don't they?

@vendethiel
Copy link

The .js.map file contains file:///Users/... for me. Not sure if I'm doing something wrong?

EDIT: it seems scala-js-dom has file:///Users/tschlatt/Documents/scala-js-dom/
EDIT: also, if you don't provide a mapping, I could see TO_URI being / by default (root). not sure
EDIT: Currently using that, and it works great:

s"-P:scalajs:mapSourceURI:file://${baseDirectory.value}->/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Contains a factual error which makes the report invalid. Closed.
Projects
None yet
Development

No branches or pull requests

3 participants