Fork me on GitHub
#shadow-cljs
<
2020-03-10
>
otwieracz06:03:44

Hey, do you have any suggestions how to import https://adazzle.github.io/react-data-grid/docs/quick-start properly so I get the function? No matter what I try, I got undefined when checking with (goog/typeOf) or object (which seems empty) when trying with ["react-data-grid" :as ReactDataGrid]))

ouvasam08:03:12

Did you you tried ["react-data-grid" :default ReactDataGrid]

ouvasam08:03:45

or ["react-data-grid" :refer (ReactDataGrid)]

otwieracz09:03:52

Right now I am fighting with other issue... I am not able to load webpage becasue:

otwieracz09:03:13

thousands of errors like that

thheller09:03:45

@UB0EMUD34 which version are you on? or did you manually set :loader-mode :script?

otwieracz09:03:36

No, I haven't.

otwieracz09:03:43

"shadow-cljs": "^2.8.52"

thheller09:03:07

then you can either set :devtools {:loader-mode :eval} in your build config or upgrade (which sets that as a default)

thheller09:03:26

drastically reduces the number of requests which fixes cases like yours where you are loading too many files at once

otwieracz09:03:06

Let me try...

otwieracz09:03:03

Still thousands of requests with 2.8.91

otwieracz09:03:15

{:deps     {:aliases [:dev]}
 :nrepl    {:port    9000
            :init-ns user}
 :dev-http {8000 "resources/public"}
 :builds   {:main {:target     :browser
                   :output-dir "resources/public/js/main"
                   :asset-path "/js/main"
                   :modules    {:main {:init-fn spreadnotes.client/init}}
                   :devtools   {:after-load spreadnotes.client/init
                                :preloads   [com.fulcrologic.fulcro.inspect.preload]}}}}

otwieracz09:03:20

Is there something inherently wrong here?

thheller09:03:43

I don't see the :loader-mode?

thheller09:03:14

if you upgraded I guess you updated the npm install but no the reference in deps.edn?

otwieracz09:03:49

let me try once again...

otwieracz10:03:21

cli version: 2.8.91 node: v8.17.0

otwieracz10:03:27

still thousands of files.

otwieracz10:03:53

But wait, maybe it didn't recompiled yet

thheller10:03:01

it says cli version

thheller10:03:21

the only version that matters here is whatever you have in deps.edn

otwieracz10:03:26

(both deps and package.json are updated to .91 - but maybe it hadn't recompiled yet)

otwieracz10:03:40

Maybe this was false alarm. 🙂 Let my try once again.

Mikko Harju12:03:42

Hi, has anyone fiddled around with replumb + shadow-cljs? I'm trying to convert a personal project of mine to shadow-cljs and it uses replumb to provide cljs evaluation. Everything else seems to be working quite well but evaluation of anything that touches the CLJS runtime library (like trying to invoke let , def , +) raises a warning :undeclared-var , and it seems to think that the function should be found in the current ns.

Mikko Harju12:03:36

Could this have to do with the module not having all the necessary runtime-stuff in it? I'll try to look into that one.

Mikko Harju12:03:31

OK, it seems that there is indeed something different in the setup. If I explicitly evaluate

(js/goog.require "cljs.core")
(cljs.core/+ 1 1)
I get the expected output of 2. 🙂

thheller12:03:49

self-hosted stuff is done via the :bootstrap target. pretty sure thats a full replacement to replumb though. see https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html for an example

Mikko Harju12:03:42

Wow. Cool 🙂 So I could ditch replumb alltogether and just use that one? I'll take a look. Can you elaborate a bit (if you have time) could replumb be used at all, what is the fundamental thing that is different in figwheel vs. shadow-cljs in this regard?

thheller12:03:29

you can still use replumbs. just need to use the shadow bootstrap stuff

thheller12:03:03

I honestly can't remember all the details but basically the :bootstrap target will pre-compile sources and the host build will just load them (instead of compiling itself)

thheller12:03:53

it works differently because this way there is one unified way to load stuff

thheller12:03:05

meaning adding dependencies and using them is easy

Mikko Harju12:03:10

OK. I'll dig into this. Thanks again!

thheller12:03:21

otherwise cljs.core was treated as special and extra deps were hard

Mikko Harju13:03:06

@U05224H0W works now. I'll continue using replumb for now, but will consider transitioning to the one given in the blog post since it seems fairly straightforward. Thanks again!

yenda13:03:04

is there a way to export functions with :target :node-library so that they have the async keyword AWS lambda needs it and it looks like it's not working when just returning a promise in the cljs function that we export For async handlers, you can use return and throw to send a response or error, respectively. Functions must use the async keyword to use these methods to return a response or error. Here what the aws lambda doc is asking for:

const https = require('https')
let url = ""

exports.handler = async function(event) {
  const promise = new Promise(function(resolve, reject) {
    https.get(url, (res) => {
        resolve(res.statusCode)
      }).on('error', (e) => {
        reject(Error(e))
      })
    })
  return promise
}

yenda14:03:01

nvm I was just confused, aws async lambda execution isn't what we wanted, it doesn't reply when the promise resolves, it just replies right away with empty 200 and keep execution going in the bg. The exported fn was working as expected

thheller14:03:47

@yenda there is also no such thing as the async keyword at runtime. that is just syntax sugar for a function returning a promise

thheller14:03:59

so if you just return a promise then your function is effectively async

🤯 4
yenda14:03:07

yes I figured, thanks

Prometheus17:03:01

any good libraries/tips and tricks for doing configuration (such as yogthos/config) in shadow-cljs?

yenda19:03:31

if you want to read from a file or env variables , you can use a macro to slurp at compile time

Prometheus19:03:00

hmm what sort of macro would that look like?

mavbozo10:03:13

we use a kind of load-config macro combined with :closure-defines goog/ENV like this code sketch

(defmacro load-config []
  `(if (= js/goog.ENV "prod")
     ;; prod config
     (load-from-file "prod-config.edn")
     ;; dev config
     (load-from-file "dev-config.edn")))

mavbozo10:03:06

the macro is just a .clj file (not .cljs file) and :closure-defines is in shadow-cljs.edn

Prometheus11:03:38

hmm cool so load from file and then set the variables

davewo19:03:21

Does the -A:alias cli option override {:deps {:aliases [:alias]}} in shadow-cljs.edn?

thheller19:03:03

@davewo not overwrite, add

✔️ 4