This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-28
Channels
- # announcements (11)
- # aws (2)
- # babashka (35)
- # beginners (173)
- # calva (3)
- # chlorine-clover (2)
- # cider (17)
- # clara (2)
- # clj-kondo (28)
- # cljs-dev (11)
- # cljsrn (53)
- # clojure (178)
- # clojure-argentina (1)
- # clojure-europe (12)
- # clojure-germany (5)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-spec (25)
- # clojure-uk (88)
- # clojurescript (109)
- # conjure (34)
- # cursive (2)
- # data-science (35)
- # datomic (15)
- # emacs (6)
- # events (1)
- # fulcro (28)
- # graphql (15)
- # helix (21)
- # hoplon (7)
- # jobs (4)
- # jobs-discuss (1)
- # joker (15)
- # lambdaisland (1)
- # lein-figwheel (4)
- # local-first-clojure (1)
- # malli (8)
- # meander (17)
- # off-topic (33)
- # parinfer (2)
- # rdf (16)
- # re-frame (3)
- # reagent (21)
- # reitit (14)
- # remote-jobs (5)
- # ring (8)
- # rum (1)
- # shadow-cljs (184)
- # sql (2)
- # testing (1)
- # tools-deps (23)
@thheller do you think it's a good idea to add support of a "pre/post-css-update-hook"? I have some animation defined in css and each time the css is live updated, the page would go through the animation process which is time consuming.
The idea is to I want to call some custom code before handle-asset-watch
, e.g. add a '.disable-animation' class to the html body to make sure the animation rules is not in effect, and remove this class after the css update.
e.g. https://github.com/lucywang000/shadow-cljs/commit/a71e74d39a64c8034a5f7ee1889b302470f03e49
@pshar10 no kaocha-cljs does not work with shadow-cljs yet. talked with the author yesterday and there are plans to get this working but nothing as of yet.
@andre this is caused by a core.async dependency conflict when using deps.edn/project.clj
make sure you don't use an ancient core.async version, should be [org.clojure/core.async "1.1.587"]
but I have only one terminal with the project on port 3000 why does it say 3000 and 3001 are in use ?
make sure you don't have any other conflicts too. maybe you have some leftover AOT cache as well?
this Exception started to happen when these ports appears, but the interesting thing I can open these ports and I can see another shadow-cljs project but they are not running in any terminal
every time someone has reported an error like this it was related to some dependency conflict. not sure what else it would be
@wxitb2017 wouldn't it be more practical if you start with a <body class="load-anim">
or so and then remove that class yourself at some point? I didn't even know that replacing the css would restart animations? do you have an example of that so I can reproduce and test?
> then remove that class yourself at some point? That need to be manually and breaks the modify => wait for css reload => evaluate new design => .. loop
yeah there are no processes, and i found it was a browser cache If i clean it ,i can see the same project on these ports, so for some reason it runs same project on different ports
and i still work with my project on port 3000 even if it says last one is 3002, but i can live with that , not critical 🙂
macos, btw it worked just fine, but at some point i was running several projects in parallel , one was on 3000 and another on 3001, probably after that this project started to show these ports and exceptions, btw it shows exception only if i open browser on port 3001 if i open it on 3000 there are no exceptions
that should show which process is listening on that port. if I remember the command correctly 😛
you can try shadow-cljs clj-repl
and then (
to see which version you get
and maybe (
to see if there are some AOT files that would break this as well
yes for some reason this project starts 3 ports, if i start it i can see 3 java listeners (3000, 3001 ,3002) if i stop it there are no listeners
@thheller you can see the demo I recorded. After removing the link node and recreating it (by undo) the animation (transition actually) is performed again.
@wxitb2017 I meant the CSS to make this happen 🙂
* {
margin: 0;
padding: 0;
text-align: center;
}
html {
background: white;
width: 100%;
height: 100%;
}
body {
height: 100px;
background-color: red;
position: absolute;
transition: background-color 3s linear 50ms;
width: 100%;
}
h3 {
margin-top: 1em;
}
html is deadly simple
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Static Template</title>
<link href="csb.css" rel="stylesheet">
</head>
<body class="">
<h3>This shall move when reloading css</h3>
<h3>(removing the css link node then undo it)</h3>
</body>
</html>
actually by talking with you I got some inspiration. The transition rule shall be added to a special selector instead of on the base.
Goodmorning, when I am trying to launch shadow-cljs using deps.edn alias I see this error:
shadow-cljs - starting via "clojure"
Unknown option: "-m"
Usage:
shadow-cljs <action> <zero or more build ids>
Supported actions are:
compile - ...
watch - ...
check - ...
release - ...
classpath - ...
node-repl - ...
browser-repl - ...
cljs-repl - ...
clj-repl - ...
clj-eval - ...
clj-run - ...
run - ...
info - ...
pom - ...
npm-deps - ...
test - ...
aot - ...
init - ...
help - ...
server - ...
start - ...
stop - ...
restart - ...
shadow-cljs.edn
{:deps {:aliases [:frontend]}
:dev-http {8080 "public"}
:builds {:app {:target :browser
:output-dir "public/js"
... }}}
looks like you have a clojure
on your classpath thats not from the official tools.deps
dist?
> try `clojure -m shadow.cljs.devtools.cli help` manually this works but If I invoke via shadow-cljs - doesnt
{ :frontend
{:deps
{org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.742"}
thheller/shadow-cljs {:mvn/version "2.8.106"}
reagent {:mvn/version "0.10.0"}
re-frame {:mvn/version "0.12.0"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}
this is from the deps.edn
aliast
I just invoke shadow-cljs compile app
worked!
thanks
I think it is mentioned here: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn
right, but now same alias cant be used for both scenarios
is it possible to specify that I want start cljs repl via clj
? (using cider)
ignore me, I’ve found that it is CIDER decides how to start shadowcljs repl
:builds {:dev {:target :browser
:output-dir "public/js"
:asset-path "/js"
:devtools {:autoload true
:http-root "public"
:http-port 3000}}
:dev1 {:target :browser
:output-dir "public/js"
:asset-path "/js"
:devtools {:autoload true
:http-root "public"
:http-port 3000}}
:dev2 {:target :browser
:output-dir "public/js"
:asset-path "/js"
:devtools {:autoload true
:http-root "public"
:http-port 3000}}
interesting if i have such config, and run shadow-cljs watch dev
I'll see this
shadow-cljs - HTTP server available at
[2020-04-28 09:43:53.975 - WARNING] TCP Port 3000 in use.
shadow-cljs - HTTP server available at
[2020-04-28 09:43:54.004 - WARNING] TCP Port 3000 in use.
[2020-04-28 09:43:54.009 - WARNING] TCP Port 3001 in use.
shadow-cljs - HTTP server available at
@thheller btw confirmed, inline requires are only lazy loaded in release, so it's normal that you see them loaded early in dev. I think :chunks should be added to the shadow docs, module just works.
@andre we are going to work with Jakub today to collects the maven deps used by shadow and put them in the nix pkgs
but it's a lot of bash you get just the deps then you have to look for the sources and signatures in the m2 directory, very rough 😄
I have this following idiom in my code:
(deftest my-test
(run-test-sync
(is (= 1 2)) ;; etc.
)
And it seems like a good idea to create a macro which would replicate this like so:
(deftest-sync my-test
(is (= 1 2))
)
And I have tried this:
(defmacro deftest-sync [name test]
`(deftest ~name ~(run-test-sync ~test))
)
But on doing in the shadow repl:
(macroexpand '(deftest-sync some-test (is (= 1 1))))
I simply get the result:
(deftest-sync some-test (is (= 1 1)))
But I seem to get the correct result in a clojure repl. Why would this be?@andre hehe yeah the dev-http stuff isn't per build and they always run. instead use https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http so you just do :dev-http {3000 "public"}
once at the top level
also don't name your builds :dev
. each build already has dev/release notion built-in, shadow-cljs release dev
is just weird 😛
btw i have an idea but i don't know if I'll have time any soon, but it would be cool to embed re-frisk into shadow dashboard and utilize shadow's websockets
plugins are pretty much impossible due to :advanced
but I'd be happy to add a
route that just delegates to a re-frisk ring handler when called?
the server supports plugins though, just not the UI. so you could hook into the shadow-cljs lifecycle if needed
:maven {:local-repo "maven"}
in shadow-cljs.edn
top level. assuming you aren't using deps/project.clj or course
how does shadow-cljs decides to use the shadow-cljs aot compiled jar? any clue why maven is downloading the sha1 signature of the jar and not the aot jar?
hmm? it defaults to using the AOT jar when using shadow-cljs.edn
to manage dependencies
is there a way to build without going through maven deps resolution again? i.e we already have classpath and deps downloaded, but don't want to rerun dependencies resolution because it will ask for tons of different version of each deps
but actually when building you need all the intermediate versions to calculate the classpath
we already have the classpath and final deps so is there a way to get straight to the building step
I mean it shouldn't do anything remote once its filled and there are no snapshot deps or ranges?
no but with lein deps when starting from an empty m2 repo we were basically taking all the downloads printed by the command to have a list of all the deps
you can literally run java -cp <that-classpath> clojure.main -m shadow.cljs.devtools.cli release app
yourself if you want 😛
yes. if I run lein deps
once to get everything and then disconnect my network and lein repl
or whatever it works?
yeah basically all the tools do is construct the classpath and ensure the files are actually downloaded
otherwise if you have the classpath you don't need anything else and can just run java
maybe need to adjust some extra args if you have :jvm-opts
or so configured since they won't be taken into account
running: npm install --save --save-exact [email protected] [email protected]
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to failed, reason: getaddrinfo ENOTFOUND
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
only if your package.json
doesn't contain all the packages that were required by cljs deps via deps.cljs
might be related to
NPM dependency "react" has installed version "16.9.0"
"16.13.0" was required by jar:file:/home/yenda/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
` thenseems like there is a mismatch between react version required by reagent and the one required by react-native
yeah but then our node_modules won't contain 16.13.0 and reagent will require it in deps.cljs?
but the npm error says it tried to install 16.13.0 running: npm install --save --save-exact [email protected] [email protected]
if it is in there it should skip trying to install it, regardless of the versions. that check is done at a different point and does NOT trigger another install
the check is dumb ... so it must be in package.json
"dependencies"
or "devDependencies"
ok will check, we do have the package.json in a different dir, might not be properly symlinked at that point
you can open an issue to just disable that check entirely if you want. it is somewhat naive anyways.
getting a weird error in CI with deftype that doesn't happen locally:
[2020-04-28T12:32:47.944Z] [:android] Compiling ...
[2020-04-28T12:33:34.658Z] ------ ERROR -------------------------------------------------------------------
[2020-04-28T12:33:34.658Z] File: /build/status-react-source-jsbundle/src/status_im/utils/multihash.cljs:53:1
[2020-04-28T12:33:34.658Z] --------------------------------------------------------------------------------
[2020-04-28T12:33:34.658Z] 50 | ;; - `hex-digest` is a string holding the hex-encoded algorithm output.
[2020-04-28T12:33:34.658Z] 51 | ;;
[2020-04-28T12:33:34.658Z] 52 | ;; Multihash values also support metadata.
[2020-04-28T12:33:34.658Z] 53 | (deftype Multihash [code hex-digest _meta]
[2020-04-28T12:33:34.658Z] -------^------------------------------------------------------------------------
[2020-04-28T12:33:34.658Z] Error in phase :compilation
[2020-04-28T12:33:34.658Z] Cannot infer target type in expression (. (. Multihash -prototype) --equiv)
[2020-04-28T12:33:34.658Z] {:warning :infer-warning, :line 53, :column 1, :msg "Cannot infer target type in expression (. (. Multihash -prototype) --equiv)"}
[2020-04-28T12:33:34.658Z] ExceptionInfo: Cannot infer target type in expression (. (. Multihash -prototype) --equiv)
I have an myapp.environment namespace like so in an environment.clj file.
(ns myapp.environment
(:require [myapp.config :refer [env]]))
(defmacro myapp-url [] (:myapp-url env))
Then I require this in an events.cljs file like
[myapp.environment :refer-macros [myapp-url]]
I get the error in shadow
The required namespace "myapp.environment" is not available, it was required by "myapp/events.cljs".
"myapp/environment.clj" was found on the classpath. Should this be a .cljs file?
when using it like so:
(http/get (str (myapp-url) "/somepath"))
How do I fix this?read https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html
Say I have a macro in the clj file to be used in a cljs file
(defmacro defelem [name element]
`(defcard ~name
(ct.react/react-card
(r/as-element
[~element]
)
)
)
)
and the dependencies are ct.react and r. Should the dependencies be required in the clj or the cljs files? I tried both but neither worked.I get the error in shadow:
(defelem cart-card cart)
-------^------------------------------------------------------------------------
Use of undeclared Var vendo.workspaces.cards/react-card
--------------------------------------------------------------------------------
Probably in the CLJS
Your macro is depending on specific alias like ct.react
and r
I believe this must be available at the file you are using it. Or you should require it in the macro.
Or use the full namespace like reagent.core/as-element
.
@pshar10 use fully qualified names in the macro and require as normal in the CLJS file. CLJ macros can't see the CLJS aliases so you need to do it manually. I mention this in the blog post.
Hi, is there some project for generating static web using Shadow-cljs? I really love hot code reloading (including CSS), so I am thinking to building the static web as a trivial React app in dev and generating static web using hiccup for the production.
@thheller this is what I have now, but it doesn't work still: In myapp.workspaces.cards (clj)
(ns myapp.workspaces.cards)
(defmacro defelem [name element]
`(nubank.workspaces.core/defcard ~name
(nubank.workspaces.card-types.react/react-card
(reagent.core/as-element
[~element]
)
)
)
)
In myapp.events (cljs) where I use this defelem macro
(ns myapp.workspaces.cards
(:require
[nubank.workspaces.core]
[nubank.workspaces.card-types.react]
[reagent.core]
[myapp.cart :refer [cart]]
))
(defelem cart-card cart)
But I get:
(defelem cart-card cart)
--------^-----------------------------------------------------------------------
Can't take value of macro myapp.workspaces.cards/defelem
Why would this be?(ns myapp.workspaces.cards
(:require-macros [myapp.workspaces.cards :refer (defelem)])
(:require
[nubank.workspaces.core]
[nubank.workspaces.card-types.react]
[reagent.core]
[myapp.cart :refer [cart]]
))
the CLJS namespace that also has macros MUST require itself via :require-macros
in its ns-form
in your case since you are also using that macro in the very same namespace you also need the refer
Hey there! I’ve got a question: if shadow watch is running, and I have an app opened in a browser, how can I trigger reload from a command line?
Yes, sorry for being ambiguous. So let’s say there are a bunch of functions marked with ^:dev/after-load
, and I’d like to call all of them via command line. Similar to CSS file watcher — when CSS changes, reload the app in the browser
hmm no there is nothing like that. you can always call those functions from the REPL though?
what are you trying to do though? why is calling that from the command line important?
We’re generating some js files along with the shadow build and would like to load them in a hot reload fashion
you mean you generate js files that aren't part of the build and are loaded via separate <script>
tag?
We’ve came up with a hacky solution of touching an empty cljs file in src/dev
directory
There's an going issue with suitable which sits somewhere between cider, and shadow-cljs. https://github.com/clojure-emacs/cider/issues/2808 the author of suitable suggests it was working and is not now. Could someone familiar with the shadow-cljs internals take a quick look and see if anything sticks out? https://github.com/rksm/clj-suitable/blob/master/src/main/suitable/complete_for_nrepl.clj#L207