Fork me on GitHub
#clojurescript
<
2018-05-16
>
theeternalpulse02:05:33

any good examples of a project using figwheel with just cljs?

Oliver George03:05:56

Interesting question. So you mean without something like re-frame. Just reloading namespaces etc.

Oliver George03:05:49

There's not too much to configure or get wrong. I'd say start with the figwheel documentation and try the lein template.

athomasoriginal12:05:05

very simple project: - latest CLJS - pure JS interop - latest figwheel - clj tool (replaces lein/boot for this project)

athomasoriginal12:05:20

When I have time, all the projects in this repo will be converted to a similar setup...although, for how I want these projects to be used, I will likely just use the clj --watch command and drop figwheel...otherwise, should be what you're looking for

theeternalpulse00:05:06

Thanks, I am starting cljs with shadow-cljs, but would like to know some of the other ways outside of the lein/boot env for getting a project up. Very cool

tianshu03:05:45

is the document of npm-deps has been removed from http://clojurescript.org?

tianshu04:05:19

@mfikes thanks, I think what i found is this: https://clojurescript.org/guides/javascript-modules#node-modules it's likely there're some pages about how to use javascript libraries.

andrea.crotti09:05:07

is there a way in a Clojurescript project (using also re-frame and integrant) to load a namespace dynamically?

andrea.crotti09:05:01

it works if I add a require in the cljs file (even if not on top) but not if I add inside a function

andrea.crotti09:05:34

the problem is simply that we have a cljc file with some specs that should always be loaded or funny things happen

joelsanchez09:05:36

I think the answer is simply "you can't", there's some info here regarding the (require outside of ns https://anmonteiro.com/2016/10/clojurescript-require-outside-ns/

joelsanchez09:05:10

anyway, if they need to be loaded, why can't you just require it in the ns form?

andrea.crotti09:05:40

yeah I think that's the real mistake, but it just contains specs and some not namespaced for some reason

andrea.crotti09:05:58

(like :something/blah instead of ::blah)

andrea.crotti09:05:21

so the proper fix would be to change that instead, thanks

👍 4
mfikes12:05:11

@andrea.crotti FWIW, when you add a require in an ns form, the order is honored. So if you need specs to be loaded before some other namespace, you can control that.

igrishaev14:05:41

Hi, did anybody face troubles with an ##Inf tag when compiling cljs? For example:

Parse error. primary expression expected
case ##Inf:
      ^
I’ve found some github/google topics so for, but none of them help. My clojure(script) deps are:
[org.clojure/clojurescript "1.9.908" :exclusions [org.clojure/tools.reader]]
[org.clojure/tools.reader "1.1.0"]
I also tried to use the latest clojuresctip complier but without any result.

dominicm14:05:49

@igrishaev I'm not sure which version of clojurescript introduced ##Inf, but that is worth checking 🙂

mikerod14:05:55

@igrishaev why are you changing the tools.reader version manually?

igrishaev14:05:38

@mikerod it was just another try. The original version of deps are:

[org.clojure/clojurescript "1.9.946"]

igrishaev14:05:26

But still, it doesn’t work. I have a feeling that some legacy version of tools.reader might be used due to multiple dependencies.

mikerod14:05:20

yeah, sounds like it

mikerod14:05:43

this was a common issue that came up with ##Inf was introduced though, probably can find some info out there

igrishaev15:05:13

@mfikes yes, I’ve been on that page. Do you know btw how to check what exact version of a library is used? I guess that something overrides tools.reader

mfikes15:05:54

The answer to that depends on which dependency management tool you are using. (`lein`, boot, clojure / deps.edn)

igrishaev15:05:05

It’s lein; I tried lein deps :tree but a bit confused with its output

mfikes15:05:22

lein classpath will show you the classpath you end up with

igrishaev15:05:21

let me check…

igrishaev15:05:11

I’ve just wiped the whole ~/.m2 folder and the problem has gone.

🎉 4
vinai20:05:23

I'm trying to get :infer-externs to correctly recognize the method .createToken as an extern. My code is

(defn- submit [stripe card token-callback]
  (fn []
    (-> ^Promise (.createToken ^js/Stripe.stripe stripe card)
        (.then (fn [^js/Stripe.result result]
                 (let [msg (error-message result)]
                   (dispatch [::set-stripe-error msg])
                   (when-not msg (token-callback (.. result -token -id)))))))))
(set! *warn-on-infer* true) doesn't warn about it with the type hint, but when I build I get the error TypeError: $stripe$$.$createToken$ is not a function Any tips why type inference isn't working there?

dnolen21:05:48

@vinai did you try master? I fixed a few things around externs inference recently

vinai21:05:20

No, this is 1.10.238

dnolen21:05:29

give master a spin to see if it’s still an issue

dnolen21:05:36

I’ll probably cut a release this Friday

vinai21:05:54

I got it working with a manual externs file, but I'll try master now to see if inference works there.

dnolen21:05:02

great thanks much

dnolen21:05:32

if you can’t get it to work then that’s another thing for me to tweak, I was just recently working on it so I can add a new test case

vinai21:05:48

Can I depend on master in a leinigen project.clj?

vinai21:05:57

Got a pointer?

dnolen21:05:07

with a checkout yes - but it’s way easier with clj tool

dnolen21:05:23

just a make a deps.edn with your deps and build

dnolen21:05:31

Quick Start covers the details

vinai21:05:43

Okay, might as well try

darwin21:05:13

@vinai for ad-hoc clojurescript master testing with lein I usually delete particular version from ~/.m2, then clone clojurescript repo, edit project.clj there to match my version (`1.10.238` in your case) and do lein install, this should put clojurescript master in place of 1.10.238 on your machine.

darwin21:05:00

better not to forget about this, so you won’t report confusing bugs

vinai21:05:15

@darwin You clone it into the original place in ~/.m2?

Alex Miller (Clojure team)21:05:34

why not just edit the project.clj to a unique value (1.10.238.mine-1)?

darwin21:05:38

no, lein install in clojuescript repo will build clojurescript and install it locally into m2

Alex Miller (Clojure team)21:05:51

then use that value instead

Alex Miller (Clojure team)21:05:14

m2 repos should be like immutable y’know? ;)

darwin21:05:17

@alexmiller yes, that’s a better solution, but one more step 🙂

Alex Miller (Clojure team)21:05:33

until you mess it up and lose a day debugging it

Alex Miller (Clojure team)21:05:43

then it’s 1000 fewer steps

12
vinai21:05:43

let me try that - will be quicker than building up the deps.edn (even though I'm 1/3 done with that).

Alex Miller (Clojure team)21:05:07

(this is how I sometimes test local clojure builds btw)

Alex Miller (Clojure team)21:05:20

you can actually do even better if you’re doing deps.edn though

Alex Miller (Clojure team)21:05:29

by making an alias that uses :classpath-overrides to swap out the mvn jar for own local one

Alex Miller (Clojure team)21:05:14

{:aliases :dbg {:classpath-overrides "path/to/clojurescript.jar"}}

Alex Miller (Clojure team)21:05:19

if you always do your local build in the same place then you can put this in your ~/.clojure/deps.edn instead and then anytime you want to test with a local build, you can -A:dbg with 0 steps

👍 4
vinai21:05:07

Creating ~/.m2/repository/org/clojure/clojurescript/1.10.238-mine.1 worked fine, but when I try to build my project I get an java.lang.IllegalArgumentException: Not a file: jar:file:/Users/vinai/.m2/repository/org/clojure/clojurescript/1.10.238-mine.1/clojurescript-1.10.238-mine.1.jar!/cljs/util.cljc

vinai21:05:36

The file /Users/vinai/.m2/repository/org/clojure/clojurescript/1.10.238-mine.1/clojurescript-1.10.238-mine.1.jar does exist though.

vinai21:05:43

Back to deps.edn

Alex Miller (Clojure team)21:05:41

does jar tf /Users/vinai/.m2/repository/org/clojure/clojurescript/1.10.238-mine.1/clojurescript-1.10.238-mine.1.jar | grep util find util.cljc? maybe it’s not built right?

vinai21:05:38

Jup, it's here

vinai21:05:53

% jar tf /Users/vinai/.m2/repository/org/clojure/clojurescript/1.10.238-mine.1/clojurescript-1.10.238-mine.1.jar | grep util
cljs/analyzer/utils.clj
cljs/util.cljc

vinai21:05:58

Is infer-externs always enabled with when building with clj -m cljs.main --optimizations advanced?

vinai21:05:17

How can I supply compiler options?

darwin21:05:00

clj -m cljs.main --help opts you put after cljs.main are for cljs

darwin21:05:40

e.g. --compile-opts

vinai21:05:54

That helps!

vinai22:05:35

Error building classpath. Unknown coordinate type for org.clojure/clojurescript: {:git/url "", :sha "78753d376d5bfe9afd1dbb98eea15fd5bd312255"}

vinai22:05:18

Somehow I'm off track... I guess I need some sleep. Sorry I wasn't more helpful checking out master works, will give it another try with a fresh brain tomorrow.