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 sourcemaps #232

Merged
merged 2 commits into from Nov 2, 2020
Merged

Fix sourcemaps #232

merged 2 commits into from Nov 2, 2020

Conversation

@stof
Copy link
Member

@stof stof commented Nov 1, 2020

Closes #231

stof added 2 commits Nov 1, 2020
- A mapping should not be written at the current position when writing
  a newline character, as that would put a mapping on a non-existent
  column of the generated file.
- A mapping must be written for each line when writing multiline content
  because each generated line is independant in the mappings. Not adding
  these mapping would cause generated content to stay unmapped (the
  compressed formatter is not impacted as it puts everything on one line
  but the expanded formatter is impacted a lot)
@stof stof added this to the 1.4 milestone Nov 1, 2020
@stof
Copy link
Member Author

@stof stof commented Nov 1, 2020

I tested this using the bootstrap framework, generating file sourcemaps (I hacked bin/pscss to support that).

When analysing the source-map with https://github.com/danvk/source-map-explorer, it reports 22% of unmapped content without the fix in the formatter to map all lines (disabling border checks due to the issue of adding a mapping when writing \n, but the percentage stays the same when running with only this issue patched and applying border checks in the analysis).
After the patch, it reports only 17 bytes as unmapped (which is exactly the @charset "UTF-8"; prefix on the first line)

@stof
Copy link
Member Author

@stof stof commented Nov 1, 2020

oh, and the fix for multiline writes was found by looking at how dart-sass builds its source maps.

@stof stof merged commit abb677e into scssphp:master Nov 2, 2020
1 check passed
1 check passed
Travis CI - Pull Request Build Passed
Details
@stof stof deleted the stof:fix_sourcemaps branch Nov 2, 2020
@stof stof mentioned this pull request Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

1 participant
You can’t perform that action at this time.