<< Back to previous view

[CLJS-474] Name every fn in CLJS sources (for debugging purposes) Created: 18/Feb/13  Updated: 26/Nov/13  Resolved: 26/Nov/13

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Thomas Heller Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File cljs-better-fn-names.patch    
Patch: Code

 Description   

As mentioned here: https://groups.google.com/forum/?fromgroups=#!topic/clojurescript/ZX6M4KXx8I8

Naming every fn in the compiled javascript functions makes it a little easier to find out whats going on when looking at a stacktrace. This patch names every function generated as fn_<ns>/<orig-name>_<line>. See example stacktrace in the discussion above.

The optional cljs snippet (https://gist.github.com/thheller/4972200) then also transforms this data and prints functions as

(pr-str name)
=> #<function cljs.core/name line:5876>

instead of dumping the javascript source on you.

The .patch has the drawback that the generated source size grows a bit (about 10% on my codebase), but advanced compilation takes care of that (although even that is still a bit larger, the closure compiler doesnt seem to strip unused function names). One could make this a compiler option if the size differences are too big.



 Comments   
Comment by Thomas Heller [ 26/Nov/13 8:18 AM ]

This is now possible via cljs.analyer/passes and can be moved to outside tools.

Generated at Sun Nov 23 15:27:36 CST 2014 using JIRA 4.4#649-r158309.