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

fix sourcemap of prepend when hire false #161

Merged
merged 1 commit into from
Oct 4, 2019
Merged

fix sourcemap of prepend when hire false #161

merged 1 commit into from
Oct 4, 2019

Conversation

yiminghe
Copy link
Contributor

@yiminghe yiminghe commented Sep 26, 2019

when prepend, the generated map is not recognized by chrome/firefox: can not set break point on second line when there are multiple lines

@yiminghe yiminghe changed the title fix sourcemap of append/prepend when hire false fix sourcemap of prepend when hire false Sep 26, 2019
@mourner mourner merged commit 9f93acf into Rich-Harris:master Oct 4, 2019
@mourner
Copy link
Collaborator

mourner commented Oct 4, 2019

Thank you!

@petebacondarwin
Copy link

I think that this fix is not entirely correct.
Now the source map contains a mapping for every line of a chunk, even though nothing has changed.

@petebacondarwin
Copy link

Each unedited chunk should only have a single mapping to mark the beginning of that chunk.
After this PR the source-map is bloated with new mappings for every line even though there is no need from the point of view of the source-map.

As an example consider:

> x = new MagicString('a\nb\nc');
> x.generateMap().mappings

'AAAA;AACA;AACA`

Notice that we have a multiline string which has had "no" operations on it but the source-map contains redundant mappings, which state that [0,0]->[0,0], [1,0]->[1,0] and [2,0]->[2,0].
The first mapping ([0,0]->[0,0]) is the only one that should be there.

Extrapolate this to a file with hundreds or thousands of lines and you get the picture.


I am not quite sure what the specific problem that @yiminghe had. I don't see why the browser would not be able to deal with the source-map only containing AAAA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants