Fork me on GitHub
#clojurescript
<
2016-11-10
>
dbsgtk03:11:17

I'd like to embarrass myself with a newbie question

dbsgtk03:11:16

i have a clojure library that I want to call from a clojurescript (figwheel) front end

dbsgtk03:11:13

i have toyed with standard figwheel template projects, and added the clojurescript and figwheel entries to the project.clj

dbsgtk03:11:40

and copied the standard resource files and core.cljs from a bare fighweel template over to the existing project.

dbsgtk03:11:04

now I start lein figwheel, hoping that it looks like a bare figwheel starter project.

dbsgtk03:11:12

but i'm getting ` Failed to compile "resources/public/js/compiled/pairwise.js" in 16.328 seconds. ---- Could not Analyze ---- /core.cljs is not a relative path`

dbsgtk03:11:39

this is obviously a trivial error on my part. But I don't know what that error is.

dbsgtk03:11:18

That should be: >>Failed to compile "resources/public/js/compiled/pairwise.js" in 16.328 seconds. ---- Could not Analyze ---- /core.cljs is not a relative path

shaun-mahood03:11:49

@dbsgtk: could you post your project.clj? If not, you could try starting again with the figwheel template and see if you can get it working from there.

shaun-mahood03:11:54

You've got a part .core/on-js-reload that I think should be something like pairwise.core/on-js-load

dbsgtk03:11:44

Thank you! I must have missed it when I was editing those sections of the file after copying from the figwheel starter project. 😕

danielstockton08:11:06

Anyone using spacemacs and successfully connecting to a cljs nrepl? I start-figwheel! (scripted) and I see the output Figwheel: Starting nREPL server on port: 7888. When I try to connect to 7888 from spacemacs with cider-connect, it doesn't suggest the port and when I manually enter 7888 it connects to a clj repl (not cljs).

danielstockton08:11:18

I have piggieback and the middleware in my project dependencies

g1eny0ung09:11:03

@danielstockton: I remember the wiki said if you want to connect nrepl manually ,set :nrepl-port __ in :figwheel. And It is easy to start cljsrepl use (cljs-repl)

danielstockton09:11:55

I followed this guide, am using cljs-repl in a script... The repl itself is fine, I just can't connect to it from spacemacs

danielstockton09:11:44

(js/alert "test") works at the repl and causes an alert in my browser at localhost:3449, i just want to be able to do the same within the editor

danielstockton09:11:59

I'm wondering if its a CIDER/spacemacs issue

g1eny0ung09:11:07

Maybe you should require your :main key 's value in you repl, I haven't use my laptop now, sorry I can't test whether I said is true:hear_no_evil:

g1eny0ung09:11:39

:cljsbuild :main

danielstockton09:11:25

I start the repl with rlwrap lein run -m clojure.main script/figwheel.clj and pass the cljsbuild options to start-figwheel! in this script

g1eny0ung09:11:41

Try to start repl with cider-jack-in, I didn't try to start the repl according your command....

danielstockton10:11:53

Trouble is, I want it to all be hooked up with figwheel. clojurescript-jack-in will start a separate headless repl

g1eny0ung10:11:12

I know what you mean, I think you can start with lein figwheel in your shell and set :nrepl-port, then use cider-connect-repl to connect you repl

g1eny0ung10:11:18

this is my spacemacs process and I use cider-jack-in, the top is for cider and refacetor middleware, and next is the figwheel server

danielstockton10:11:38

there are so many ways of doing things, you really have to understand how each part works

g1eny0ung10:11:41

I don't have a deep study about *repl start*, so sorry I can't help you more with more info:grimacing:

danielstockton10:11:45

every guide i read does things slightly differently

darwin10:11:14

for conceptual overview, you could try to look here: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md it is not cider/spacemacs specific, but I had to understand whole picture to make Dirac REPL + Figwheel work (the last schema)

danielstockton10:11:23

Thanks, hopefully I can piece it together

cfleming11:11:13

Hi, can anyone help me with executing a CLJS Node application?

cfleming11:11:32

I’m using lein-npm, but the :main functionality doesn’t seem to work.

miikka12:11:55

Is with-redefs supposed to work with advanced compilation?

cfleming12:11:57

Actually, never mind me, I’m incapable of reading documentation.

miikka12:11:01

Oh, right, I'm missing a ^:dynamic

mfikes12:11:01

Congrats to @anmonteiro with Lumo topping HN :)

vikeri12:11:00

I get a strange message from the compiler when trying to compare goog.date.DateTime, try this in planck:

(require '[goog.date.DateTime])
(def d (goog.date.DateTime.))
(< d (goog.date.DateTime.))
It returns true but the compiler throws the following warning: WARNING: cljs.core/<, all arguments must be numbers, got [nil goog/date.DateTime] instead. at line 1

dnolen13:11:28

@vikeri that is expected

dnolen13:11:39

we compile but inform you the code is incorrect

mfikes13:11:44

Yeah, it is essentially a static analysis thing.

vikeri13:11:51

@dnolen @mfikes Alright, so < works for goog.date.DateTime but should not be used?

mfikes13:11:10

The analyzer can see the type of the second argument and thus it can emit a warning. < only works for numbers.

dnolen13:11:15

@vikeri it does not "work"

dnolen13:11:41

if you write that code you are OK with one day that code not working at runtime

dnolen13:11:52

that is the fact that it happens to work is an implementation detail - not a guarantee

vikeri13:11:16

@dnolen Got it, any pointers on comparing date-times? If I extend goog.dateDateTime, adding ICompare, would that make it work properly?

dnolen13:11:42

IComparable is for compare

dnolen13:11:01

it’s simply not possible to overload the numeric operators at this time

dnolen13:11:22

however nothing is stopping you from writing your own arithmetic operators with full overloading

dnolen13:11:36

you can always exclude core defs and def your own

vikeri13:11:27

@dnolen Alright, got it!

mfikes13:11:15

(extend-type goog.date.DateTime
   IComparable
   (-compare [x y] (goog.date.Date/compare x y)))

mfikes13:11:45

Then you can (compare d (goog.date.DateTime.))

vikeri13:11:20

@mfikes And then test that for neg? or pos?. Seems good

mfikes13:11:43

@vikeri Yep. Or if you don’t want to extend, just use it directly, of course

(defn earlier? [x y] (neg? (goog.date.Date/compare x y)))

vikeri13:11:00

:thumbsup:

danielstockton13:11:53

finally managed to get a cljs cider repl working according to https://github.com/clojure-emacs/cider/blob/master/doc/up_and_running.md#using-the-figwheel-repl-leiningen-only but now the figwheel autobuild isn't working 😄

danielstockton14:11:33

ah brilliant, newer versions of figwheel validate the config and don't allow css-output-to from om-css

danielstockton14:11:57

there is a :validate-config false option for that

idiomancy17:11:55

okay, so I know that clojurescript is growing and changing super rapidly, and I've yet to get into it. is Modern-Cljs https://github.com/magomimmo/modern-cljs still the best place to get started?

jrheard17:11:13

if you read that book and work through https://github.com/clojure/clojurescript/wiki/Quick-Start , and look up figwheel and reagent, i think that’d be a good foundation

jrheard17:11:34

i haven’t looked at modern-cljs, it could be better than the setup i suggest above

idiomancy20:11:17

is the situation with lein really so bad that boot is necessary?

idiomancy20:11:03

Cursive for IntelliJ, my preferred editor, is all very leiningen based, so I really dont want to use boot.

thheller20:11:23

@idiomancy I have been doing CLJS/CLJ for over 3 years now and never had a problem with lein, never had a reason to even look at boot. quite happy with lein.

idiomancy20:11:58

Cool. Learning the boot stack is real frustrating. Have you been doing figwheel/react stuff?

thheller20:11:12

ah hehe should have mentioned that I use my own cljs tooling .. so no to figwheel

idiomancy20:11:09

ah, interesting. I mean I love clojure so i'm not opposed to building tooling, but the problem is my whole career has been backend focused, so I dont have a lot of front-end experience to draw from when setting stuff up

thheller20:11:15

lein-cljsbuild was very frustrating but haven't used it since basically ever

idiomancy20:11:31

makes sense.

thheller20:11:39

what are you trying to do?

idiomancy20:11:48

lern 2 frontend

idiomancy20:11:01

without learning javascript.

thheller20:11:16

that is going to be tough

idiomancy20:11:43

yeah. I believe it. I mean, to the degree that one can. Its like learning clojure without java

thheller20:11:45

some stuff you just need to know

idiomancy20:11:51

you just have to know what you have to know.

idiomancy20:11:12

I want to learn enough javascript to let me use clojurescript and no more.

thheller20:11:14

nah you can get a lot further in clojure without java

thheller20:11:09

well depends on how many java APIs you want to use

thheller20:11:20

but you can certainly built entire projects without any java

idiomancy20:11:31

but the same is not true for clojurescript/javascript?

markx20:11:57

it really depends on what your project is

thheller20:11:03

well as soon as you touch anything javascript native (like the DOM)

thheller20:11:09

you gonna need some JS basics

markx20:11:28

I just got bitten there.

idiomancy20:11:42

okay. by "not learn javascript" I meant "not learn javascript web frameworks"

idiomancy20:11:15

I know basic rules about function scope and prototype chains etc for your run of the mill javascript stuff

idiomancy20:11:21

but I don't know the web stack

thheller20:11:44

well there are many popular cljs web things like reagent or om

thheller20:11:55

they all should work without much js knowledge

thheller20:11:24

but I find myself using js interop a lot more in cljs than I otherwise would in clj

thheller20:11:47

but I frequently do low lvl stuff ... so I'm sure you can get quite far without it

rads20:11:51

if nothing else, learn React

idiomancy20:11:55

Hmm. Well, I guess I'll keep working through these books. An aside, @thheller you said you dont use boot, but @markx do you know if theres a boot new <project> equivelant of lein?

markx20:11:38

@idiomancy I don’t know. I haven’t tried boot.

rads20:11:50

never used it. I just start with a single build.boot file and add things as I go

idiomancy20:11:14

cool, I'll give that a shot

idiomancy20:11:19

well, both, i suppose

thheller20:11:38

figwheel has pretty good documentation

thheller20:11:55

so the amount of JS you need to learn should be the same no matter the tool used

magomimmo20:11:50

@idiomancy I switched to boot from lein mainly because it let me use one JVM only for all the stuff. Then, I never hade the time to keep updated both the boot and the lein version of the modern-cljs series. Unlikely I have no time to keep modern-cljs updated as well. Anyway, there is still the old modern-cljs version available in the git repo which is based on lein and cljsbuild, but it’s even older than the boot one. https://github.com/magomimmo/modern-cljs/tree/master/doc/first-edition

idiomancy20:11:14

gotcha. I think the problem is mostly personal attachment to my intelliJ tooling that I need to just get over.

idiomancy20:11:58

looks like some other curmudgeons have gone and hacked it for me

idiomancy20:11:12

by the way, youre the bomb. Your guide is awesome. I hope you know that!

idiomancy20:11:20

Thanks for making it!

magomimmo20:11:21

@idiomancy I tried to leave emacs more times, but my fingers do not agree 🙂

idiomancy20:11:49

@magomimmo I just got hired by a shop that "encourages" uniformity in dev environments, and they're a mac/emacs shop

idiomancy20:11:02

so I'm going to get dragged kicking and screaming into the emacs world

dominicm20:11:59

Switch to vim and them who's boss