This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-24
Channels
- # announcements (12)
- # aws (11)
- # babashka (1)
- # beginners (73)
- # cider (4)
- # clj-kondo (2)
- # cljsrn (4)
- # clojars (2)
- # clojure (68)
- # clojure-europe (8)
- # clojure-nl (5)
- # clojure-spec (6)
- # clojure-sweden (1)
- # clojure-uk (29)
- # clojurescript (41)
- # conjure (22)
- # datomic (33)
- # docker (58)
- # duct (3)
- # emacs (8)
- # events (1)
- # expound (3)
- # figwheel-main (5)
- # fulcro (33)
- # graphql (2)
- # kaocha (2)
- # lambdaisland (39)
- # leiningen (1)
- # nrepl (49)
- # nyc (1)
- # off-topic (77)
- # pathom (1)
- # re-frame (33)
- # reagent (28)
- # reitit (1)
- # rewrite-clj (2)
- # shadow-cljs (195)
- # spacemacs (1)
- # sql (60)
- # tools-deps (13)
- # vim (18)
- # xtdb (46)
it isn't possible to use shadow-cljs inspect from a clojure (not clojurescript) project, is it?
Yep :) you need to start the server only.
It is really useful as it replace somehow the REBL haha
Oh I see, I'm running into this > As of https://github.com/clojure/clojurescript/commit/5f0fabc65ae7ba201b32cc513a1e5931a80a2bf7#diff-c62a39b0b4b1d81ebd2ed6b5d265e8cf, ClojureScript instrumentation errors only contain data and leave formatting/printing errors to the edge of the system e.g. the REPL.
Now, is it possible to load that in the node-test target without overriding shadow.test.node/main
(ts/instrument)
is a side-effecting macro which needs to be called AFTER everything has been compiled
but you are calling it at a point BEFORE everything is compiled, or maybe partially compiled thus not instrumenting everything
its working for me atm, so must be the luck of compile order? What would be the proper way to fix it? Could I put it at the end of every test file that needs instrumentation ?
just copy this https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs
@thheller the new cljs_eval
function is really nice! how do you do the lookup between a var in the form and which function to call / value etc?
ah ... I'm just compiling on the server as all the REPLs do. this has basically no logic on the client at all.
yeah this isn't self-hosted. all the compiler stuff happens in the watch
worker process on the server.
Hey all, does anyone know if theres a way to utilize clojure.datafy in a manner that is compatible with optimized output?
i wasnt sure if there was a way to annotate/utilize such that the generated code gets enough of a hint to allow datafy to do its thing
you and I spoke about this area before, but it was before I knew about datafy, so I was revisiting to see if that could help
(defmacro invoke-unary
[client method req auth]
`(p/create
(fn [resolve# reject#]
(let [result# (~method ~client
~req
(cljs.core/clj->js {"authorization" ~auth})
(fn [err# resp#]
(if err#
(reject# err#)
(resolve# (datafy (.getMessage ^js resp#))))))]
(.on result# "status" (fn [status#]
(let [s# (datafy ^js status#)]
(when-not (zero? (:code s#))
(reject# s#)))))))))
core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: {"code" 16, "details" "invalid auth token", "metadata" #js {:cache-control "private, no-cache", :connection "keep-alive", :content-length "0", :content-type "application/grpc-web-text+proto", :date "Wed, 24 Jun 2020 12:09:43 GMT", :grpc-message "invalid auth token", :grpc-status "16", :server "istio-envoy", :x-envoy-upstream-service-time "1"}}
turn on https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs. it'll tell you about the things that fail
@thheller can I ask why it's not the default? Everytime I start a new project, I add infer-externs because I find it extremely useful 🙂
(defn get-providers [auth]
(let [req (pb/ProvidersGetRequest.)]
(.setHeader req (utils/make-header))
(invoke-unary (connect) .getProviders req auth)))
use shadow-cljs release app --pseudo-names
. that will give a better idea of what Z.og
is
diff --git a/src/cljs/mcp_admin_ui/grpc/macros.clj b/src/cljs/mcp_admin_ui/grpc/macros.clj
index 344cc97..0f6d050 100644
--- a/src/cljs/mcp_admin_ui/grpc/macros.clj
+++ b/src/cljs/mcp_admin_ui/grpc/macros.clj
@@ -6,14 +6,14 @@
[client method req auth]
`(p/create
(fn [resolve# reject#]
- (let [result# (~method ~client
- ~req
- (cljs.core/clj->js {"authorization" ~auth})
- (fn [err# resp#]
- (if err#
- (reject# err#)
- (resolve# (datafy (.getMessage resp#))))))]
- (.on result# "status" (fn [status#]
- (let [s# (datafy status#)]
- (when-not (zero? (:code s#))
- (reject# s#)))))))))
+ (let [result# (^js ~method ^js ~client
+ ~req
+ (cljs.core/clj->js {"authorization" ~auth})
+ (fn [err# resp#]
+ (if err#
+ (reject# err#)
+ (resolve# (datafy (.getMessage ^js resp#))))))]
+ (.on ^js result# "status" (fn [status#]
+ (let [s# (datafy ^js status#)]
+ (when-not (zero? (:code s#))
+ (reject# s#)))))))))
no you can do it in the macro but ~method
becomes (unquote method)
so you have ^js (unquote method)
which is not the place you need it in
i ran lein shadow release app --pseudo-names
but nothing is jumping out at me to see if it did anything
TypeError: Z.og is undefined
this should be different. if its not then the arg was passed properly
:shadow-cljs {:nrepl {:port 8777}
:dev-http {8280 {:root "resources/public"
:proxy-url ""}}
:builds {:app {:target :browser
:compiler-options {:infer-externs :auto}
:output-dir "resources/public/admin/js/compiled"
:asset-path "/admin/js/compiled"
:modules {:app {:init-fn mcp-admin-ui.core/init}}}
:rel {:target :browser
:compiler-options {:infer-externs :auto
:optimizations :advanced}
:output-dir "resources/public/admin/js/compiled"
:asset-path "/admin/js/compiled"
:modules {:app {:init-fn mcp-admin-ui.core/init}}}}}
however, watch rel
still results in a bunch of independent js, so I think im not quite doing what i expected
shadow-cljs server
and leaving that running. then shadow-cljs release app
is quicker. no clue about your docker setup or lein shadow
though. I do not recommend lein shadow
because it makes all of this harder.
watch
does not run optimizations at all ever so setting it does nothing. :rel
is identical to :app
basically as the default is :optimizations :advanced
anyways
Uncaught TypeError: Cannot read property '$datafy$' of undefined
at Array.<anonymous> (app.js:33921)
at zb (app.js:2042)
at Ma.<anonymous> (app.js:2041)
at xa (app.js:2026)
at ra (app.js:2026)
at vb (app.js:2034)
at Ma.O (app.js:2062)
at Ma.K (app.js:2062)
File: /Users/ghaskins/sandbox/git/mcp-admin-ui/src/cljs/mcp_admin_ui/grpc/account_service.cljs:14:5
--------------------------------------------------------------------------------
11 | (defn get-providers [auth]
12 | (let [req (pb/ProvidersGetRequest.)]
13 | (.setHeader req (utils/make-header))
14 | (invoke-unary (connect) .getProviders req auth)))
-----------^--------------------------------------------------------------------
Use of undeclared Var clojure.datafy/datafy
i tried using a fully qualified (clojure.datafy/datafy) form, but its still unhappy with me calling that in optimized mode
im out of ideas...i added a js/console.log just prior and the object seems to be valid
status: {code: 16, details: "invalid auth token", metadata: {…}}
app.js:33922 Uncaught TypeError: Cannot read property '$datafy$' of undefined
at Array.<anonymous> (app.js:33922)
at zb (app.js:2042)
at Ma.<anonymous> (app.js:2041)
at xa (app.js:2026)
at ra (app.js:2026)
at vb (app.js:2034)
at Ma.O (app.js:2062)
at Ma.K (app.js:2062)
for
(.on ^js result# "status" (fn [status#]
(js/console.log "status:" status#)
(let [s# (datafy status#)]
(when-not (zero? (:code s#))
(reject# s#)))))
it has something to do with clojure.datafy/datafy...even though that exists in both clj and cljs, i think its somehow not recognized in the macro expansion when in release build
thats a weird error. do you call .datafy
somewhere? using datafy otherwise does not create a datafy
property since its a protocol?
in summary, both ["datafy" "js-cljs"] throw erros about the var not existing within the macro ns (even though i had referred it in the macro ns)....making datafy fully qualified explicitly as clojure.datafy/datafy still results in a undefined var, and cljs.core/js->clj works
(.on ^js result# "status" (fn [status#]
(let [s# (cljs.core/js->clj status# :keywordize-keys true)]
(when-not (zero? (:code s#))
(reject# s#)))))
its entirely possible I have some subtle expansion error in my macro that ive yet to uncover
just to confirm, I also dropped the :refer approach and did (:require [clojure.datafy :as d])
and (d/datafy)
shadow-cljs release app --debug
gives you pseudo-names + source maps which makes that easier
I dont really have the full context/knowledge to know whats right, but if I had to guess, the issue is simply that the gensym'd symbol isnt datafy-able ?
oh wait .. how did you setup your macro? do you actually require clojure.datafy
in CLJS code?
i was only able to get it to work with a single .clj + :require-macros in the consumer, but only in dev mode
adding the :require to the consumer got rid of both the :undeclared-var warning at compilation, and the $datafy$ TypeError at runtime
core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: [object Object]
i guess the only weird thing left is that datafy and js->clj both return a map in dev, but only js->clj returns one in :advanced
I don't know what fetch-providers
is but I assure you datafy works just fine in :advanced
core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: {:code 16, :details "invalid auth token", :metadata {:date "Wed, 24 Jun 2020 16:58:04 GMT", :server "istio-envoy", :grpc-status "16", :x-envoy-upstream-service-time "2", :cache-control "private, no-cache", :content-length "0", :grpc-message "invalid auth token", :content-type "application/grpc-web-text+proto", :connection "keep-alive"}}
Has any one ever got https://chakra-ui.com/getting-started working under shadow-cljs? I can get it working with React but with shadow no dice :S
I was missing empty maps as the attributes for the components