Fork me on GitHub
Luis Santos14:02:56

Hi everyone, Whats the recommended way to use static assets installed via npm? Let's say that I want to install bootstrap or tailwindcss using CSS and I want the assets to be available int he public folder and later in the dist folder. What are the best practices?


I just use tailwind with postcss as described in the tailwind docs

👍 1

Hi there. I'm combing through the doc and there doesn't seem to be any way to tell shadow-clj which lein profile to use dynamically instead of having it hardcoded inside shadow-cljs.edn? The reason for this is I have multiple lein profiles, each of which corresponding to different environment like dev, test, prod, etc. and I'd like shadow-clj to be able to do the same. Would appreciate any insight. Thanks in advance 🙂


shadow-cljs does not support this and it usually isn't required for CLJS. at least I haven't heard a convincing argument for it yet 😉


you can just use lein if you really must


instead of shadow-cljs release app you do lein with-profiles +whatever run -m shadow.cljs.devtools.cli release app


Thanks a lot 🙂 I'm not sure if it's technically hard to do but having separate lein config inside each build would be nice for something like this I imagine.


the way things currently work this is not possible and I have no interest in changing it. if you must do this you can just use lein as described.


I'm having an adventure failing to understand how to connect my editor (Neovim/Conjure) to a REPL for a :target :node-script build. So first I'm doing shadow-cljs start && shadow-cljs clj-repl app and then running (shadow/watch :app) and (shadow/repl :app) from there, per The prompt then changes to cljs.user=> and when I evaluate forms directly from there it complains "No application has connected..." which is to be expected I think since I haven't actually started a Node process. So far so good I guess. However, at this point when I do :ConjureConnect 7001 from my editor and try to evaluate forms, it is connecting to a plain Clojure REPL and doesn't consider JS forms e.g. (js/console.log ...) valid. I think this is because the (shadow/... :app) forms only transform that one client connection into a CLJS REPL; the nREPL server itself is still in Clojure "mode"...but how do I get the server itself to compile CLJS forms?


@ctamayo first of all are you sure shadow-cljs node-repl isn't enough for your use case? second if you connect to the nrepl that connection starts out in CLJ mode. so you switch it via (shadow/repl :app)


the server is always in CLJ mode and that cannot be changed. you just switch your connection when needed.


When I do shadow-cljs node-repl it starts up the server on 7001 but when I do :ConjureConnect 7001 it complains:

[2021-02-07 12:53:39.022 - WARNING] :shadow.cljs.devtools.server.nrepl-impl/init-ns-ex - {:init-ns }
FileNotFoundException Could not locate media_server/app__init.class, media_server/app.clj or media_server/app.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
My main file is src/media_server/app.cljs and when I change it to .clj it complains that the ns form does not conform to spec because I'm trying to require the "fs" node module.


sorry I can't answer conjure questions. I have never used it and have no idea what it does.


It's a REPL client for Neovim, no worries :thumbsup::skin-tone-3:


I know what it is. I just don't know what it does on connect and stuff


looks like its trying to change the CLJ connection to that ns. that will not work, it needs to be switched to CLJS first


think of shadow-cljs as a CLJ server only. it then takes commands to build CLJS. you cannot eval CLJS without giving those commands first


for the node-repl you can just run shadow-cljs server .. connect to nrepl and then run (shadow/node-repl)


Yeah, I immediately remembered I hadn't done that, sorry. Here's what happens when I do though.

$ shadow-cljs node-repl
shadow-cljs - config: /home/tamayo/projects/media-player/server/shadow-cljs.edn
shadow-cljs - server version: 2.9.6 running at 
shadow-cljs - nREPL server started on port 7001
cljs.user=> (shadow/watch :app) ;; <----------- TRYING TO SWITCH MODES HERE ----------<<<<<
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: :1:2
 No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow"
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:2
 Use of undeclared Var shadow/watch
TypeError: is not a function
    at cljsEval (<eval>:1:16)
    at global.SHADOW_NODE_EVAL ([stdin]:105:10)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
    at ret (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:49:13)
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:120:11)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:47:1)
    at shadow$cljs$devtools$client$node$process_message (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:106:5)
    at /home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:242:9
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:194:7)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:248:7)


or shadow-cljs server ... connect nrepl then (shadow/watch :app) and (shadow/repl :app)


if you run shadow-cljs node-repl in the command line that will drop you directly into CLJS mode as indicated by cljs.user=> prompt


but ONLY that command. not the nrepl server


only that command meaning only that connection/client?


listen. kill all processes. run shadow-cljs server.


that starts a blank server that just does nothing except wait for further commands


THEN connect nrepl or run other commands in a separate terminal


you can use the shadow-cljs commands or you can run all those directly over nrepl


just don't confuse the two and their purpose


sorry for making this more confusing by bringing up node-repl. that is just a simplified node repl that is already ready to go with its own node process but not coupled to any build


vs :node-script where you have to manage the node process yourself


> not coupled to any build I see, that is the piece I was missing. I understand the piece about server vs the various REPL commands...I tried various ways but still can't get my editor REPL to play nice with CLJS. So I need to just figure out what the issue is on the Conjure side. Sorry if it seemed like I wasn't listening, I was just trying to validate my understanding.


so you get an error if you run shadow-cljs server and then connect conjure? without doing anything else?


that shouldn't happen but if it does its on the conjure side of things


unless you maybe configure :nrepl {:init-ns ...} in your shadow-cljs.edn config?


Ah, I did do that, now I understand why it wouldn't like that...


and yes, it errors at that point w/o anything else


right yeah. that would switch the CLJ nrepl to that ns but since its a CLJS ns that doesn't work


you switch the default ns for you build via :devtools {:repl-init-ns} in your build config instead


gotcha, that makes sense


I’m using shadow-cljs on an M1 MacBook Pro for a couple of week. (PS: it’s amazing. IntelliJ/Cursive, shadow-cljs watch, kaocha watch, Fulcro RAD app running in browser. Laptop stays cool, totally silent, and runs for hours with only 20-30% battery consumed. So different than my Intel MBP, which would last for no more than 45m!) But I have noticed something strange, and don’t know how to best document this strange behavior. When using an ARM JVM (either IntelliJ JBR or Azul JVM), it seems to take much longer to detect file changes. This affects the shadow-cljs builds, and kaocha watch tests. When a save a file, it may take between 3 seconds and maybe even up to 10+ seconds for the file change to trigger a compile or test run. Has anyone else run into this problem? Is there a simple test case or scenario I can use to isolate what is causing the delay? (I haven’t tried using an x86 JVM yet. I’m sufficiently afraid I’ll permanently break my dev setup by doing that… Unwarranted I’m sure, but… 🙂


@genekim I assume this is on Big Sur so try the latest version. I removed the old hawk file watching lib which seemed to cause trouble on Big Sur

🤯 2

Incredible, @thheller. Thank you!! Always blown away by shadow-cljs , and how it makes the build system just fade into the background, in the best possible way! 🎉🎉🎉 So wonderful!

❤️ 3

don't know anything about how it affects M1 though. only had reports from older hardware but all related to big sur so maybe the same on M1


Will try this right now!


you can also set :fs-watch {:hawk false} in shadow-cljs.edn top level on older versions, basically the same effect


Confirmed that file watcher issue seems to have disappeared. Thanks, @thheller!!

👍 2