Fork me on GitHub
#shadow-cljs
<
2020-09-30
>
thheller08:09:58

@loganpowell (:refer-clojure :exclude (resolve)) in the ns would fix it too

Logan Powell11:09:45

Thank you sir. I actually did just this by just copying the library that conflicted and appending that code within the conflicting namespace.

Logan Powell11:09:24

Funny thing is - I know it's been a while (about six months) - that I recall I used to get the same conflict warning, but I would still be able to run my code...

martinklepsch12:09:46

I have a bit of code that stores a JS object in an atom and I have to add ^js hints whenever I want to interop with that object. Would there by another way that doesn’t require adding ^js everywhere?

(defonce ^:private remote-config
  (atom nil))

(defn init! []
  (reset! remote-config (firebase/remoteConfig))
  (set! (.-settings ^js @remote-config)
        #js {:minimumFetchIntervalMillis config/remote-config-fetch-interval})
  (p/do!
    (.ensureInitialized ^js @remote-config)
    (.fetchAndActivate ^js @remote-config)))

thheller12:09:41

@martinklepsch why are you putting it in an atom if you are going to mutate it anyways?

martinklepsch12:09:26

Because I can’t construct it at namespace loading time

thheller12:09:36

you can reduce the number of ^js with a (let [^js cfg @remote-config] ...) and just operating on cfg but other than that I don't know of a way to typehint deref

martinklepsch12:09:41

(If that makes any sense)

thheller12:09:12

(def thing nil) (set! thing "something") should be fine?

martinklepsch12:09:10

Ah, didnt realize set! could also be used on „vars“ kind of assumed it had to have an interop form as first arg

kimim13:09:06

Hello, I'm using react-data-grid to show some data. But since version 7.0.0.canary.17 this lib uses some ES2020 feature, as it says: react-data-grid is published as ES2020 modules, you'll probably want to transpile those down to scripts for the browsers you target using Babel and browserslist. How can I enable this for cljs? Thanks.

thheller15:09:30

@kimi.im automatically done for you

kimim22:09:49

But there are some weird problem if I switch the version. Or maybe that’s react-data-grid’s bug. I put the example in github here: https://github.com/kimim/cljs-react-data-grid

thheller23:09:40

please provide at least some kind of error description. I don't know what I'm supposed to be looking for and don't have time to run through the entire repo

kimim02:10:15

It is expected to display the table, but it did not show any thing now if I use the canary.22 version of the lib.

thheller08:10:01

as far as I can tell it is the div with height: 100%. if I set that to 200px or so it displays the table just fine?

kimim08:10:23

Thank you @thheller, I think that is the bug in react-data-grid itself, as it is under some big changes in recent versions. Anyway shadow-cljs is a great tool, which ease a lot of pain to use clojurescript.

👍 3
localshred15:09:12

Hi friends, I'm struggling to find a way to invoke a node script during compilation (after files have changed) for live reload of generated css. My app has garden styles written in each of my reagent components that I'm then building with a node target which writes out the index.html and app.css files in my public directory. I'd like to invoke that :static node target (which becomes resources/bin/static.js) during the normal :browser target live reload compilation. All of the generator code for producing the index and css files live in a namespace separate from my primary application, as I don't want that code ending up in the released app. I've tried every configuration trick I can find in the user manual: + :dev/before-load or :dev/after-load doesn't appear to work as the gen namespace isn't required by app (is my guess). + Adding a separate module (the generator ns) that depends on app ns. This nearly worked, but was invoking things in a cljs context which meant I didn't have access to write files to the system. + :build-hooks after :flush stage Currently my shadow file looks like this:

{:deps {:aliases [:cljs]}
 :builds
 {:browser
  {:target     :browser
   :modules    {:app {:entries []}}
   :output-dir "resources/public/js/my/app"
   :asset-path "/js/my/app"
   :devtools   {:before-load my.gen/generate!
                :after-load  
                :http-root   "resources/public"
                :http-port   43234}}

  :static
  {:target           :node-script
   :main             my.gen/generate!
   :output-to        "resources/bin/static.js"
   :compiler-options {:reader-features #{:node}}}}}
Anyone have any ideas?

thheller15:09:39

not supported. you could do it in a :flush hook of the :static builds. I'm assuming that also loads all the code the browser build is loading

localshred15:09:30

yes it does, it requires the component ns' to get the styles for compilation

localshred15:09:56

now that I write that here, I'm thinking I could write a shim fn in the browser code that does the compilation and just dynamically injects a style tag into the head or something, then have that code stripped out of the release build

localshred15:09:38

thanks @thheller for the response, and of course for the wonderful tool that shadow is

👍 3
mrchance22:09:46

Hi, I have some weird behavior with shadow cljs and an npm library... I (:refer ["d3-hierarchy" :as d3])and call (.tree d3) which worked before, but now it says tree is not a function, and on inspection the d3 object is just an empty map. I cleaned, restarted the build, even re-installed all npm dependencies, but it didn't change it. Any idea how that might've happened?

mrchance22:09:39

Occasionally the build also claims that [nil] is not a valid hiccup form for a component in the same namespace, which by this point is literally just

(defn foo []
  [:div "wtf"])

thheller09:10:09

did you maybe install a different version of the package? sometimes stuff is moved to different packages. I vaguely remember someone else reporting and issue but it was something based on the package. can't remember the details though.

mrchance14:10:52

I did have the "full" d3 package installed before, but I don't see that either in the package.json or the lockfile anymore, and everything else I deleted and reinstalled as far as I can tell