shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
wcalderipe 2021-04-11T15:09:30.057400Z

hey folks ๐Ÿ‘‹ I'm having issues with cider-connect-cljs on a shadow-cljs project. I'm not sure this is the right channel to post my question, but I'm in the hope that someone else here would have faced the same issue before and will point me in the right direction or just say the right channel :) I noticed that when I connect Emacs to a running nrepl using cider-connect-cljs, my REPL doesn't work the same way as it does when I use cider-jack-in-cljs for instance. To be honest, I don't know if cider-connect-cljs and cider-jack-in-cljs have different user experiences but I assume they don't. I have recorded a video to try to explain the problem a bit better. What you can see is: - Run shadow-cljs watch to have the app and a REPL running - Use cider-connect-cljs to connect Emacs on the running REPL - Try to set the current namespace using cider-repl-set-ns - Try to eval a fn using cider-eval-last-sexp The project you see on the video is here https://github.com/wcalderipe/cljs-playground (there's nothing special). Versions: macOS Big Sur 11.2.2 Emacs 27.1 Cider latest commit on master (I'm using straight.el)

wcalderipe 2021-04-11T15:10:58.057700Z

I've just noticed the video is on extremely low quality. Sorry in advance ๐Ÿ˜…

thheller 2021-04-11T15:11:48.057900Z

yeah I can't tell what is going on

thheller 2021-04-11T15:12:03.058100Z

but I don't use emacs anyways so I don't have a clue what any of those commands are supposed to do

thheller 2021-04-11T15:12:49.058300Z

if the cider-repl-set-ns executes (in-ns 'whatever) then that will not work unless the NS is already compiled and loaded

thheller 2021-04-11T15:13:03.058500Z

if that is not the case you need a (require 'whatever) first

thheller 2021-04-11T15:13:24.058700Z

but I'd assume the error would show up somewhere telling you that

wcalderipe 2021-04-11T15:17:46.058900Z

@thheller I believe it does execute (in-ns 'foo) under the hood. btw, in-ns works if I just type it on the REPL

thheller 2021-04-11T15:20:29.059100Z

in general #cider likely is a better place to ask this

wcalderipe 2021-04-11T15:21:40.059300Z

thanks. will do ๐Ÿ™‚

wcalderipe 2021-04-11T15:27:01.059500Z

I'll leave the message here in the hope someone using Emacs save me. Moreover, I'll drop my second screen record with higher quality.

dpsutton 2021-04-11T15:59:00.059900Z

just to fill in, CIDER is aware it starts with a clj repl and is waiting on (shadow/nrepl-select <the-build>). But since cider-nrepl is not on the classpath it never realizes that the clj repl has been switched to cljs and is stuck in a pending state (or what it thinks is a pending state)

sh54 2021-04-11T18:11:16.062600Z

Not sure what dependency that is causing an issue here butโ€ฆ I am getting an issue with goog.isBoolean not being defined. This is right now only happening in my karma build. And only in the cljs-oops library: https://github.com/binaryage/cljs-oops It is getting called by the oops function (in js terms) Object.oops$core$validate_object_access_dynamically I took a look at the generated output javascript file and I see that stuff like goog.isObject gets assigned and even goog.isDateLike which I donโ€™t think I am directly touching in this project. But there is no similar assign to goog.isBoolean in the output file so it looks like it got pruned. My karma build parameters are: {:target :karma :output-to "target/test-ci.js" :compiler-options {:devcards true :infer-externs true :output-feature-set :es-next :warnings {:redef-in-file false :infer-warning false} :pretty-print true :pseudo-names true}}

thheller 2021-04-11T18:15:50.063400Z

@slack1003 those predicate functions were removed from the closure-library, see the CLJS release announcement https://clojurescript.org/news/2021-04-06-release Noteworthy & Breaking Changes

โœ… 1
sh54 2021-04-11T18:35:28.064300Z

oops got updated

sh54 2021-04-11T18:36:09.064800Z

so fixed by moving to 0.7.1

sh54 2021-04-11T18:36:11.065100Z

thanks

sh54 2021-04-11T18:49:33.070600Z

Is there a way to use something like the leiningen test selectors with the karma build?

sh54 2021-04-11T18:49:35.070800Z

All I really want to do is exclude running certain tests that were tagged with the relevant metadata. I have a bunch of webgpu tests which only run in Chrome Canary (and similar) which bail in regular headless chrome. There are work arounds like just checking if various js globals are defined. But I would prefer to just tag relevant namespaces and tests with some metadata and let the test runner figure it out. Since I am also targeting regular clojure too I tend to just run the tests via clojure when I am developing

thheller 2021-04-11T18:50:54.071700Z

that is not yet supported no. I have some changes regarding testing planned but didn't get around to them yet. might be a while too.

sh54 2021-04-11T18:53:41.073100Z

alright. Do you have some guidance on adding a new target? I just need a hint or two. Is it possible to supply a new target without replacing shadow-cljs with a fork?

sh54 2021-04-11T18:57:11.074400Z

great job on the whole system though! It is really nice to work with. This really is the only real sticking point I have come up against which I see I can get around with that regex or snooping for javascript globals

thheller 2021-04-11T19:00:24.075Z

yes you can write targets without changing shadow-cljs. in fact all targets are implemented that way. https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets

thheller 2021-04-11T19:01:13.075800Z

you can also specify :target your.own-target

thheller 2021-04-11T19:01:33.076400Z

that ns would then need to declare a (defn process [build-state] build-state)

thheller 2021-04-11T19:01:53.077Z

none of that is documented in particular though, so will require some digging

sh54 2021-04-11T19:02:15.077500Z

and itโ€™ll find it in my project as long as the process bit is there?

thheller 2021-04-11T19:02:37.077900Z

can be in your project or a library yes, as long as that ns is on the classpath

thheller 2021-04-11T19:03:34.078400Z

its just a regular CLJ namespace and the process function is called repeatedly for each step

thheller 2021-04-11T19:03:52.078800Z

:browser is by far the most complicated target but karma pretty straightforward

sh54 2021-04-11T19:07:03.079500Z

k thanks for the help there! Iโ€™ll take a look. may also just take the shortcut ๐Ÿ™‚

thheller 2021-04-11T19:09:52.079800Z

fwiw the node-test target already has some configuration options

thheller 2021-04-11T19:09:59.080400Z

or rather runtime options configuring which tests to run