hello all, beginner question here. How do people go about authoring styles in cljs projects? Coming from JS-land I've enjoyed preprocessors and css-in-js. I'm doing some googling, but if anyone has recommendations I'd love to hear
These are the projects that I know of, in no particular order: - https://github.com/clj-commons/cljss - https://github.com/roosta/herb - https://github.com/khmelevskii/emotion-cljs - https://github.com/dvingo/cljs-emotion - https://github.com/noprompt/garden
Thank you!
Would the feedback on how similar one set of css styles was to another on your application be useful for people? I'm thinking something that reads any styles you have and provides you with a list of "very close" results. This could be used to Prevent style drift if the styles were supposed to be the same but weren't shared data
Hey all, a bit of non-standard question here: how do you usually use an HTTP client in ClojureScript with Node.js target? โClojure-httpโ isnโt an option since it uses XMLHTTPRequest under the hood. Maybe someone has a decent example? Only need to make a simple POST with some qparams. ๐
Thank you, will give it a try
Maybe you can try to update your Shadow-cljs version and then rebuild.
@thedanpetrov So did you find the culprit?
If this hasnโt been resolved, there is a video illustrating using axios: https://www.youtube.com/watch?v=0zaw3gcf0Sk
Hmm haver tried with the way in your repo, still gives me the same error ๐ Iโll check out the video too. Maybe I am building wrong? I use this script: shadow-cljs release :lambda --debug
(same as the package.json I posted above)
The video is nice, however it uses Figwheel + the :bundle
target of CLJS...I'm not sure that helps because with Shadow-CLJS it's different.
Did you try updating your Shadow-cljs version and then rebuild a new release?
Or did you try to run with shadow-cljs watch lambda
and see if the error is still there?
itโs already the latest shadow version, same one that you use in your example, so I donโt think that is the issue here
Another suggestion, you can also tried to npx shadow-cljs build lambda
to see if it works without production optimizations.
Maybe you mean compile
? But in any case I get a strange error like this:
The required namespace "main.lambda" is not available, it was required by "shadow/umd_helper.cljs"
Even though my namespace is declared and the path is correctExactly, I was meaning compile
. ๐
When you do tree src/
, did you have the right path src/main/lambda.cljs
?
Your lambda file extension is "cljs" not "clj"?
Yep, this is what tree
looks like:
src
โโโ main
โย ย โโโ lambda.cljs
โโโ test
โโโ lambda-test.cljs
Hmm, strange...I see no other solution than to invoke the Shadow master! ๐ @thheller Do you have any clue about this error?
Cannot find module 'axios'
this is the error in question right?
the answer to that is simply that shadow-cljs does not bundle JS dependencies when running node. it is assumed that node will provide them at runtime which mean whereever you are running them the node_modules/axios
needs to be available. if you want a self-contained JS file with no external dependencies post-process the file with something like https://github.com/vercel/ncc
Fine thank you @thheller, since the project is intended to run on aws Lambda, this must be the reason indeed. @thedanpetrov you confirm that you encounter these errors on Aws Lambda. Have you tried running it locally to see if it works? And then deploy with the bundle dependencies https://stackoverflow.com/a/48357506/5773724
Hmm I thought shadow-cljs bundles your npm dependencies for you, just like webpack? Or am I deceiving myself.
it does for browser builds yes. for node builds that is typically not needed or wanted
I see, that explains a lot then :D thanks guys!
I have tried using interop and the axios
library, but I get an import error:
(ns main.lambda
(:require ["axios" :as axios]))
"Error: Cannot find module 'axios'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
Iโve used this in my current project https://github.com/Jarzka/stylefy
Hi @thedanpetrov How do you run ClojureScript ? Shadow-CLJS, Figwheel or vanilla CLJS ?
Hey, shadow
my shadow-cljs.edn looks something like this:
{
:lein false
:source-paths ["src"]
:dependencies
[]
:builds
{:lambda {:target :node-library
:output-to "./dist/lambda/index.js"
:exports {:handler main.lambda/handler}
:compiler-options {:infer-externs :auto}
}
:node {:target :node-script
:output-to "./dist/node/index.js"
:main main.lambda/start
:devtools {:after-load main.lambda/reload}}
:test {:target :node-test
:output-to "./build/test.js"}
}}
It works for me. And your package.json file?
{
"name": "yuno",
"description": "",
"version": "0.1.0",
"private": true,
"devDependencies": {
"shadow-cljs": "2.10.19"
},
"dependencies": {
"axios": "^0.20.0"
},
"scripts": {
"build": "shadow-cljs release :lambda --debug",
"predeploy": "npm run build",
"deploy": "cd dist/lambda && zip lambda.zip index.js && aws lambda update-function-code --profile cvi-aws-admin --function-name yuno --zip-file <fileb://lambda.zip>",
"clean": "rm -rf dist"
}
}
I donโt think too much out of the ordinary here
Thanks. This Garden projects seems to be quite popular seeing as it's used by multiple two of these other projects
This is a very strange warning, anyone have a clue to what it means: > WARNING: The org.clojure/core.async dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility.
@cattabanks it means that you should not include core.async in dependencies for shadow-cljs
Any reason why?
https://github.com/thheller/shadow-cljs/commit/06015e1c4d5d8b0127b27abb5b7112dc0d760af6
things break badly when using an incompatible core.async version since shadow-cljs uses core.async directly itself
so core.async is always available
Got you
I made a simple repo who works perfect for me, maybe it can help: https://github.com/PrestanceDesign/cljs-node-axios