Fork me on GitHub
#clojurescript
<
2015-08-07
>
shofetim04:08:39

Anyone having problems with

shofetim04:08:42

No such namespace: cljsjs.react, could not locate cljsjs/react.cljs at line 1 file:/root/.m2/repository/org/omcljs/om/0.8.8/om-0.8.8.jar!/om/dom.cljs

shofetim04:08:56

I get that as soon as I require om/dom in a newly created project from chestnut.

martinklepsch04:08:37

Does lein deps :tree show a cljsjs/react dependency?

shofetim04:08:22

om/dom depends on it, though I don't depend on it directly.

shofetim04:08:54

[org.omcljs/om "0.8.6"] [cljsjs/react "0.12.2-4"]

martinklepsch04:08:37

@shofetim: what version of cljs?

shofetim04:08:26

The template uses 0.0-3058 but I've tried the latest ( 1.7.48 ) as well

shofetim04:08:29

Same result.

shofetim04:08:14

From many google searchs it seems like anything more recent then 3115 should have all potentially related bug fixes.

bhagany04:08:20

Upon upgrading to 1.7.58, from 0.0-3308, I'm having a problem with cljs.test. Specifically, a call to cljs.test/run-tests appears to be macroexpanding to include a call to cljs.core/vswap! (here: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/test.clj#L268), which is failing with Use of undeclared Var cljs.core/vswap!. I've inspected the generated javascript, and it's true that cljs.core.vswap_BANG_ is in the bit generated by run-tests, but it's not in the generated source for cljs.core. cljs.core.swap_BANG_ is defined there though. Has something changed here recently?

bhagany04:08:10

If I'm reading it right, I think that calls to vswap! in cljs.core get compiled to cljs.core._vreset_BANG_… not sure if that's relevant but it seems interesting

martinklepsch04:08:01

@shofetim: still half sleeping but have you tried explicitly depending on most recent cljsjs/react?

shofetim04:08:44

(grr. This error shouldn't be possible...)

shofetim05:08:36

@darwin: It looks like you had the same problem a few months ago?

nberger05:08:26

@bhagany I was just looking into http://dev.clojure.org/jira/browse/TCHECK-61 today, which seems like a similar issue. Have you tried adding (:require [cljs.core]) in your ns?

bhagany05:08:00

@nberger: I'll give that a try

nberger05:08:31

Also, how are you requiring the macro? (:require-macros ...) or (:require ... refer-macros ...)?

bhagany05:08:25

like this: [cljs.test :as test :include-macros true :refer [report]] - I believe I cribbed that from a gist for testing with figwheel

bhagany05:08:00

then the invocation is like (test/run-tests …)

nberger05:08:01

hummm ok...

nberger05:08:12

that looks good

nberger05:08:51

what level of :optimization? :none, :simple, :advanced?

nberger05:08:25

ok, just guessing now... with :simple or :advanced is the same?

bhagany05:08:36

hrm… I have that profile configured for figwheel, which requires :none… one moment

bhagany05:08:43

ah, this isn't going to be quick, I don't have any non-dev environment (read: a page that's not expecting figwheel) to run this

nberger05:08:53

vswap! is a macro, so maybe you could try adding (:require [cljs.core :include-macros true])

bhagany05:08:29

same result

nberger05:08:48

ok... I have have to say: yes, something has changed 😛. I guess you could try to track down which version between 0.0-3308 and 1.7.58 brings this issue

bhagany05:08:19

that was my next step, but I decided to do it tomorrow and have some scotch instead simple_smile

bhagany05:08:37

I probably should go to sleep, it's nearing 1am here

nberger05:08:38

good idea, clearly

bhagany05:08:51

I appreciate your help, thank you

bhagany06:08:10

well, I decided to do this anyway - the issue appears in 1.7.10

bhagany06:08:24

and now I'm actually going to sleep simple_smile

darwin07:08:32

@shofetim: I don’t remember

dnolen11:08:20

@bhagany: seems unlikely to me at the moment. I’ve been using cljs.test with 1.7.X without issue.

dnolen11:08:53

make sure you don’t have some weird caching issues or somehow have conflicting versions of ClojureScript.

dnolen11:08:02

@shofetim: seems similarly strange to me. did you try lein deps :tree and audit?

mitchelkuijpers11:08:23

Does anyone know why a javascript function if you

aget
it with clojurescript loses it's this binding? I am writing
(.bind (aget "matcher" "setRows") (aget "matcher"))
everywhere 😞

dnolen11:08:08

@mitchelkuijpers: that’s how JavaScript works

dnolen11:08:25

also you want goog.object/get not aget for this

dnolen11:08:35

finally, write a macro to remove the boilerplate if you like

mitchelkuijpers11:08:43

Aha that was actually what I wanted to ask

dnolen11:08:38

it would still be (.bind (gobj/get …) (gobj/ get …))

dnolen11:08:47

but easy to write a macro bound-fn, or plain function too, so you only write (bound-fn foo “methodName”)

mitchelkuijpers11:08:04

Sure but I can just write a function if it bothers me to much

mitchelkuijpers11:08:06

Btw pretty awesome stuff the buit-in google closure stuff, currently using AutoComplete ^^

dnolen12:08:13

@mitchelkuijpers: if you’re using Google Closure then you do not want goog.object/get either

dnolen12:08:23

your code will not work under advanced optimizations

dnolen12:08:06

and you’ll need a macro, not a function, for boilerplate removal in that case

mitchelkuijpers12:08:13

I can just call the functions with google closure right? like

(.setRows matcher)

dnolen12:08:42

@mitchelkuijpers: yes, I’m just trying to explain based on what you’ve said so far

dnolen12:08:55

you haven’t explained why you need bound fns

mitchelkuijpers12:08:58

@dnolen: true the reason I need them right now is because i am wrapping a google closure component as a reagent component, where i need access to the matcher and I did a dirty hack where i set the matcher on this in

component-did-mount
link this
(aset this "matcher" matcher)

mitchelkuijpers12:08:39

But this was a bad idea so refactoring it already

bhagany12:08:37

@dnolen - interesting… I had considered conflicting versions of clojurescript and had already pruned lein deps :tree, but per your suggestion I decided to clear my local .m2 and try again. And then I watched it pull down four (!) ancient versions of clojurescript, none of which appear in lein deps :tree. My lack of understanding runs deep. I'll investigate further, thanks for the nudge.

bhagany12:08:41

also, if anyone has any clue what I'm missing about that, I will humbly accept your correction

nberger13:08:15

@bhagany: be sure to clean your output dirs... lein clean but depending on your cljsbuild profile you might need to manually check everything is wiped

nberger13:08:34

I mean, lein clean only wipes :target-path, but it's common to have output in other dirs as well, if that's the case you can configure :clean-targets but in the meantime clean it manually simple_smile

bostonaholic13:08:51

@bhagany: I had the same issue a while back. Doing what @nberger like so, :clean-targets ^{:protect false} [:target-path :compile-path "resources/public/js"] worked for me

bostonaholic13:08:01

(your paths may be different)

bostonaholic13:08:34

then lein clean of course

nberger13:08:39

@bhagany: also, about the 4 ancient clojurescript versions pulled, I think lein might be pulling the entire dependency tree based on your declared dependencies but ignoring :exclusions and also including every declared clojure & clojurescript dependency in your tree

nberger13:08:52

it's just that when building the classpath, it will apply your :exclusions and your declared clojure & clojurescript versions will take precedence (or it simply ignores the versions declared in your dependencies, not sure about this)

nberger13:08:41

I just got 8 clojurescript versions pulled after wiping .m2

crisptrutski13:08:57

I believe it’s pulling all mentioned versions just to get their transitive dependencies - for aether (?) dependency resolution algorithm

shaunlebron13:08:23

@dnolen: wondering if 1.7.58 is a pre-release

dnolen13:08:56

@shaunlebron: occasionally we cut quickfix releases for some users that need no more extensive announce

dnolen13:08:01

1.7.58 was for Windows users

sisawat15:08:09

Is the author of Javelin here? Alan Dipert?

bhagany15:08:57

@nberger, @bostonaholic I've been cleaning my compilation targets on every run simple_smile Also, good to know, regarding the dependency tree/exclusions interaction

bhagany15:08:41

To try to get down to a more minimal repro, I started a new project with minimal dependencies. It still pulls 0.0-2411, but I haven't tried compiling anything that calls run-tests yet. I'll try to make some time for more exploration around lunch time. Thanks for the help!

cfleming15:08:31

@sisawat: Try #C053K90BR

zspencer16:08:46

Starting off a new clojurescript project that will likely involve svg; recommend lein template?

zspencer16:08:12

Planning to use Google’s material design for interface, unless there are better recomendations? (Only really need sliders)

bensu16:08:47

@zspencer: are you going to use a React wrapper?

zspencer16:08:54

Not really sure yet.

zspencer16:08:00

This is very much a “Let’s explore” project

zspencer16:08:07

I’ve poked at reagent and om a bit

zspencer16:08:24

There wil not be a server side component atm

bensu16:08:29

it will make a big difference when it comes to using a CSS framework

zspencer16:08:13

Yeah, that’s my impression…

zspencer16:08:25

looking for something that ties material-ui and react together

bensu16:08:27

many CSS frameworks assume jQuery and/or implement sliders and dropdowns through direct DOM manipulation.

bensu16:08:09

good, that's what I meant

zspencer16:08:17

yea, material-ui seems to do the jquery thing

bensu16:08:41

most do, it's a pity

zspencer16:08:54

maybe I’m thinking this through wrong

zspencer16:08:58

all I want is a slider widget that isn’t terrible

zspencer16:08:10

I guess I can get by with just plain old input boxes restricted to text

zspencer16:08:26

erm numbers*

zspencer16:08:50

or rather input type range

bensu16:08:56

but it forces inline CSS

zspencer16:08:17

Yep, exactly 😞

zspencer16:08:21

I think I’ll pass

zspencer16:08:47

And poke at re-frame and not worry about fancy ui stuff

mihailt16:08:39

Incase wasn’t here yet. Good read from the guy behind DataScript http://tonsky.me/blog/the-web-after-tomorrow/

domkm16:08:13

zspencer: Are you sure material-ui relies on jquery? The changelog and issues lead me to believe that it doesn't require jquery.

zspencer16:08:21

hmm I could be wrong

zspencer16:08:57

also hey, I think we’ve met before but maybe not.

domkm16:08:29

and you recently added me on Facebook 😉

zspencer16:08:11

Yes, that was me mistaking you for DDDagradi :x

zspencer16:08:07

but then I realized who you were after Is ent it and was like “Ah, we know each other kinda, what the hay!"

bhagany17:08:27

@nberger @bostonaholic - I've done more experimenting, trying to narrow the issue down, and this is about as far as I've been able to get: https://github.com/bhagany/flarg

bhagany17:08:33

Basically, compiling in the quickstart way outputs something slightly different from compiling via cljsbuild (yes, I know)

bhagany17:08:13

My goal here though is to continue using figwheel, and I'm unaware of any hoops to jump through to do so without cljsbuild

bhagany17:08:29

I should add, both the cljsbuild output and the build.api output claim to have been compiled with clojurescript 1.7.48

bhagany17:08:30

My efforts to divine what cljsbuild is doing differently have been… unfruitful

bensu17:08:17

@bhagany: I might be missing some context, but is the clojurescript :aot flag intentional?

bhagany17:08:03

@bensu: yes, I think I added that on a recommendation from a @dnolen blog post?

bensu17:08:45

hmm :aot is great when everything is working and you want to speed up your compilation process. not so good for finding deps related problems

bhagany17:08:45

trying cljsbuild without it now

bhagany17:08:09

well, I'll be, that worked

bhagany17:08:56

the only new dep it pulled down was the 1.7.48 jar

dnolen17:08:04

@bhagany: using cljsbuild with :aot is a recipe for disaster

dnolen17:08:16

I would only use :aot in a Maven only project

bhagany17:08:44

@bensu @dnolen: lesson learned, thank you!

bensu18:08:36

@bhagany: glad it helped

bhagany18:08:58

someday, I may even understand how or why simple_smile

dnolen18:08:21

@bhagany: ha, I don’t know why either - and I don’t want to know

bhagany18:08:36

hahahaha, noted

Paco19:08:46

@zspencer: I used http://materializecss.com/ with not too much pain

Paco19:08:22

and straight up reagent and channels no re-frame

zspencer19:08:00

Spent at least an hour just reading through Re-frame’s supporting docs :0

Paco19:08:42

re-frame seems cool and all but I am not conviced. Also the readme and docs are scary

zspencer19:08:27

Yes very “You must be this smart to ride the ride"

Paco19:08:28

you can get really far with just channels and making sure you never mutate state in the components

pandeiro19:08:08

i think the re-frame readme is one of the great works of GitHub lit

Paco19:08:53

@pandeiro: what does that mean ? 😛

zspencer19:08:07

“Software As a Readme"

Paco19:08:19

Readme driven development?

roberto19:08:27

it is the best Readme I’ve read

zspencer19:08:38

200 lines of code, 4000 lines of docs

pandeiro19:08:40

Portrait of a Software as a Young Code

roberto19:08:47

i haven’t had the need to go outside the readme (and it’s wiki) to do anything with re-frame

pandeiro19:08:55

it takes several readings to really dig into the depths of it

zspencer19:08:18

Its definitely entertaining

pandeiro19:08:31

and that mirrors the debugging experience

zspencer19:08:50

Being entertaining?

pandeiro19:08:50

you might say some browsers aren't really able to appreciate the way it lays out its code

Paco19:08:55

dude I just have use reagent.session to put all app state create a bunch of reagent.core/cursor that i pass to my components

Paco19:08:03

its verbose but clean

pandeiro19:08:28

that is the best synthesis of re-frame that i've read

pandeiro19:08:59

you clearly aren't the same ever since you read that readme

Paco19:08:08

then create chans to communicate your components with some data mutation functions in your main namespace et voila

Paco19:08:15

no need for a fancy framework

zspencer19:08:27

I know some of those words 😉

Paco19:08:57

lol happy to walk you throug my code zee

zspencer19:08:12

When I get back from my impromptu, low-bandwidth travels simple_smile

akiel19:08:11

what lib should I use if I want send some data over a websocket to a cljs app?

Paco19:08:32

+ 1 on chord

akiel20:08:31

yes chord looks less verbose

dnolen20:08:54

so it appears ClojureScript can have optional type checking

teslanick20:08:06

Chord is less verbose but does less for you out of the box.

bensu20:08:00

@dnolen: type checking? please do explain.

dnolen20:08:26

@bensu Google Closure has very sophisticated type checking built in

dnolen20:08:43

we emit very simple JavaScript, a lot of interesting type checking can occur

dnolen20:08:49

in the Closure pass

bensu20:08:26

@dnolen: you mean adding jsdocs to the emitted code so that Closure can pick it up?

dnolen20:08:56

yep I already tested that it works just fine

dnolen20:08:04

so this means a bunch of things

dnolen20:08:19

automatically generating @interface for all protocols

dnolen20:08:42

automatically generating @extends for deftype / records that implement

dnolen20:08:50

and then letting Closure just do it’s thing

bensu20:08:08

by optional you mean implementing core.typed annotations, or ^tags?

bensu20:08:27

I'm not very familiar with jsdocs "type system"?

dnolen20:08:37

if you want to type something you could always just add it to the docstring

dnolen20:08:48

ClojureScript comments always became JSDocs

dnolen20:08:52

this idea is not even new

dnolen20:08:00

Rich Hickey mentioned it on day 1 of ClojureScript’s release

bensu20:08:09

right but writing "my comments @param ..." wouldn't be very idiomatic

dnolen20:08:20

this is not even a new feature, it always worked

dnolen20:08:41

the only difference would be supply more information for people who want to turn it on.

dnolen20:08:53

@bensu there no such thing as idiomatic docstrings

dnolen20:08:18

I actually started thinking about this again because there isn’t a good doc solution for Clojure or ClojureScript

dnolen20:08:23

turns out that YUIDoc seriously rocks

dnolen20:08:32

which also accepts full JSDoc

bensu21:08:39

wouln't it be better (though more work) to take ^tags and convert them into jsdocs?

dnolen21:08:56

absolutely not

dnolen21:08:02

that’s definitely not idiomatic

dnolen21:08:15

you can put whatever you want in a docstring

dnolen21:08:22

markdown, links, JSDoc

dnolen21:08:27

and more importantly JSDoc gives us a typing interop story

bensu21:08:30

sure, but I thought since Clojure already has a type hinting system...

dnolen21:08:33

type hints are too simple for that

dnolen21:08:41

and type hints aren’t about validation

dnolen21:08:43

never will be

bensu21:08:09

ahh ok. I clearly don't know enough about the underlying behavior to argue about it simple_smile

dnolen21:08:44

in anycase this isn’t about treading into core.typed territory or messing with type hints

bensu21:08:45

when it comes to built in types it would work like "@param cljs.core.PersistentHashMap"

dnolen21:08:51

it's just about simple validation

dnolen21:08:32

@bensu the one thing we might do is automatically map preconditions into JSDoc

bensu21:08:47

as in {:pre :post}

dnolen21:08:50

so you don’t have to write long things like that.

dnolen21:08:55

this isn’t about typing everything - just more checks if you want them.

dnolen21:08:28

but also a big win for interacting with Google Closure Library

dnolen21:08:32

that stuff is already typed

bensu21:08:00

yeah, I can see that. I've been gradually typing for a while and I see the benefits.

bensu21:08:20

:pre conditions can be arbitrary functions, I'm trying to look how can they be added to jsdocs

dnolen21:08:47

yeah we’re not going to handle arbitrary predicates simple_smile

lvh21:08:03

Is there a way to read resource files so they’re available to Clojurescript? I’m okay with doing all my reading at compile time.

dnolen21:08:04

but map? vector? string? number? (or nil? number?)

dnolen21:08:09

this stuff is all easy to support

bensu21:08:12

ahh ok sure.

bensu21:08:21

@lvh there is! use slurp in a macro

lvh21:08:36

oh. Huh. That makes sense I guess simple_smile

dnolen21:08:37

@bensu also can easily add support for instance? satisfies? implements?

dnolen21:08:51

and easily infer that a function is just a type check predicate

lvh21:08:09

Maybe I should also explain the more general problem I’m trying to solve, just in case there’s an even better solution

lvh21:08:26

I’m writing a greasemonkey plugin and would like to use Clojurescript (of course :))

bensu21:08:31

as long as the user doesn't add a (integer? (f a b)). I see how it's possible, cool.

lvh21:08:43

I’m trying to test said greasemonkey plugin, incidentally using bensu’s excellent doo simple_smile

dnolen21:08:00

@bensu: yep all that stuff just becomes @param {*} foo

dnolen21:08:11

but that doesn’t hurt the problems you can catch

lvh21:08:19

bensu: now that I have you here, by the way, have you ever considered using lein-auto for the “repeat” behavior for doo? I haven’t checked if that would let you shave off some code.

bensu21:08:17

@dnolen: right. I'll ponder the code that recognizes validation functions

bensu21:08:21

@lvh: by the way, checkout the new :optimizations :none test runners.

aengelberg21:08:34

Does clojurescript support (:use-macros [my.ns :refer [macro1] :rename {macro1 macro2})?

lvh21:08:55

0.1.4-SNAPSHOT allows :optimizations :none for all platforms but rhino, changes valid-compiler-options?'s signature to take js-env, adds the browsers alias, and changes many of the compiler requirements.

bensu21:08:41

I think doo is now the first test runner to support :none in several targets.

bensu21:08:22

on lein-auto, the cljs.watch.api lets me write all of lein-doo in 5 lines. (which feels like all of cljsbuild)

lvh21:08:45

Oh, right, I forgot about cljs.watch

dnolen21:08:11

@aengelberg: no support for :rename at all

dnolen21:08:30

patch welcome for that, but fair warning, the ns stuff is a monster

dnolen21:08:54

@cfleming: yeah Node.js debugging mostly works, at least as well as in the browser, the only janky bit is I have to set breakpoint in generated JS

cfleming21:08:26

That is hot. Seriously, I must have been asleep at my TweetDeck.

dnolen21:08:41

yeah saved me a ton of time

dnolen21:08:53

ClojureScript master Node.js REPL can now be started with :debug-port

dnolen21:08:06

and connecting to this from IntelliJ is trivial

cfleming21:08:09

I tried to play around with spy-js when writing some JS the other day but couldn’t make it work.

dnolen21:08:22

yeah still haven’t messed with spy-js

cfleming21:08:24

I didn’t try too hard, though.

cfleming21:08:50

So you can connect to a remote debug session? I wasn’t sure you could do that.

dnolen21:08:00

@cfleming: that’s what I did, works

dnolen21:08:36

:debug-port means you can of course use anything (node-inspector) or whatever, but happy that IntelliJ JS support works well enough for me to stay in the IDE

cfleming21:08:47

That’s nice. JetBrains seemed fine with giving me access to the source, but I’m pretty backlogged right now.

sonnyto21:08:36

hi.. I am trying to compare two functions like this

sonnyto21:08:37

(compare (fn []) (fn []))

sonnyto21:08:52

I tried to implement IComparable

sonnyto21:08:00

(extend-protocol IComparable IFn (^number -compare [x y] (println "compare function") (cond (identical? x y) 0 (< x y) -1 :else 1)))

sonnyto21:08:30

however I am getting an error

sonnyto21:08:31

Uncaught TypeError: Cannot set property 'cljs$core$IComparable$' of undefined

sonnyto21:08:50

clojurescript functions are of type IFn right?

dnolen21:08:03

@sonnyto: you cannot extend protocols in ClojureScript, you can’t do that in Clojure either

dnolen21:08:18

Clojure does support extending Java interfaces though, and that’s not really possible in ClojureScript

sonnyto21:08:55

@dnolen: thanks. so how can I make (compare (fn []) (fn [])) work?

dnolen21:08:01

if you want the analog for your particular application ...

sonnyto21:08:08

i need it because I'm inserting functions into datascript

sonnyto21:08:31

and datascript does a compare on the value

dnolen21:08:51

(extend-type IComparable default (-compare [x y] (if (and (fn? x) (fn? y)) … (throw (ex-info …)))))

sonnyto21:08:16

cool! i'll try that.

sonnyto22:08:08

@dnolen: it seems matching against default captures all types. now even string comparison will use that compare. is there a way to only implement compare for functions only ?

sonnyto22:08:04

@dnolen: nm. didn't realize there's also cljs.core.function . that worked

dnolen22:08:32

@sonnyto you didn’t do what I said to do

dnolen22:08:46

notice the (throw (ex-info …))

dnolen23:08:59

been busy so just now reading this but, this is so awesome