dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
frank 2016-01-25T05:14:33.000005Z

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?

frank 2016-01-25T09:44:17.000006Z

I ended up creating two source files for my thing.devtools namespace, one of which is a dummy

frank 2016-01-25T09:44:36.000007Z

configured lein-cljsbuild to use the dummy for production and the real one for dev

frank 2016-01-25T09:46:38.000008Z

(`thing.devtools` is the namespace that calls devtools.core/install!)

2016-01-25T13:21:44.000009Z

@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

frank 2016-01-25T13:27:27.000012Z

unfortunately I don't think I can change too much about how we bootstrap our app at work 😕

frank 2016-01-25T14:53:29.000013Z

is it normal to be seeing "No such namespace" when using namespace qualified vars?

frank 2016-01-25T14:53:49.000014Z

also, I'm seeing a lot of "Use of undeclared var" warnings, even though it seems to evaluate just fine

2016-01-25T14:54:14.000015Z

do you use :parallel-build true cljs compiler option?

frank 2016-01-25T14:54:25.000016Z

no

2016-01-25T14:54:55.000017Z

hm

frank 2016-01-25T14:55:10.000018Z

so this is after using in-ns to go into a namespace

frank 2016-01-25T14:55:13.000019Z

and evaluating vars there

frank 2016-01-25T14:55:40.000020Z

e.g.

> (in-ns 'my.ns)
> foo

2016-01-25T14:57:44.000021Z

do you have access to normal piggieback-based REPL? I would try it there if it behaves the same

frank 2016-01-25T15:04:26.000022Z

😕 no there isn't one set up for the current project

frank 2016-01-25T15:04:27.000023Z

but

frank 2016-01-25T15:04:36.000024Z

I'm getting the same behaviour in the demo project

2016-01-25T15:04:46.000025Z

great, let me test it in the demo project

frank 2016-01-25T15:07:33.000027Z

this isn't really critical, since it's just harmless warnings

2016-01-25T15:08:52.000028Z

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

2016-01-25T15:09:30.000029Z

I’m no expert in this nREPL stuff, this might point to some problem in dirac (n)REPL environment

frank 2016-01-25T15:10:39.000030Z

ah I see

frank 2016-01-25T15:14:15.000031Z

I'll let you know if I find anything myself :simple_smile:

frank 2016-01-25T15:14:32.000032Z

Less important question: is dirac pronounced like Iraq?

jaen 2016-01-25T15:20:25.000033Z

I suppose it would be like the physicist. I'd hazard a guess the name was inspired by planck ; d

2016-01-25T15:20:54.000034Z

@jaen: exactly :simple_smile:

jaen 2016-01-25T15:21:10.000035Z

@frank: /dɪˈræk/ in that case (which yes, should be like aq in Iraq)

2016-01-25T15:21:26.000036Z

coming up with names is hard, as you all know, I like this new tradition naming projects after famous physicists :simple_smile:

jaen 2016-01-25T15:23:10.000037Z

Then I'm curious what would a library called noether do ;' ) Her theory always makes me go whoa.

jaen 2016-01-25T15:27:11.000039Z

Feynman is pretty obvious though - totally a bongos module for Overtone ;' )

2016-01-25T15:27:47.000040Z

:simple_smile:

2016-01-25T16:22:12.000041Z

@frank: I have another way how to include devtools conditionally, you can call goog.require from your code based on some condition

2016-01-25T16:23:36.000044Z

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

2016-01-25T16:24:10.000046Z

this particual code depends on lein-environ, but the condition can be anything

frank 2016-01-25T16:24:56.000047Z

I'm not seeing the part in the example where goog.require is being used

2016-01-25T16:25:24.000048Z

right, it is not there, I’m going to add it for my alternative weasel config now

frank 2016-01-25T16:25:33.000049Z

ah ok

2016-01-25T16:25:44.000050Z

something like ` (when (weasel?) (js/goog.require "devtools_sample.weasel"))

frank 2016-01-25T16:26:07.000051Z

I'll try that

2016-01-25T16:26:29.000052Z

it depends on the fact that in dev mode all namespaces get compiled

frank 2016-01-25T16:26:37.000053Z

yeah

frank 2016-01-25T16:27:09.000055Z

I actually tried a conditional goog require, but I sort of combined it with setting :source-paths for lein-cljs

frank 2016-01-25T16:27:26.000056Z

anyway

frank 2016-01-25T16:27:32.000057Z

I'll try it the right way now

2016-01-25T16:27:41.000058Z

the devtools_sample.weasel must be in :source-paths, but must not be in any cljs ns :require

2016-01-25T16:28:01.000059Z

so it is compiled, but not included by cljs require system

2016-01-25T16:28:10.000060Z

you require it dynamically

frank 2016-01-25T16:29:17.000061Z

would it still work with :advanced optimization though?

2016-01-25T16:29:49.000062Z

yes, I believe, that dynamic require code should not execute

2016-01-25T16:29:56.000063Z

and whole file will be a dead code

frank 2016-01-25T16:30:27.000064Z

but the when statement is evaluated at run time, rather than compile time, isn't it?

frank 2016-01-25T16:30:33.000065Z

wouldn't the compiler just bundle it in?

2016-01-25T16:30:46.000066Z

if you use macro for generating that condition, the optimizer should elide whole (when false <body>)

2016-01-25T16:31:41.000067Z

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

2016-01-25T16:31:43.000068Z

but during runtime

frank 2016-01-25T16:32:21.000069Z

hmm

frank 2016-01-25T16:32:24.000070Z

I see

frank 2016-01-25T16:33:33.000071Z

I'll have to figure out a test that can be used at compile time

frank 2016-01-25T16:33:37.000072Z

thanks for the idea!

2016-01-25T16:34:39.000073Z

that environ library is pretty handy

2016-01-25T16:35:04.000074Z

this way you can bring envriomental settings into your cljs code (via macros)

2016-01-25T16:35:37.000075Z

and lein-environ allows you to muck environ via lein project.clj

2016-01-25T16:35:56.000076Z

combined with lein profiles it is quite versatile tool

frank 2016-01-25T16:42:36.000077Z

the default lein profile used is :dev, right?

frank 2016-01-25T16:42:58.000078Z

I guess I would need to use with-profile to use any other profile?

2016-01-25T16:43:11.000079Z

for some tasks, yes

2016-01-25T16:43:32.000080Z

I usually define lein :aliases

2016-01-25T16:43:44.000081Z

so I can hide with-profile complexity

2016-01-25T16:44:12.000083Z

a side note: lein-pprint is important tool for debugging profiles

2016-01-25T16:44:33.000084Z

it will show you how your profile composition evaluates into final config map

frank 2016-01-25T16:47:40.000085Z

so I guess I can use with-profile together with lein-pprint to see what the final config map looks like?

2016-01-25T16:47:53.000086Z

correct

2016-01-25T16:48:26.000087Z

and you can also select path into final map to narrow it into your scope of interest

2016-01-25T16:49:35.000088Z

e.g. lein with-profile +my-profile pprint :dependencies

2016-01-25T16:50:14.000089Z

I have [lein-pprint "1.1.1”] in :plugins in my ~/.lein/profiles.clj

2016-01-25T17:01:02.000091Z

@frank: I have just test that warning issue with piggieback+weasel and the problem is there as well: https://gist.github.com/darwin/20bda519cf6742b460f6

2016-01-25T17:01:24.000093Z

now when I think about it more, I guess we have to require our namespace first somehow

2016-01-25T17:01:44.000094Z

when using clojure repl you also have to require namespaces before you can use vars from them

2016-01-25T17:02:31.000095Z

I think, in cljs it works by coincidence, warning is emitted, but generated code matches situation in the VM, so the result evaluates properly

2016-01-25T17:03:32.000096Z

unfortunately (require ‘devtools-sample.more) fails, maybe that REPL env needs some paths or some way how to require files

frank 2016-01-25T17:07:09.000097Z

hmm yeah I get namespace not found when I try to require

2016-01-25T17:07:56.000098Z

what do you use as your code editor/IDE?

frank 2016-01-25T17:08:01.000099Z

I'm using emacs

2016-01-25T17:08:32.000100Z

I want to work on integration with other nREPL clients, so they can eval code in Dirac REPL

2016-01-25T17:08:49.000101Z

want to start with Cursive, but emacs cider or something should work similar way

2016-01-25T17:09:13.000102Z

so you can eval whole file in the REPL and switch to its namespace in one go

frank 2016-01-25T17:14:20.000103Z

that would be amazing

2016-01-25T17:15:09.000104Z

how do you start your piggieback+weasel in your nREPL session today (when not using Dirac)

2016-01-25T17:15:13.000105Z

?

frank 2016-01-25T17:16:06.000106Z

at the moment, I don't

frank 2016-01-25T17:16:12.000107Z

I just use figwheel's brepl

frank 2016-01-25T17:16:14.000108Z

😞

frank 2016-01-25T17:54:29.000109Z

@darwin: I heard from a coworker that Dirac can work with regular Chrome as well

frank 2016-01-25T17:54:31.000110Z

is this true?

2016-01-25T17:55:32.000111Z

could be