Fork me on GitHub
#clojurescript
<
2016-03-03
>
jrheard00:03:03

whenever i do eg lein cljsbuild once min, i just see the output "Compiling ClojureScript..." and then the command exits and nothing gets compiled. this happens to me on every cljs project, it's never worked for me. has anyone else seen this behavior?

jrheard00:03:11

lein cljsbuild auto works, but not once

dnolen00:03:15

@jrheard: it doesn’t do anything if no files have been touched

jrheard00:03:24

for embarrassing context, what i typically do is have a long-lived lein figwheel session, then ctrl-c it and run lein cljsbuild once min so i can get a minified js file to scp around (rudimentary i know, i'll have a better system in place for this toy project eventually)

jrheard00:03:31

should i rm -rf target and resources/public/js/compiled first?

jrheard00:03:37

pretty sure that hasn't helped in the past, but will attempt

jrheard00:03:48

the "then ctrl-c it" bit happens every few days when i have something stable+good i want to upload so my friends can see it

jrheard00:03:02

well look at that, killing those dirs seems to have worked. could have sworn it didn't last time. sorry to bug you, thx david

richiardiandrea01:03:19

Has anyone had experience with SyntaxError: Unexpected token . while developing cljs macros?

akjetma03:03:14

i can’t tell if i’m really tired or if this is weird, need sanity check:

(defn send!
  ([ev-id] (@ws-send! [ev-id]))
  ([ev-id ev-data] (@ws-send! [ev-id ev-data])))
is causing ANALYSIS ERROR: Parameter declaration "send!" should be a vector at line 27 /Users/adamjetmalani/code/conch/src/conch/arbiter.cljs on file /Users/adamjetmalani/code/conch/src/conch/arbiter.cljs, line 27, column 1

mfikes03:03:27

@akjetma: Your defn works for me. (And it looks correct.) Which version of ClojureScript are you using?

akjetma03:03:14

whew! 1.7.228

akjetma03:03:53

wasn’t sure if there was some rule about a multi-sig function having to call itself or something

mfikes03:03:10

@akjetma: I’ve also confirmed it works on 1.7.228. I have no other thoughts other than to clean build.

akjetma03:03:05

thank you! yeah, i’ve cleaned it (several times).

akjetma03:03:44

k, that’s weird, i just redefined it to not be a multi-signature function and still getting the same error. must be some pebkac somewhere

akjetma03:03:05

okay! still strange, but there was a function later in the file that was missing its params declaration. not sure why the error message has the wrong function name

danlucraft09:03:12

@escherize: this is terrific thanks so much for making this simple_smile

slotkenov10:03:11

I can’t seem to find out how to mock cljs-http.client/get in my test

slotkenov10:03:06

Neither the get nor the dispatch get called. It times out.

slotkenov10:03:31

I guess the with-redefs does not work as I expect it to?

nberger13:03:10

@slotkenov: it would be nice to see the code for set-up-csrf-token, without it it's difficult to say why the get or dispatch are not being called

nberger13:03:47

I can't see anything wrong, apart from a word of caution about using with-redefs with async, but let's discuss that after understanding why "the mock is not being called" simple_smile what test runner are you using?

slotkenov13:03:14

I’m running with doo

nberger13:03:10

I'm asking because some runners don't wait properly for tests to finish when there are async tests... but doo should not have that problem

slotkenov13:03:06

Ah, no. It properly waits and continues after the timeout I’ve set

nberger13:03:18

So the "Timeout" is being printed... hmmmm

slotkenov13:03:28

I am using with-redefs in another test without async with success. So might be the combination of those that bring the trouble, like you said.

matthavener13:03:35

I would imagine http/get is crashing in the go block

nberger13:03:13

it should call the mock...

matthavener13:03:24

Does with-redefs cross go block boundaries in cljs?

nberger13:03:24

and at least it should do the first println...

nberger13:03:57

the thing with with-redefs is that done from async is a continuation fn that will execute the rest of your test suite... and depending on the layout of your code it might execute it in the scope of the with-redefs, so you might "see" the redefs in other tests

nberger13:03:42

so you have to call done "outside" of the with-redefs

nberger13:03:10

but I don't think that explains why your mocks are not being called...

matthavener13:03:22

the dispatch is going to be called in a different stack frame, where with-redefs wasn’t applied

matthavener13:03:38

so its probably calling the non-redefed dispatch

matthavener13:03:23

i would say the fact that it mocked http/get successfully is probably an implementation detail, but i dont know enough about the cljs core.async spec :X

slotkenov13:03:24

The same logic would go for the get function then?

nberger13:03:32

but why it's not printing Mocked GET?

nberger13:03:04

I mean, it should be calling the mocked http/get, no?

matthavener13:03:47

ohh, it didn’t. yeah, I don’t think that would be guaranteed?

matthavener13:03:04

(go (…)) should immediately return the channel and then execute (…) in some other frame

nberger13:03:18

oh right, makes sense

matthavener13:03:25

like a setTimeout(#(…), 0), thinking in js

matthavener13:03:39

and in that frame, with-redefs isn’t applying. you’d need some global with-redefs 😛

slotkenov13:03:04

ah, that would mean you can’t mock something that’ being called from within a go block?

matthavener13:03:09

i don’t know, looking at the source of with-redefs it seem possible, but i dont see a public API

nberger13:03:15

hmmm, I was trying to understand why it is working in some tests that I have... and it's because I'm doing the with-redefs inside of a go block, and then I even give the other go block (what would be your set-up-csrf-token fn) the chance to execute with a (<! (async/timeout 50))... dirty, but it works for me

nberger13:03:36

it's so dirty that I should have kept it secret 😛

slotkenov13:03:42

haha, that is dirty indeed

nberger13:03:55

I'd love to find a better a way to do this

slotkenov13:03:18

Not use go blocks...

slotkenov13:03:44

I’m trying your method, getting into the dispatch function now

slotkenov13:03:15

and the http/get as well

nberger13:03:50

just be careful to not call done before the body of your with-redefs has finished, so as to not "see" the redefs in the following tests...

slotkenov13:03:30

Yeah, that’s another problem

slotkenov13:03:54

I know I’m done when inside of the dispatch fn...

slotkenov13:03:53

Just put a flag in another channel there? And watch for it outside of the with-redefs

nberger13:03:45

yeah, I'm doing something like that... I'm using an atom though, but it's the same effect

slotkenov14:03:37

I don’t seem to be needing the (<! (async/timeout 50))

arnaudsj15:03:18

Hi, starting to really jive ClojureScript on NodeJS for use with AWS Lambda. However, I wanted to double check that the best effort to get a REPL for this env was still via inf-clojure on Emacs. It appears that Cider does not support ClojureScript on NodeJS yet?

ashercoren16:03:46

I want to use in my app both react-with-addons and bootstrap-cljs. But when in my code I call a bootstrap function, I get in the browser an error: ReactBootstrap is not defined. It seems to me that the problem is that in order to use react-with-addons I had to exclude the regular react package in my project.clj: [org.omcljs/om "0.9.0" :exclusions [cljsjs/react]]. Am I correct? Is there a way around it?

peeja16:03:01

@ashercoren: You are correct, but that shouldn't be causing a problem. cljsjs/react-with-addons and cljsjs/react each provide React, but neither provide ReactBootstrap

peeja16:03:07

That should be coming from cljsjs/react-bootstrap, which is dependency of bootstrap-cljs

peeja16:03:36

Are you failing to require bootstrap-cljs.core, perhaps?

ashercoren17:03:49

@peeja: In my project.clj dependencies I have om with the exclusion of react, followed by react-with-addons and then bootstrap-cljs. In my cljs namespace I require bootstrap-cljs.core. When I remove react-with-addons from the porject.clj and remove the exclusion of react, the bootstrap component works fine

peeja17:03:23

@ashercoren: Are you seeing any other errors that could be stopping ReactBootstrap from fully loading?

ashercoren17:03:22

@peeja: There is another error, coming from react-bootsrap.inc.js: Uncaught TypeError: Super expression must either be null or a function, not undefined

peeja17:03:18

I don't know react-bootstrap at all, so I have no idea what that would be off the top of my head, but I would guess that it's the problem

peeja17:03:43

Maybe you're getting different versions of React between the two dependencies?

ashercoren17:03:33

@peeja: Good catch. I found this in closed issue in react-bootstrap: Following React-Bootstrap this will only support React > 0.14. React-with-addons uses react v0.12

ashercoren17:03:54

Is there a way to use a higher version of React when using react-with-addons?

peeja17:03:21

Sure, you can get it in all the same versions: [cljsjs/react-with-addons "0.14.3-0"]

ashercoren17:03:36

Thank you! works like a charm!

peeja17:03:10

Is it possible for a macro to throw an error/warning that would show up, for instance, in the Figwheel notice at the bottom of the screen?

peeja17:03:03

I tried using throw, but it appeared to silently halt compilation (at least, if you're only looking at the browser)

peeja17:03:48

I've resorted to having the macro insert a throw into the CLJS so it shows up at runtime in the console, but I don't love it.

richiardiandrea18:03:50

Hello everybody, a question, what if in doo I want to setup my environment before the test namespace(s) are required in my runner? Is there a way?

mathpunk19:03:23

I may be asking in the wrong neighborhood but--- if I'm trying to jack into a repl in cider, and I get a java.lang.ClassNotFoundException regarding piggieback, is that because piggieback needs to be included in my project in order to connect to a repl in that fashion?

mathpunk19:03:49

hunch: piggieback needs to be in plugins, since it's necessary for working on the project but it's not code that my project is actually depending on

mathpunk19:03:56

oooohhh the project file has a profiles key? huh.

bensu21:03:33

@richiardiandrea: care to explain further? set up what environment?

bensu21:03:21

in a node repl, is there an equivalent to load-file to load google closure style modules that I've written myself?

bnoguchi22:03:26

Anyone here worried about cljsjs introducing global variables — e.g., if 2 cljsjs packages both introduce conflicting X's into the js namespace as js/X? Curious what other alternatives people are using to incorporate npm modules into their clojurescript projects.

arnaudsj22:03:40

Hi, does anybody have a good tutorial on how to write a NPM module in ClojureScript?

bensu22:03:01

@arnaudsj: there is a template. be right back

arnaudsj22:03:28

not a boot-cljs version template by any chance? 😉

bensu22:03:08

I don't know, ask in #C053K90BR (or make it, since it can't be very hard)

chrisoakman22:03:45

@arnaudsj: another idea is to just export your module as an object

chrisoakman22:03:45

(atom extensions are basically npm modules with some special rules)

richiardiandrea23:03:22

@bensu thanks for asking but I solved, I used build-time trickery in order to differenciate browser/node conf...at the beginning I was thinking of using the runner but of course by the time you are in the namespace all your tests are already required (and you cannot use require in the runner anyways)

lvh23:03:55

Does anyone have any suggestions for an efficient sliding buffer in CLJS? I want to keep up to n maps around, and ideally without hitting pathological cases for the persistent data structures. subvec seems to suggest that it’s always very fast, but it seems like it should be slightly faster in some cases than others, notably when you can throw away an entire interior node?

lvh23:03:01

Perhaps I just misunderstand how vectors work simple_smile

donaldball23:03:38

That sounds like a good use case for core.async buffered channels tbqh