This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-29
Channels
- # announcements (35)
- # aws (40)
- # babashka (10)
- # beginners (119)
- # calva (25)
- # cider (13)
- # clj-kondo (15)
- # cljsrn (23)
- # clojure (205)
- # clojure-dev (3)
- # clojure-europe (15)
- # clojure-germany (3)
- # clojure-italy (3)
- # clojure-nl (2)
- # clojure-uk (58)
- # clojurescript (193)
- # community-development (2)
- # conjure (147)
- # core-async (49)
- # cursive (47)
- # datomic (27)
- # duct (1)
- # fulcro (19)
- # graalvm (3)
- # graphql (1)
- # helix (3)
- # hoplon (11)
- # jackdaw (1)
- # joker (1)
- # juxt (5)
- # kaocha (1)
- # keechma (3)
- # lambdaisland (6)
- # local-first-clojure (27)
- # malli (5)
- # off-topic (41)
- # rdf (27)
- # re-frame (7)
- # reagent (15)
- # reitit (5)
- # rum (11)
- # shadow-cljs (157)
- # spacemacs (18)
- # sql (4)
- # xtdb (8)
@jayzawrotny one guess would be that it tries to eval stuff even when no runtime (eg. browser) is connected to do the actual eval?
I don't think it's that as I'm getting the error when running a node process while connected to the REPL. Sounds like it's not obvious so the maintainer will likely need to find time to debug.
@thheller We've examined the stack-trace more carefully and found the issue is due to this function returning false. https://github.com/rksm/clj-suitable/blob/master/src/main/suitable/complete_for_nrepl.clj#L204-L205 Anything stick out there?
Hi, is possible that shadow-cljs exclude .scss.js* node module files from target build?
(ns app.main
(:require [reagent.core :as r]
["@fluentui/react" :refer [Button PrimaryButton Stack]]
["@uifabric/utilities/" :as fu]
["@uifabric/styling/" :as fs]))
yeah, usually libraries ship with those either removed completely or already converted to .js
so the lib seems to presume that you are using webpack with a scss loader configured?
/* tslint:disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".root_d7ec3e0f{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:none;box-shadow:none;margin:0;padding:0}.root_d7ec3e0f *{overflow:visible}.root_d7ec3e0f *::-moz-focus-inner{border:0}.root_d7ec3e0f *{outline:transparent}.root_d7ec3e0f *{position:relative}.ms-Fabric--isFocusVisible .root_d7ec3e0f *:focus:after{content:'';position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;border:1px solid " }, { "theme": "neutralSecondary", ...
this import is in @fluentui/react/lib/Calendar.js
export * from 'office-ui-fabric-react/lib/Calendar';
and office-ui-fabric-react
package is in node_modules directoryOk, thank you very much for your interest. I wait until you have an solution, you are shadow-walker 🙂
first time I see a package using this method it would go away if the require in those files just used require("./Calendar.scss.js")
but I guess they had to rely on that little bit of extra magic 😛
I'll see if I can sort this out easily. the filtering I did for css is a bit naive anyways
yeah first time I see the combination of actually keeping the .scss require and just expecting to pick up the .scss.js
Hi! I’m using shadow-cljs and loving it. Thanks so much for doing this! I have a question: is there a convenient a way to run just one specific test from the command line?
not yet. the testing has been neglected for a bit but I have some plans to make that a bit more convenient.
https://github.com/scterm/scterm/blob/master/src/test/scterm/test/runner.cljs#L29-L31
Thanks for your quick responses 🙂 I will play around with you suggestions!
Anyone get prepl working with shadow-cljs? Or can point me in the right direction
Using vim conjure and setting :prepl {:app 5557}}
and when conjure tries to connect, I get a Stream Closed: http://java.io.IOException
I never managed to get prepl to work nicely with Conjure I'm afraid, it requires a few more patches to shadow-cljs (and every other prepl implementation tbh)
You'll probably have better luck with Conjure's new develop branch which uses nREPL and works with shadow-cljs REALLY well.
You get completion and go to def too 😄 same key bindings, no pre-compile step, :help based docs. It's a lot better.
Awesome. So dev branch supports prepl and nrepl going forward?
Just nREPL today, but prepl is on my roadmap. The prepl won't be as feature rich, but I hope to add some support for it.
Continuing conversation in the #conjure channel since this is Conjure specific really.
Doesn’t master support prepl?
is there a way to prevent objects like goog.i18n.NumberFormatSymbols_en to be advanced compiled?
I require it in the require, then I want to update a key after js->clj but it's advanced compiled
you can use the simplified externs https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs
and just list the property names, then it shouldn't rename those and allow swapping?
I'm not actually sure how google handles localization. there is a bunch of stuff already built-in so there should be ways to get this done
ok thanks yeah it does we just have a special case where we want to format a currency number but without adding the symbol to the formatting
Hello all,
I’m working on setting up re-frame-10x with my project. However, it is not registering my app-db (I can inspect
and see my re-frame db) in my re-frame-10x tool. I know using shadow-cljs with this library required some extra configs so I followed the sample for conduit project as closely as I could:
https://github.com/jacekschae/conduit-re-frame-10x-demo/blob/master/shadow-cljs.edn
However, for their shadow-cljs.edn, this is their :modules
setup:
:modules {:main {:entries [devtools.preload
day8.re-frame.trace.preload
conduit.core]}}
but my shadow-cljs.edn looks like this:
{:deps true
:builds {:app {:target :browser
:output-dir "public/out"
:asset-path "/out"
:modules {:main {:init-fn alpha-journal.core/main}}
:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {"goog.DEBUG" true
"re_frame.trace.trace_enabled_QMARK_" true
"_frame.tracing.trace_enabled_QMARK_" true}
:optimizations :whitespace}
:devtools {:http-root "public"
:http-port 8020
:after-load alpha-journal.core/main
:preloads [devtools.preload
day8.re-frame-10x.preload]}}}}
How can I setup my preloads while using my :init-fn
? Is this possible?that project is setup as a demo of re-frame-10x using a release build setup so don't use it as an example for a regular project
@thheller so currently I’m not getting any info in my dashboard for my app-db. My first thought is that I wasn’t using the
[devtools.preload
day8.re-frame.trace.preload]
because I omitted using :entries
for :init-fn
. I’m not sure if that is the reason for my dashboard not picking up on my app-db or something elsesorry I don't quite understand what your issue is. :init-fn
is effectively the same as you specifying :entries [alpha-journal.core]
it makes no difference as far as re-frame-10x is concerned?
and the preload ensures it is running before the init so I don't really know what you are asking about here?
To clarify why I thought :init-fn
might be problematic in my case, the example case has the vector:
:entries
[devtools.preload
day8.re-frame.trace.preload
conduit.core]
but my case I only include my run function :init-fn: alpha-journal.core/main
so I don’t explicitly call for any preloads except in the devtools (which is only when it hot reloads?). This could be completely unrelated to my problem, but it was the one that seemed most potentially problematic since I figure I wasn’t loading the preloads. My then question was how can I load preloads while using :init-fn
rather than :entries
.
Back on your comment saying that the conduit app is a release example. Does that mean I don’t need the :compiler-options
and :preloads
in :devtools
if I were to create a minimum working example?
According to this doc, it seems like shadow-cljs doesn’t require any extra config? Is that true? https://github.com/day8/re-frame-10x/blob/master/docs/Advanced-Setup.md
Thanks for all the help @thheller! I will ask the re-frame channel if this has nothing to do with my shadow-cljs settingsHmm that’s strange since I already should be using that one:
(ns alpha-journal.core
(:require
[reagent.core :as r]
[reagent.dom :as dom]
[re-frame.core :as rf]
[alpha-journal.events]
[alpha-journal.views :refer [app]]))
(defn render
[]
(dom/render [app]
(js/document.getElementById "app")))
(defn main
[]
(rf/dispatch-sync [:initialize])
(render))
or maybe try
(defn main
[]
(js/setTimeout
(fn []
(rf/dispatch-sync [:initialize])
(render))
100))
I vaguely remember something about timing issues but not really sure anymore. long time ago.
Okay so I found some things that might be related to shadow-cljs. So this were my steps to get it working: 1. I loaded my app (re-frame-10x shows nothing) 2. I made a change to a view file and saved 3. Hot reloaded 4. My app now shows the db in re-frame-10x
I’m going to try the setTimeout now as well
setTimeout
didn’t work. I’m just curious if the hot reloads are running something that my first load isn’t
Yeah I tried with 10000 and it doesn’t work
ok then I have no clue. as someone that actually knows how this is supposed to work. 😛
ignore the default docs .. the only difference you have in shadow-cljs is that you don't specify a :main
but instead have :modules
with a :init-fn
Haha, @thheller thanks for the help and clarifying about the docs 🙂. I’ll see if I could figure something out and ask around as well
dunno how current this is https://github.com/mhuebert/shadow-re-frame
I’ll check that out, thanks
@thheller earlier, I mentioned this briefly: > Back on your comment saying that the conduit app is a release example. Does that mean I don’t need the :compiler-options and :preloads in :devtools if I were to create a minimum working example? To clarify, are the :compiler-options settings only for releasing an app? ex.
:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {"goog.DEBUG" true
"re_frame.trace.trace_enabled_QMARK_" true
"_frame.tracing.trace_enabled_QMARK_" true}
:optimizations :whitespace}
Thanks for explaining this all to a beginner like me 🙇Hi! What is the best way to deal with the runtime config in shadow-cljs? E.g. I want to pass different firebase credentials depends on where I deploy. Thanks in advance!
So I have a promise in a test like so:
(deftest login-test
(day8.re-frame.test/run-test-async
(testing "login test"
(async done
(go
(let [_ (<p! (js/Promise. (see/landing!)))
]
(prn "done")
)
)
(done)
)
)
)
)
And running this test just hangs. What do you think is causing this?
Oh yeah, I'm also getting this error on evaluating just the js/Promise part, but have no clue what it means:
TypeError: Promise resolver #<cmp> is not a function
TypeError: Promise resolver #<cmp> is not a function
at new Promise (<anonymous>)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:2)
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_] ()
You need to call (done)
function when your async code finished. Here is the good section if you use core.async https://github.com/wilkerlucio/wsscode-async#javascript-async-tests
Or this doc has a better example: https://clojurescript.org/tools/testing#async-testing
The problem with your code is most likely that async macro accepts only two arguments and your (done) call is 3rd arg, but I can't check it right now.
If you move your (done) inside the (go) block it should work.
@U4EFBUCUE Now there's no error, but it just hangs at "testing my.namespace"
is your promise ever resolved?
<p!
will wait for promise to be resolved or rejected before continuingwhat is see/landing! doing?
evaluating that promise part gives me this though:
TypeError: Promise resolver #<cmp> is not a function
at new Promise (<anonymous>)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:118)
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 ()
Try:
(-> (js/Promise. (see/landing!)
(.then (fn [res] <some print>))
(.catch (fn [err] <some other print>)))
Oh, wait, I know what the problem is: (js/Promise. (fn [resolve reject] <your code that need to call either resolve or reject> )
disregard the message with threading macro above, it will show you the same error
@U4EFBUCUE, I don't quite understand what you mean. Would you give a full example how I would run these two functions sequentially in the test: (f1) (f2) where f1 returns nil?
is see/landing async? Based by name I assume so.
If it is async, then you need to somehow let your test know that it finished working. You can do this by either having this function return async.core channel and function will post a value on the channel. It will look like this:
(deftest test-async
(async done
(go
(is (= (<! (see/landing!) nil))
(done))))
Alternatively, you can pass callback to the see/landing and let it call it once it is done:
(deftest test-async
(async done
(let [callback #(done)]
(see/landing! callback))
or with a promise:
(deftest test-async
(async done
(let [_ (<p! (js/Promise. (fn [resolve reject] (see/landing! resolve reject))) ]
(done))
(parens) might be off since I'm typing it directly in chat
In last two cases (see/landing!) must call the callback it gets passed as an argument
What about if I have something that follows this see/landing! function that I want to execute after see/landing?
This didn't evaluate the second function as expected:
(deftest test-async
(async done
(go
(<! (see/landing!))
(<! (interact/click-login-btn))
(done))))
So, <! is an operation that takes from channel. go block will wait until something is posted on the channel to resume code that follows. If you want a sequential operation execution you need to make sure that you post/read from the same channel. It is hard to explain in a message. I recommend reading this to get yourself more familiar with core.async: https://www.braveclojure.com/core-async/
But reading between the lines, it looks like you're trying to make a UI test that will wait for the landing page to load and then run something
What do you use to load your landing page? Most likely it returns promise that you can chain your checks to.
I'm using the react-testing-library's render function to mount the component to the dom. After some familiarity with the async I have the following simple test:
(deftest test-async
(let [result (waitFor (+ 1 2)) ]
(async done
(go
(is (= 3 (<p! result)))
(prn "done")
(done)
)
)
))
waitFor is a react-testing-library function that returns a promise.
But this gives me the following error:
ERROR in (test-async) (Error:NaN:NaN)
expected: (= 3 (<p! result))
actual: #error {:message "Promise error", :data {:error :promise-error}, :cause #object[TypeError TypeError: Cannot read property 'current' of undefined]}
"done"
It looks like the promise is rejected with an error. I'm not familiar with waitFor and what it does.