Fork me on GitHub
#clojurescript
<
2016-10-25
>
tianshu03:10:10

sometimes it's really hard to find the js/NAME after require some foreign js libraries.

alex-glv08:10:27

I noticed I often have of issues with the tooling and once things go astray it takes a lot of effort to fix.. Nrepl, Figwheel, Piggieback, Austin. I’d like to keep things to the minimum without sacrificing convenience (autocomplete, cljs repl). Any suggestions on the workflows? Maybe sample projects I could use as a reference?

slipset08:10:55

@dnolen the “Getting Started” link on http://clojurescript.org/guides/guides returns a 404

Pablo Fernandez09:10:02

I created a library called free-form and it has a namespace called free-form.re-frame but a project using this library cannot find it. I get this error: No such namespace: free-form.re-frame, could not locate free_form/re_frame.cljs, free_form/re_frame.cljc, or Closure namespace "free-form.re-frame"

hlolli09:10:12

Its looking for source directory free_form, do you have it?

Pablo Fernandez09:10:03

@hlolli it’d be in the library I’m using, not in the current project.

Pablo Fernandez09:10:38

Interestingly, Cursive doesn’t seem to see the library either.

hlolli09:10:16

How did you create your library, could it be that the namespace name was incorrectly created against your source structure?

hlolli09:10:42

Dont see anything either. Must be something so simple that is being overseen. If the library compiles correctly and is in your dependencies, it should be fine. Did you add this to clojars?

Pablo Fernandez09:10:05

How do I install a jar in my local system? To debug how i’m packaging it.

hlolli09:10:38

With leiningen you can add a jar to source path (with boot I've had some diffuculties with that).

hlolli09:10:07

:src ["src/cljs" "dir/jarfile.jar" ..etc...]

thheller09:10:33

@pupeno the sources are in the wrong directory in the jar

thheller09:10:59

add :source-paths ["src/cljs"] to your project.clj

thheller09:10:09

then release the jar again

thheller09:10:23

~/.m2/repository/com/pupeno/free-form/0.4.0]$ jar -tvf free-form-0.4.0.jar
   119 Mon Oct 24 10:56:24 CEST 2016 META-INF/MANIFEST.MF
  2722 Mon Oct 24 10:56:24 CEST 2016 META-INF/maven/com.pupeno/free-form/pom.xml
  1195 Mon Oct 24 10:56:24 CEST 2016 META-INF/leiningen/com.pupeno/free-form/project.clj
  1195 Mon Oct 24 10:56:24 CEST 2016 project.clj
  9535 Mon Oct 24 10:56:24 CEST 2016 META-INF/leiningen/com.pupeno/free-form/README.md
 11218 Mon Oct 24 10:56:24 CEST 2016 META-INF/leiningen/com.pupeno/free-form/LICENSE
     0 Mon Oct 24 10:56:24 CEST 2016 META-INF/
     0 Mon Oct 24 10:56:24 CEST 2016 META-INF/maven/
     0 Mon Oct 24 10:56:24 CEST 2016 META-INF/maven/com.pupeno/
     0 Mon Oct 24 10:56:24 CEST 2016 META-INF/maven/com.pupeno/free-form/
   147 Mon Oct 24 10:56:24 CEST 2016 META-INF/maven/com.pupeno/free-form/pom.properties
     0 Mon Aug 15 19:12:48 CEST 2016 cljs/
     0 Mon Oct 24 10:38:38 CEST 2016 cljs/free_form/
  6938 Mon Oct 24 10:38:38 CEST 2016 cljs/free_form/core.cljs
   593 Mon Aug 22 18:50:56 CEST 2016 cljs/free_form/re_frame.cljs

thheller09:10:32

cljs/free_form/core.cljs

Pablo Fernandez09:10:40

@thheller I was just trying that fix… thanks for confirming.

thheller09:10:55

because the standard :source-paths is src

Pablo Fernandez09:10:56

Now I’m wondering… how did this ever worked. Because it used to work.

thheller09:10:44

the cljsbuild config has the :source-paths but that does not affect lein jar

Alex Miller (Clojure team)13:10:42

@slipset that's weird - I will fix that

slipset13:10:11

I made an issue of it on github.

slipset13:10:30

Am at #euroclojure right now, so not in position to propose a solution 🙂

Alex Miller (Clojure team)13:10:25

fix deploying now - that page was from the clojure site and never got updated

Alex Miller (Clojure team)13:10:17

actually, that page should never show up as it should get covered by a redirect, however the prior build failed so was only partially deployed (did not get to installing the redirects), which was a good thing to catch. I’ve installed the same automatic retry logic I use on the clojure site for the case of intermittent AWS failures so this won’t happen again.

gowder17:10:58

out of curiosity, has anyone worked with jstat before? I'm trying to get it to play nice with cljs and not having any luck, even when I drop down to native js arrays. e.g.:

(def test-mini (js/jStat (array [[1 2] [3 4] [5 6]])))
(.log js/console (.dimensions test-mini))
returns {rows: 1, cols: 1} -- which is obviously incorrect. Working w/o any compiler optimizations...

thheller17:10:56

@gowder the inner vectors are still vectors

thheller17:10:35

no idea what jStat is but you probably want #js [#js [1 2] #js [3 4] #js [5 6]]

thheller17:10:47

or just use clj->js

sekao17:10:12

if I have a page that includes two separate files compiled via clojurescript, is there a way for one to get access to the namespaces and vars of the other? assume they are both compiled with :optimizations :none but are compiled completely separately.

gowder17:10:38

Ooooh thanks @thheller --- bet that will solve it. (jStat is a js stats library. I'm messing around with in-browser data analysis)

jrheard17:10:42

@gowder - clj->js is super-handy for investigative/exploratory situations like the one you’re currently in, where you’re just trying to get something working quickly+simply, but FYI it’s slow when called a bunch of times in a tight loop, so just remember i said this if you start pumping a ton of data into your project and notice it has frame rate issues 🙂

jrheard18:10:16

(chrome devtools’ profiler is super-great for tracking down performance issues)

gowder18:10:10

Hah yeah, good call @jrheard --- I'm not really loving all this interop in general, thinking I might just roll my own stats

jrheard18:10:12

if you’ve got the time and want to have that experience, goforit! there are a ton of js stats/graphing/etc libraries, though, and once you get used to it, js interop isn’t all that paintful 🙂

jrheard18:10:18

agreed that it feels clunky at first

jrheard18:10:24

but anyway do what you see fit, have a great time, glgl

gowder18:10:57

heh thanks. I'm poking around right now, and yeah, it doesn't look like there's a good pure cljs matrix algebra solution (not a ton of full-featured core.matrix impls I can find on the js platform), and while I've rolled a little bit of stats on my own, it's only been in python where numpy is available... not all that excited about rolling my own matrix algebra library to avoid interop!

gowder18:10:22

also pretty sure any perf loss I'm giving up messing around with stuff like clj-js would be nothing compared to the perf loss from trying to write my own matrix math

jrheard18:10:22

have you seen https://github.com/mikera/core.matrix ? says it supports clojurescript

jrheard18:10:13

found via the math section of http://www.clojure-toolbox.com/ (it’s missing the cljs tag on that site)

gowder18:10:17

I think it supports clojurescript in principle, but it looks like it requires a pluggable implementation, and the one I can find doesn't have much of the math defined. might be misreading the code though...

jrheard18:10:27

ah, gotcha

jrheard18:10:56

i don’t know much about matrix algebra in any context, much less cljs, so i’m not very helpful here :’(

gowder18:10:05

although come to think about it, I'm poking around in the core.matrix code again and it looks like a lot of stuff is in the default implementation... so maybe the math is there! that would be exciting 🙂

gowder18:10:13

(clearly the answer is to try some experiments...)

mping19:10:27

Hi all, I'm playing with this: https://github.com/martinklepsch/electron-and-clojurescript and I'm trying to use a nodejs lib for the main electron process, but it seems I cannot use node's require. Is this possible?

csm19:10:49

@mping cljs.nodejs/require?

csm19:10:24

Is it possible to find the jar file a cljs file lives in? Possibly with lein’s help?

csm19:10:15

what I’m really after is a cljs analog to http://clojure.java.io/resource