Fork me on GitHub
#clojurescript
<
2015-10-13
>
richiardiandrea00:10:31

oh ok @maria, did not know that, maybe I missed the place where it is written ..

richiardiandrea00:10:06

thanks for solving, i was banging my head on the floor 😄

steve06:10:46

anyone around who can give me some pointers around cljs.test

steve06:10:20

I setup some simple "hello world" style deftest's last night and I was able to run them successfully using cljs.test/run-tests

steve06:10:33

now though it doesn't seem to be able to locate them

steve06:10:49

I'm doing an in-ns just prior to running run-tests

steve06:10:15

(all from clojurescript repl running with figwheel)

Pablo Fernandez07:10:49

Are there any best practices in how to shape returns from an API? right now I’m doing {:status :success :other-data blah-blah} or {:status :some-sort-of-failure :other-data blah-blah}

dimovich08:10:17

@sander: so, running java -cp cljs.jar:src clojure.main repl.clj, will result in java.lang.RuntimeException: No such var: cljs.build.api/build

martinklepsch08:10:48

@maria: is the reason that :main causes the foreign libs not to be included that a file that's not loaded by main does not transitively require the foreign lib? Somehow the example repo doesn't seem to require jqconsole anywhere

maria09:10:21

@martinklepsch: I believe it’s a bug in ClojureScript. When using the :main option in combination with :advanced or :simple, instead of returning an IJavaScript map of the compiled file, the compiler returns a String which doesn’t have a goog.require for the foreign library. Will try to create the ticket and the patch today and then let’s see what dnolen says 😉

martinklepsch09:10:19

Ah interesting thanks @maria :)

thheller09:10:40

@maria part of me wants to talk you into building lein-cljsbuild on top of shadow-build, but are you even aware of its existence? simple_smile

thheller09:10:30

I suck at writing docs which is why I generally don't advertise it much

thheller09:10:05

but pretty much all of the bugs or build problems talked about here do not exist in shadow-build

thheller09:10:09

but it may have other issues 😉

thheller09:10:29

I started it a while back to get closure modules

thheller09:10:49

David kinda implemented them in cljs but is missing some stuff

thheller09:10:53

and still doesn't work in :none

thheller09:10:37

which is a big issue for me because I think :none should be as close as possible to :advanced as possible from the user side of things

maria09:10:01

@theller: No, I didn’t know shadow-build. Having a look now 😉

thheller09:10:02

:main not working in :advanced is just another example of that not being the case in cljs 😞

thheller09:10:09

but I started rewriting some stuff last week to finally get a complete REPL going

thheller09:10:22

but the general idea stays the same

juhoteperi09:10:56

@thheller: Have you thought about using Cljs public API instead of the implementation namespaces?

maria09:10:57

I like the idea to just use a Clojure script to build your project. Especially now that ClojureScript supports JavaScript transforms which require you to add your own transform function.

thheller09:10:17

@juhoteperi: that won't work cause it is pretty much a reimplementation of cljs.closure

thheller09:10:37

@maria yeah seems to be the latest trend in cljs/figwheel to create a scripts/thing.clj to run things

thheller09:10:45

which was the basic idea behind shadow-build from day 1

thheller09:10:29

my general opinion being that cljs.closure/build is not enough to drive complex builds since you cannot express all options in a hashmap

thheller09:10:15

@maria your work on transforms is not supported in shadow-build yet because I do not have a proper example of a library where that should work

thheller09:10:33

I never had a need for it so I didn't port it yet

thheller09:10:14

but as I said, I suck at writing docs so I don't blame you if you'd rather stick with CLJS proper

sander10:10:26

@dimovich no idea, sorry. are you sure you're using exactly the same cljs.jar in windows and in ubuntu?

bensu11:10:43

@steve do you mind posting an example repo? Remember that cljs.test/run-tests is a macro that takes namespaces, finds their test vars, compiles the tests, and then runs them. If you are in the REPL and somehow "delete" the namespace, then run-tests will find no vars inside.

asolovyov12:10:58

anybody had problems here with figwheel failing to re-compile .cljc files?

jreedmoore13:10:19

does anyone use ClojureScript + Node for making outbound HTTP connections?

sander13:10:08

jreedmoore: yes

jreedmoore13:10:09

I'm trying to write something for AWS Lambda on top of https://github.com/nervous-systems/cljs-lambda that talks to a bunch of HTTP RESTy APIs

jreedmoore13:10:42

@sander do you just use the node libraries w/ bare JS interop? or are there any nice wrappers around those?

sander13:10:20

@jreedmoore: no experience with aws, but i like the node.js request library

jreedmoore13:10:03

that looks pretty full featured and awesome!

jreedmoore13:10:44

I have no idea what I'm doing, but any advice on how I can turn the callbacks in there into core.async channels?

sander13:10:38

@jreedmoore: there are probably different opinions but here is one example: http://www.lispcast.com/core-async-code-style

dnolen14:10:46

before putting together a proper announce it’d be great if people could take a second to test it

dnolen14:10:55

might take a few minutes for it to hit Maven Central

dnolen14:10:44

it looks like it hit MC

Pablo Fernandez14:10:44

Figwheel is reloading a cljc file, but faling due to an undefined function, but this function is called inside a #?(:clj …) block and the function is defined in a clj file. The Clojure side of things is working fine and if I restart figwheel, it’ll work fine, but not hot-code loading. Any ideas what’s going on?

dnolen14:10:54

probably a bug?

shaun-mahood14:10:51

@dnolen: Everything looks good with 1.7.145 for me, no issues in a Reagent app running on Windows

dnolen14:10:59

great thanks!

jeremyraines14:10:45

I’m trying to get going with emacs and cider via spacemacs. When I try to send my buffer to cider in a clojurescript project, I get this error: No such var: clojure.core/require-macros . . . can anyone give me a nudge in the right direction?

bensu14:10:32

@dnolen: I just tested a couple of applications with 1.7.145 with all I got (rhino, slimer, phantom, chrome, etc.) without problems

bensu14:10:28

@jeremyraines: I'm not sure about this but I don't think cider supports clojurescript like that. It is probably trying to read your namespace as a clojure file and failing.

jeremyraines14:10:29

oh, dang. Back to vim I guess

jeremyraines14:10:31

or — what are people’s workflows for repls and clojurescript with emacs? I was experimenting with making the switch because whenever people spell out their vim setups for clojure, usually someone says something along the lines of “emacs does all that, but better, and better repl integration"

bensu14:10:58

people (meaning me) say that about clojure jvm. I use emacs + evil-mode

bensu14:10:28

but it is not integrated at all with my clojurescript workflow, which is mostly terminal/browser based

bensu14:10:41

I've been trying to use intellij + cursive but my machine can't really take 2 jvms so it crashes often when I ran tests/servers on the side

potetm14:10:26

For clojure + vim ^^

jeremyraines14:10:50

I see. I want to do clojure jvm stuff as well, so I’ll check into non-integrated workflows for clojurescript

potetm14:10:28

Man bensu that sucks about crashing… Cursive is IMO by far the best clojure editing experience

bensu14:10:11

@potetm: I now, but that will most likely change if I get a new machine with more RAM.

jeremyraines15:10:45

I tried cursive for a couple months, it wasn’t really for me; maybe I didn’t put in enough effort into learning intellij, but it seemed difficult to customize

dnolen15:10:58

@jeremyraines: that’s interesting, I basically have all the customizations I ever had in Emacs and more

dnolen15:10:10

the only thing I miss is org-mode, and I still use Emacs for that

dnolen15:10:10

ClojureScript 1.7.145 is out! big thanks to everyone who contributed

jeremyraines15:10:13

ok. I know my issue is probably lack of knowledge about the clojure / clojurescript repl in general. I’m coming from Ruby, where I’m very proficient with Pry, and am not there yet. I’ve spent time learning the language and (some minimal part of) the ecosystem, and now I’m trying to get procifient with the tooling and understand whya lisp repl is so superior (I don’t doubt that it is)

dnolen15:10:10

@jeremyraines: Ruby REPLs are not bad, they actually support reloading

dnolen15:10:37

however mostly programming via a REPL just wasn’t something I could ever do with Ruby

bensu15:10:42

@jeremyraines: what I find superior is the REPL workflow combined with an expression oriented language.

bensu15:10:09

@dnolen: the way to inform you of "Patch in need of revision" is to assign it to you?

jeremyraines15:10:35

TBH @dnolen my immediate goal is to use a setup where I can get the most out of the workshop this weekend. I think I’ll be exposed to a lot of cool techniques that I want to be able to incorporate immediately rather than abandon or translate to vim. I know that’s not the primary goal at all but I got jealous of Tims’ emacs-fu during the Arcadia workshop

jeremyraines15:10:55

I’m up and running enough with Cursive that I could probably use that

sander15:10:30

@jeremyraines: not sure if that's what you're looking for, but i found inf-clojure a lot easier to set up in emacs than cider

jeremyraines15:10:48

thanks, I’ll check that out too

dnolen15:10:04

@jeremyraines: we’ll probably recommend Cursive to cut down on environmental issues

dnolen15:10:15

anything else will be too much trouble and consume too much time

dnolen15:10:51

people who are very comfortable w/ Clojure can make do of course, but it won’t be recommended

roberto15:10:16

+1 for Cursive if you are just starting and are time constrained.

colin.yates16:10:28

how do you all handle combining ring war with ‘components’ when the handlers need collaborators? At the moment I have my handlers pull out of the system map pulled in via a namespace - yuck. The problem is that ring war wants to access the (no-op) handler var….

colin.yates16:10:56

@roberto +1 for Cursive regardless. +1 for Emacs + cider (+ prelude) though as well simple_smile

roberto16:10:57

yeah, I started with Cursive and switched to Emacs. But my motivation was because I really wanted to learn Emacs.

roberto16:10:30

Cursive is great

colin.yates16:10:19

I can’t live without helm (helm-ag and helm-occur just rock my world).

colin.yates16:10:29

and avy as well

steve18:10:26

Anyone running tests from repl in their development flow? Can you share your work flow?

steve18:10:42

Mine stopped working... trying to figure out why?

steve18:10:48

(in-ns 'blah.core)

steve18:10:51

(run-tests)

bensu19:10:10

@steve do you mind posting an example repo? Remember that cljs.test/run-tests is a macro that takes namespaces, finds their test vars, compiles the tests, and then runs them. If you are in the REPL and somehow "delete" the namespace, then run-tests will find no vars inside.

dnolen20:10:13

Om 1.0.0-alpha1 is out

dnolen20:10:34

3 tutorials to play with at your leisure, feedback, and bug reports now welcome

dnolen21:10:19

there’ll be a slew of releases as we get things ironed out. Overall I’m very excited about the architecture. I’d say this puts Om another 20 odd months ahead of everyone else simple_smile

bensu21:10:34

haha concat "again"

shaun-mahood21:10:32

Does anyone have any good, up to date instructions on how to integrate figwheel with ring? I've found some older ones but would like to get something current into the wiki.

lfn321:10:58

@shaun-mahood: you mean using figwheel to host your ring handler?

keeds21:10:44

Thanks @dnolen. Looks really interesting. Great work as usual.

dnolen21:10:46

once the various issues are ironed you will have to pry Om Next from my cold dead heads, this is the UI tool I’ve been wanting for the last 10 years.

xgavin21:10:44

nice work @dnolen, can't wait to give it a try

keeds21:10:42

Even with all the issues you identified with original Om, it has been a super useful tool and made developing UI's a pleasure. If Om Next proves to be half as good as you say then everybody else should pack up!!!! Which will be a shames as I've quite enjoyed playing with PureScript recently.

shaun-mahood21:10:02

@lfn3: I think I mean using ring to host figwheel, but I could be wrong. Essentially it would be what Chestnut does, I think. I've always had things split up in different projects up until now but want to start integrating the 2.

lfn321:10:51

@shaun-mahood: Right. So afaik, figwheel will totally handle it’s own thing, independent of ring. See https://github.com/bhauman/lein-figwheel#scripting-figwheel

keeds21:10:42

@dnolen: No problem. The thanks is all to you. Just converting a prototype I'm building to Om Next. Hopefully it will be enough to persuade a team of CoffeeScript/Backbone devs to switch to ClojureScript/Om Next!??!

lfn321:10:44

You can just put something like that snippet somewhere downstream from your servers init method

shaun-mahood21:10:23

@lfn3: Ok that kind of explains what that whole section was for. I'll see what I can figure out, thanks.

lfn321:10:48

Good luck!

sandbags22:10:37

When using a CLJC file, am I wrong in assuming there are intermediate .clj or .cljs sources generated at some point that I could inspect?

sandbags22:10:18

i’m trying to work out why a macro is generating what appears to be the wrong code and I really want to see the .cljs source to see what the #?(:cljs …) has emitted

sandbags22:10:38

but i’ve been over my project folder and they don’t seem to appear there

bensu22:10:29

you are wrong 😞 I think this is handled by the reader which just selects the appropriate part without generating an intermediate file

sandbags22:10:44

hrmm… darn

sandbags22:10:49

thanks bensu

bensu22:10:28

in any case, you should be able to macroexpand whatever you are producing

sandbags22:10:39

i can, and the code is wrong

sandbags22:10:57

what’s not clear to me is why it’s wrong simple_smile

sandbags22:10:52

ah, i wonder if this is about macros being clojure not clojurescript

bensu22:10:58

just in case: remember that macro expansion is done in clojure jvm so it would pick up #?(:clj ...)

bensu22:10:29

right, if you use the compiler from the jvm, all macros are clojure jvm code.

sandbags22:10:55

yes it just occurred to me that this might be why it’s emitted the ‘clj path

sandbags22:10:13

so… now i am unsure how to emit cljs compatible code from a macro

bensu22:10:21

@mfikes to the rescue

sandbags22:10:24

hrmm… but this means writing a special case macro

sandbags22:10:31

unless i misunderstand the message here

sandbags22:10:41

if i have to do that i can just write a CLJS compatible alternative macro

sandbags22:10:07

of course i would really rather not have to do that

bensu22:10:36

ahh you want a macro that you can call from the jvm and js and that generates different code for each

sandbags22:10:51

i have to work around a bug in cljs

sandbags22:10:02

so i need the macro to emit different code for each path

sandbags22:10:50

the pragmatic thing to do is probably just say fuck it and write defcomponent-cljs

dnolen22:10:39

@sandbags: this is not really a bug. cljc just doesn’t cover macros - was out of scope.

sandbags23:10:07

dnolen: not sure what you mean, i’m not referring to cljc not handling #?(:cljs) as a bug

sandbags23:10:19

(in the macro case)

dnolen23:10:40

@sandbags: I’m not sure what you mean simple_smile

dnolen23:10:51

you can’t put macros in #?(:cljs ...)

sandbags23:10:03

dnolen: i’m working around a CLJS bug that means I need my macro to be different in the clj and cljs cases

sandbags23:10:21

and i lost track of macros being compile-time and, hence, clj only even in a cljs context

sandbags23:10:35

so the #?(…) construct in my macro is always evaluating the :clj case

dnolen23:10:43

but what is the actual bug?

bensu23:10:49

maybe you can #? over the top form and have #?(:clj defmacro :cljs defmacro) -- sorry this wouldn't work unless you used bootstrapped

dnolen23:10:54

bug is a strong word, if there is a bug I want to know about that simple_smile

sandbags23:10:03

dnolen: it’s a known bug

sandbags23:10:26

i can find the number if you’re interested but it’s something you know about already, came up last week

dnolen23:10:26

@sandbags: can you be more specific? known where?

sandbags23:10:24

dnolen: IIRC 1451

dnolen23:10:05

ah the qualified protocol method names

sandbags23:10:32

my first approach was to use #?(:clj component-key :cljs ~(symbol “component-key))

sandbags23:10:48

but of course this fails because the :cljs case is never taken

dnolen23:10:20

yep I know what you’re talking about now

sandbags23:10:37

i’m still quite inexperienced writing macros

sandbags23:10:20

it occurs to me to wonder if the :cljs path would work for :clj also

dnolen23:10:40

though working around this via macros is about as likely to be as much work as just submitting a patch

dnolen23:10:02

the number of people that think that route is harder and then try and are surprised it’s really straighforward … simple_smile

sandbags23:10:04

submitting a patch? to clojurescript you mean?

sandbags23:10:15

i think you overestimate my chances

dnolen23:10:30

I think you overestimate how complicated the ClojureScript compiler is 😄

sandbags23:10:57

possibly, possibly not but i’d also have to understand the problem and the context which frankly i don’t … i mean i can take a look but as someone who only has the odd hour or two a week to code these days, i’m not sure it’s something i can tackle

dnolen23:10:31

@sandbags: yeah the problem is very simple

dnolen23:10:46

we’re not calling name on the protocol method

dnolen23:10:56

that would drop the namespace part

sandbags23:10:23

i’m having a look at the CLJS source now

sandbags23:10:36

i have about 15 min before i have to hit the hay simple_smile

sandbags23:10:42

i would like to get past this problem simple_smile

bensu23:10:46

I think you underestimate @dnolen's patience. He'll write the patch through slack through you if needed 😄

sandbags23:10:28

if he can do that in <15 then i have underestimated him for the last time

bensu23:10:13

hahaha I don't know if you've noticed but there were 2 releases today, I would never underestimate him

dnolen23:10:21

you can ignore pretty much everything except the calls to set! around this section

dnolen23:10:28

we’re just bashing on the JS prototype.

dnolen23:10:02

the pf argument is likely a problem

dnolen23:10:10

since it will be a namespaced thing

dnolen23:10:15

again the trick is just to drop this

sandbags23:10:56

okay this is odd, i checked out the clojurescript project on github but the source appears to be different

sandbags23:10:10

i think perhaps i am tired

sandbags23:10:07

okay yes, tired, there it is

dnolen23:10:26

in general I would rather help people fix the real issues than have them resort to dirty hacks

dnolen23:10:31

then everybody wins

dnolen23:10:43

and I’m not the only person that knows how this stuff works simple_smile

sandbags23:10:57

assuming i understood this code or what you are suggesting, how would i go about testing this?

dnolen23:10:47

bunch of info about that here

dnolen23:10:48

gotta run but happy to answers more question left here later.

sandbags23:10:34

okay, i might have to come back to this next time … 00:21 here and I suspect i’m just not compehending, thanks anyway for your help, also @bensu

bensu23:10:11

@sandbags: If you don't have the time I'll start with it tomorrow working on it with @dnolen's pointers

sandbags23:10:28

@bensu: that’s kind of you, i’m about done tonight and no idea when i’ll get a chance to code again

sandbags23:10:57

but i have the code (not that I understand it) and I will check back

sandbags23:10:23

feel kind of daft for not realising sooner why my macro was expanding wrong … <sigh>

sandbags23:10:53

ah well, g'night

steve23:10:43

@bensu I started with this "lein new figwheel om-tut -- --om"

steve23:10:12

Then added this to the :require at the top [cljs.test :refer-macros [deftest is testing run-tests]]

steve23:10:27

of core.cljs

steve23:10:39

as well as this simple test (deftest test-numbers (is (= 1 1)))

steve23:10:03

Then thought running this "om-tut/core=> (cljs.test/run-tests `om-tut.core)"

steve23:10:23

or simply "om-tut/core=> (run-tests)"

steve23:10:36

on the "lein figwheel" cli would find them.

steve23:10:09

But run-tests doesn't seem to detect my deftest, why? (sorry folks for newbie question)