Fork me on GitHub
#dirac
<
2016-01-25
>
frank05:01:33

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?

frank09:01:17

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

frank09:01:36

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

frank09:01:38

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

darwin13:01:44

@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

frank13:01:27

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

frank14:01:29

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

frank14:01:49

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

darwin14:01:14

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

frank14:01:10

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

frank14:01:13

and evaluating vars there

frank14:01:40

e.g.

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

darwin14:01:44

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

frank15:01:26

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

frank15:01:36

I'm getting the same behaviour in the demo project

darwin15:01:46

great, let me test it in the demo project

frank15:01:33

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

darwin15:01:52

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

darwin15:01:30

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

frank15:01:15

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

frank15:01:32

Less important question: is dirac pronounced like Iraq?

jaen15:01:25

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

jaen15:01:10

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

darwin15:01:26

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

jaen15:01:10

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

jaen15:01:11

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

darwin16:01:12

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

darwin16:01:36

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

darwin16:01:10

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

frank16:01:56

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

darwin16:01:24

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

darwin16:01:44

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

frank16:01:07

I'll try that

darwin16:01:29

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

frank16:01:09

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

frank16:01:32

I'll try it the right way now

darwin16:01:41

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

darwin16:01:01

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

darwin16:01:10

you require it dynamically

frank16:01:17

would it still work with :advanced optimization though?

darwin16:01:49

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

darwin16:01:56

and whole file will be a dead code

frank16:01:27

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

frank16:01:33

wouldn't the compiler just bundle it in?

darwin16:01:46

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

darwin16:01:41

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

darwin16:01:43

but during runtime

frank16:01:33

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

frank16:01:37

thanks for the idea!

darwin16:01:39

that environ library is pretty handy

darwin16:01:04

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

darwin16:01:37

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

darwin16:01:56

combined with lein profiles it is quite versatile tool

frank16:01:36

the default lein profile used is :dev, right?

frank16:01:58

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

darwin16:01:11

for some tasks, yes

darwin16:01:32

I usually define lein :aliases

darwin16:01:44

so I can hide with-profile complexity

darwin16:01:12

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

darwin16:01:33

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

frank16:01:40

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

darwin16:01:26

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

darwin16:01:35

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

darwin16:01:14

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

darwin17:01:02

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

darwin17:01:24

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

darwin17:01:44

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

darwin17:01:31

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

darwin17:01:32

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

frank17:01:09

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

darwin17:01:56

what do you use as your code editor/IDE?

frank17:01:01

I'm using emacs

darwin17:01:32

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

darwin17:01:49

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

darwin17:01:13

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

frank17:01:20

that would be amazing

darwin17:01:09

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

frank17:01:06

at the moment, I don't

frank17:01:12

I just use figwheel's brepl

frank17:01:29

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

frank17:01:31

is this true?