Fork me on GitHub
#nbb
<
2022-10-24
>
jaide01:10:21

Does nbb work with cljc files?

jaide01:10:22

For a static site, there's a script to transform the root hiccup file to a public/index.html file. The asset function is used to synchronously copy and generate a file name hash for uses like (asset "/img/logo.svg'). The client-side app though is built with shadow, and was thinking of creating a similar asset macro that uses Java to do the same thing. While it would work, it does mean duplicating the logic between JS and Java. In theory, could make it a bit better creating a single cljc file with some conditionals but not sure if that's feasible

genRaiy17:10:29

I have added camel-snake-kebab to nbb.edn and it barfs like this

genRaiy17:10:46

$ npx nbb
Downloading dependencies...
Extracting dependencies...
Done.
Welcome to nbb v1.0.136!
user=>  (require '[camel-snake-kebab.core :as csk])
"#error {:message \"Could not resolve symbol: defconversion\", :data {:type :sci/error, :line 49, :column 1, :message \"Could not resolve symbol: defconversion\", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 49, :column 1, :ns #object[Oq camel-snake-kebab.core], :file \"/home/ray/qqq/.nbb/.cache/e4754d38932a5ba3dcbfe8a138680e6ec55900db/nbb-deps/camel_snake_kebab/core.cljc\"})}], :file \"/home/ray/qqq/.nbb/.cache/e4754d38932a5ba3dcbfe8a138680e6ec55900db/nbb-deps/camel_snake_kebab/core.cljc\", :phase \"analysis\"}, :cause #error {:message \"Could not resolve symbol: defconversion\", :data {:type :sci/error, :line nil, :column nil, :file \"/home/ray/qqq/.nbb/.cache/e4754d38932a5ba3dcbfe8a138680e6ec55900db/nbb-deps/camel_snake_kebab/core.cljc\", :phase \"analysis\"}}}"
user=> 

genRaiy17:10:24

it claims compatibility with bb on the README but I guess there is more to do for nbb? What can I advise the project?

borkdude17:10:14

oh it's .cljc, hmm, yeah, something to look into. can you make an issue perhaps? Can look later this week hopefully

borkdude18:10:26

#nbb: scripting for Clojure on Node.js 1.0.139 ā€¢ https://github.com/babashka/nbb/issues/268: Fix :require-macros (compatibility with https://github.com/clj-commons/camel-snake-kebab) ā€¢ https://github.com/babashka/nbb/issues/264: make load-file auto-await cc @raymcdermott

šŸ˜ 1
genRaiy19:10:51

works for me šŸ™‚

alex19:10:07

What is the idiomatic way to execute some logic when a clojure.test/is assertion fails? For example, if https://github.com/babashka/nbb/blob/main/examples/playwright/example.cljs#L38 were a failing assertion, I would want to execute "test failed" logic e.g. taking a screenshot of the .page at that time Playwright throws exceptions when one of its commands fail, so those exceptions can be caught through a single catch handler. Is there a catch-equivalent for failed assertions?