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

Build: Use github URL instead of local path in SJSIR files #91

Merged
merged 1 commit into from
Mar 19, 2021

Conversation

ajablonski
Copy link
Contributor

I'm fairly new to Scala.JS, so apologies if any of the below sounds flat-out wrong, if there's a good reason why a change like this doesn't make sense, or if there's a better solution you've already considered. But here's what I seem to have found:

The source URL that's included in the .sjsir seems to default to the local source path. In certain toolchains that try to include/reference library sources (in my case, that includes scalajs-bundler), this leads to persistent warnings in the webpack process along the lines of this one:

[warn] NonErrorEmittedError: (Emitted value instead of an instance of Error) Cannot find source file '../../../../../../../../raquo/code/scala/laminar/src/main/scala/com/raquo/laminar/DomApi.scala': Error: Can't resolve '../../../../../../../../raquo/code/scala/laminar/src/main/scala/com/raquo/laminar/DomApi.scala' in [my project directory]

The fix I've seen for this is to use the mapSourceURI compiler flag to map to the raw.githubusercontent.com URL, and that seems to change the URL in the sjsir files from a local file:/ path to a remote one on Github.

The perhaps bigger benefit (besides fewer warnings in specific use cases) is that, with this change, I'm able to inspect library sources in the browser when I generate a source map that includes included libraries.

@raquo
Copy link
Owner

raquo commented Mar 11, 2021

Thanks @ajablonski! I don't actually use source maps myself so I missed this.

Question: does it mean we need to add the same to Laminar dependencies to be able to see their sources too? Could you please check if you can see Airstream sources (anything in com.raquo.airstream) from your project, with just this one change?

@ajablonski
Copy link
Contributor Author

Yeah, I think this change would also need to be made in other Laminar dependencies. In my project, which right now directly depends on only Laminar and Airstream, I also saw sourcemap warnings about relative URLs for the transitive dependency scala-dom-types . I'm happy to make PRs in those other repos too, just wanted to start the conversation with one.

@raquo
Copy link
Owner

raquo commented Mar 14, 2021

Thanks for checking @ajablonski! I'm not an expert on build stuff, but what you're saying sounds correct.

If you could submit similar PRs to SDT and Airstream, that would be great! Otherwise I can do myself next week.

@ajablonski ajablonski changed the title Build: Use github URL instead of relative path in SJSIR files Build: Use github URL instead of local path in SJSIR files Mar 16, 2021
@ajablonski
Copy link
Contributor Author

Oh man am I not an expert in build stuff either; PRs submitted to those other two as well, I spot checked the URLs that ended up in the SJSIR files and they all seemed valid (they were https://raw.githubusercontent.com URLs that correctly resolved instead of file:// local paths)

@raquo
Copy link
Owner

raquo commented Mar 18, 2021

Awesome, thanks @ajablonski ! Turns our this option was renamed in Scala 3, so I fixed SDT build like this.

@ajablonski
Copy link
Contributor Author

Ah, nice catch!

@raquo raquo changed the base branch from master to develop March 19, 2021 06:03
@raquo raquo merged commit 9d718ed into raquo:develop Mar 19, 2021
@raquo
Copy link
Owner

raquo commented Mar 22, 2021

I have all the code ready, just wanted to test that this solves the source maps issue, and if it does, what sbt / scalajs-bundler / webpack config is required for source maps to work. I'm guessing something like this. I should have time to do the release next week(end).

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 this pull request may close these issues.

None yet

2 participants