Fork me on GitHub
#clojurescript
<
2015-08-26
>
timgilbert03:08:43

Hey, will lein-cljsbuild pass the :closure-defines options down to the clojurescript compiler? I’ve got {:builds {:dev {:compiler {:closure-defines {“spam” “eggs”}}}}} but I’m getting warnings about "unknown @define variable” at compile time

juhoteperi05:08:14

@timgilbert: Afaik :closure-defines only works for :advanced builds. You can use goog-define to set values for dev builds (requires 1.7.48).

timgilbert05:08:12

Oh, thanks @juhoteperi. Actually I think what I was missing was including the namespace in my define (I was using :advanced)

timgilbert05:08:27

Will give that a try. Looking at the source is helpful.

viesti06:08:53

hmm, wondering how to pass dependent state in component function arguments in reagent

viesti06:08:13

I have something like this:

(defn main-view []
  [:div
   [target-component {:sub-category (-> @state/categories :sub-categories first)
                      :category (-> @state/categories :categories first)
                      :target ""
                      :editing? true}]
   [target-list]])

viesti06:08:53

@state/categories get’s loaded in an ajax request, so on the first render it is empty

viesti06:08:32

I could wrap the argument of target-component into a reaction...

viesti06:08:06

but target-component maintains local state and initializes it from the argument...

val_waeselynck06:08:09

@viesti: this really depends on how what target-component does

val_waeselynck06:08:41

but initializing local state like this is probably the reason this goes wrong

val_waeselynck06:08:29

I mean, your best chance is to not use local state

val_waeselynck06:08:17

@andre.richards: thanks, still struggling with my English sometimes simple_smile

viesti07:08:41

@val_waeselynck happens also if I don't have local state in target-component. Seems that the component is created once with the data given as argument isn't refreshed

val_waeselynck07:08:10

@viesti: hard to help you without seeing what's inside target-component

viesti07:08:24

hmm, trying to iterate a bit simple_smile

viesti07:08:53

might actually relate to local state, hmm iterating, thanks for the response though simple_smile

val_waeselynck07:08:02

Can happen if target-copmponent is in the form (fn [args] <do something> (fn []))

ricardo11:08:43

Anyone else using pushy? Looking at the source it seems like it tries to handle all URLs, even those that do not point to the site itself. Workaround might be adding external URLs as targeting _blank.

jellea13:08:50

How do I interface with ES6 classes from Clojurescript? Is it possible?

jackjames14:08:01

@jellea: can you be more specific? are you trying to do something that isn't working?

exupero14:08:30

@jellea: I think ES6 classes are just regular ES5 prototypes. ES6 adds new syntax, but I think the underlying functionality is the same.

Pablo Fernandez16:08:37

ricardo: I’m using it, but I haven’t added any external links yet. That sounds like a bug.

Pablo Fernandez16:08:16

This document explains how to have figwheel running: https://github.com/bhauman/lein-figwheel/wiki/Quick-Start but I don’t want figwheel in production, do I? How should I handle the difference between dev and prod here?

bhauman19:08:44

@pupeno: you will have a second build config and you will omit the :figwheel true

bhauman19:08:36

#tel React components have a lifecycle protocol and should work pretty well for managing services. And as a bonus you can declare them in and out of existence easily.

tel19:08:43

Yes, but there’s a lot of runtime state which exists outside of react components...

bhauman19:08:13

I'm just suggesting that you can sometimes bottle that state in custom React components.

bhauman19:08:28

They can be your monad.

bensu19:08:03

does anybody have experience using custom tag literals with data_readers.clj while compiling ClojureScript?

bhauman19:08:29

@bensu I don't think that works

bhauman19:08:54

@bensu did you see that js reloading is working now?

bensu19:08:21

haven't tried it yet, I'll do it tonight when I switch to open source mode simple_smile

bensu19:08:29

it's going to be super useful thanks!

bensu19:08:06

@bhauman: ok, I thought it might be not a good idea/feasible but I wanted to confirm.

bhauman19:08:46

@bensu: I'm not completely confident in my answer

bensu19:08:55

@bhauman: in any case it's not trivial. so I won't solve it today. Therefore I might as well fire up Figwheel 0.3.8-SNAPSHOT!

shaun-mahood19:08:23

@bhauman: Not sure if I've said it before, but thanks a ton for figwheel. I have had to start doing some C# dev work that includes a bunch of reloading again and it reminded me how much of a difference figwheel has made to all off my web development.

bhauman19:08:58

@shaun-mahood: thanks man! I appreciate it.

shaun-mahood20:08:39

I just tried upgrading from clojurescript 0.0-3308 to 1.7.48 and have run into an error java.lang.IllegalArgumentException: character to be escaped is missing at java.util.regex.Matcher.appendReplacement (Matcher.java:809) - anyone have any idea where to start looking for the problem?

bensu20:08:09

@shaun-mahood: to be honest, it doesn't ring any bells. Are you defining your own macros?

bhauman20:08:23

@shaun-mahood: I have seen that before

bhauman20:08:47

@shaun-mahood: lein clean is your friend

bhauman20:08:27

Also make sure you are using clojure 1.7 and java 1.8

shaun-mahood20:08:00

@bhauman: Tried lein clean, tried clojure 1.7 and 1.8.0-alpha4, no luck

bensu20:08:08

@bhauman: hot coding javascript makes me smile... thanks! should I close the issue?

shaun-mahood20:08:14

@bensu: none of my own macros

bhauman20:08:34

@bensu: which did you try?

bhauman20:08:49

which type of js reloading that is

bensu20:08:34

:libs ["src/js/my-closure-like-file.js"]

bensu20:08:43

which is under my sources

bhauman20:08:32

@bensu: now without :libs add a GClosure file namespaced as you would a cljs file

bensu20:08:54

@shaun-mahood: the only thing I can think of is to look at lein deps :tree and look for new conflicts

shaun-mahood20:08:58

Oh cool - moved to clojurescript 1.7.107 and it works again!

bensu20:08:38

@bhauman: you mean without restarting and editing project.clj just drop a file and require it?

shaun-mahood20:08:54

Might be a problem specific to developing on a windows machine

bensu20:08:59

sure thing

bhauman20:08:46

@bensu like right next to your core.cljs file or something like that

bensu20:08:54

@shaun-mahood: hahahaha! you should always start with that. after a fair amount of major releases, windows bugs are quickly discover and windows specific issues are cut.

bhauman20:08:54

in your source tree

shaun-mahood20:08:44

@bensu: the cljs github has 1.7.48 listed as the latest stable version, I'm not used to going to maven to see what is newer than that.

bensu20:08:19

for newest.js with goog.provide('newest') if fails to find it once I require it. I'll now try with a properly namespaced one

bhauman20:08:09

@bensu place it and name it as you would a cljs source

bhauman20:08:00

for example example/core.cljs has example/helper.js that provides goog.provide('example.helper')

bhauman20:08:27

@bensu the compiler needs help here

bhauman20:08:07

and example.core needs to require example.helper

bhauman20:08:49

this can be done without editing the project.clj

bensu20:08:57

ok, there might be one hiccup: I'm using a hyphenated folder name: dep_graph/helper.js. do I provide goog.provide(dep_graph.helper`)` or goog.provide(dep-graph.helper)`

bhauman20:08:20

the first one

lvh20:08:26

Does cljs.repl support nREPL? I can’t find anything in the repo besides nrepl files being in gitignore, which suggests “no"

dottedmag20:08:38

bhauman: A friend of mine asked recently whether I miss LiveReload. I said I don't, because I have figwheel now, and it works where LiveReload does not.

bensu20:08:50

@bhauman: !!!! It works !!!! Fantastic

bensu20:08:22

@lvh: cljs.repl is not very friendly towards nREPL.

bhauman20:08:25

isn't that the shit!!!1

bhauman20:08:50

no more libs and just create js when you want to

bensu20:08:57

I don't even want to think about the crazyness you've must've dealt to support it.

bhauman20:08:29

that was the easiest js reloading to support

bhauman20:08:43

the compiler loves it

bensu20:08:05

This is giving me the strange feeling that I should start using Google Closure and a ClojureScript workflow for my JavaScript only projects which is clearly insane. Cool!

bhauman20:08:43

One thing I didn't try was to see if an empty project with just a single js file will work

bhauman20:08:16

It may be possible to not have any cljs at all. which of course is just silly

bensu20:08:22

I can easily try now simple_smile

bhauman20:08:35

@dottedmag: didn't see your comment. That's sweet!!! you should try the new js reloading it's kinda freaky

bhauman20:08:56

I'm glad you like figwheel.

dottedmag20:08:48

@bhauman: This friend is actually the author of LiveReload :) Thanks a lot for figwheel.

bhauman20:08:35

@dottedmag: OMG thats rough, LiveReload has a ton of code in it now

bensu20:08:58

@bhauman: let's test how much you trust your baby: should an only js project work?

bensu20:08:06

a hint, you'll love the answer

bhauman20:08:27

@bensu thats SICKKKK!!!

bensu20:08:55

I can document this any way you want.

bhauman20:08:32

"figwheel the better way to write js" hahahaha

bensu20:08:52

but tree src shows only one js file, the compiler produces a full goog.base & cljs-deps file, and figwheel takes it from there

bensu20:08:58

reload, repl, everything

bensu20:08:17

@bhauman: making the crazy, possible.

dottedmag20:08:36

@bhauman: That's what one gets for supporting everything and a kitchen sink and not being integrated in one build system. I pity him sometimes :)

bensu20:08:09

I'll make a small repo so you can show it off anyway you want!

bensu20:08:25

figwheel driven js development

bhauman20:08:36

@dottedmag: he started a great thing though

bhauman20:08:27

@bensu: well I haven't put any thought into this part of the design.

dottedmag20:08:29

Completely agree.

bhauman20:08:31

@bensu: its actually not part of the design, just something that happens as a side effect

bhauman20:08:53

If you are interested in documenting the implicit GClosure js behavior that would be amazing, if not no big deal

bensu20:08:14

@bhauman: paradoxically that is what happens when you have good design, it surprises you in pleasant ways.

bhauman20:08:31

its kinda crazy

bensu20:08:46

I'll add a wiki entry with a description and a link to the example project.

bhauman20:08:41

@bensu: I'm sure it's requiring cljs.core, etc even in :advanced

bensu20:08:22

ohh sure, I'm not proposing this as anything reasonable nor fully functional, but it's fun and somebody might find some use for it

bhauman20:08:28

Folks aren't going to believe its this easy to dev js alongside cljs

bhauman20:08:05

@bensu: there is one more important improvement, figwheel 0.3.8 is automatically reloading dependents wether they are recompiled or not.

bhauman20:08:52

This eliminates the need for ^:figwheel-always

bensu20:08:39

that's cool. I have a couple of projects with tricky ^:figwheel-always declarations

bhauman20:08:48

@bensu: if a file is dependent on a recompiled file now it gets reloaded, so things are now pretty seemless

bensu21:08:59

@bhauman: I got interrupted, here is the sample project https://github.com/bensu/figwheeljs

bensu21:08:19

I'll add a short wiki in Figwheel now, pointing to it.

bensu22:08:54

with a short notice not to open issues for this use case since it is not a priority at all

Pablo Fernandez23:08:34

@domkm: In omelette, here: https://github.com/DomKM/omelette/blob/master/src/omelette/render.clj#L12 does it mean you are parsing JS in every HTTP request?

Pablo Fernandez23:08:45

Ah, I see. I’ll have to implement something like that.

domkm23:08:24

I think there is now a way to store parsed JS in Nashorn so you don't have to keep reading it. I haven't looked at Nashorn in ages but it might be worth looking into.

Pablo Fernandez23:08:34

Oh, I’ll look into that.

bensu23:08:19

@bhauman: final note on the Figwheel for javascript adventure, a short demo: https://www.youtube.com/watch?v=Y0ulIVLbuX8

bensu23:08:32

Thanks once again for Figwheel simple_smile

bhauman23:08:25

@bensu: wow what a great demo!!!

bhauman23:08:15

did you tweet this already?