Fork me on GitHub
#shadow-cljs
<
2022-06-16
>
shaunlebron03:06:38

Can I get help importing react-virtualized-auto-sizer? https://github.com/bvaughn/react-virtualized-auto-sizer AutoSizer is null when importing with: ["react-virtualized-auto-sizer$default" :as AutoSizer]

thheller06:06:38

@shaunlebron from the example import {AutoSizer, List} from 'react-virtualized'; and see translation listing here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

thheller06:06:15

or as usual try without the $default, also see my answer here on how to figure this out https://stackoverflow.com/a/72196457/8009006

shaunlebron14:06:16

Thanks! leaving out the $default returned what I needed I think since it evaluated to a function when logging it, but I gave up on getting it working in reagent

Drew Verlee14:06:42

Given shadow-cljsjs has a exportSybmol for Raven why would my shadow-cljs watch not be able to find it? The error i see

[:app] Build failure:
The required JS dependency "raven-js" is not available, it was required by "cljsjs/raven.cljs".

Drew Verlee15:06:39

do I also need to install raven-js via npm?

Drew Verlee15:06:58

adding raven via yarn add raven-js causes the build not to fail because it's missing the js dep raven.

Drew Verlee15:06:43

If i add the library via yarn and it's declared in my shadow-cljs.edn file as cljsjs/somelib <some-version> how does the app know which version to use the package.json or the shadow-cljs.edn one? I feel like adding them to both must not be the correct way to handle this.

Derek15:06:53

Ah my mistake shadow-cljsjs

Drew Verlee15:06:06

In a shadow project how would i go about resolving these requires?

[cljsjs.codemirror]
            [cljsjs.codemirror.mode.clojure]
            [cljsjs.codemirror.addon.edit.closebrackets]
            [cljsjs.codemirror.addon.edit.matchbrackets]
The first would be
(ns cljsjs.codemirror
  (:require ["codemirror" :as cm]))

(js/goog.exportSymbol "CodeMirror" cm)
Is the next one then
(ns cljsjs.codemirror.mode.clojure
  (:require ["codemirror/mode/clojure" :as cm]))

;; what would go here?
(js/goog.exportSymbol "CodeMirror" cm)
It's not clear to me in the namespace that uses the functionality how things are used there is just one js/CodeMirror so i assume my guess above is wrong and i'm supposed to somehow shove all the functions into that symbol. Maybe through js/goog.object.set ?

Drew Verlee15:06:01

err maybe i can just create a deps file with this boot task? https://github.com/cljsjs/packages/blob/master/codemirror/build.boot

dpsutton15:06:38

i’ve got a demo repo using codemirror and shadow-cljs if that is helpful to you: https://github.com/dpsutton/field-editor

Drew Verlee15:06:15

i get a 404 with that link

dpsutton15:06:42

it was private. try now

dpsutton15:06:59

clone it and i’m gonna set it private again

Drew Verlee18:06:22

Thanks I'll take a look!

thheller16:06:31

@drewverlee if you are controlling the requires you should just include npm packages directly and not use the cljsjs "bridges". they are really only provided for cases where you can't change them because some library uses them

👍 1
Drew Verlee15:06:52

thanks. that makes sense.