Fork me on GitHub
#clojurescript
<
2018-05-28
>
aaron5100:05:49

Why can’t a MetaFn be used inside a js-obj? Seems like only js/Functions are allowed in a js-obj? ((I’m trying to use an alexanderjamesking/spy spy inside a js-obj)

aaron5100:05:04

Ideal code would be (js-obj "addListener" (spy/stub)) But because spy/stub is a MetaFn, you can’t call addListener on the js-obj

aaron5113:05:39

decided to use Sinon 👍

ajk19:05:50

Interesting, I’ll take a look into this, maybe I’ll need a different solution than metadata for cljs then. Thanks for letting me know @U3JH0P5LJ

Bravi11:05:33

hi everyone. if anyone’s using lein + shadow-cljs in their project, may I see the example of project.clj and shadow-cljs.edn please?

Bravi11:05:54

no matter what I do in config files, I get the following

Could not locate clojure/spec/alpha__init.class or clojure/spec/alpha.clj on classpath.

troglotit11:05:32

@bravilogy seems like, you’re requiring clojure.spec.alpha, but in cljs it’s cljs.spec.alpha

troglotit11:05:11

the differences in API described here https://cljs.github.io/api/ and a little bit here https://clojurescript.org/about/differences

Bravi11:05:06

but I’m not manually requiring it anywhere

Bravi11:05:30

it looks like shadow-cljs is requiring it somewhere

thheller11:05:38

@bravilogy clojure 1.9 is required. I suspect you have clojure 1.8?

Bravi11:05:46

oh I see. actually this is my project.clj

:source-paths ["src"]


  :dependencies  [[binaryage/devtools "0.9.7"]
                  [thheller/shadow-cljs "2.3.28"]]

I’m testing it out at the moment and would like to use it with an existing project, so I created the project files from scratch

thheller11:05:11

just add [org.clojure/clojure "1.9.0"] to :dependencies

thheller11:05:41

or just don't use lein at all. then you don't have to worry about such things

Bravi11:05:56

gladly, but my spacemacs goes crazy 😄

Bravi11:05:59

I can’t use some of spacemacs refactoring functionalities if I don’t jack-in repl

Bravi11:05:25

I tried doing it cider/nrepl way but turned into a mess

thheller11:05:08

yeah I never can get emacs working right either 😉

Bravi11:05:46

it’s a shame that there’s no support for shadow-cljs yet 😞

thheller11:05:04

latest version of cider has support built-in

Bravi11:05:23

I mean in spacemacs

thheller11:05:46

does that not use cider?

Bravi11:05:21

oh yeah you’re right

Bravi11:05:07

but whenever I try to use add dependency tool within spacemacs, it specifically requires project.clj

Bravi11:05:52

and the main reason why I decided to switch to shadow-cljs is that I want to use a react-dropzone file uploader in my project 😄

Bravi11:05:02

and it’s so simple to use npm modules

Bravi11:05:21

I haven’t explored other things in shadow-cljs yet

Bravi11:05:39

at the moment, to use that component with with figwheel, I have to yarn add .., then I use webpack to copy the script from node_modules (along with a few other js libraries) and compile it in a single file that I include in my project as a separate <script>

Bravi11:05:53

so basically I’ve got figwheel and webpack running at the same time

thheller12:05:59

yeah thats no fun

Bravi12:05:58

P.S. should I be worried about these?

shadow-cljs - Using IP "192.168.10.1" from Interface "vboxnet0"
May 28, 2018 12:51:12 PM clojure.tools.logging$eval1037$fn__1040 invoke
INFO: Found multiple IPs, might be using the wrong one. Please report all interfaces should the chosen one be incorrect.
May 28, 2018 12:51:12 PM clojure.tools.logging$eval1037$fn__1040 invoke
INFO: Found IP:192.168.10.1 Interface:vboxnet0
May 28, 2018 12:51:12 PM clojure.tools.logging$eval1037$fn__1040 invoke
INFO: Found IP:192.168.1.64 Interface:en0
May 28, 2018 12:51:12 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
May 28, 2018 12:51:12 PM org.xnio.nio.NioXnio <clinit>

thheller12:05:01

not really but I'll add a filter for the vbox stuff so the correct en0 gets picked

Bravi12:05:33

👍 thanks

thheller12:05:33

and bump it down from warning. not really a warning problem

leongrapenthin12:05:47

is there a sample command line for cljs.main with: nodejs target, repl and file watch and compile-opts in a edn file having npm-deps?

leongrapenthin12:05:57

i. e. is this supposed to work at all?

leongrapenthin13:05:38

it seems like the watch is not working. it complains that target is nodejs, but no :main option specified. I have specified a :main option however

Bravi13:05:12

@thheller sorry to bother you again. I’ve just set it up on the actual project and I’m getting the following error in my browser:

browser.cljs:310 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I have a feeling this is to do with
:http-host    ""
         :http-port    8700
in my config. basically I’ve got the server already running through vagrant and I was hoping that it would listen to changes to http-host

thheller13:05:54

happy to answer but lets jump over to #shadow-cljs

scknkkrer13:05:54

I am using clj->js to store my data. But I have to load this data. the keyword values transforms into strings. --Not keys, the values-- Is there easy way to transform these values into keywords ?

scknkkrer13:05:26

I have read something about this topic. But, it says, you can use Prismatic/Schema.

scknkkrer13:05:57

Is there another way to do that ?

troglotit13:05:29

You could use https://github.com/cognitect/transit-cljs if you use serialization just to store it and read it later in cljs

thheller13:05:24

@scknkkrer pr-str and then cljs.reader/read-string also works

🐣 4
leongrapenthin13:05:10

is it standard that I can't require nodejs standard lib in ns require decl anymore?

leongrapenthin13:05:30

(ns my.app (:require [http])) doesnt work

leongrapenthin13:05:45

what is the correct way to do this nowadays?

wilkerlucio13:05:13

@leongrapenthin it's recommended that you use strings to require node namespaces, like (:require ["http" :as http])

thheller13:05:09

well ... I recommend that ... officially symbols are "ok". 😉

leongrapenthin13:05:20

doesnt work nonetheless

rnagpal13:05:00

@scknkkrer Didn’t get your question completely but you can use (js->clj payload :keywordize-keys true) to convert keys into keywords

thheller13:05:46

dont use clj->js if you intend on doing js->clj since that will loose vital info like sets, keywords, symbols

thheller13:05:14

serialize via pr-str or transit

scknkkrer13:05:12

@rnagpal thanks, but I need to transform values, not keys.

scknkkrer13:05:16

But I solved my problem with the pr-str, serialization.@thheller

rnagpal14:05:12

From experience we have seen that transit ser/dser is faster than clj->js/js/cljs

rnagpal14:05:34

how does transit compare to pr-str

leongrapenthin14:05:06

transit is not designed for persisting afaik

souenzzo15:05:27

Where did you see this?

bhauman17:05:41

I thought that transit was used to handle compiler analysis caching, which is persisting eh?

thheller14:05:06

transit is faster

scknkkrer14:05:03

@thheller but how ? Is not the idea behind the Library different ?

thheller14:05:35

the idea is the same: serializing clojure data, implementation details make transit faster in practice. not relevant adding the extra lib unless you are frequently using it though.

troglotit14:05:01

Am I right that read-string is clojure reader, so using it should bring whole compiler to the bundle?

favila15:05:26

should :foreign-libs libraries be consumable from closure js code in a cljs project?

favila15:05:43

my intuition was yes but it doesn't seem to work

favila15:05:57

JSC_MISSING_PROVIDE_ERROR from the closure compiler pointing at the require in my js

thheller15:05:01

@troglotit no read-string is using cljs.tools.reader. so not the full compiler.

thheller15:05:47

@favila pretty sure foreign-libs are never exposed to closure since they are just prepended

favila15:05:27

they have a :provides entry and a goog.addDependency call

favila15:05:00

but it doesn't seem to be visible to cljs :libs

favila15:05:09

or rather, it's only visible in raw mode