-
Notifications
You must be signed in to change notification settings - Fork 1.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
fix line numbers when inline sourcemap is used #3717
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3717 +/- ##
==========================================
- Coverage 73.31% 73.28% -0.03%
==========================================
Files 278 278
Lines 20425 20456 +31
==========================================
+ Hits 14975 14992 +17
- Misses 4499 4507 +8
- Partials 951 957 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
js/compiler/compiler.go
Outdated
// the lines in the sourcemap (if available) will be fixed by increaseMappingsByOne | ||
conditionalNewLine = "\n" | ||
newCode, err := state.updateInlineSourceMap(code, index) | ||
if err != nil { | ||
c.logger.Warn("while compiling %q we couldn't update it's inline sourcemap which might lead "+ |
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.
It is not clear to me as a user, if I can fix it in some way. Do we have a suggestion? Or the answer is there isn't much you can 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.
I would argue this warning is mostly so that when they report an issue - they report it with this warning
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 the case of the originally attached script, the line number has been corrected. At the same time, if I transfer the throw expression to another function, it no longer works.
interface User {
name: string;
id: number;
}
class UserAccount implements User {
name: string;
id: number;
constructor(name: string) {
this.name = name;
this.id = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
}
}
function newUser(name: string): User {
throw "other";
return new UserAccount(name);
}
export { User, newUser };
@szkiba - I used the wrong base64 encoding, that doesn't support padding , and just so happened the original example works with it 😓 , but not this new one 🤦 I have now fixed it as well as fixing the warning message a bit |
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.
It works now.
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.
LGTM, just a small text suggestion
Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com>
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.
LGTM
What?
Fix sourcemaps when they are inlined.
Before that if there was an inline sourcemap we won't load it and go through the already used method of updating it.
This isn't a problem if babel actually transpiles it as it will load it, but in case the sourcecode was already transpiled with inline maps this will now update the lines correctly.
Why?
To have correct lines when people user sourcemaps .
Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)
#3689