Fork me on GitHub
#shadow-cljs
<
2022-08-25
>
g7s08:08:56

I am starting shadow in embedded mode and when I start a repl I get a weird Stdin: prompt in the Emacs minibuffer instead of using the in-buffer one. Versions shadow-cljs - 2.11.23 cider - 1.5.0 I have used the same setup in the past and didn’t have this issue. Does anyone have any idea what’s going on? Couldn’t find anything around and I’m not sure if it’s cider or shadow related

g7s08:08:56

:face_palm: looks like it.. I somehow missed that I had to include the shadow nrepl middleware, I’ll try this thanks @thheller

pez14:08:07

Hello. When setting up a minimal project I started to wonder about the dev web server. Some questions: • In some projects out there there is :http-server and :http-port config under :build {:my-build {:devtools { .... I can't find this mentioned in the user guide. Are these deprecated, or does this have some other functionality that the :dev-http config does not give me? • The user guide says that :dev-http is not needed for code hot reloading, but will configure hot-reload of CSS automatically. If I understand things correctly. So if I want to use my own web server, I can skip configuring a :dev-http and have code hot reload, but if I want to have CSS hot reload I should configure :watch-dir. Am I understanding this correctly?

thheller14:08:59

correct. :dev-http replaces the config in :devtools, and not using :dev-http requires setting :watch-dir for CSS reloads

🙏 1
pez14:08:07

I also wonder about :modules {:entries [...]. Here I have trouble formulating a question, actually. 😃 The guide says that it is: > The namespaces that serve as the root nodes of the dependency graph for the output code of this module. I don't quite understand what this means. Can it be elaborated on a bit? When does this get important? I'm looking at a sample project I once created and it doesn't have any :entries configured. Only :init-fn.

pez14:08:27

@U02KYBC5WJY and I are planning a video about Calva and shadow-cljs and will demo setting up a minimal project. I'd like to not spread too much misinformation in this video. 😃

🎉 1
thheller14:08:59

:init-fn foo.bar/init desugars to :entries [foo.bar] plus calling (foo.bar/init) when the module is loaded

thheller14:08:25

:entries just gives you extra ways to add code to a module. you don't need to set it if you don't need extra namespaces

thheller14:08:00

it becomes relevant when you have namespaces that aren't otherwise required but should still be included in the build

thheller14:08:09

(in code splitting scenarios mostly)

pez14:08:00

Awesome, thanks! We will not enter into code splitting territory in this video, but super good to know.

thheller14:08:27

yeah then just stick with :init-fn. usually there is no need for :entries without code-splitting

🙏 1
👍 2
vlad_poh21:08:22

Hi getting this error and not sure how to troubleshoot. Any tips?

Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
shadow-cljs watch frontend generates a js file with 41 warnings.

thheller21:08:25

getting this error when? this would happen way before watch would ever build anything?

thheller21:08:51

I'm guessing you are using deps.edn to manage dependencies and either don't have shadow-cljs in there at all or on an alias that isn't activated?

vlad_poh21:08:47

trying to use shadow-cljs only

vlad_poh21:08:53

do i need to use deps?

thheller21:08:15

no, just shadow-cljs.edn is fine

vlad_poh21:08:16

oh and the error happens when i try to jack-in calva leiningen+shadow-cljs

thheller21:08:37

well. then you are not using shadow-cljs only are you? then you are using leiningen.

😅 1
thheller21:08:00

if you jack-in with leiningen then leiningen is in control of your dependencies

thheller21:08:12

so you need to add thheller/shadow-cljs to project.clj

winsome21:08:39

Does :web-worker true work in modules defined in :target :esm?

thheller21:08:11

@winsome it does not, but also shouldn't be necessary

winsome21:08:38

Alright, I'll give it a swing :thumbsup:

winsome21:08:55

Is it possible to generate a "default" export using :target :esm? Right now I've got a (def exports #js {:all all :my my :fns fns}), which works, but I'd like to just export the whole ns.

vlad_poh22:08:58

@thheller I added the following to the leiningen profile

:profiles
  {:cljs
   {:source-paths ["src/cljs"]
    :dependencies [[thheller/shadow-cljs "2.19.9"]
                   [reagent "0.9.1"]]}}
and got the same error trying to jack in
Execution error (FileNotFoundException) at user/eval8784 (form-init8455403758683339037.clj:1).
Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
Socket closed
Socket closed
Socket closed
Socket closed
do i need to make changes in the shadow-cljs.edn file?

thheller22:08:48

@kbosompem when you use leiningen to manage dependencies then you need to use leiningen properly. did you enable the :cljs alias when you jack-in?

thheller22:08:38

this is entirely emacs -> leiningen

vlad_poh22:08:24

yes i check of :cljs and click ok

thheller22:08:49

don't know what you mean by that? since when can you click anything in emacs?

vlad_poh22:08:59

no i’m in calva

thheller22:08:18

so which command does it run when you jack-in?

vlad_poh22:08:09

; Jacking in...
; Starting Jack-in Terminal: lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- with-profile +cljs repl :headless
; nREPL Connection was closed
; Hooking up nREPL sessions...
; Connected session: clj
; TIPS:
;   - You can edit the contents here. Use it as a REPL if you like.
;   - `alt+enter` evaluates the current top level form.
;   - `ctrl+enter` evaluates the current form.
;   - `alt+up` and `alt+down` traverse up and down the REPL command history
;      when the cursor is after the last contents at the prompt
;   - Clojure lines in stack traces are peekable and clickable.
clj꞉vgs.core꞉> 
; Creating cljs repl session...
; Connecting cljs repl: Leiningen + shadow-cljs...
;   The Calva Connection Log might have more connection progress information.
; Failed starting cljs repl for build: :frontend. Is the build running and connected?
   See the Output channel "Calva Connection Log" for any hints on what went wrong.
; Jack-in done.
clj꞉vgs.core꞉> 

thheller22:08:39

ok that looks fine. what do you do next?

vlad_poh22:08:52

that’s as far as i get

vlad_poh22:08:14

backend runs but no js generated

thheller22:08:51

sorry but I don't have a clue what you are doing there. I don't see a command to run a backend or any output related to that?

thheller22:08:11

I don't have a clue what calva does

thheller22:08:28

what is in this Calva Connection Log? any more info on what it tried to do?

vlad_poh22:08:52

only the following

Execution error (FileNotFoundException) at user/eval8784 (form-init8455403758683339037.clj:1).
Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
Socket closed
Socket closed
Socket closed
Socket closed
Socket closed
Socket closed
Socket closed

thheller22:08:03

did you place the profile correctly?

thheller22:08:09

not nested in some other map or so?

thheller22:08:24

that error is basically just telling you that the dependency was not loaded

thheller22:08:28

that doesn't tell me anything about what is in your actual project.clj 😉

vlad_poh22:08:44

i think i’m missing the clojure and clojurescript dependency

thheller22:08:00

no, you are definitely missing the shadow-cljs dependency

thheller22:08:48

I mean to make things easier just move shadow-cljs to your main dependencies