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

Add improved source-mapping implementation #792

Merged
merged 1 commit into from
Jan 5, 2015

Conversation

mgreter
Copy link
Contributor

@mgreter mgreter commented Dec 31, 2014

This PR is the successor of #603 and #786. IMO this is already better than the current implementation, so I dare anyone to try it out. IMO we could include this "as is" in the next version to get this moving in the right direction, since the current implementation does not really work anyway IMHO. The whole feature is very complex, so I cannot give any guarantee that it will work for all mappings. But IMHO the current state of this PR is satisfactory and we could move on from that!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) when pulling 33a9e45 on feature/improved-source-maps into 420d7fb on master.

@mgreter mgreter changed the title Add improved source-mapping implementation [WIP] Add improved source-mapping implementation Dec 31, 2014
@mgreter
Copy link
Contributor Author

mgreter commented Dec 31, 2014

There is still a lot of debug stuff included in this PR which should be removed before merging!

@am11
Copy link
Contributor

am11 commented Dec 31, 2014

@mgreter, can we test source-maps with sassc without involving ruby/sass-spec?

I can write a simple test runner which couts the results. The only "fancy stuff" would be using the json.c and actually parsing the result as JSON and test the member/ingridentes of JSON while treating it as an object (as opposed to string). This way we don't have to worry about the order of items or items in sources[] and contents[] arrays. Then we can create some tests and even borrow some from less. :)

All this in with pure sassc, no ruby, no gem, just C! 😎

@mgreter
Copy link
Contributor Author

mgreter commented Jan 3, 2015

I have added a simple "test runner" to perl-libsass while developing this feature to keep at least some track of what I was doing. @am11 you probably know how hard it is to debug this kind of stuff. I currently (not published yet) store this directory structure as the "sourcemap tests":

  • config
  • input.s[ca]ss
  • output.css
  • output.css.map

The config file is a map to context options (C-API options in a colon separated map), while the rest should be self explanatory. The output.css.map file is parsed and the stuff like included paths should be compared. I currently only implemented to compare the mappings, which does a search for expected mappings only, while ignoring additonal ones! This proved to be pretty effective during developement, since I was able to update the expected file incrementally (after inspecting and verifying the specific cases/mappings manually!).

Basically this topic is endless since one could discuss about how a mapping should be done is pretty open (how do you map a calculation? Include every operator, number and so on?). This PR is already at a point where I would say is at least 50% better than before. Some code is certainly not optimal (reparse/remap part), but I don't really know how to improve it much more! And it gets tedious to maintain such a big commit! This particular feature (remap) would not have worked before anyway; so I guess I'm willing to take the risk that it will now only work a few percent better. This might be 100% or 0.05%!

I guess not many people really want to try it out and report back specific issues here! So I only can encourage the "first scream" approach! Just get it merged into 3.2 and let's see 🍌

Btw. this inquiry by the original(?) implementor of source-maps seems to be handled here!

@mgreter mgreter added this to the 3.3 milestone Jan 3, 2015
@@ -140,7 +140,7 @@ extern "C" {
}
catch (Sass_Error& e) {
stringstream msg_stream;
msg_stream << e.path << ":" << e.position.line << ": " << e.message << endl;
// msg_stream << e.pstate.path << ":" << e.pstate.line << ": " << e.message << endl;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Review Note: Revert!

@mgreter mgreter force-pushed the feature/improved-source-maps branch from 33a9e45 to d31f1ab Compare January 5, 2015 10:24
@mgreter mgreter changed the title [WIP] Add improved source-mapping implementation Add improved source-mapping implementation Jan 5, 2015
@mgreter mgreter modified the milestones: 3.2, 3.3 Jan 5, 2015
@mgreter mgreter force-pushed the feature/improved-source-maps branch from bd615e5 to e9ef4b4 Compare January 5, 2015 23:12
@coveralls
Copy link

Coverage Status

Coverage increased (+0.23%) when pulling e9ef4b4 on feature/improved-source-maps into 065b366 on master.

mgreter added a commit that referenced this pull request Jan 5, 2015
Add improved source-mapping implementation
@mgreter mgreter merged commit 2ee5dfa into master Jan 5, 2015
@am11
Copy link
Contributor

am11 commented Jan 5, 2015

Today is turning out to be a big achievement day! 👍 ⭐

Congratulations! :)

@HamptonMakes
Copy link
Member

WEEEEEEE

@xzyfer
Copy link
Contributor

xzyfer commented Jan 6, 2015

Nice work!

@mgreter
Copy link
Contributor Author

mgreter commented Jan 6, 2015

Thx all! Just to be perfectly clear, this does not magically fix all of our source-map problems. This is merely a step in the right direction to provide a base to make this happen. I only verified a few common complicated cases. Most of the rest should behave as before plus a few additional perks.

@mgreter mgreter deleted the feature/improved-source-maps branch January 6, 2015 01:56
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.

5 participants