Fork me on GitHub
#shadow-cljs
<
2021-07-11
>
Jo Øivind Gjernes09:07:12

I can't seem to get my cytoscape.js import to work. Ending up with this:

Uncaught TypeError: module$node_modules$cytoscape$dist$cytoscape_esm.cytoscape is not a function
    at Object.topology$graph$cytoscape_clj [as cytoscape_clj] (graph.cljs:36)

thheller10:07:56

@jodleif no clue what cytoscape is but I'm guessing you used it wrong. check the translation table and section about default exports here: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

Jo Øivind Gjernes14:07:59

0. (https://cytoscape.org/ visualization library) 1. I've verified that the function it is complaining about exists in the js source shadow-cljs is pointing to 2. I've also verified other npm packages work :man-shrugging: (i.e. calling imported function, getting something back in repl) 3. What's the next step in debugging this? The import seems to work but i'm obviously missing something...

thheller14:07:27

did you read the docs? II'm almost 100% sure that your :require is just wrong

thheller14:07:43

pretty sure thats the only thing you need to debug

Jo Øivind Gjernes14:07:07

I've read docs and some blog posts you have written

thheller14:07:25

I really can't help you without seeing code. I can only guess what you are doing. From the error message I'm guessing you used :refer (cytoscape) when either :as cytoscape or :default cytoscape would be correct.

thheller15:07:49

so (:require ["/js/cytoscape.esm.min" :default cytoscape])

thheller15:07:02

(cytoscape (clj->js {}))

thheller15:07:29

why /js/cytoscape.esm.min? why not use the npm package? or is that not an npm package?

Jo Øivind Gjernes15:07:43

Just hammer debugging. :default seems promising, I've tried that as well- but maybe repl had dirty state Now:

(cytoscape (clj->js {}))
#object[eo$$module$js$cytoscape_esm_min [object Object]]

Aron13:07:59

I see that the https://github.com/thheller/reagent-react-native was updated, but the readme is a bit confusing, would it be all right if I suggest further changes in a PR? E.g. why use both yarn and npm? then how to go twice into the same directory? cd react-native appears twice.

thheller13:07:18

the rn commands you run in the react-native dir so you need to cd into it

thheller13:07:59

happy about a PR to adds more docs if that makes it clearer

Aron16:07:29

so, i tried it and it works, i just feel that what i learned is too empirical, don't understand why it works the way it works. not the shadow-cljs part, that's transparent at least, but now I am guessing the yarn install is there so that --legacy-peer-deps is avoided for npm, and I rather use the web interface, but otherwise the watch keeps the terminal, so I see why it's mentioned twice

Aron16:07:51

i also have to run adb devices first for the react native run command to work, this something that start to look like religious rituals : )

thheller16:07:40

can't comment on any react-native parts and would recommend following their docs

thheller16:07:59

I got it running once when I setup that example. I have not launched it since and probably won't for a while 😛

Aron16:07:05

do you publish to mobile some other way or not very much?

thheller19:07:24

just regular web stuff