Fork me on GitHub
#clojurescript
<
2017-11-17
>
seako03:11:22

anyone found a way to require npm-deps that use export default someName?

seako04:11:03

well, here's a minimal project based off of lein new re-frame that adds react-bootstrap-typeahead to :npm-deps and requires react-bootstrap-typeahead in the views.cljs file https://github.com/seako/react-bootstrap-typeahead-minimal-cljs-example the two errors generated from this minimal example are:

tokenContainer.js:22 Uncaught TypeError: (0 , _reactOnclickoutside2$$module$Users$seako$dev$seako$github_repos$react_bootstrap_typeahead_minimal_cljs_example$node_modules$react_bootstrap_typeahead$lib$containers$tokenContainer.default) is not a function
    at tokenContainer (tokenContainer.js:22)
    at Token.react.js:31
tokenContainer @ tokenContainer.js:22
(anonymous) @ Token.react.js:31
typeaheadContainer.js:48 Uncaught TypeError: (0 , _reactOnclickoutside2$$module$Users$seako$dev$seako$github_repos$react_bootstrap_typeahead_minimal_cljs_example$node_modules$react_bootstrap_typeahead$lib$containers$typeaheadContainer.default) is not a function
    at module$Users$seako$dev$seako$github_repos$react_bootstrap_typeahead_minimal_cljs_example$node_modules$react_bootstrap_typeahead$lib$containers$typeaheadContainer.default (typeaheadContainer.js:48)
    at Typeahead.react.js:32

seako04:11:18

@U0CK4CKAP could you take a look at this? I'd love to be able to figure out a solution that works with the npm deps feature of the cljs compiler

seako04:11:12

in the javascript source of those two name spaces there are exports that look like:

export default tokenContainer(Token);
and
export default typeaheadContainer(Typeahead);
respectively

seako04:11:59

any help you all might be able to provide would be much appreciated

thheller07:11:03

@seako looks like react-bootstrap-typeahead is not compatible with :npm-deps. you can try using shadow-cljs instead. lein new shadow-cljs thing +reagent

seako07:11:33

thanks, i'll give that a whirl

seako07:11:08

is shadow-cljs something used in addition to lein-cljsbuild or instead of?

thheller07:11:23

instead of. standalone build tool.

seako07:11:37

your announcement has a good sales pitch https://groups.google.com/forum/#!topic/clojurescript/oiXKTnJ2r9o now i'm even more intrigued

thheller07:11:10

hehe a lot has happened since then

thheller07:11:28

npm install
npx shadow-cljs watch app
open 

seako08:11:10

hey neat, it works on my machine too

hkjels08:11:36

I’m testing :npm-deps here and would like to require application-insights: https://github.com/Microsoft/ApplicationInsights-JS#readme However, I get the error: Uncaught Error: Undefined nameToPath for applicationinsights_js

hkjels08:11:59

any ideas why?

hkjels08:11:55

The module is downloaded and all

borkdude10:11:50

How do I ask in ClojureScript if something is derefable?

p-himik10:11:30

@borkdude (satisfies? IDeref value), I think.

fbielejec10:11:30

@hkjels using figwheel from emacs/cider by any chance? What if you just lein clean && lein figwheel dev in terminal?

hkjels10:11:46

I was, but it’s the same result from terminal

fbielejec10:11:17

did you include all the dependencies, including peerDependencies? Also confirm that it actually is inside your node_modules

lovuikeng10:11:55

lein deps :tree

fbielejec10:11:36

if all else fails you're better of packaging it as a cljsjs. Which you'd probably have to do anyways for a production build.

risto10:11:08

what happens if you use clj->js with some map that has javascript objects? not simple plain objects, ones that are called with new does it leave those alone or does it end up doing something weird

risto10:11:35

i'm wondering if I need to use #js or if it'll handle those cases ok

hkjels11:11:08

@fbielejec I’ve tried a few different packages now with the same result. Why would you package as a cljsjs in prod? Is :npm-deps just a toy?

fbielejec12:11:49

@hkjels it's an experimental feature. From my experience in most cases it doesn't survive advanced optimization, even with externs. Are you on the most recent toolchain? (clojurescript compiler, figwheel cljsbuild etc)?

mfikes12:11:43

@risto If values, such objects pass through. You can see this if you do (source clj->js): Map values have cljs->js applied to them, and you can see that the if/cond will bottom out in an :else x. On the other hand, if the objects are keys, then key->js comes into play, and from its implementation you can see that they will be converted to strings via pr-str.

mfikes13:11:48

The #js tag can be used at compile time to create JavaScript object literals. If you already have a JavaScript object being produced at runtime via new, then no need to consider #js (it is actually too late at that point).

risto13:11:01

the use case I have is something like: var Foo = function() { ... } { :foo { :bar (new Foo) } }

risto13:11:21

i'm wondering if it'll treat Foo as a map and try to parse it

risto13:11:19

you're saying it won't right? because it's not a clojurescript type, it's not keyword?,`symbol?`, map? or coll? so it hits :else and is left unchanged right?

mfikes13:11:27

Right. For example (clj->js {:foo {:bar (new Uri "")}}) yields #js {:foo #js {:bar #object[Object ]}}

mfikes13:11:52

By the way, instead of (new Foo) you can write (Foo.). I think the latter is more prevalent.

risto13:11:17

thanks 🙂

mfikes13:11:50

No problem. If you (macroexpand '(Foo.)), you will get back (new Foo). This will ultimately be covered in the official interop guide, I would expect; the draft has https://github.com/mobileink/clojurescript-site/blob/88805681e76a86dcab068ec8b574ed733ebd5f8c/content/reference/javascript-interop-ref.adoc#alternative-macro-syntax

Bravi13:11:57

is there a nice way to use http://socket.io with cljs?

sova-soars-the-sora16:11:16

Dearest cloojurescript family, For realtime serverside/clientside backend/frontend comms ... is sente still the gold standard? What do you guys like to use?

sova-soars-the-sora16:11:08

@bravilogy I don't know of a nice way to use http://socket.io with cljs, but there are a handful of libs/frameworks(?) that will make socket comms possible (and super fast) like Sente.

sova-soars-the-sora16:11:32

Hey! Recently I learned that people use expo (yes?) to make native android and iOS apps using clojurescript!

sova-soars-the-sora16:11:43

(so many questions, i'll pace myself.)

gklijs17:11:54

I tried sente but did it seemed more complicated that it should. I don’t mind there is no ajax as a back-up, so I just use a js websocket, and combined with a clojure-nginx websocket for the back-end it works great. But I did spend some lines getting it to reconnect etc.

gklijs17:11:03

@sova don’t know about expo, I know with cordova you you can make an app with just httml, css and js, so that should also work with js build by clojurescript

sova-soars-the-sora17:11:53

Thanks @gklijs I want to use the audio engine of the iOS ... and want to clojure...

gklijs17:11:45

Not sure how far you get with html5 in that case, I’m not an app developer myself, but are team does some api stuff for a team that does.

sova-soars-the-sora17:11:42

Yeah, looks like I gotta stay in Xcode if I want to make instruments:saxophone: on the iPhone

sova-soars-the-sora17:11:43

would love to do it in cljs though! 😭

mccraigmccraig18:11:15

i started a cordova project two years ago @gklijs - if i was to start the same project today i would probably start in react-native. two years ago react-native was mostly ios only, with an android beta and no windows or web support. today it covers all those platforms and i would go with react-native + reagent + re-frame

mccraigmccraig18:11:48

(and there is #cljsrn for react-native specific chat)

vemv19:11:44

what are some general ideas/hypotheses I can try out when something doesn't work under :advanced compilation?

vemv19:11:08

i.e. some 'troubleshooting checklist' would be ace

dnolen19:11:26

Alex Miller just cut core.async 0.3.465, this includes @juhoteperi macro enhancement

dnolen19:11:55

should be less cumbersome to use now - please give it a spin

qqq19:11:18

@vemv: is it an js accessor issue? rewrite using https://github.com/binaryage/cljs-oops

vemv20:11:39

it's a React rendering issue, under certain circumstances a datepicker (https://github.com/cljsjs/packages/tree/master/react-dates) doesn't pop up

vemv20:11:55

generally it has worked for us

qqq20:11:31

do you get errors in the chrome -> inspect -> console ?

qqq20:11:12

that's beyond my pay grade -- good luck!

mikethompson20:11:09

@vemv the first thing you do is to turn on the :pseudo-names compiler option, plus :pretty-print true https://clojurescript.org/reference/compiler-options#pseudo-names

mikethompson20:11:45

That will give you more human-readable transpiled code.

vemv20:11:07

awesomesauce! thanks so much

vemv20:11:55

getting some weirdness after trying those options

vemv20:11:03

my app makes 0 calls to pprint probably an issue with the flags itselves

thheller21:11:51

@vemv this can either be caused by missing externs for javascript you add to the page besides the CLJS output

thheller21:11:09

google analytics being one that is easily missed

thheller21:11:01

errors like this might also happen when using js->clj on JSON you load at runtime

thheller21:11:18

first you should ensure that the CLJS output is the only javascript on the page

thheller21:11:38

see if the problem goes away then

vemv21:11:12

thanks for the suggestions! unfortunately they don't seem to apply though

vemv21:11:33

these two inputs have the same issue: clicking them won't pop up anything

vemv21:11:25

tried bisecting... I'm 500 commits behind now, issue still there. likely our code was never good under :advanced

vemv21:11:39

(we're pre MVP, don't test out a lot under :advanced)

thheller21:11:46

do you have other JS on the page?

vemv21:11:03

nope, just one <script>

thheller21:11:14

are you using :npm-deps with React? or cljsjs.react?

vemv21:11:36

uhm, now I'm 571 commits behind, issue fixed likely I'll be able to figure it out. thanks for the suggestions!