Give your eval a name with //@ sourceURL
The first Firebug feature I worked on was a whopper: eval() debugging. One of the challenges is how to name the source code buffer.
By default Firefox names the eval() buffer using the containing filename. This is a disaster: it’s the debugger equivalent of overstrike: eval functions overlap orginal functions.
Coming up with an alternative is not so easy. The name has to uniquely identify the buffer to support breakpoints and yet be understandable by developers. The Firebug default is to compute an MD5 hash for the buffer then show the developer a string related to the calling file and the source.
Firebug also supports developer-named eval() buffers: just add a line to the end of your eval(expression) like:
//@ sourceURL=foo.js
This makes the source appear to come from the calling domain at file foo.js. The syntax of the line needs to match this regular expression:
sroussey points out that this feature has recently been added to Webkit so it should also work in Safari.
jjb
March 7th, 2012 at 11:07 am
[...] browserify geschrieben, mittlerweile verwende ich webmake für die Erstellung der Client Datei. SourceURL hilft dabei in der großen Datei beim Debuggen nicht die Übersicht zu verlieren. Die [...]
March 21st, 2012 at 4:55 pm
[...] further reading on eval naming and the displayName [...]
September 27th, 2012 at 2:07 pm
[...] further reading on eval naming and the displayName [...]