Closed magnars closed 5 years ago
Yep, figured it out. I had omitted the plain :require
for devcards.
Could possibly change the readme to use [devcards.core :refer-macros [defcard]]
to avoid the double require? :)
Hmmm this is all dependent on the environment. I did a lot of work to make sure that devcards gets completely excluded from the application when it's not needed. But this is all a bit tenuous.
I'm going to revisit this soon because nobody is really using devcards this way.
Are you using :devcards true?
Yeah, it worked just as expected when I included (:require [devcards.core])
along with the :require-macros
. It also worked when I simplified it down to (:require [devcards.core :refer-macros [defcard]])
to avoid having to have statements declaring devcards in both :require
and :require-macros
. Which was where I had blundered with copy-paste earlier. :stuck_out_tongue:
We are currently using devcards inline with the production code, but there's no problem moving them out to a devcards-folder. It is nice having some examples straight there in the code tho. :smile:
Our config looks like this:
{:id "devcards"
:source-paths ["src"]
:figwheel {:devcards true}
:compiler {:main "link-app.director"
:asset-path "js/compiled/devcards-out"
:output-to "resources/public/js/compiled/link-app-devcards.js"
:output-dir "resources/public/js/compiled/devcards-out"
:source-map-timestamp true}}
Yeah when you require 'devcards.core and not just the macros you will get a large compiled codebase increase.
Just requiring the macros ensures that there is no devcards output in the final compiled output.
The warnings may happen initially but should maybe go away on subsequent compiles.
Again I will have to look at this.
Aha, I see! That makes sense.
Yeah, the warnings are only on the first load of devcards. It gets really spammy when starting the repl tho, and I'm trying to show the other developers here the wonderful world of figwheel+devcards+cljs - I didn't want their first impression to be 60 error messages. :smile:
Thanks for looking into it!
As we ran into this issue, we used this workaround: Have a namespace myproject.devcards
, which all namespaces with inline defcard
s require in addition to the require-macros
. This myproject.devcards
is empty the classpaths for all builds, except for the devcards build, where we include a version of it where it :require
s devcards.core
.
This solves the warnings and lets us have the defcard
s inline with the code while not shipping devcards in our production builds.
That's really the only solution that makes sense.
Starting figwheel with devcards, I get lots of these:
One such pair per
defcard
invocation.I use it like this:
This happens with both
[devcards "0.2.1-6"]
and[devcards "0.2.0-8"]
. ClojureScript version1.7.228
Any ideas?