shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
thheller 2020-09-30T08:16:58.168200Z

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

2020-09-30T11:56:45.168400Z

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

2020-09-30T11:58:24.168800Z

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...

martinklepsch 2020-09-30T12:06:46.170900Z

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)))

thheller 2020-09-30T12:19:41.171300Z

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

martinklepsch 2020-09-30T12:20:26.172500Z

Because I can’t construct it at namespace loading time

thheller 2020-09-30T12:20:36.172900Z

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

martinklepsch 2020-09-30T12:20:41.173100Z

(If that makes any sense)

thheller 2020-09-30T12:21:12.173600Z

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

martinklepsch 2020-09-30T12:27:10.175100Z

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

2020-09-30T13:11:06.175500Z

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.

thheller 2020-09-30T15:11:30.175800Z

@kimi.im automatically done for you

thheller 2020-10-01T08:03:01.193800Z

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?

2020-10-01T08:30:23.194100Z

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.

👍 1
localshred 2020-09-30T15:51:12.183200Z

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 [<http://my.app|my.app>]}}
   :output-dir "resources/public/js/my/app"
   :asset-path "/js/my/app"
   :devtools   {:before-load my.gen/generate!
                :after-load  <http://my.app/render|my.app/render>
                :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?

thheller 2020-09-30T15:54:39.184900Z

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

localshred 2020-09-30T15:55:30.185300Z

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

localshred 2020-09-30T15:56:56.186200Z

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

localshred 2020-09-30T15:58:38.186700Z

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

👍 1
2020-09-30T22:03:46.189800Z

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?

thheller 2020-10-01T09:29:09.194400Z

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.

2020-10-01T14:49:52.199300Z

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

2020-09-30T22:20:39.189900Z

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"])

2020-09-30T22:32:49.192700Z

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

thheller 2020-09-30T23:14:40.193Z

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