-
Notifications
You must be signed in to change notification settings - Fork 466
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
SourceMap: Produces incorrect "mappings" #324
Comments
With the way we were extracting the selectors before, some nested scenarios were failing. With these changes, each subset of selector now corresponds to its selector. Secondly, SCSS' source maps is buggy. Either that or they are doing it differently than LESS and CoffeeScript. Nonetheless, an issue is filed at sass/libsass#324. Meanwhile, a post-process(ugly hack) is deployed to bring harmony/uniformity in decoded maps from various compilers.
With the way we were extracting the selectors before, some nested scenarios were failing. With these changes, each subset of selector now corresponds to its selector. Secondly, SCSS' source maps is buggy. Either that or they are doing it differently than LESS and CoffeeScript. Nonetheless, an issue is filed at sass/libsass#324. Meanwhile, a post-process(ugly hack) is deployed to bring harmony/uniformity in decoded maps from various compilers.
Here is the source-map generated by sass gem: {
"version": 3,
"mappings": "AAEQ,iCAAY;EACR,OAAO,EAAE,IAAI;AAEjB,mCAAgB;EACZ,KAAK,EAAE,KAAK;AAIpB,qBAAW;EACP,MAAM,EAAE,IAAI",
"sources": ["test.scss"],
"names": [],
"file": "test.css"
} Decompiles to:
Not as comprehensive as LESS (which captures the interim unlinked selectors -- with no declaration -- too) but at least the line numbers are not misleading like |
@am11 it's a libsass issue I believe. |
With the way we were extracting the selectors before, some nested scenarios were failing. With these changes, each subset of selector now corresponds to its selector. Secondly, SCSS' source maps is buggy. Either that or they are doing it differently than LESS and CoffeeScript. Nonetheless, an issue is filed at sass/libsass#324. Meanwhile, a post-process(ugly hack) is deployed to bring harmony/uniformity in decoded maps from various compilers.
Is there any update on this issue? What can people do to help move this along? |
After #443 (comment), I tried to dig into it. The essence is; the libsass internals are only reporting the start of line (not even the correct column number), while it should be reporting a map for each token. My knowledge about that code is still wooly.. The operation is taking place in I used http://murzwin.com/base64vlq.html (looks like it's written in Ruby) for decoding the VLQ-B64s while implementing the VLQ class and the hack for node-sass in Web Essentials. Perhaps other folks like @akhleung, @mgreter and @nschonni can provide some insightful pointers here about that code. |
Thanks for the detailed response. I really hope that you can get some help |
The problem is, when both rtlcss and autoprefixer are enabled, it works fine with SCSS, but throws with LESS. When the code is too complicated, the `result` object seems to have problem with returning `result.css` member. When the code is comparatively straight-forward, it throws a slightly lenient error. /cc @MohammadYounes
Yeah @svnieuw, we'd all really appreciate your help getting source maps right! |
@svnieuw 😄 👍 |
I will try to have a look at this issue this week, but can't promise On Sun, Oct 5, 2014 at 11:57 PM, Adeel Mujahid notifications@github.com
|
Thanking you in anticipation! 😄 |
@am11 I'm vaguely aware of what's happening there. My hunch would be that the @svnieuw it'd be great if you could do a write up on how you're debugging and verifying the correctness of sourcemaps so one the maintainers can try dealing with these issues in the future. |
👍 |
1 similar comment
👍 |
This issue should (hopefully) be addressed/fixed by #792. |
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
* Removes fallback VLQ cure for sass since sass/libsass#324 is fixed. * `.ToList()` to eagerly load VLQ maps. The subsequent `.Count()` was causing redundant processing of all mappings (which is pretty expensive). * Autoprefix takes stringly maps and returns object for map. So we are strigifying returned map in Less and Sass.
Consider the following code:
When compiled with source map switch, it produces the following B64VLQ mappings:
The decompiled form becomes:
Note in first row we have three pairs.
First one says source rule start at 1,0 (line, column) and generated rule is also present at 0,0 in CSS file.
Second suggests; when source is at 1,11 generated one starts at 0,11.. similarly the third one.
1: Inconsistent line numbers and column number
For source code, the line number start from 1 and column number starts from 0.
For generated code, both the line and column number start from 0.
Note that the second generated-column (0,11) is suddenly 1-based! The expected pair was (0,10).
Please make source file line number start from 0 (LESS and CoffeeScript also do the same).
But wait; what if in
.scss
file, we just have:Then it shows 0,0 !! So the issue is more than the wrong line number. Perhaps the following portion has some gotchas...
2: It feels wrong in certain context!
Compile the same code with LESS, the mappings it generates are:
Decompiles to:
Compare the last decoding of source line and column pair in first row:
There is no 22nd column on line 1 in source code. Both are referring to
.selector1a
, which is present on line#3 of source.It turned out; SCSS is not targeting the token itself but referring to the consecutive ranges. The pervious range of 1,22 is 1,11. So basically it reads like; "start from 11 on first line and read the following 22 characters".
But still it sees all three of them:
all on same line number 1; which is incorrect.
Please change its behavior (or provide an optional behavior); so the individual pair points to the exact beginning of token.
Thanks. 8-)
The text was updated successfully, but these errors were encountered: