ClojureScript

Name every fn in CLJS sources (for debugging purposes)

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • 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.

Activity

David Nolen made changes -
Field Original Value New Value
Priority Major [ 3 ] Minor [ 4 ]
Hide
Thomas Heller added a comment -

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

Show
Thomas Heller added a comment - This is now possible via cljs.analyer/passes and can be moved to outside tools.
Thomas Heller made changes -
Resolution Declined [ 2 ]
Status Open [ 1 ] Resolved [ 5 ]
Thomas Heller made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: