-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
ref(injection): Rebuild fixup_js_file
on top of magic-string
and sourcemap composition
#1693
Conversation
fixup_js_file
on top of magic-string
fixup_js_file
on top of magic-string
and sourcemap composition
src/utils/sourcemaps/inject.rs
Outdated
something else"#; | ||
|
||
let m = PRE_INJECT_RE.find(source).unwrap(); | ||
dbg!(&source[m.range()]); |
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.
Should we actually assert on something here?
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.
Forgot to remove that test when I was writing this. I don't think it serves much of a purpose.
Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>
Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.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.
That's a beefy change, fingers crossed🤞
This makes debug id injection into JS files precise.
"use strict";
statement.magic-string
to insert the debug id code snippet at the injection point and append the//# debugId
comment.magic-string
give us a sourcemap that maps between the injected and original file. This is really only relevant for the code snippet, the comment is just appended and shouldn't affect mappings anyway.The sourcemap obtained in (3) is then used to rewrite the original sourcemap using
SourceMap::adjust_mappings
.This also minorly refactors
fixup_js_file_end
.