cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
zackteo 2021-05-15T05:51:46.010700Z

What Clojurescript repl type do people usually use? :o

zackteo 2021-05-15T05:55:57.010800Z

Really don't quite understand the cider clojurescript workflow - if any

zackteo 2021-05-15T06:01:36.011400Z

Evaluation within Emacs won't work unless I use weasel is that correct ?

dpsutton 2021-05-15T06:11:26.011900Z

Donโ€™t think weasel is really a thing

dpsutton 2021-05-15T06:29:29.014600Z

there are largely three ways to go about this. figwheel (deprecated but still widely used), figwheel main and shadow-cljs. Clojurescript is a clojure library that compiles cljs files into js files. Evaluating code requires a js context, as clojurescript can only emit code, not evaluate it. This is where figwheel-main and shadow come in. They have all of the filewatchers to keep recompiling, and open websockets to update the javascript environment with the latest code.

dpsutton 2021-05-15T06:30:31.016400Z

for the purposes of CIDER, a cljs repl is a regular clj repl that gets "upgraded". you start a clj repl, and call functions in either figwheel main or shadow that move evaluation from the jvm and into the js context

zackteo 2021-05-15T06:30:33.016600Z

Hmmm, I'm using shadow-cljs but not sure if im supposed to be able to be able to evaluate code inside cider. I am able to get hot-reloading by saving

dpsutton 2021-05-15T06:31:08.017300Z

you absolutely should be able to. m-x cider-jack-in-cljs should prompt you for a few things. pick shadow and then choose your build and it should just work

zackteo 2021-05-15T06:32:24.018600Z

Am i supposed to have a project.clj ? Am wondering if it is because I only have shadow-cljs.edn with ..

;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dev-http {8081 "public"}

 :dependencies
 [[reagent "1.0.0"]
  [re-com "2.13.2"]
  [binaryage/devtools "1.0.3"]]

 :builds {:app {:target     :browser
                :output-dir "public/scripts/"
                :asset-path "/scripts/"
                :modules    {:main {:init-fn ura.frontend.core/run}}}}}

dpsutton 2021-05-15T06:32:44.019100Z

that will start a shadow process npx shadow-cljs ... and then at the repl it calls (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s)) for you where the %s is replaced with your build

dpsutton 2021-05-15T06:32:56.019400Z

you only need a project.clj file if you need a lein process

dpsutton 2021-05-15T06:33:15.019800Z

totally fine to just have just a frontend

zackteo 2021-05-15T06:33:40.020Z

hmmmm

dpsutton 2021-05-15T06:34:59.020400Z

the equivalent for figwheel main is (do (require 'figwheel.main) (figwheel.main/start %s)), basically the same api

zackteo 2021-05-15T06:36:36.020600Z

let me try again

zackteo 2021-05-15T06:37:01.021Z

this call: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s)) should be done by cider right ?

dpsutton 2021-05-15T06:38:59.021200Z

correct

dpsutton 2021-05-15T06:39:03.021400Z

just jack-in-cljs

dpsutton 2021-05-15T06:39:12.021700Z

and hopefully just follow the prompts

zackteo 2021-05-15T06:44:43.022600Z

Is it supposed to change from shadow.user> to cljs.user>

dpsutton 2021-05-15T06:45:47.023Z

Yeah once you open the browser to your app

dpsutton 2021-05-15T06:46:07.023500Z

Local host 8081 for you according to your file above

zackteo 2021-05-15T06:48:45.023800Z

I think I have this issue https://shadow-cljs.github.io/docs/UsersGuide.html#missing-js-runtime

dpsutton 2021-05-15T06:50:18.024600Z

Have you opened the browser to your site and seeing your app?

zackteo 2021-05-15T06:53:06.024700Z

Yeapp. But it doesn't watch the app. Doesn't hot reload. Need to manually start the watch

thheller 2021-05-15T06:54:24.025300Z

honest question: can shadow-cljs do something different that makes this easier to understand? seems like A LOT of people struggle with this in cider?

thheller 2021-05-15T06:55:15.026Z

this question never comes up for cursive but somehow the cider jack-in process seems to make this complicated? why?

dpsutton 2021-05-15T06:56:13.027400Z

I think it opens the browser automatically. I donโ€™t understand

zackteo 2021-05-15T06:56:19.027600Z

maybe it is because most start with the clj experience and the cljs experience is very foreign to most ?

dpsutton 2021-05-15T06:57:09.029300Z

But the symptoms here are strange. If itโ€™s not watching the app. If you change some string In your files does it reload the app and show a bit of ui from shadow?

zackteo 2021-05-15T06:57:24.029500Z

Oh it opens the browser and the app is there but ill get shadow-cljs - Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running?

zackteo 2021-05-15T06:58:21.029600Z

Let me try again... hmm

dpsutton 2021-05-15T06:59:29.030700Z

I think I remember seeing that when the browser opens before compilation has finished. The repl should show compiling and then when it finishes

dpsutton 2021-05-15T06:59:38.031100Z

And then just hit refresh in your browser

zackteo 2021-05-15T07:05:32.032500Z

Now i seem getting sync nrepl timeout. If I do (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app)) myself, it seems to work . Like on save it will say [:app] configuring build. [:app] Compiling ...

zackteo 2021-05-15T07:05:38.032700Z

but doesn't actually update the app

dpsutton 2021-05-15T07:06:00.033200Z

that sounds like a configuration problem. did you read through how to set up the init and after-refresh functions?

codeasone 2021-05-15T07:06:10.033300Z

@zackteo here's how I set things up with deps.edn in case it provides some pointers https://github.com/codeasone/starter-cider-tools-deps-shadow

zackteo 2021-05-15T07:07:07.034600Z

wait. Emacs setup or shadow-cljs.edn?

dpsutton 2021-05-15T07:07:08.034700Z

you can try this repo here: <https://github.com/dpsutton/asg-ignite-app>. just clone, npm install and then cider-jack-in-cljs, choose shadow, and the app build, then open localhost 3000

codeasone 2021-05-15T07:07:11.034800Z

I found the cider session handling confusing.

zackteo 2021-05-15T07:14:38.035500Z

having some issues with npm install @dpsutton can't seem to find this tho semver.simplifyRange is not a function

dpsutton 2021-05-15T07:15:36.035700Z

when doing npm install?

zackteo 2021-05-15T07:15:42.035900Z

yeap

dpsutton 2021-05-15T07:15:56.036200Z

weird. for me ran just fine, added 114 packages

zackteo 2021-05-15T07:16:49.036500Z

189 verbose stack TypeError: semver.simplifyRange is not a function
189 verbose stack     at Advisory.[calculateRange] (/usr/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/advisory.js:191:16)
189 verbose stack     at Advisory.load (/usr/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/advisory.js:148:28)
189 verbose stack     at Calculator.[calculate] (/usr/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/index.js:59:14)
189 verbose stack     at async Promise.all (index 0)
189 verbose stack     at async Map.[init] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:177:7)
189 verbose stack     at async Map.run (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:105:7)

zackteo 2021-05-15T07:16:50.036700Z

hmmmm

dpsutton 2021-05-15T07:18:02.037200Z

looks like that's in the audit report. there are some advisories in these deps but it doesn't matter for demo purposes

dpsutton 2021-05-15T07:18:10.037400Z

might be fine to just ignore and continue

zackteo 2021-05-15T07:21:18.038Z

not sure why my nrepl sync keeps timing out now but probably might be resolved with a restart hmm

dpsutton 2021-05-15T07:22:12.038600Z

one thing you can try is npx shadow-cljs compile app and then try everything. if its timing out due to compilation taking a while, you can kinda help it out

dpsutton 2021-05-15T07:22:22.038900Z

don't know if compilation can cause a timeout or not but something to try

zackteo 2021-05-15T07:39:19.039200Z

Okay it works so it is my app config

zackteo 2021-05-15T07:39:25.039400Z

could i ask what is ["react-modal" :as Modal]

zackteo 2021-05-15T07:50:07.039800Z

yeah evaluation works with your project too

thheller 2021-05-15T07:51:35.040400Z

that is a require for the react-modal npm package, what exactly that does I don't know ๐Ÿ˜‰

zackteo 2021-05-15T08:05:35.041Z

the hot reload seems to work already. But evaluation still does not work for my project ... hjmmm

zackteo 2021-05-15T08:25:48.041100Z

Okay cool it works now

pithyless 2021-05-15T12:56:44.041200Z

@zackteo if working with any npm code, it is good to be aware of the different ways you can translate JS requires to CLJS. There is a useful Table 1: ES6 Import to CLJS Require in this section: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

zackteo 2021-05-15T12:58:24.041400Z

Oooo! Thank you! So using a string like so is the standard for npm packages?

pithyless 2021-05-15T12:59:22.041600Z

As an aside, @thheller - I've had to reference and point to that table many times; any chance you can add a page id so one can link to the table directly? It's not immediately "obvious" when you link to the section, because it's below the page fold.

๐Ÿ‘ 1
pithyless 2021-05-15T13:03:18.041800Z

@zackteo yes; the strings are used only for external JS imports

๐Ÿ‘ 1