Tom Connors
unread,Dec 28, 2018, 6:30:33 PM12/28/18Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Clojure Dev
I've been looking for ways to produce smaller scripts, and one plausible approach is to remove or simplify exception messages. I've never found the error messages I get from advanced-compiled builds to be helpful and I wouldn't miss them if they were gone. Reactjs currently does something similar to what I'm proposing.
Suppose the clojurescript compiler gets a new option, "shrink-error-messages", and the core library exposes a new macro, "removable-error-message".
When writing code that throws errors we could replace:
`(throw (js/Error (str "Invalid arity: " (.-length arguments))))`
with
`(throw (js/Error (removable-error-message "Invalid arity: " (.-length arguments))))`
When "shrink-error-messages" is false, those two examples would produce the same output, but with shrink-error-messages=true, the macro would return "(removed)", or some other short string - perhaps this could be configurable. Another option would be to produce "Error 1234", where 1234 is the key of the error in a lookup table that is generated during compilation and spat out in some file next to the compiled js file.
In my testing, doing this to just cljs.core saves 2KB after gzipping.
Would this change be likely to be accepted?