Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Fixing fixup of source locations, mostly. #2356

Closed
wants to merge 4 commits into from
Closed

Conversation

NTillmann
Copy link
Contributor

@NTillmann NTillmann commented Aug 2, 2018

Release notes: Fixing source map support.

I kept getting seemingly garbage source locations in error messages, and looked into that.
I found various issues:

  • We in-place update positions, but they are actually shared between locations, and thus we may revisit positions. When we do, we map them again, and so on...
  • Locations are also shared between nodes, so we kept revisiting and rewriting yet again.
  • The actual mapping doesn't pay attention to the filename, so we apply the wrong mapping altogether, especially in the presence of multiple input files. I am not fixing this, but added a TODO, and opened Sourcemaps are broken with more than one source file #2353.
  • Another remaining but not blocking issue is that something goes wrong with end-positions: They are sometimes mapped to some seemingly random position in the right line. If anyone knows anything about this, please let me know...

@NTillmann NTillmann added Instant Render WIP This pull request is a work in progress and not ready for merging. labels Aug 2, 2018
@NTillmann NTillmann removed the WIP This pull request is a work in progress and not ready for merging. label Aug 2, 2018
@NTillmann NTillmann changed the title Fixing fixup of source locations. Fixing fixup of source locations, mostly. Aug 2, 2018
);
return info;
}
function fixupPosition(pos: BabelNodePosition, posInfo, otherInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide parameter types and a return type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since posInfo already includes all of the information in pos, why pass it in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

posInfo does not include a pointer to pos which is what we want to mutate.

new_pos.column = old_pos.column;
new_loc.source = old_pos.source;
});
function getPositionInfo(position: BabelNodePosition) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a return type annotation.

if (posInfo.rewritten) return;
if (posInfo.originalPosition.source == null) {
invariant(otherInfo.originalPosition.source != null);
pos.line = Math.max(0, pos.line + otherInfo.originalPosition.line - otherInfo.newLine);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to see something like:

let delta = posInfo.newLine - otherInfo.newLine;
pos.line = Max.max(0, otherInfo.originalPosition.line + delta);

fixupPosition(locEnd, endInfo, startInfo);

// NOTE: The end position seems to be sometimes wrong, probably due to a limitation of
// what's persisted in the sourcemaps. In fact, the end position maybe so wrong that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be

@NTillmann NTillmann force-pushed the FixingSourceMaps branch 2 times, most recently from f8a408d to 78a7204 Compare August 2, 2018 22:11
Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTillmann is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTillmann is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Release notes: Fixing source map support.

I kept getting seemingly garbage source locations in error messages, and looked into that.
I found various issues:
- We in-place update positions, but they are actually shared, and thus we may revisit positions. When we do, we map them again, and so on...
- The actual mapping doesn't pay attention to the filename. I am not fixing this, but added a TODO, and opened #2353.
- Another remaining issue is that something goes wrong with end-positions: They are sometimes mapped to some seemingly random position in the right line. This also requires further investigation. If anyone knows anything about this, please let me know...
… serialization.

Also, never show end positions to user.
Typing source maps.
Fixing casing
Fixing filename logic
Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTillmann is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTillmann is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@hermanventer hermanventer deleted the FixingSourceMaps branch August 15, 2018 02:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants