-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(es): Improve sourcemap url error messages. #9422
Conversation
Parse based on the provided prefix: inline urls must start with "data:", so only trying one will ensure the correct and more helpful error message will be shown. Currently, any error while trying to load a sourcemap file will give the unhelpful error: > ERROR failed to read input source map: failed to parse inline source map url > index.js.map > > Caused by: > relative URL without a base > at <snip>/swc-0.273.28/src/lib.rs:386 Further, for the common "missing file" error, give a better message that hopefully describes the two paths tried, rather than increasing confusion by talking about a `.js.map.map` file if it was correct. There are more improvements that could make this code clearer and more reliable, but this should resolve many of the confused users (including me!) See (maybe can be considered to fix): swc-project#8944, swc-project#8910
🦋 Changeset detectedLatest commit: 5a43d86 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
compile() expects a filename, not a url: it passes the value directly to the bindings module, which immediately parses it as a `Path` unconditionally. This causes input file source maps to fail to load, as it attempts to find the URL as if it were a file on disk. (see swc-project/swc#9422) This is a targeted fix which hopefully minimizes the chance of things breaking.
CodSpeed Performance ReportMerging #9422 will not alter performanceComparing Summary
|
compile() expects a filename, not a url: it passes the value directly to the bindings module, which immediately parses it as a `Path` unconditionally. This causes input file source maps to fail to load, as it attempts to find the URL as if it were a file on disk. (see swc-project/swc#9422) This is a targeted fix which hopefully minimizes the chance of things breaking.
Should I be concerned about those performance changes? I haven't touched anything that should affect them, so I assume they are noise, but the messaging on the bot implies it's pretty confident... |
Nope, it's quite flaky. |
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!
Description:
Parse based on the provided prefix: inline urls must start with "data:", so only trying one will ensure the correct and more helpful error message will be shown.
Currently, any error while trying to load a sourcemap file will give the unhelpful error:
Further, for the common "missing file" error, give a better message that hopefully describes the two paths tried, rather than increasing confusion by talking about a
.js.map.map
file if it was correct.Now it will show, for example:
(This example appears to be an issue in swc-node, where it is passing a file URL which is treated as a path, and therefore never exists, I'm working on a PR for there too)
There are more improvements that could make this code clearer and more reliable, but this should resolve many of the confused users (including me!)
Related issue:
See (maybe can be considered to fix): #8944, #8910
PR in swc-node to fix the originating issue