is there a good way to configure lein-cljsbuild
to only include cljs-devtools (and the namespaces that would call the setup functions) for certain lein-cljsbuild
profiles?
I ended up creating two source files for my thing.devtools
namespace, one of which is a dummy
configured lein-cljsbuild
to use the dummy for production and the real one for dev
(`thing.devtools` is the namespace that calls devtools.core/install!
)
@frank: your solution is fine, other solution could be to use lein’s profiles, also what I do is to goog.require namespaces manually, so that way I have control over exact order of inclusion namespace trees, devtools should be required early: https://github.com/binaryage/dirac/blob/master/resources/unpacked/background.js
unfortunately I don't think I can change too much about how we bootstrap our app at work 😕
is it normal to be seeing "No such namespace" when using namespace qualified vars?
also, I'm seeing a lot of "Use of undeclared var" warnings, even though it seems to evaluate just fine
do you use :parallel-build true cljs compiler option?
no
hm
so this is after using in-ns
to go into a namespace
and evaluating vars there
e.g.
> (in-ns 'my.ns)
> foo
do you have access to normal piggieback-based REPL? I would try it there if it behaves the same
😕 no there isn't one set up for the current project
but
I'm getting the same behaviour in the demo project
great, let me test it in the demo project
this isn't really critical, since it's just harmless warnings
I’m glad you were able to reproduce it in the demo project, I confirm the behaviour here on my OS X system, so I can investigate it further
I’m no expert in this nREPL stuff, this might point to some problem in dirac (n)REPL environment
ah I see
I'll let you know if I find anything myself :simple_smile:
Less important question: is dirac pronounced like Iraq?
I suppose it would be like the physicist. I'd hazard a guess the name was inspired by planck ; d
@jaen: exactly :simple_smile:
@frank: /dɪˈræk/ in that case (which yes, should be like aq in Iraq)
coming up with names is hard, as you all know, I like this new tradition naming projects after famous physicists :simple_smile:
Then I'm curious what would a library called noether do ;' ) Her theory always makes me go whoa.
Feynman is pretty obvious though - totally a bongos module for Overtone ;' )
:simple_smile:
@frank: I have another way how to include devtools conditionally, you can call goog.require from your code based on some condition
look here: https://github.com/binaryage/cljs-devtools-sample/blob/master/src/demo/devtools_sample/boot.cljs#L31
debug? is a macro, which evals to env variable, which is defined here: https://github.com/binaryage/cljs-devtools-sample/blob/master/project.clj#L53
this particual code depends on lein-environ, but the condition can be anything
I'm not seeing the part in the example where goog.require
is being used
right, it is not there, I’m going to add it for my alternative weasel config now
ah ok
something like
`
(when (weasel?)
(js/goog.require "devtools_sample.weasel"))
I'll try that
it depends on the fact that in dev mode all namespaces get compiled
yeah
I actually tried a conditional goog require, but I sort of combined it with setting :source-paths
for lein-cljs
anyway
I'll try it the right way now
the devtools_sample.weasel must be in :source-paths, but must not be in any cljs ns :require
so it is compiled, but not included by cljs require system
you require it dynamically
would it still work with :advanced
optimization though?
yes, I believe, that dynamic require code should not execute
and whole file will be a dead code
but the when
statement is evaluated at run time, rather than compile time, isn't it?
wouldn't the compiler just bundle it in?
if you use macro for generating that condition, the optimizer should elide whole (when false <body>)
if that <test> in (when <test> …) is some more complex dynamic code it will stay there probably, but it won’t cause any harm, because it will eval to false anyway
but during runtime
hmm
I see
I'll have to figure out a test
that can be used at compile time
thanks for the idea!
that environ library is pretty handy
this way you can bring envriomental settings into your cljs code (via macros)
and lein-environ allows you to muck environ via lein project.clj
combined with lein profiles it is quite versatile tool
the default lein profile used is :dev
, right?
I guess I would need to use with-profile
to use any other profile?
for some tasks, yes
I usually define lein :aliases
so I can hide with-profile complexity
a side note: lein-pprint is important tool for debugging profiles
it will show you how your profile composition evaluates into final config map
so I guess I can use with-profile
together with lein-pprint
to see what the final config map looks like?
correct
and you can also select path into final map to narrow it into your scope of interest
e.g. lein with-profile +my-profile pprint :dependencies
I have [lein-pprint "1.1.1”] in :plugins in my ~/.lein/profiles.clj
@frank: I have just test that warning issue with piggieback+weasel and the problem is there as well: https://gist.github.com/darwin/20bda519cf6742b460f6
now when I think about it more, I guess we have to require our namespace first somehow
when using clojure repl you also have to require namespaces before you can use vars from them
I think, in cljs it works by coincidence, warning is emitted, but generated code matches situation in the VM, so the result evaluates properly
unfortunately (require ‘devtools-sample.more) fails, maybe that REPL env needs some paths or some way how to require files
hmm yeah I get namespace not found when I try to require
what do you use as your code editor/IDE?
I'm using emacs
I want to work on integration with other nREPL clients, so they can eval code in Dirac REPL
want to start with Cursive, but emacs cider or something should work similar way
so you can eval whole file in the REPL and switch to its namespace in one go
that would be amazing
how do you start your piggieback+weasel in your nREPL session today (when not using Dirac)
?
at the moment, I don't
I just use figwheel's brepl
😞
@darwin: I heard from a coworker that Dirac can work with regular Chrome as well
is this true?
could be