-
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 line numbers in case of commonJS file with no sourcemap #3687
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3687 +/- ##
==========================================
- Coverage 73.33% 73.33% -0.01%
==========================================
Files 278 278
Lines 20329 20332 +3
==========================================
+ Hits 14908 14910 +2
- Misses 4477 4478 +1
Partials 944 944
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
🚀 🚀
Previously if someone imports or runs a commonJS file (one that won't need to go through babel) we still need to wrap it in some code to run it. But we don't have a sourcemap to update, unless it already had one(internal babel adds it). This leads to all lines being off by 1. This is fixed by updating the sourcemap in the other case. Unfortunately short of generating an "identity" sourcemap and then shifting it by 1 with adding `;` to the first mapping, this can't be done. The sourcemap implementation specifically wants to find each mapping, so unless it can do that it will not do anything. The remaining hack (adjusting any available sourcemap) still stands as it also fixes the columns on the *first* line of the file. As well as actually being better.
What?
Fix line numbers in case of commonJS file with no sourcemap:
Why?
Previously if someone imports or runs a commonJS file (one that won't
need to go through babel) we still need to wrap it in some code to run
it. But we don't have a sourcemap to update, unless it already had
one(internal babel adds it). This leads to all lines being off by 1.
This is fixed by updating the sourcemap in the other case.
Unfortunately short of generating an "identity" sourcemap and then
shifting it by 1 with adding
;
to the first mapping, this can't bedone.
The sourcemap implementation specifically wants to find each mapping, so
unless it can do that it will not do anything.
The remaining hack (adjusting any available sourcemap) still stands as
it also fixes the columns on the first line of the file. As well as
actually being better.
Also found that while fixing linter issue I broke the tc39 error generation :(.
Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)