sass/libsass — pull request #786 by mgreter (2014-12-29 23:36:57+00:00)
Title: Source map test

This is my next shot at fixing/improving source maps in libsass!

My ultimate goal, beside having correct source-maps from libsass, is to create a base and re-usable [library] [1] for source-maps, which I can re-use for my other project. This branch incorporates and normalizes most
changes included in #603. The main issue this branch addresses is a [single line in selector expansion] [2].

This line comes into play when selectors get exented. It first renders the selectors into a new string and puts it through another parser run. It seems pretty much impossible to attach the previous source positions to the output string ... but what are source-maps good for :) I have moved/added sourcemaps also to the inspect context, which is then used to ["remap"] [3] the intermediate string back to the actual original sources.

input.scss:
```CSS
blockquote {
.selector1 {
display: none;
}
}
```
output.css:
```CSS
blockquote .selector1 {
display: none; }
/*# sourceMappingURL=output.css.map */
```
output.css.map
```json
{
"version": 3,
"file": "input.css",
"sources": [
"input.scss"
],
"sourcesContent": [],
"mappings": "AAAA,UAAU,CACN,UAAU;GACN,SAAS",
"names": []
}
```
[decoded sourcemap] [5]:
format: `([from_position](source_index)=>[to_position])`
```
([0,0](#0)=>[0,0]) | ([0,10](#0)=>[0,10]) | ([1,4](#0)=>[0,11]) | ([1,14](#0)=>[0,21])
([2,8](#0)=>[1,3]) | ([2,17](#0)=>[1,12])
```

IMHO source-maps seem pretty broken currently, so I guess we could take a step to get the base moving in the right direction (even if we introduce some more regressions). IMO the current implementation is not good enough to work on, so we have to make some core changes here. I would like to include at least some base changes for the next version after 3.1!

[1]: https://github.com/mgreter/sourcemap.cpp
[2]: https://github.com/mgreter/libsass/blob/master/expand.cpp#L49
[3]: https://github.com/mgreter/libsass/blob/source-map-test/source_map.cpp#L150
[4]: https://github.com/mgreter/libsass/blob/source-map-test/expand.cpp#L52
[5]: http://murzwin.com/base64vlq.html