underscore icon indicating copy to clipboard operation
underscore copied to clipboard

Experiment with sourceURLs for better Underscore Template Debugging

Open jashkenas opened this issue 11 years ago • 3 comments

Could this be helpful?

http://fitzgeraldnick.com/weblog/59/

jashkenas avatar Dec 10 '14 15:12 jashkenas

Devs find it helpful. I do this in the dev builds of my implementation. I remove them from the minified build. Chrome has supported sourceURLs in Function for a long time now. I believe Firefox used to only support it in eval, when it used an @ instead of an #, so yay Firefox 36 for joining the Function sourceURL party.

Some have also found it useful to be able to set the sourceURL via a template option, {sourceURL: ...}, too.

jdalton avatar Dec 10 '14 15:12 jdalton

Chrome gives you access to the eval'd VM instance and its line numbers anyways. What's the benefit of naming the instance?

screen shot 2014-12-10 at 12 03 46 pm

akre54 avatar Dec 10 '14 17:12 akre54

I find it useful to have them in the sources view for a quick at-a-glance to make sure logic is right without having to instrument the code, even in the absence of a thrown error. Having the sourceURL configurable also allows organizing template sources which is nice.

Related Firefox issue #1107541.

jdalton avatar Dec 10 '14 18:12 jdalton