day8 / re-frame-debux

A fork of debux for tracing re-frame code (for eventual consumption by re-frame-10x)
Eclipse Public License 1.0
43 stars 7 forks source link

Add tracing-stubs ns to main package #30

Closed thheller closed 4 years ago

thheller commented 4 years ago

Currently it is recommended to include the tracing-stubs library on the classpath for "release" builds but this requires changing the classpath which shadow-cljs currently does not support on its own. It does however support aliasing namespaces so it can achieve the same result without actually switching the classpath.

Instead of having a separate package that just replaces the day8.re-frame.tracing ns with one that does nothing it would be nice to have those stubs instead included as a separate namespace as part of the regular tracing package. Maybe named day8.re-frame.tracing-stubs or day8.re-frame.tracing-noop.

In a shadow-cljs build config the user can then specify

{:builds
 {:app
  {:target :browser
   ...
   :release
   {:build-options
    {:ns-aliases
     {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}}}

This redirects every (:require [day8.re-frame.tracing :as x]) to use the stubs instead in a release build and development builds just use the regular code. I think this is an easier method than messing with the classpath. It is however only supported by shadow-cljs.

I can just include those tracing stubs in shadow-cljs itself if you prefer to keep these black magic tricks out of your package. ;)

superstructor commented 4 years ago

Thanks @thheller :smiley: We will do this in re-frame-debux within the next couple of days :+1: It is definitely something that shadow-cljs shouldn't have to special-case for us. Its also a good solution because it is backwards compatible with the current way of doing things for those using other tools.

thheller commented 4 years ago

Nice. Thanks.