shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
thheller 2021-01-10T00:56:13.437700Z

@ajsnow2012 should be fixed in latest version

thheller 2021-01-10T00:56:42.438200Z

@ghvanw283 the closure compiler does not support dynamic import() so shadow-cljs doesn't either

thheller 2021-01-10T00:58:04.439100Z

@royalaid there is no CLJ funtion to connect to a remote server. that is all done from the npm bits. I guess you could do the same thing that does but there is nothing built-in for that from CLJ

👍 1
GHvW 2021-01-10T01:23:47.439700Z

Got it. Thank you so much for the reply @thheller

Mr. Savy 2021-01-10T02:12:34.439800Z

ok, thank you sir!

stuartrexking 2021-01-10T02:24:53.442700Z

I’m getting a compile error I don’t understand. 1. In a CLJC file, in a #?@(:clj block I require a couple of clj namespaces, using :as to name them. 2. In that same CLJC file, in a #?(:clj form, I use those names to destructure keys on a map param. I get this:

stuartrexking 2021-01-10T02:25:31.443300Z

Does shadow parse :clj forms?

stuartrexking 2021-01-10T02:29:54.443500Z

My guess is it’s this https://clojurians-log.clojureverse.org/shadow-cljs/2020-07-01

stuartrexking 2021-01-10T02:39:07.444Z

Yeah that was it. CLJC for everything or nothing.

zendevil 2021-01-10T06:58:02.444300Z

how to run tests in shadow-cljs?

zendevil 2021-01-10T06:58:11.444600Z

I have the following shadow-cljs.edn

zendevil 2021-01-10T06:58:29.444800Z

that contains a test build

zendevil 2021-01-10T06:58:29.445Z

{:deps true
 :source-paths ["src"]

 :dependencies [[reagent "0.10.0"]
                [re-frame "0.12.0"]
                [re-frame-steroid "0.1.1"]
                [rn-shadow-steroid "0.2.1"]
                [re-frisk-remote "1.3.3"]
                [cljs-ajax/cljs-ajax "0.8.1"]
                [day8.re-frame/http-fx "0.2.2"]]

 :builds
 {:test {:target :browser-test
         :test-dir "test/humboi"
         :runner-ns humboi.core
         :devtools  {:http-port          8021
                     :http-root          "test/humboi"}
         }
  :dev
  {:target     :react-native
   :init-fn    humboi.core/init
   :output-dir "app"
   :compiler-options {:closure-defines
                      {"re_frame.trace.trace_enabled_QMARK_" true}}
   :devtools   {:after-load steroid.rn.core/reload
                :build-notify steroid.rn.core/build-notify
                :preloads [re-frisk-remote.preload]}}}}

zendevil 2021-01-10T06:58:59.445400Z

but running (shadow/watch :test) doesn’t run the tests

zendevil 2021-01-10T06:59:15.445800Z

my tests are in the test/humboi directory

zendevil 2021-01-10T06:59:23.446Z

and the core.cljs contains

zendevil 2021-01-10T06:59:33.446200Z

(cljs.test/run-tests)

zendevil 2021-01-10T07:06:43.446400Z

I’m getting the following error:

zendevil 2021-01-10T07:06:43.446600Z

Errors encountered while trying to parse file /Users/prikshetsharma/Desktop/Humboi/node_modules/react-native/index.js {:line 13, :column 7, :message “cannot use keyword ‘typeof’ here.“}

dmrd 2021-01-10T07:07:22.447Z

I am in search of examples using shadow cljs with replumb. Is anyone familiar with any example code? Came across this thread in this channel previously, which describes that bootstrap shadow target is probably necessary. For context, I’m debugging a replumb repl I have setup that doesn’t seem to have any symbols defined in the cljs/user namespace. Basic types like 1 and 'this-is-a-keyword work fine, but defs & any function call fails

dmrd 2021-01-10T07:11:20.447600Z

I have a feeling it is related to the default init-fn! for replumb not working out-of-the-box with shadow: https://github.com/arichiardi/replumb/blob/dde2228f2e364c3bafdf6585bb1bc1c27a3e336c/src/cljs/replumb/browser.cljs#L4

zendevil 2021-01-10T07:12:59.447900Z

this is my core_test.cljs

zendevil 2021-01-10T07:13:02.448300Z

(ns humboi.core-test
  (:require [humboi.core :as sut]
            ["@testing-library/react-native" :refer [render fireEvent]]
            [humboi.auth.core :refer [google-sign-in-comp]]
            [cljs.test :as t :include-macros true]))

(defn mount! [component]
  (render (r/as-element component)
          #js {:container (testing-container)}))

(deftest google-login-test
  (is (mount! [google-sign-in-comp])))

(defn start [] (cljs.test/run-tests))

(defn stop [done]
  ;; stopping the tests 
  (done))

(defn ^:export init []
  (start))

thheller 2021-01-10T11:22:53.449300Z

@ps ask in #cljsrn. I do not know anything about react-native testing but I do know that you cannot run them via :browser-test or :node-test

thheller 2021-01-10T11:23:33.449700Z

@ritt93 use https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html instead of replumb

2021-01-10T17:39:39.451200Z

I will try to explain a rather complicated problem in my "English" ;) I am trying to use macro with alter-var-root to redefine how defn and defn-.

(ns patch.tufte
  (:require
   [taoensso.tufte :as tufte :refer [p]]
   [taoensso.encore :as enc]
   #?(:clj
      [cljs.core]))
  #?(:cljs (:require-macros [patch.tufte])) <- Here's the problem!
  )

...
...

#?(:clj
   (alter-var-root #'cljs.core/defn (constantly #'defnp)))

#?(:clj
   (alter-var-root #'cljs.core/defn- (constantly #'defnp-)))
If the specified line is not commented out when launching shadow, it looks like cljs.core is compiling with my new defn. However, if I uncomment the line after compiling the project for the first time, everything works. Can it be solved somehow?

thheller 2021-01-10T18:34:49.452300Z

side-effects like that are not supported and will break just about everything shadow-cljs knows about compiling

2021-01-10T18:37:37.452700Z

Still, shadow-cljs it's awesome 🙂

2021-01-10T18:38:07.452900Z

Thanks as always for your work and quick reply.

2021-01-10T19:14:38.453200Z

@thheller is there any way to force recompilation of the ENTIRE project?

2021-01-10T19:15:38.453500Z

after compile time after using force-compile in the dashboard it seems to me that this only compiles the latest changes

thheller 2021-01-10T20:28:27.453900Z

@huxley you can delete the cache in .shadow-cljs/builds/<build-id>

thheller 2021-01-10T20:28:46.454200Z

otherwise it'll always use the cache

thheller 2021-01-10T20:29:09.454600Z

need to restart the watch after that though since that still everything in memory