is it possible to do something like the following in shadow-cljs?
import './App.css';
no
mmmh... I wonder if there are any constraints/reasons why?
well the constraint is that shadow-cljs knows how to build JS and CLJS files. adding support for CSS files would be a non-trivial amount of work.
the reason I haven't done it is because I don't think it is useful
I usually have a secondary build system for my CSS anyways and I can just put the import there. I think its silly to use JS constructs for that.
for example you can use the setup described here
and then either put your css in this file directly https://github.com/jacekschae/shadow-cljs-tailwindcss/blob/main/src/css/tailwind.css or have that import the other files
I know that it would be more convenient if shadow-cljs handled all that automatically but I currently don't have the time/energy to work on that
alright
Hello! I struggle with REPL-driven development with shadow. The problem is that when I define some troubleshooting / dev vars (such as (defn f [& args] (def *debug args) (...))
), they tend to disappear. I suppose that is because I do most of my coding inside a (comment ...)
and when IntelliJ saves the file after any changes, Shadow reloads the code. I thought that vars would survive that (as they do in clj) but it seems they do not, at least sometimes.
Any tips? 🙏
well yeah hot-reload and REPL are sort of at odds with each other
hot-reload is not additive so it'll remove definitions that you only defined in the REPL
so one option is to disable the hot-reload and just use the REPL like you would in CLJ
or you keep the hot-reload but accept that stuff sometimes gets undefined
technically it is all still there on the JS side, just the compiler doesn't know about it anymore
things aren't additive with hot-reload since I want warnings to show up ASAP. say I changed (defn foo [])
to (defn bar [])
. I want to see warnings for all places still using foo
ASAP. In Clojure I often only notice such things when I restart my process a couple hours/days later since foo
will still be around and valid until then.
I guess I could compromise somehow and track which def
was defined from a REPL and keep those instead of resetting the entire ns
Thanks a lot! Is there a quick way to switch hot-reload on/off?
(I agree that being non-additive to show such warnings ASAP is in general the better choice. I just need to find out an effective way of doing experiments/troubleshooting in the REPL - which may be telling intellij not to save files automatically.)
from the CLJ REPL you can call (shadow/watch-set-autobuild! :app false)
Not sure if that’s relevant for you/shadow, but figwheel will actually refuse to load namespaces with warnings and namespaces that depend on them. That feels like a good default to me.
same in shadow
Cool 👍
Hello.. I am relatively new to ShadowCLJS and using Clojure_Script_… and was wondering if you all might be able to point me in the general direction on JS libraries that use Node dependencies
there might be two issues going on: 1st - we are trying to use the Redlock library, and when we do as part of the require:
~ 9 ["ioredis" :as Redis]
~ 10 ["redlock" :as Redlock]
I get the following compilation error:
[:employee_record] Compiling ...
The required JS dependency "async_hooks" is not available, it was required by "node_modules/bluebird/js/release/util.js".
Dependency Trace:
shadow/umd_helper.cljs
user_auth_profile/employee_record/update.cljs
user_auth_profile/system_config.cljs
node_modules/redlock/redlock.js
node_modules/bluebird/js/release/bluebird.js
node_modules/bluebird/js/release/promise.js
node_modules/bluebird/js/release/util.js
Searched for npm packages in:
/Users/sproctor/guaranteed-rate/user-auth-profile/node_modules
See: <https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install>
The part that is confusing is that async_hooks
is part of NodeJS
which :target
is your build? when building for the browser the native node packages are not available
a :node-library
we are deploying to AWS Lambda
did you set :js-provider :shadow
in your build config?
yes
here is the build target:
:employee_record {:target :node-library
43 :exports {:update user-auth-profile.employee-record.update/-main}
44 :source-map false
45 :output-dir "target/employee-record"
46 :output-to "target/employee-record/lambda.js"
47 :compiler-options {:infer-externs :auto
48 :externs ["externs/httpurr.js"]}
49 :js-options {:js-provider :shadow
50 :keep-native-requires true}
~ 51 :release {:compiler-options {:optimizations :simple}}}
so you can either not do that at all or add :keep-as-require #{"async_hooks"}
note that I do NOT recommend using :js-provider :shadow
for node builds
better to keep the default and post-process with https://github.com/vercel/ncc or so if you really need things to be standalone
Is there some detail in the UserGuide that outlines this? Wondering if I have missed it, or mis-understood this
:js-provider :shadow
is built and optimized for browser builds. that is works for node was due to some experimental changes and I decided this wasn't worth doing so didn't continue working on it.
so you likely found out about it in the github issue about this in the first place? the docs don't mention it
I have been trying to ramp up on ShadowCLJS as new projects at work are starting to use it over Figwheel for our AWS Lambda deployments
I have a little playground example for getting cljs working with lambda. I think it still works https://github.com/omnyway-labs/lambda-play
This also looks interesting. Not (yet) supporting cljs but it makes it easy to use Java, GraalVM or Babashka for lambdas https://github.com/FieryCod/holy-lambda The biggest issue I found with using cljs in lambdas (or probably any standalone node style program) is you are trapped in single thread / Promise / Async hell that you don't really experience in a browser / reagent / re-frame app
I saw some, but might have mis-understood what that issue was referring to
I think its best to NOT post-process the files at all and just "deploy" your .js file together with the needed node_modules
but I don't use AWS lambda so I don't know the details of how deploys actually work
I did see this item yesterday: https://github.com/thheller/shadow-cljs/issues/290
got lost in the other references around MongoDB, and some other side threads on it… 😉
Thank you for your help!!!
need to take this back to the larger team and understand how we want to proceed
thanks again
Is the story for having a library play nice with figwheel is to just provide the CLJSJS fallbacks? If so, how do I provide the equivalent :require
calls?
As much as I'd like to slap a "won't fix/use shadow" tag on the issue haha
@neo2551 did you ever figure out shadow-cljs with kamera?
Not really. What I did figure out though was to use Clojure dev tools protocols used in kamera to navigate to the page and make the screenshot and then use these screenshot with kamera.
Since I am using re-frame, I also had a list of events that cdp could use to go to the desired state.
Thanks 🙂 I'm in a similar situation
> use Clojure dev tools protocols used in kamera to navigate to the page Any chance you could elaborate on this?
for people using figwheel with :target :bundle
:require
is exactly identical and no CLJSJS is needed
for CLJSJS you need to setup that CLJSJS package and setup the proper :foreign-libs
to emulate the :require
in the code nothing changes
Kamera library looks fairly hackable, gonna try forking it. Will post more if it works.