-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Invalid URLs (absolute paths) in source maps in some cases #9837
Comments
Sorry, I may be missing something here, the output in cases 1, 2, and 4 look identical? They are all {"version":3,"sources":["C:/Users/rreverser/Projects/temp-wasm/temp.c"],"names":[],... All those are absolute paths, I think? That seems to conflict with
|
Maybe related to https://github.com/emscripten-core/emscripten/pull/7481/files ? |
Oops, sorry - copy-paste mistake. Fixed output of the case 1. |
Maybe it was revealed by it, but definitely not the original cause as the change in PR seems correct. |
Got it, thanks @RReverser! Fix in #9882, PTAL |
Summary
Source maps are supposed to contain only valid URLs in the
sources
array (either relative, or absolute with scheme). Emscripten sometimes emits absolute paths into that array instead, making them impossible to load by a browser.Examples
For a file
C:\Users\rreverser\Projects\temp-wasm\temp.c
with arbitary content in a foldertemp-wasm
, I'm trying different formats for the filename.Note that this is not a Windows-specific issue, and you'll get same results with Unix filepaths.
emcc ./temp.c -g4 -o temp.wasm
(relative filename in the same folder):emcc temp.c -g4 -o temp.wasm
(same relative filename, but without explicit./
):emcc ../temp-wasm/temp.c
(relative filename with a folder):emcc C:\Users\rreverser\Projects\temp-wasm\temp.c -g4 -o temp.wasm
(absolute filename):Results
When a filename is relative but without a leading
./
or is specified as absolute, Emscripten outputs an absolute filename insources
, which is not a valid URL and can't be handled by DevTools. It could be valid if prefixed withfile:///
specifier, but that's not an ideal solution.The only case where Emscripten
sources
ends up being valid URL is when a filename is specified as explicitly relative (cases 1 and 3).Then, Emscripten outputs a relative URL as well, which can be handled well by DevTools both in case of loading from filesystem as well as a static HTTP server.
More so, even though case 3 outputs a relative filename, it's not ideal.
Suggested solution
Emscripten should always compute relative URL out of the source map filename and the actual sources, and emit that in
sources
array.The text was updated successfully, but these errors were encountered: