Skip to content
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

Make line counts reflect all line endings #691

Closed
wants to merge 4 commits into from

Conversation

danielsmc
Copy link
Contributor

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.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 26, 2021
@sota000 sota000 added this to Needs Triage in Metro Pull Requests Aug 2, 2021
@motiz88 motiz88 self-requested a review August 27, 2021 16:41
Copy link
Contributor

@motiz88 motiz88 left a 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.

@facebook-github-bot
Copy link
Contributor

@motiz88 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@motiz88 motiz88 moved this from Needs Triage to Imported for Internal Review in Metro Pull Requests Aug 27, 2021
@motiz88 motiz88 moved this from Imported for Internal Review to Blocked in Metro Pull Requests Aug 27, 2021
@facebook-github-bot
Copy link
Contributor

@motiz88 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@motiz88 motiz88 moved this from Blocked to Imported for Internal Review in Metro Pull Requests Sep 1, 2021
Metro Pull Requests automation moved this from Imported for Internal Review to Closed Sep 20, 2021
@facebook-github-bot
Copy link
Contributor

@motiz88 merged this pull request in a75e292.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants