Fork me on GitHub
#fulcro
<
2021-05-23
>
yubrshen04:05:37

Has anyone succeeded in getting https://github.com/fulcro-community/fulcro-exercises/ working for the 0 step with emacs? When I executed M-x cider-connect-cljs it connects to the shawdow-cljs server and the REPL's namesapce was set to cljs.user. But I when I evaluated

cljs.user> (shadow/repl :main)
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: <eval>:1:2
 No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow"
--------------------------------------------------------------------------------

------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var shadow/repl
--------------------------------------------------------------------------------
then when I evaluated the namespace holyjak.fulcro-exercises I got no feedback of success, nor feedback of error. then when I modified the step 0 as follows:
(do ;; comment ; 0 "Try it out!"
  (do
    (defsc Root0 [_ _]
      (h1 "Hello, I am a Fulcro app from the exercise 0!"))

    ;; Send this whole `do` to the REPL. Do you see the UI change in the browser?
    (render! Root0)

    (comment ; try running the hint fn 3 times!
      (hint 0)
      (hint 0)
      (hint 0))

    nil))
After saving the file, I got an error at the shadow-cljs server web page at http://localhost:8000/ shadow-cljs - [reload failed] Failed to load holyjak/fulcro_exercises.cljs: nil passed to get-query I found no other error nor feedback.

yubrshen16:05:41

But I am able to get repl working with Cursive. And with Cursive, I can manually execute functions and get the expected behavior at the web page and the repl output buffer. So the problem is just related to emacs of connecting to cljs/shadow-cljs buffer.

yubrshen16:05:55

This is a great way for me, a beginner in ClojureScript, and Fulcro, to appreciate the functionality of Fulcro/ClojureScirpt. Thanks for the critcial help!

Jakub Holý (HolyJak)17:05:22

Are you sure that cider-connect-cljs does what you expect? I thing what you should actually do is to starta clj REPL connecting to the running shadow repl and then run (shadow/repl :main) from that shadow clojure repl to connect to the cljs REPL. But #shadow-cljs might be a better place to get advice.

yubrshen01:05:39

Yes, cider-connect-cljs is the command to connect to externally started REPL. I found a solution. It requires additional dependency to cider.nrepl. Here is the details: https://yubrshen.github.io/20210529164328-deps_edn_for_clojurescirpt_shadow_cljs_be_connectable_with_cider_connect_cljs.html

🎉 3
Jakub Holý (HolyJak)18:05:37

@U2QGRCMSM could you be so kind and check whether the updated instructions and deps work for you out of the box? See https://github.com/fulcro-community/fulcro-exercises/pull/3/files (if you have cloned the repo before, then you can fetch and check out the fix/cider-support branch. Thank you!!!

🙌 3
yubrshen19:05:16

Sure. I'll.

🙏 3
yubrshen14:06:29

Yes, following your instruction, after starting REPL by clojure -M:cider:serve then from emacs with M-x cider-connect-cljs then, I can evaluate ClojureScript code in the project's source code buffer. Thanks for a very clearn accomodation! (In my experiement, cider/piggieback {:mvn/version "0.5.1"} is not necessary.)

yubrshen15:06:24

On another note, in shadow-cljs.edn, should :deps {:aliases [:dev]} be :deps {:aliases [:serve]} as the required dependencies for shadow-cljs.edn from deps.edn is defined by :serve I tried to start REPL within emacs M-x cider-jack-in-cljs It seemed the above fix is needed.

Jakub Holý (HolyJak)09:06:16

Thanks a lot! Deps: I will just remove the alias, it can perhaps cause problems if it is not defined on your machine (I have it in my global deps.edn). The :serve deps are not required by shadow in my experience.

yubrshen16:05:55
replied to a thread:Has anyone succeeded in getting https://github.com/fulcro-community/fulcro-exercises/ working for the 0 step with emacs? When I executed `M-x cider-connect-cljs` it connects to the shawdow-cljs server and the REPL's namesapce was set to `cljs.user`. But I when I evaluated cljs.user&gt; (shadow/repl :main) ------ WARNING - :undeclared-ns ------------------------------------------------ Resource: &lt;eval&gt;:1:2 No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow" -------------------------------------------------------------------------------- ------ WARNING - :undeclared-var ----------------------------------------------- Resource: &lt;eval&gt;:1:2 Use of undeclared Var shadow/repl -------------------------------------------------------------------------------- then when I evaluated the namespace `holyjak.fulcro-exercises` I got no feedback of success, nor feedback of error. then when I modified the step 0 as follows: (do ;; comment ; 0 "Try it out!" (do (defsc Root0 [_ _] (h1 "Hello, I am a Fulcro app from the exercise 0!")) ;; Send this whole `do` to the REPL. Do you see the UI change in the browser? (render! Root0) (comment ; try running the hint fn 3 times! (hint 0) (hint 0) (hint 0)) nil)) After saving the file, I got an error at the shadow-cljs server web page at http://localhost:8000/ `shadow-cljs - [reload failed] Failed to load holyjak/fulcro_exercises.cljs: nil passed to get-query` I found no other error nor feedback.

This is a great way for me, a beginner in ClojureScript, and Fulcro, to appreciate the functionality of Fulcro/ClojureScirpt. Thanks for the critcial help!