Fork me on GitHub
#shadow-cljs
<
2020-05-02
>
lilactown00:05:23

shadow-cljs only reloads the namespace and direct dependents by default

lilactown00:05:13

if you’re doing something like:

(ns config
  (:require a))

(def values
  {:a a/value})
and a/value relies on something in namespace b, then editing b will not update the value you’ve saved a reference to in your config namespace

lilactown00:05:34

I believe this behavior is consistent with Clojure

lilactown00:05:21

the trick is to use a var (at least if while you’re developing):

(def values
  {:a #'a/value})
or, a function:
(defn values []
  {:a a/value})

Pavel Klavík01:05:25

hmm, changing values into fn helped, but what is the difference? that the value is recomputed everytime values is called?

Lucy Wang03:05:58

@pavel.klavik it depends how you use it. If you use it like def config {:a (a/values)} then it's only recomputed everytime the ns is reloaded, which is prob. exactly what you want.

thheller07:05:16

@pavel.klavik holding values from other namespaces is not a good idea since it hinders hot-reloading. you can use :devtools {:reload-strategy :full} in your build config to always reload all dependent namespaces but that can get a lot slower

Pavel Klavík13:05:17

Thx. In this particular case, probably both solutions are ok since the project is tiny. But it is good to understand how it works.

andre07:05:17

hi, is there a way to listen to compiling errors in the app? i would like to indicate it somehow in the react native app, thanks

thheller07:05:20

right now it just does nothing

andre08:05:29

nice! thanks

thheller08:05:09

is there an easy way to show a warning or something that doesn't require knowing anything about other components on the page?

thheller08:05:31

that ideally works in expo and react-native?

andre08:05:09

im not sure about expo, but at least would be useful to have an option so shadow throws a warning, how figwheel does

andre08:05:27

i don't have warning from figwheel now, but here is how warning looks in rn app

thheller08:05:32

I don't do react-native so someone actually knowing how it works can probably build something nice

thheller08:05:47

happy about a PR doing it in a generic way

andre08:05:02

we just migrated to shadow so for sure we'll contribute

Spaceman22:05:22

Do you have a react native template that you can share?

Spaceman22:05:36

Like re-natal for Figwheel?

awb9914:05:44

I have question: shadow-cljs is getting transient npm dependencies and writes them to package.json. So far so good. But now I also use npm dependencies in the app I am building. And now I have a package.json that is somehow changed by transient dependencies, and partially by the npm dependencies of my app. Now this can get confusing.. as package.json does not allow comments inside. Is it possible to define npm dependencies for my app somewhere else, so that the package.json can become a pure build-artefact do shadow-cljs ?

amalantony14:05:24

While installing dependencies for a new shadow-cljs project, I get this error: shadow-cljs - dependency update failed - Could not transfer artifact thheller:shadow-cljs:jar:aot:2.8.109 from/to clojars (): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Any ideas on how I can resolve this?

amalantony14:05:09

Seems like a Java related issue. But this does not come up in a Clojure Lein project that I have.

thheller15:05:19

@amalantony what java version do you use? maybe its too old?

amalantony15:05:54

@thheller I have OpenJDK 10.

thheller15:05:09

the error is about missing SSL certs, so if you use an OS installed version you might need to update that

thheller15:05:45

yeah jdk10 isn't officially supported anymore. either use jdk11 for long-term-support or use the newest jdk14 and keep updating with every new version

thheller15:05:51

java10 ended support on September 2018 for OpenJDK

amalantony15:05:05

@thheller thank you, I’ll try with the latest version.

thheller15:05:44

it might be enough to update the ssl certs on your system but I don't know how to do that 😛

amalantony15:05:25

@thheller Updating the JDK version seems to have done the trick! I suppose it’s easier than updating the ssl certs since it’s a simple brew install command on Mac 🙂.

👍 4
Pavel Klavík16:05:00

Hi, is it possible to run watch on multiple builds at the same time? My shadow-cljs.edn looks like this:

{:source-paths ["src"]
 :dependencies [...]
 :nrepl        {:port 9000}
 :builds       {:client  {:target           :browser
                          :output-dir       "resources/public/js/compiled"
                          :asset-path       "/js/compiled"
                          :modules          {:main   {:init-fn    orgpad.client.core/init}}
                          :devtools         {:after-load     orgpad.client.core/mount-root
                                             :watch-dir      "resources/public"
                                             :browser-inject :main
                                             :loader-mode    :script}}
                :landing {:target     :browser
                          :output-dir "landing/resources/js"
                          :asset-path "/js"
                          :modules    {:main {:init-fn orgpad.landing.dev/init}}
                          :devtools   {:http-root      "landing/resources"
                                       :http-port      3500
                                       :after-load     orgpad.landing.dev/mount-root
                                       :watch-dir      "landing/resources"
                                       :browser-inject :main}}}}

thheller16:05:13

shadow-cljs watch client landing

thheller16:05:44

or shadow-cljs server and start the builds from the ui (URL printed on startup, usually http://localhost:9630)

Spaceman22:05:06

Everytime I reload the page, the whole test namespace seems to disappear from shadow, and if I evaluate anything with cider in the test namespace, I get the following:

TypeError: Cannot read property 'address_input_bar_suggestions_QMARK_' of undefined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:22)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (: Cannot read property 'p__GT_c' of undefined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:98)
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:7:3)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
ERROR in () (TypeError:NaN:NaN)
expected: (some? (<p! (js/Promise.resolve (dom/mount-landing!))))
  actual: #object[TypeError TypeError: Cannot read property 'p__GT_c' of undefined]
How do I fix this?

Spaceman22:05:51

in fact all of the namespaces within test seem to disappear.

Spaceman22:05:02

I do have the test directory in my source-paths though

thheller22:05:31

just having something on the classpath means nothing. the files need to be actually required by your build.

thheller22:05:22

or use the :browser-test target which has rules to include all namespaces matching a regexp

Spaceman22:05:15

how do I require the files in my build?

Spaceman22:05:22

automatically?