philoskim / debux

A trace-based debugging library for Clojure and ClojureScript.
468 stars 19 forks source link

Dev vs production builds? #1

Closed deg closed 6 years ago

deg commented 6 years ago

This looks fantastic, thanks!

But, could you add some tips (to the examples or readme) of best practices to pull in this code only in dev builds?

philoskim commented 6 years ago

Thank you for the first issue! ^^

As far as I know, there is no way to selectively 'require' another namespace at run-time in ClojureScript because of the static nature of the Google Closure compiler.

For example,

(ns example.clog
  (:require [debux.cs.core :as d :refer-macros [clog clogn clog clogn break]]))

the above cannot be replaced with the following in ClojureScript.

;; project.clj
   ...
    :closure-defines {goog.DEBUG true}
   ...
;; example.clog.cljs
(ns example.clog)

(when js/goog.DEBUG
  (require '[debux.cs.core :as d :refer-macros [clog clogn clog clogn break]]))

I wanted to implement what you mentioned, but unfortunately I could not find the way.

If you have any idea, please let me know about it. Then I will reflect the feature in the next version of debux.

deg commented 6 years ago

I don't know any really good answers, sorry!

Perhaps another approach would be to always have the requires, but to have a set of macros that only expand when js/goog.DEBUG is set.

Also, probably worth asking this question on slack. Wiser minds than mine might have much better answers.

deg commented 6 years ago

I found some info that may help you in https://github.com/binaryage/cljs-devtools/blob/master/docs/installation.md#advanced-builds

philoskim commented 6 years ago

Now debux has a new configuration feature (https://github.com/philoskim/debux#debux-config) for development and the production version debux-stubs (https://github.com/philoskim/debux#two-libraries) library. So I close this issue. Thanks a lot for the suggestion!