Clojurians
#clojurescript
<
2016-01-11
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

grav08:01:03

Hi there! I have a part-web, part-node app. I have the source in two different src-folders. Since I’m using Reagent for the web-part, I currently have a reagent.core/atom for the state, but that leaves me with a problem in the node-part, since I cannot/don’t want to require Reagent there.

grav08:01:58

Now, since the r-atom and the regular atom have the same interfaces (at least the part I am going to use), the solution could probably be to include a my-app.state namespace in both src-folders, where the atom will be defined.

grav08:01:24

But in a way that seems like a hack to me. What do you reckon? Is it idiomatic to have two namespaces with the same “interface” in each their src-folder?

grav08:01:10

Or maybe I should have a shared namespace with a function taking an atom, and let each target initialize the app with an atom of their liking?

mudphone10:01:22

Kind of a shot in the dark I guess, but I’m getting an error in the console after compiling with optimizations for whitespace or advanced. Of course, it works with no optimizations. It’s an Om Next app. The console error for :advanced optimizations is:

Uncaught TypeError: Object prototype may only be an Object or null: undefined

mudphone10:01:06

is there a good resource for learning about how to set up :advanced optimizations? a lot of the instructions that I’ve seen are pretty straight-forward… which is great, but I don’t know how to go about debugging.

darwin11:01:14

@mudphone: :pseudo-names[1] and Chrome DevTools is your best bet, I guess. Note, you should also be aware of the “Pretty print” feature in Sources panel. That will help you ,make sense of minified code. Look for “{}” in status line of source view in DevTools. https://github.com/clojure/clojurescript/wiki/Compiler-Options#pseudo-names

darwin11:01:42

You should be able to break on uncaught exceptions and that with above two tools should give you pretty good idea where is the problem in optimized code

martinklepsch12:01:10

@mudphone: do you have other JS on the page?

martinklepsch12:01:24

IME runtime issues with advanced compilation are most often caused by other scripts redefining variables. There's an :output-wrapper compiler option to avoid those clashes

skardan14:01:11

Hi! Question regarding REPL with Node.js: Has anybody tried running cljs REPL to remote Node.js?

skardan14:01:52

i.e. to run (for example) cider+java+clojurescript on one dev machine and hosting node on another?

skardan14:01:03

as far as I can tell from src code, cljs.repl.node assumes that they are both on same machine and exchange code using shared filesystem

dnolen14:01:19

@skardan: the way to make that work would be to use socket REPL

dnolen14:01:49

however there is a caveat - the source must exist at the remote target

dnolen14:01:45

if you want to leverage all the various REPL bits and incremental compilation things

dnolen14:01:59

you can of course just send forms - but for ns forms won’t be enough

skardan14:01:27

@dnolen thank you. The use case: remote nodejs runs on ARMv7 (like eg RapsberyPi) so I am looking to a way how to develop without running cljs in java

dnolen14:01:07

@skardan: if you just want to do some light interactive dev - the above should be enough

dnolen14:01:20

if you want something fancier you’ll probably want to consider a fancier custom REPL design a la Ambly

skardan14:01:23

so you suggest nodejs runs cljs-in-cljs and I connect with socket repl (or inerior-lisp-mode)

dnolen14:01:41

cljs-in-cljs is not necessary for anything that I’ve said above

denik14:01:26

not sure how to use it within sablono / om.dom

mfikes14:01:36

@skardan: I suspect that, if you can mount a filesystem on your ARMv7 device (you could do this manually), with some slight tweaks to the Node REPL code (to use :output-dir and to cope with connecting to a remote Node instance—dealing with stdout, for example), you could pull this off. Take a look at how Ambly works and you could envision a similar thing for Node.

skardan14:01:53

@mfikes thanks, I guess something like nfs could be enough. I am looking to your source code in Ambly and you communicate the files using webdav, right?

mfikes14:01:59

@skardan: In fact, you can probably just pass :output-dir as a compiler option to the existing Node REPL if you set up the mount point ahead of time.

mfikes14:01:12

@skardan Ambly actually has the OS do the WebDAV mounting. Beyond that, the ClojureScript compiler thinks it is talking to a regular local filesystem.

skardan14:01:12

@mfikes @dnolen thanks for suggestion, I will try it

eyelidlessness15:01:49

is there something like alter-var-root for cljs?

eyelidlessness15:01:03

or even a way to just redefine a var?

grav15:01:35

Can I avoid compiling every target when running lein cljsbuild test?

dnolen15:01:58

@grav you should be able to specify a test build

dnolen15:01:17

@eyelidlessness: doesn’t exist, but you can just set!

eyelidlessness15:01:17

@dnolen: thanks!

grav15:01:38

@dnolen: I’ve looked in https://github.com/emezeske/lein-cljsbuild/blob/1.1.2/example-projects/advanced/project.clj and the only thing I can find is how to run the tests (eg :test-commands). Doesn’t seem to specify a test build per se, just a build called “test"

grav15:01:47

When I do that, every target is still compiled

dnolen15:01:17

doesn’t lein cljsbuild test <foo> work?

eyelidlessness15:01:32

@grav: if your cljsbuild build doesn't have an :id, give it one (the old map format uses the key for the id i believe), then use lein cljsbuild test <whatever-id>

grav15:01:20

my build does have an id, but what you specify with lein cljsbuild test <id> isn’t the target id, it’s the :test-commands id

grav15:01:54

The :test-commands id just specifies /how/ to run the tests. It doesn’t specify what to compile

grav15:01:30

@dnolen ^

dnolen15:01:50

@grav then no idea

dnolen15:01:59

somebody else will have to chime in

eyelidlessness15:01:00

@grav: that isn't what i'd expect, but a workaround would be to use a :notify-command in the cljsbuild build, rather than :test-commands

grav15:01:07

Okay, it’s not the biggest of deals in a CI context. It’s more a matter of being able to quickly re-run tests locally, but then again, the compilation of the test-target alone is pretty slow.

grav15:01:18

@eyelidlessness: ok, i’ll look into that one

eyelidlessness15:01:42

it takes a vector of the cli strings, just like the vector in :test-commands

eyelidlessness15:01:37

(then call lein cljsbuild once <id> rather than test)

grav15:01:49

@eyelidlessness: ah, great. and then can I use it with cljsbuild auto to evaluate tests repeatedly?

grav15:01:03

cool! thanks

lvh15:01:38

Is there a working test coverage thing for Cljs?

darwin16:01:44

@grav: I think you want to use lein with-profile, this way you can limit what part of your cljsbuild map is effective

bensu19:01:43

@grav you might be interested in https://github.com/bensu/doo for running the tests without thinking about the runners

skardan19:01:17

@mfikes @dnolen followup to discussion about remote nodejs repl

skardan19:01:04

it works very well (on Linux) - I share a directory using sshfs (do not want to spend time setting up nfs)

skardan19:01:07

then set :output-to "/tmp/cljs-repl" and invoke node using :node-command (which invokes remote node)

martinklepsch19:01:19

Does anyone have experiences with i18n w/ Closure? Tower does an ok job but I'm wondering if there might be something nice that could be built on top of Closure. Hard to find any sort of guide /cc @nullptr maybe you have some pointers?

nullptr19:01:09

not aware of any guides — have done a decent amount of i18n stuff but all “guidance” was via digging through closure-library source

nullptr19:01:27

it’s pretty straightforward generally, though

faceyspacey20:01:13

Does Om Next support query subscriptions like Meteor? If not, now how would you go about that?

martinklepsch20:01:30

@faceyspacey: probably best to ask in #C06DT2YSY

martinklepsch20:01:46

I also recall that this has been asked before so maybe it's in some FAQ already :simple_smile:

mudphone23:01:10

@darwin: thanks will take a look

mudphone23:01:31

@martinklepsch: yes, I have a separate js file for the Phoenix Framework’s default JS.

mudphone23:01:00

I’ll take a look at the output-wrapper option thank you!