This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-10
Channels
- # beginners (50)
- # cider (112)
- # cljs-dev (7)
- # clojure (34)
- # clojure-brasil (1)
- # clojure-greece (4)
- # clojure-italy (8)
- # clojure-nl (14)
- # clojure-russia (4)
- # clojure-uk (94)
- # clojurescript (96)
- # clojutre (5)
- # cloverage (1)
- # cursive (5)
- # datomic (59)
- # docs (53)
- # figwheel (4)
- # fulcro (1)
- # hoplon (1)
- # hyperfiddle (3)
- # jobs (3)
- # luminus (6)
- # nyc (3)
- # off-topic (9)
- # onyx (3)
- # overtone (4)
- # re-frame (2)
- # reagent (16)
- # reitit (9)
- # ring (2)
- # ring-swagger (1)
- # rum (1)
- # shadow-cljs (81)
- # spacemacs (14)
- # specter (12)
- # sql (1)
- # tools-deps (2)
- # vim (110)
Hey I've nearly finished putting together the first iteration of a build tool based on shadow. I'm striving for 100/100 lighthouse audit out of the box when testing the release locally on the shadow-cljs server. The failing points I have are.
1. Does not redirect HTTP traffic to HTTPS
2. Does not use HTTP/2 for all of its resources
Is there a simple way to set this up?
There is some strange behaviour when I use srcset
on an img
tag. For some reason using this attribute triggers a network request for the same image every time I change the browser size. When hosted on Netlify this does not happen.
@oscar shadow-cljs is focused on CLJS development. if you want to build a CLJ server you should do so using CLJ tools which you are going to need anyways for release (by which I mean build your own CLJ webserver, do not piggyback on the built-in server)
@grounded_sage no not currently. feels a bit out of scope. since HTTPS requires domain names the only way to do this is running on localhost:80 + localhost:443. if you run on http://localhost:8080 you cannot redirect to https://localhost:8080 but must use a different port which then is treated as a different server and the whole spiel begins again
@lilactown @wilkerlucio ^:export
doesn't actually preserve the "namespace". there are no namespaces in :advanced
compilation. it just basically sets your.app.foo = xW;
after the fact. so what once was your.app.foo
became xW
and is then reassigned later.
Hello guys! I'm just starting with shadow-cljs on a new project... has anyone a example of using material-ui with it? I've tried the cljsjs way, but I saw that this is not supported anymore... I'm a bit confused...
@gleisonsilva the whole point is to use npm
directly, so you npm install
it and start using it
I was trying to follow this -> https://github.com/cljsjs/packages/tree/master/material-ui
i'm not sure... i'm a begginer with both (shadow-cljs and material-ui react components) i'm trying to find examples of react components with shadow-cljs, but I haven't found yet..
yes. i'll use reagent
I would recommend going through https://www.jacekschae.com/learn-reagent-free/uk29i?coupon=SHADOW
I made this example repo a while ago https://github.com/thheller/shadow-react-avatar-editor
showing the use of react-avatar-editor
. you can substitute that with material-ui
or any other of the material design wrappers
tks, @thheller! I'll check that out.
@gleisonsilva for boilerplate, I did this
(:require
["material-ui/styles" :as styles]
["material-ui/AppBar" :as AppBar]
["material-ui/styles/MuiThemeProvider" :as Theme]
)
(def muiTheme
(styles/createMuiTheme
#js {:palette #js {:primary #js {:main "#7796a8" ;; "#3f50b5"
:dark "#848F92" ;; "#BCCACD"
:light "#e0e7eb" ;;"#002884"
:contrastText "#fff"}
:secondary #js {:light "#7796a8" ;; "#3f50b5"
:main "#e0e0e0" ;;"#757ce8"
:dark "#e0e7eb" ;;"#002884"
:contrastText "#000"}
:stepper #js {:iconColor "green"}}}))
..later...
[:> Theme/default {:theme muiTheme} .... rest of app]
tks, @hlolli! I'll try.
@hlolli @gleisonsilva you can avoid having to do Theme/default
. If your require is instead ["material-ui/styles/MuiThemeProvider" :default Theme]
then you can just say Theme
.
@gleisonsilva also, I'd suggest directly using Material-UI v1 (which is a lot different than v0.x). Translation from JS is pretty straightforward and the new require strings ("@material-ui/core/styles" work just fine as :require
statements in shadow-cljs. I've been using it for a while so feel free to direct questions my way.
I just updated to the shadow-cljs 2.4.17 and now I am getting DEBUG
logs from shadow-cljs in my console. Is there a way to configure shadow-cljs logging?
For example, I'm getting messages like these:
18-07-10 15:23:32 Kenny-Compute-Software-Macbook.local DEBUG [shadow.cljs.devtools.server.worker.impl:286] - :shadow.cljs.devtools.server.worker.impl/runtime-msg 7b6011fe-e547-4b81-8ee2-fba61e36daf8 :ping
Not in my cljs app. It is possible some other dependency is pulling one of those in though.
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level=INFO
java.util.logging.FileHandler.limit=5000000
java.util.logging.FileHandler.count=3
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level=WARNING
java.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS - %4$s] %5$s%6$s%n
java.util.logging.FileHandler.pattern=.shadow-cljs/shadow-cljs.log
I think its :jvm-opts ["-Djava.util.logging.config.file=logging.properties"]
in deps.edn
I don't know why you are seeing debug messages though. those are usually hidden by default so you might have some logging going on already
Yeah, it is strange. I have had numerous cases where tools-deps resolves things differently than lein which causes issues similar to this one.
yeah tools.deps is stricter. which is good but different from lein
so sometimes has unexpected results
any particular reason you fight with lein
or tools.deps
instead of just using the built-in dependencies support?
Yes, twofold.
1. We switched to tools.deps to use Git dependencies. Does shadow-cljs have support for this?
2. I like to use the lein-cooper
plugin to start shadow-cljs and node-sass
via a single command (i.e. lein dev
).
You are missing a ]
in your example here: https://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run
Strange error on my first cut. I would've expected the exception immediately:
kenny@Kenny-Compute-Software-Macbook ~/c/ui-frontend> shadow-cljs clj-run dev.build/start-dev
shadow-cljs - config: /Users/kenny/compute_software/ui-frontend/shadow-cljs.edn cli version: 2.4.17 node: v10.1.0
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server for :app available at
shadow-cljs - server version: 2.4.17
shadow-cljs - server running at
shadow-cljs - socket REPL running on port 52269
shadow-cljs - nREPL server started on port 9999
^Cshutting down ...
failed to run function: dev.build/start-dev
{:tag :shadow.cljs.devtools.cli/clj-run, :main-sym dev.build/start-dev}
ExceptionInfo: failed to run function: dev.build/start-dev
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:124)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:79)
shadow.cljs.devtools.cli/blocking-action (cli.clj:140)
shadow.cljs.devtools.cli/blocking-action (cli.clj:130)
shadow.cljs.devtools.cli/main (cli.clj:191)
shadow.cljs.devtools.cli/main (cli.clj:146)
Caused by:
No configuration for build ":my-build" found.
shutdown complete.
The issue was I copy and pasted the code from the example and forgot to update the build id to the build id for my project.what do you mean immediately? the exception was caused by your code so it can't happen "earlier"?
Oh, I think I know the problem. I have a call to sh
that did not complete because it is node-sass
's watch
command. So I'm guessing the call to shadow/watch
did not occur until after I ^C'ed.
(defn start-dev
{:shadow/requires-server true}
[& args]
(prn (shell/sh "npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"))
(shadow/watch :app))
hmm now that I think about it there is no easily accessible "run in background but show streaming output" type of utility fn built-in
(let [cmd ["npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"]]
(future
(-> (ProcessBuilder. cmd)
(.inheritIO)
(.start)
(.waitFor))))
I forgot I actually extracted lein-cooper into a self-contained library several months ago haha: https://github.com/ComputeSoftware/join-process/blob/master/src/join_process/core.clj. I think I can use that here.
btw you can also just use tools.deps directly. you do not have to go through shadow-cljs
clojure -m shadow.cljs.devtools.cli compile app
is identical to shadow-cljs compile app
can just replace shadow-cljs
with clojure -m shadow.cljs.devtools.cli
for any command the only thing you miss out of is the server support. see https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html
So I got it to work like this:
(ns dev.build
(:require
[join-process.core :as join-proc]))
(defn start-dev
[& args]
(join-proc/join-process [{:name "cljs"
:cmds ["shadow-cljs" "watch" "app"]}
{:name "sass"
:cmds ["npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"]}]))
(defn -main
[& args]
(apply start-dev args))
Running this command clj -A:dev:start-dev
with these deps.edn :aliases
:
{:dev {:extra-paths ["env" "devcards-src"]
:extra-deps {compute/join-process {:git/url ""
:sha "3068d554275575f499c0bd999ea3e17fc41eabad"}}}
:start-dev {:main-opts ["-m" "dev.build"]}}
I would've expected this to work though:
kenny@Kenny-Compute-Software-Macbook ~/c/ui-frontend> shadow-cljs clj-run dev.build/start-dev
shadow-cljs - config: /Users/kenny/compute_software/ui-frontend/shadow-cljs.edn cli version: 2.4.17 node: v10.1.0
shadow-cljs - connected to server
^C⏎
However, nothing was printed to the console.