Fork me on GitHub
#clojurescript
<
2015-09-24
>
benzen00:09:13

I'm having some diffuculty with devcards

benzen00:09:49

i can start it by including (devcards.core/start-devcard-ui!)`

benzen00:09:05

Using boot

benzen00:09:46

I can find the way to not get the devcrard ui from starting in dev or prod builds

benzen00:09:39

i can't find the way ....

danielcompton01:09:29

I think I might have figured out the lein doo memory issues. The project I was running didn’t have :jvm-opts explicitly set. CircleCI’s boxes have 240GB of ram and report this much as being available to applications. My hypothesis is that the JVM thought it had plenty of room to grow before GCing and so pushed up past the 4GB memory limit enforced by Circle on any app testing. Adding :jvm-opts seems to have fixed the issue.

bo01:09:47

@dnolen: > it doesn’t matter what optimization setting you use, ns-interns will dump vars, remove it if you don’t want that Yeah I figured that out in the end. What was throwing me is that the file metadata was definitely an absolute path in :advanced compilation but a relative (to root) path in with :none so when I was searching for the path string, I wasn't finding it at first. Once I knew what the culprit was and could jump straight to the relevant code, I could see all the var metadata (albeit with relative paths). Now that I know ns-interns is the reason, my sanity is restored, and I have a couple of alternatives I can explore. Thanks though!

bo02:09:01

@dnolen It is worth mentioning, though, that the surprising behaviour wasn't ns-interns output, so much as the absolute file paths that were present. I still find it surprising in fact, but I may be missing the relevant use case. In my current mind, it doesn't seem ever useful to know the location on disk of the machine that compiled the source, since that's not reasonably expected to be accessible from the consumer of the JS.

dnolen02:09:56

@bo sure but that's just a minor issue. Var stuff isn't for production anyway.

bo02:09:54

Just glad I got it sorted in the end. It all makes sense once I put the pieces together

timothypratley03:09:02

figwheel question: is there a way to get the behavior of {:http-server-root "public/js/out"} when running my own server? I can't use the built in figwheel ring server because I'm using HttpKit for websockets, and things work almost great except that figwheel is trying to reload files without respect to public/js/out

timothypratley03:09:06

figwheel detects the file change and tries to reload the files but is looking for them in /

meow03:09:44

@benzen: If it's any help to you, I just keep my devcards in a separate project, such as this one: https://github.com/decomplect/ive

meow03:09:15

Also there is a #C09GR9UJC channel that might get you more help.

meow03:09:57

And I know @bhauman is probably busy with Strange Loop right now, but he's usually here on Slack providing help as well.

bhauman03:09:11

@benzen: you will have to do a wrapper ns that starts the ui and requires the namespaces you want the cards from. Then don't include this ns in the main application build

timothypratley04:09:11

hmmm well https://github.com/enterlab/rente works great without http-server-root, so I must just be missing something

mbertheau06:09:27

In (.-target event) what's the - in front of target?

asolovyov06:09:56

@mbertheau: so (.target event) would compile to event.target(). Minus prevents the call, so (.-target event) compiles to event.target

asolovyov06:09:02

that's attribute accessor

asolovyov06:09:29

initially clojure had no such thing since in Java you can understand if you're calling a function or accessing an attribute by typing

asolovyov06:09:02

in javascript you can't determine that, so programmer has to tell the language what to do simple_smile

shofetim08:09:35

I'm trying to use :foreign-libs compiler option, it works if I use lein cljsbuild auto but raises a "No such namespace:" error if the namespace is compiled via figwheel's autodetection... I'm at a loss how to track it down further. Any ideas?

martinklepsch08:09:53

@benzen: you can also have a Directory "devcards" that you only add to :source-paths when you want devcards.

mbertheau08:09:48

How would I elegantly create a vector ["begin" "a1" "a2" "b1" "b2" "end"] where the middle elements are calculated from the sequence '("a" "b")?

mbertheau08:09:50

I have this: (-> [] (into (list "begin")) (into (for [letter '("a" "b")] [(str letter "1") (str letter "2")]))) which results in ["begin" ["a1" "a2"] ["b1" "b2"]]

mbertheau08:09:09

I thought about just flattening that list, but I'd need just 1 level of flattening, and that's (apply concat) and then that's not really elegant anymore:

(-> []
 (into (list "begin"))
 (into (apply concat (for [letter '("a" "b")] [(str letter "1") (str letter "2")]))))

danielcompton09:09:08

@mbertheau:

(cons
  "begin"
  (for [letter ["a" "b"]
        num    [1 2]]
    (str letter num)))

mbertheau09:09:45

@danielcompton: I cannot express computing the elements from the letters as an additional iteration in (for) in my case

mbertheau09:09:24

For every element in ["a" "b"] I must return in fact three elements that should end up in the vector.

mbertheau09:09:39

@danielcompton: I simplified the case here.

danielcompton09:09:49

I don’t quite follow, can you give the full case?

mbertheau09:09:21

(Any other recommendations and hints to improve this code are very welcome as well simple_smile )

mbertheau09:09:55

@danielcompton: I find this code quite unreadable and am trying to improve it.

danielcompton09:09:34

@mbertheau: I find it a little hard to read too simple_smile First thing to do is probably to factor that out into several functions that can be called. I’m not able to run it because it’s depending on reframe and bare-input. If you’re able to make a slightly more minimal reproduction case I might be able to understand it better and help.

mbertheau09:09:35

@danielcompton: I updated it, should be free of dependencies now.

mbertheau09:09:38

Thanks for your effort!

mbertheau09:09:18

Ok, just replacing bare-input with map didn't work, sec.

mbertheau09:09:55

I have an idea for a vastly simpler case for illustration.

danielcompton09:09:10

gotta run sorry

colin.yates10:09:17

@mbertheau: I am only scanning and need to run as well but that second (into (apply concat)) seems like mapcat might be useful there

bhauman10:09:02

@shofetim: please file an issue

juhoteperi12:09:12

Does anyone have examples of using goog.editor with ClojureScript? I would be especially interested in bindings for any React wrapper

juhoteperi12:09:55

I already have somewhat working version: https://gist.github.com/Deraen/930022461005a9625f1b but before I finalize the bindings for Reagent I would like to hear if someone already has done this

afhammad12:09:40

What does the consumption of ClojureScript libs from Javascript look like? Is it just a matter of explicitly exporting friendly names (like mori does)? Can this be automated with metadata?

hmadelaine13:09:54

Hi @dnolen thank you very much for sharing your om-next-demo simple_smile This is very instructive to read the source. I guess it is a read-only and not meant to be run ? I tried to build it and overcome some issues : changed ring handler namespace in

project.clj
. I have used the
script/brepl.clj
to build the app.js but now I have issues when interacting with the app :
mutation does not supply :action

canweriotnow13:09:22

Is it possible I missed a change to lein-cljsbuild? for some reason lein uberjar deletes my compiled cljs before anything else, even though :jar true is in the build profile used when I compile my cljs with lein cljsbuild once release

bostonaholic13:09:26

@canweriotnow: do you have

:profiles {:uberjar {:hooks [leiningen.cljsbuild]}}

canweriotnow13:09:46

nope... could be the problem simple_smile

canweriotnow13:09:12

If I have multiple build configurations, do I need to pass that in as well?

bostonaholic13:09:11

I ran into this before and if I recall, it defaults to using the first build profile you have defined for cljsbuild

canweriotnow13:09:22

or does it match the build id to the profile used

canweriotnow13:09:49

ah, okay, Ill just reverse the order so my release build is listed first and my dev build is last.

bostonaholic13:09:09

yeah, that's what I had to do, if my memory serves me

canweriotnow13:09:20

my memory often serves no one, lol

canweriotnow14:09:13

I'll let you know how it goes. Trying now.

canweriotnow14:09:32

I think it's working...

canweriotnow14:09:30

Okay, it did indeed pick up the first defined build profile...

canweriotnow14:09:22

Ah, almost, but I think the problem is my fault...

Successfully compiled "resources/public/js/app.js" in 107.026 seconds.
Uberjar aborting because jar failed: duplicate entry: clerestory/history.cljs
Error encountered performing task 'uberjar' with profile(s): 'production'
Uberjar aborting because jar failed: duplicate entry: clerestory/history.cljs

canweriotnow14:09:55

Or actually I can blame my coworker for this one 😄

bostonaholic14:09:46

looks like you're getting close

canweriotnow14:09:46

Yeah, find . -iname history.cljs only shows one file, so I'm a little confused... maybe there's a cljc of the same name? Hmm...

bostonaholic14:09:33

you may need to :clean-targets ^{:protect false} [:target-path :compile-path "resources/public/js"] so that lein clean will remove the compiled js

martinklepsch14:09:48

@afhammad: (defn ^:export add-numbers [a b] (+ a b)) — are you asking about the automatic insertion of ^:export?

canweriotnow14:09:56

Huh, I thought I actually had that already... lemme check...

canweriotnow14:09:58

It's in there... cleaning and running again...

bostonaholic14:09:20

@canweriotnow: if you lein clean can you verify that it is cleaning everything you need it to?

canweriotnow14:09:16

λ derpy clerestory → λ git master* → lein clean
λ derpy clerestory → λ git master* → ls resources/public/js
shiv.js

canweriotnow14:09:26

No compiled cljs present

bostonaholic14:09:28

what about find . -name "*.cljs" to see if history.cljs exists multiple places

canweriotnow14:09:34

λ derpy clerestory → λ git master* → find . -name "*.cljs" |grep history
./src/cljs/clerestory/history.cljs

juhoteperi14:09:17

run the find after running cljsbuild, it probably copies the cljs files to output-dir for source-maps

canweriotnow14:09:42

λ derpy clerestory → λ git master* → find . -name "*.js" |grep history
./resources/public/js/out-release/clerestory/history.js
./resources/public/vendor/moment/tasks/history.js
But that shouldn't matter since it's an external js file, should it?

juhoteperi14:09:46

Hmh, and if the cljs files were inside resources/public/js/ they wouldn't be duplicate as they would be in different path

canweriotnow14:09:16

I don'toutput source-maps for prod

canweriotnow14:09:36

only dev and staging

bostonaholic14:09:26

I would try removing ./resources/public/js/out-release manually, maybe something got out of sync when changing the cljsbuild configs?

tabrez14:09:58

modern-cljs is very outdated and Etudes for ClojureScript returns 404 page, why are they not edited out from ClojureScript wiki home page?

canweriotnow14:09:06

mm, verified that lein clean is removing everything...

canweriotnow14:09:23

Ah... I may have something...

tabrez14:09:15

I have removed Etudes for ClojureScript link, hope a drone won't burn down my house in the night.

canweriotnow14:09:54

This has all happened before...

canweriotnow14:09:04

compiling now...

bostonaholic14:09:55

heh, you can see my comment is the last one

bostonaholic14:09:15

about the order of build targets

canweriotnow14:09:36

I still had :jar true in my build target, hopefully that's it

bostonaholic14:09:47

ah, yeah I don't have that

dnolen14:09:31

@tabrez: thanks for removing the dead link, tending the wiki is a community effort.

dnolen14:09:14

@tabrez: I haven’t look at modern-cljs in a while, is the issue simply that it refers to older versions of Clojure & ClojureScript?

bostonaholic14:09:15

@canweriotnow: which version of lein-cljsbuild?

dnolen14:09:11

@hmadelaine: it’s probably possible to run it via lein but I haven’t bothered setting that up, I’m just doing everything with a REPL at the moment since it’s changing so much. You can switch into todomvc.server and run the top expressions in the comment in the bottom. Then launch script/repl.clj, I just do that via Cursive.

dnolen14:09:36

@afhammad: that’s a use case that’s just not well supported unless it’s OK that cljs.core gets included into your module. Any ClojureScript library is going to be at lesat 30-40K gzipped (this is the case for Mori for example). But yes, if you want to do this use ^:export or goog.exportSymbol directly.

tabrez14:09:57

@dnolen: The last commit in modern-cljs was two years ago! The version numbers are old, the cljsbuild format in project.clj is outdated, there's no clean task in cljsbuild anymore. Just the first tutorial needed a bunch of changes which a new user is never going to figure out.

dnolen14:09:52

@tabrez ah, k, so I would move it down the list and put (Old) by the link for now.

tabrez14:09:20

@dnolen: Sounds great.

afhammad14:09:11

@dnolen: yeh its fine if cljs.core is included. looks like ^:export is what i need. thanks

afhammad14:09:25

@martinklepsch: thanks, wasn’t aware of the ^:export metadata.

afhammad15:09:58

@dnolen. lets say i want to export multiple separate libs that will be loaded optionally on the same platform, is it possible to compile cljs.core on its own and the libs that depend on it separately so that it is not downloaded with each lib. I’m not even sure I need this yet but just looking at my options.

martinklepsch15:09:06

@afhammad: probably something like this could be achieved with closure modules?

afhammad15:09:58

@martinklepsch: possibly, i’ll look into that.

canweriotnow15:09:40

@bostonaholic: success! key was using :prep-tasks instead of :hooks - found this: https://github.com/emezeske/lein-cljsbuild/issues/366

canweriotnow15:09:52

See @cemerick's comment at the end...

bostonaholic15:09:28

oh, interesting

canweriotnow15:09:41

Should also fix your issue with selecting the cljsbuild, I was able to do this: :prep-tasks ["compile" ["cljsbuild" "once" "release"]]

bostonaholic15:09:53

I wonder if this is new in 1.1.0, all my projects are on 1.0.6 at the moment

bostonaholic15:09:32

probably not, opened in feb.

canweriotnow15:09:49

I don't think so, I think that's a striaght leiningen thing, orthogonal to cljsbuild?

bostonaholic15:09:59

thanks for adding to my TODO list @canweriotnow 😜

dnolen15:09:02

@afhammad: you can do code splitting but to be clear it’s not what people of think of them when they think of modules

canweriotnow15:09:34

@bostonaholic: thank YOU, would have taken MUCH longer to track that down without your help!

dnolen15:09:46

@afhammad: the splits can only work with each other (i.e. you could not swap in a different core or anything like that) and the sub module parts of the split are unusable without the base modules.

bostonaholic15:09:55

@canweriotnow: not a problem. happy I could help!

dnolen15:09:09

@afhammad: in general the weakest part of the ClojureScript story is creating a module for client-side JavaScript users. And that’s unlikely to ever change due to the Closure compilation strategy.

afhammad15:09:34

@dnolen: in my case its not so much a public lib that others will use in their apps. More of a framework that can be used (from JS) to build mini apps that will be compiled and run in a controlled environment, hence the need/want to share the core, but its not a deal breaker.

dnolen15:09:38

@afhammad: if you’re building a framework-y thing then of course much less of issue

mbertheau15:09:43

@danielcompton: Thanks! That pushed me in the right direction.

ddellacosta16:09:42

I can’t get CLJS to load in IE9, anyone had this issue? ClojureScript could not load :main, did you forget to specify :asset-path?

ddellacosta16:09:37

strange how it’s inconsistent depending on environment though…hrm

dnolen16:09:43

@ddellacosta: when using :main with :none we load via document.write

dnolen16:09:06

is the relevant code, we might be doing something wrong, but easy to test this by dropping :main and writing the code by hand and see what’s wrong.

ddellacosta16:09:06

yes, that I figured out—I guess what I was ignorant of is that IE9 doesn’t support this, or is buggy in this case

dnolen16:09:53

don’t have IE9, so happy to take a patch that fixes :main support under :none for it, no doubt something simple

ddellacosta16:09:14

yeah, will poke at it a bit and see what I can figure out. Thanks dnolen

dnolen16:09:10

@ddellacosta: make sure everything about your markup is correct, disable quirks mode (declare HTML doctype) etc.

ddellacosta16:09:25

good points, thanks

dnolen16:09:40

there’s a good chance it’s an HTML issue, pretty sure IE9 is fine w/ document.write + checking if a JS thing is loaded immediately after

meow17:09:19

@mbertheau: I suggest (cons "begin" (conj (into [] (mapcat f [\a \b \c])) "end"))

mbertheau17:09:11

@meow: Thanks. Still seems complicated to me, especially given how clojure is very pragmatic and readable usually. I'd like something like (make-vector ["begin"] (mapcat f [\a \b \c]) ["end"]). I could write that of course.

dnolen17:09:54

`[“begin” ~@(mapcat f [\a \b \c]) “end”]

mbertheau17:09:29

macro splicing! Nice. Thanks! simple_smile

shofetim17:09:58

I couldn't reproduce against the latest version, so whatever it is, looks like you already fixed it simple_smile

danielcompton20:09:24

To make dnolen’s example a little clearer:

`["begin" ~@(mapcat f [\a \b \c]) "end"]

danielcompton22:09:13

@shofetim: Cursive Clojure has refactoring support for ClojureScript, though I don’t think it supports everything in clj-refactor

cfleming22:09:19

@danielcompton: @shofetim: No, it doesn’t, sadly.

danielcompton22:09:45

@cfleming doesn’t support cljs, or doesn’t support everything in clj-refactor?

cfleming22:09:10

It does support cljs, but it doesn’t support everything in clj-refactor, even for Clojure.

cfleming22:09:29

Everything it does support works equivalently in clj and cljs.

shofetim22:09:00

I was thinking that Cursive's support for cljs was limited, I'll have to give it another go.

shofetim22:09:15

(or maybe PR clj-refactor.... emacs is hard to give up)

lvh23:09:09

hm. Requiring [goog.dom.xml :as xml] results in ExceptionInfo #object[TypeError TypeError: goog.dom.xml is undefined] when I try to use it. Isn’t the Closure library supposed to be available by default?

lvh23:09:25

I guess something’s special about goog.dom.xml because goog.math works fine

shofetim23:09:59

is goog.dom.xml in the *bundled* Clojure library? I think an upcoming clojurescript release will bring google clojure up to date.

lvh23:09:35

shofetim: How can I tell?

lvh23:09:41

I mean, it seems like it mightn’t be

lvh23:09:51

I’ve definitely found some code that pretends to be able to require it

shofetim23:09:58

lvh: sorry, I don't know. I recall seeing a bug report about that recently, but now all I can find is this: http://dev.clojure.org/jira/browse/CLJS-535

lvh23:09:41

hm, I see

lvh23:09:48

maybe goog.dom.xml is only in recent versions

lvh23:09:58

doesn’t explain that hickory code though

lvh23:09:10

I pulled in a dependency with an old cljs dep

lvh23:09:12

maybe that’s why