Fork me on GitHub
#clojurescript
<
2017-12-12
>
Jon04:12:21

bad docs though, I learnt most of its features by asking thheller with GitHub issues or even privately on Slack

ampersanda09:12:56

Greetings, Is there a Rum channel or this channel include of it šŸ™‚ ?

ampersanda10:12:54

@tonsky: thank you "creator" šŸ™‚

kurt-o-sys17:12:54

Hey all... I'm trying to add a react library/component to a cljs/re-frame project. This is how far I got now: in project.clj:

:compiler     {...
                                                    :install-deps         true
                                                    :npm-deps             {"react"           "16.2.0"
                                                                           "react-flatpickr" "3.6.3"}}}
 
That seems to work fine (starting lein figwheel dev results in a new directory node_modules, so it seems the deps are downloaded.

kurt-o-sys17:12:37

In my namespace where I want to add the component:

(:require ...
            ["react-flatpickr" :as flatpickr]
 
No error, so it means it is somehow recongized. But now I'm stuck...

kurt-o-sys17:12:52

I can't seem to do anything with flatpickr

tungsten17:12:32

@kurt-o-sys why not use cljsjs

kurt-o-sys17:12:25

because that react component is not there

kurt-o-sys17:12:37

It has flatpickr, not react-flatpickr.

kurt-o-sys17:12:38

I tried to make a reagent component, but failed so far. However, since the react component already exists, I thought it would be fairly straight forward to import it... šŸ˜›

tungsten17:12:30

it should be

kurt-o-sys17:12:55

Well, I can't find react-flatpickr in the cljsjs libs.

kurt-o-sys17:12:51

(Also, I thought it would be straight forward to add existing react components to reagent, and I feel I'm really close, but I'm not sure what I'm overlooking)

tungsten17:12:53

when you do this kind of interop you don't use :require like you are

tungsten17:12:00

you just require the library

tungsten17:12:06

and then you access the javascript global

kurt-o-sys17:12:11

right... I saw it like that somewhere (and it's the closest I've been - i.e. no warnings or errors šŸ™‚ ). But I can try again doing it differently. So, you mean I have to use (js/require ...), right?

tungsten17:12:41

You should watch the video I linked to above

tungsten17:12:12

you just directly access the JS globals as needed

kurt-o-sys17:12:16

I saw the video's, I'm busy for about 2 days trying all these things to make it work, and I can't make it work... If anyone can walk me through this or help me out, that would be nice.

scknkkrer17:12:01

So silly question but, how can I require my npm deps in cljs ? I have found a doc but itā€™s not working. https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules What have I miss ?

kurt-o-sys17:12:51

that's exactly my question šŸ™‚

scknkkrer17:12:04

OMG. Sorry bro.

scknkkrer17:12:11

I didnā€™t see your question.

kurt-o-sys17:12:23

I can't make it work properly either.

scknkkrer17:12:02

Guys, what have we missed ?

kurt-o-sys17:12:55

it seems people don't seem to know šŸ™‚.

scknkkrer17:12:29

Guys, is it obvious ?

nha18:12:48

some libs are already packaged- http://cljsjs.github.io this predates https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules (havenā€™t had a chance to try it yet)

nha18:12:57

but I know cljsjs works well

nha18:12:39

ah right - seeing your messages above

scknkkrer18:12:43

I tried itā€™s not working.

nha18:12:46

ā€œnot workingā€ is a bit vague though? I mean there are probably people in this channel that could help given more information

kurt-o-sys18:12:42

right... agreed. What should we try first? (That may be faster, than retrying what we/I tried already) It's about adding an existing npm module to a cljs project.

nha18:12:24

Never used it myself. But you have the latest clojurescript stable, :npm-deps, maybe :install-depsand no compiler error?

nha18:12:42

using simple compilation?

kurt-o-sys18:12:44

well, I don't have a compiler error using :npm-deps.

kurt-o-sys18:12:02

that seems to work fine (different node_modules are installed)

kurt-o-sys18:12:49

just not sure how to proceed afterwards ["react-flatpickr" :refer [Flatpickr]] doesn't give any compile time error

kurt-o-sys18:12:59

but I can't seem to use it.

nha18:12:00

["react-flatpickr" :as flatpickr] does printing flatpickr give anything?

kurt-o-sys18:12:11

so it may be better to do it the other way: can someone explain how to add external npm modules to a project?

kurt-o-sys18:12:33

well, did that before, until someone told me to put :refer šŸ™‚

scknkkrer18:12:16

OMG. It works in clean project. I think, I have to look at my project deeply.

noisesmith18:12:08

@kurt-o-sys :refer and :as are allowed together, I only suggested :refer because thatā€™s how your working example was doing it

kurt-o-sys18:12:04

right... I know they are allowed together. I'm just wondering if there's a step by step guide somewhere. I haven't found one that works yet.

scknkkrer18:12:44

I just update my figwheel dep and it worked for left-pad dep. But react-markdown still doesnā€™t work.

kurt-o-sys18:12:16

@scknkkrer something like this:

:devcards    {:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
                                     :figwheel     {:devcards true}
                                     :compiler     {:main                 "ui-app.cards"
                                                    :asset-path           "js/devcards_out"
                                                    :output-to            "target/cljsbuild/public/js/app_devcards.js"
                                                    :output-dir           "target/cljsbuild/public/js/devcards_out"
                                                    :source-map-timestamp true
                                                    :optimizations        :none
                                                    :pretty-print         true
                                                    :install-deps         true
                                                    :npm-deps             {:react-flatpickr "3.6.3"}}}
?

kurt-o-sys18:12:50

(I changed the string with a keyword now, just trying all kinds of stuff, all things that are scattered around the internet :p)

adamvh21:12:32

if i have figwheel going and i add a dependency to project.clj, do i need to restart figwheel to have that dependency available?

noisesmith21:12:26

thatā€™s been my experience, yes

mfikes22:12:01

The underlying mechanism is that by adding a dependency you essentially need to add a new JAR to the classpath.

mfikes22:12:36

While there are ways to try to do this without restarting, the straightforward solution is to stop and start a new JVM with the new classpath.

martinklepsch22:12:28

Iā€™m looking for a large-ish real-world OSS ClojureScript projects. Any pointers? (large-ish ~= dozens of files / thousands of lines)

Oliver George02:12:47

Does it need to be OSS? I've got 22k lines of SPA using re-frame which has a few years development by a small team.

Oliver George02:12:30

So long as it remains private and our client can see possible benefits (to the community) I can probably share a snapshot.

Oliver George02:12:08

(last time we shared was with the re-frame guys who we thought might be interested in seeing our "scale" pain points)