-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Option to produce source maps (src-dest line mapping) #29
Comments
@bevry Ping |
Oddly enough, I never noticed that the Obviously, this ability is invaluable for debugging. I would love this for CSON!But JSON doesn’t allow comments (…wtf…). And the directive at the end of the compiled JS output? Yeah, it’s a comment. So, here’s what I propose…
This accomplishes the following:
I’m pushing for this because I’m actually in this exact situation. I bet it would make CSON a more attractive alternative to YAML (yuck!). 😉 @bevry ? What do you think? (Tell me you still love this repo! :D) |
@bevry ping |
@bevry ping ping ping ping ping :) |
@bevry I’m dying, here! Please tell me this can be done… |
Source maps for CSON files? |
@RobLoach Yep. I’m working on a project where this is sorely needed. We’re using CSON to write human-friendly tests, and the compiled JSON for test runners. When a test fails, we need the line number of the CSON, because that’s what people will be using. |
(Forgot to explain…Why are we using JSON at all? Because these tests are going to be run by many different languages. They can all read JSON, but the tests needs to be human-friendly in ways that JSON is incapable of; linebreaks, multiline strings, and so forth. Therefore, CSON is perfect for humans, JSON is perfect for multiple languages to parse and run tests, and the only thing that’s missing is a line map back to the original source when a test breaks.) |
Sounds pretty neat. I'm sure there could be a way to get source maps working. Have you investigated at all? Would be a great feature to have. |
Unfortunately, I’m amazingly bad at {Java|Coffee}Script. :) I’m trying to learn, but it’s coming slowly. So, it’s not within my current skillset to investigate. The best I could do is spot CoffeeScript’s ability to generate maps between But alas! I can only ask for a guide to the promised land. I do not know the way. :-/ |
That said…if you check out the CoffeeScript mapping feature, see what needs to happen, and can walk me through it, I’d be happy to help you code through any nitty-gritty. I just need your guidance. :) |
(Forgot…last comment was for @RobLoach .) |
It took a bit of stumbling, but I’ve almost got something working for this. Slightly messy, but it’s passing about half the tests. The tests fail with module.exports = {
filename: require('path').basename(__filename)
abc: [ "a", "b", "c" ]
a:
b: "c"
} For whatever reason, I’m getting the following error:
I’ll be publishing a branch with my changes shortly, so you can see what’s happening under the hood. |
(On a side note, it would be nifty if the test files could explain what they are testing. Since adding comments into the test files themselves would alter the tests—test |
(Opened #39 as a standalone issue. 😃) |
My embarrassing attempt at this is now published. :) Zearin/cson@b590c17 |
(EDIT: D’oh! I originally linked to the wrong SHA in the last comment. Fixed now.) |
So, CSON 2.0 is out! And its parser has been abstracted to groupon/cson-parser. Yay! I’m rusty on the code for this. Does anyone know if it’s possible to get source maps of the original CSON to the generated JSON? (Maybe the refactoring of groupon/cson-parser made it easier…?) |
This is now an issue for groupon/cson-parser rather than for us. When they add sourcemap support to their cson parser, we'll add support for their API in bevry/cson. |
Since one of CSON’s main selling points is that of a readable alternative to JSON, many people will be writing in CSON, and converting to JSON for use with other code. If something happens in that generated code, it’s desirable to have some way to find where the JSON’s relevant counterpart is in the CSON.
I know that JSON doesn’t actually allow comments. Maybe…
The text was updated successfully, but these errors were encountered: