-
Notifications
You must be signed in to change notification settings - Fork 649
Make line counts reflect all line endings #691
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
Conversation
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.
This is fantastic @danielsmc - sorry about the late review.
@motiz88 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@motiz88 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary
Metro included a few functions to count source lines, some of which didn't correctly count all line terminators specified in the ECMAScript standard. This PR replaces those implementations with the correct one found in
packages/metro/src/shared/output/RamBundle/util.js
.The user-facing issue which led me to this was that importing a file with CRLF line endings caused
/symbolicate
to return incorrect mappings for all files after that one in the bundle. Metro-transform-worker was double-counting the line endings and getExplodedSourceMap was carrying that erroneous offset through.Test plan
There's a new test for a variety of line endings, and the several existing tests that exercise countLines pass without modification.