Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix relative paths in wasm backend source maps. Fixes #9837 #9882
Fix relative paths in wasm backend source maps. Fixes #9837 #9882
Changes from 2 commits
a213913
c813941
6367083
4c2cf4a
842caaf
acef71d
a9467bd
18ac680
c9a3bd0
bb04bd9
917b74c
3b15d9e
6bdc495
8412ca7
2174057
f2b9909
450097c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is correct: it uses a path relative to the current directory, but browsers / spec expect
sources
to be relative to the source map file.For example, consider case like following:
Currently this produces a source map
dist/temp.wasm.map
with following contents:But this is incorrect, because
temp.c
is actually in a folder up and needs to be referenced as../temp.c
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case wouldn't the user need to set up
--source-map-base
to fix that? But I've never really understood any of this stuff, hopefully you do...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
--source-map-base
helps browser to find a source map from WebAssembly module.But once browser found that source map, it now needs to find source files. There are three potential ways for it to do that:
sources
are specified as absolute URLs (not great for local files, but can work well enough for public libs).sources
are specified as relative URLs to the source map itself.sourceRoot
, and then allsources
are relative to that instead (could be used in our case as an alternative, but it's a bit more complicated IMO).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, maybe you're right, and in this case
--source-map-base
might be enough, at least if.wasm.map
is always emitted alongside.wasm
. Hmm...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, wait, scratch that, because relative URL still has to be relative to the source map itself. So the comment before still stands :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What browser is basically doing:
sourceMappingURL
from the WebAssembly module (this one is{--source-map-base}/out.wasm.map
).sourceRoot
, prepend it to each item insources
.sources
relative tosourceMappingURL
.So we need each item in
sources
to be relative toout.wasm.map
, no matter where it is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think I see a little better. I'm still confused about how that
sourceMappingURL
option is used in two places for seemingly different purposes, though?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both places it's used as "URL of the .wasm.map". First, to find the map, and later to resolve other files it references, but semantic meaning is the same.
It's similar to how most module systems work, too: if A imports B, and B imports C, then first B is found from A, and then reference to C is resolve relatively to B.