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

SourceMap support to make debugging less annoying #442

Closed
technicalpickles opened this issue Mar 18, 2013 · 11 comments
Closed

SourceMap support to make debugging less annoying #442

technicalpickles opened this issue Mar 18, 2013 · 11 comments

Comments

@technicalpickles
Copy link
Member

One of the most annoying things about debugging hubot .coffee scripts is the mismatch between the coffee source and the error stack traces. I came across this article talking about Mozilla adding better coffeescript via source maps, which sounds just like the thing I'm looking for

Some other things found along the way:

I think the node-source-map-support is probably the way to go, but I haven't been able to test thoroughly yet.

@atmos
Copy link
Contributor

atmos commented Mar 19, 2013

@technicalpickles
Copy link
Member Author

@technicalpickles
Copy link
Member Author

From the original pull request to coffee-script that added support for source maps:

Line numbers in exceptions would be pretty sweet. I have the beginnings of something like this working already, although I was going to code it up as a separate npm module. It would be good to do something that is compatible with longjohn and long-stack-traces, too.

I think that's a more common case, so it's not quite there yet.

@technicalpickles
Copy link
Member Author

@jlord have you messed with source maps at all? A big problem we have in hubot land is that stack traces from errors don't correlate to source code lines in coffeescript files (I die a little bit on the inside every time). We could feasibly compile to javascript and sourcemap more directly, but would take a bit of effort as we run everything dynamically with the coffee command.

@jlord
Copy link

jlord commented Jul 24, 2013

@technicalpickles No, I haven't worked with source maps. I'm picking some brains at the meetup I'm at right now and it seems one thought coffee would return the error's line in the .js and the coffeescript? Also grunt makes source maps, right?

I still haven't ventured into coffeescript land yet (it's looming close, I know) but I think you can't go wrong with writing small, well named functions and console.log-ing and running before compiling. That's the best I got right now :/

@jlord
Copy link

jlord commented Jul 24, 2013

@technicalpickles Browserify will make source maps, too.

21:15 < substack> first way: browserify -c 'coffee -sc' main.coffee > bundle.js
21:15 < substack> second way: npm install coffeeify; browserify -t coffeeify main.coffee > bundle.js
21:16 < substack> second way is probably best
21:16 < substack> the second way works with source maps when you use --debug

@tombell
Copy link
Contributor

tombell commented Jul 24, 2013

coffee does return the line numbers in the .coffee and .js files so maybe source mapping hubot isn't needed?

@tombell
Copy link
Contributor

tombell commented Sep 18, 2013

Closing this as CoffeeScript outputs both line in JavaScript and CoffeeScript.

ReferenceError: foo is not defined
  at Object.<anonymous> (/Users/tom/src/lumberyard/foo.coffee:2:1, <js>:4:3)
  at Object.<anonymous> (/Users/tom/src/lumberyard/foo.coffee:1:1, <js>:6:4)
  at Module._compile (module.js:456:26)

@tombell tombell closed this as completed Sep 18, 2013
@technicalpickles
Copy link
Member Author

@tombell since when, is it a specific coffee release? I don't think I've seen that output in practice.

@tombell
Copy link
Contributor

tombell commented Sep 18, 2013

It's in whatever the latest is

@tombell
Copy link
Contributor

tombell commented Sep 18, 2013

screen shot 2013-09-18 at 18 49 16 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants