This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-17
Channels
- # announcements (4)
- # aws (17)
- # beginners (108)
- # calva (2)
- # clojure (164)
- # clojure-austin (1)
- # clojure-europe (3)
- # clojure-italy (1)
- # clojure-nl (17)
- # clojure-uk (98)
- # clojurescript (31)
- # code-reviews (1)
- # cursive (23)
- # data-science (1)
- # dirac (6)
- # emacs (21)
- # figwheel-main (1)
- # fulcro (53)
- # graphql (2)
- # hoplon (1)
- # lein-figwheel (1)
- # leiningen (2)
- # lumo (21)
- # off-topic (118)
- # onyx (4)
- # pathom (59)
- # pedestal (2)
- # planck (3)
- # reagent (47)
- # reitit (2)
- # shadow-cljs (258)
- # spacemacs (3)
- # sql (10)
- # tools-deps (37)
hello @thheller, I think the documentation regarding nrepl middleware needs to be updated. including the latest shadow-cljs with no nrepl exclusions, you need to use shadow.cljs.devtools.server.nrepl04/...
middleware for things to work, and the documentation just mentions the old version https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server
yeah. I can probably remove the old implementation now. or rather just flip it. nobody should be using .nrepl04
directly
i create a project from luminus, and then i try to change its cljsbuild to shadow-cljs, and its dependencies by deps.edn, but when i execute shadow-cljs compile app, it show warnning, i don’t know what’s this means
@thheller i follow your example https://github.com/thheller/lumifoo, but i don’t know how to fix this
@thheller this is my repo, https://github.com/vinurs/admin could u help me?
@haiyuan.vinurs you need to fix your source path
The namespace represent the filepsth starting the the root of the innermost source path
Yes, if you have deps.edn take care of the deps, shadow wil hand over the responsibility of classpath to depsedn
But preferably yu should have lein and shadow point to deps.edn but thats maybe a matter of taste
because some times cljs and clj need the same library, so i want to share deps between clj and cljs, that is lein and shadow-clj, so i use deps.edn
Yes thats good thinking, but the :lein true you have in shadow-cljs.edn seems redundant to me
but now it’s global, so in lein, the paths will auto import? does it conflict with clj’s src/clj?
No because you can only have 1 compiler reading at any given time. Cant have clj and cljs running as 1 compiler
actually, i do want, but i don’t know how to set seperately for clj and cljs, so i set in project.clj before
Look at the leiningen deps middleware/plugin. Then you dont neeed to set classpaths in leiningen, 1 source of truth for both shadow and lein, that would be clean
@haiyuan.vinurs its taking some time, are you using leiningen to generate the index.html?
Caused by: java.lang.RuntimeException: could not find a non empty configuration file to load. looked in the classpath (as a "resource") and on a file system via "conf" system property
Hello
How do I handle local clojurescript dependencies with shadow-cljs?
I.e. I have foo/shadow-cljs.edn
and a bar/shadow-cljs.edn
, and want bar to depend on foo.
If this was leiningen, I'd go into foo
and do lein install
, then that would copy the artifact to my local maven cache, and I would depend on it from bar
normally.
Is there a shadow-cljs equivalent?
library dev is currently not covered by shadow-cljs. so either lein or deps.edn works. if your foo
doesn't add any deps you can just do :source-paths ["src/main" "../foo/src/main"]
in shadow-cljs.edn of bar
Then again, if foo
has npm dependencies, and I do lein install
the resulting jar won't include those deps or any reference to them :(
I'll try this thing, I guess https://github.com/colindresj/package-json-to-deps-cljs
@polymeris I'd use leiningen for this usecase to create a jar
yes I think this is one of the case where shadow-cljs wont solve, to package clojure sourcefiles.
you can have a fairly minimal leiningen file that only has the source files set up and lein jar will produce the jar you need to iinstall into your maven path
I just wanted to have everything handled by npm to make things easier for people coming from that ecosystem
Theres a lein runner in npm. But you should ofc only upload compiled js respurces to npm
@haiyuan.vinurs Caused by: java.lang.RuntimeException: could not start [#'admin.config/env]
this is beyond the scope of shadow-cljs, I'll just create a index.html, confirm if the paths are correct, then you can ask for lein question on different channel
now, the problem is that, when i in emacs cider-jack-in, then it start a nrepl, and then in terminal, i type: shadow-cljs watch app, then in chrome i visit http://127.0.0.1:3000/, but it shows
ok make sure you don't have any figwheel or anything connected to clojurescript operating in your leiningen file
and I'd refactor your project.clj file, I think the source of this mess is there, for example all the dependencies you have under your profiles, you don't need it with deps.edn, and figwhell cand shadow are solving the same problem in development so you don't want any cljsbuild or leiningen running
:modules {:app {:entries [admin.core]}} :devtools {:after-load admin.core/mount-components}}}}
I see @haiyuan.vinurs you have :devtools in the wrong map
sorry Im blind, it is like that, I'm leaving anyway, maybe @thheller can see why it fails 😄
alternative is to just execute the function in that file (mount-components) at the bottom
@haiyuan.vinurs did you figure it out or still need help?
if you set either :deps
or :lein
in shadow-cljs.edn
the :source-paths
and :dependencies
there will have no effect at all
and what do you actually want to use? the repo has everything so I'm not sure what you actually want
I'm not sure how lein-tools-deps
works though but you are currently setting :source-paths
in 3 places which is just confusing
this is project.clj, lein may use different source paths in different env, how can i do this?
:dev
{:compiler-options {:closure-warnings {:global-this :off}
:source-map true
:optimizations :none
:pretty-print true}}
:release
{:compiler-options {:optimizations :advanced
:pretty-print false
:closure-warnings
{:externs-validation :off
:non-standard-jsdoc :off}}}
:compiler-options {:closure-warnings
{:global-this :off
:externs-validation :off
:non-standard-jsdoc :off}}
{:deps {:aliases [:cljs]}
:builds
{:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:closure-warnings
{:global-this :off
:externs-validation :off
:non-standard-jsdoc :off}}
:modules {:app {:entries [admin.core]}}
:devtools {:after-load admin.core/mount-components}}}}
the content is just the html content, but in html i wrote {% script “/js/app.js” %}, and when i visit this page, i want the html execute the mount-components function, it a render
ah. you expect :devtools {:after-load admin.core/mount-components}
to call mount-components?
that is not what that does. that tells the devtools to call that function after it has loaded code
{:deps {:aliases [:cljs]}
:builds
{:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:closure-warnings
{:global-this :off
:externs-validation :off
:non-standard-jsdoc :off}}
:modules {:app {:init-fn admin.core/init!}}}}}
;; admin.core js
(defn ^:dev/after-load mount-components []
(rf/clear-subscription-cache!)
(r/render [#'page] (.getElementById js/document "app")))
^:dev/after-load
tells the devtools to call that function after loading code. I think its cleaner there than in the build config
if i change the mount-components to this, then i need to set :modules {:app {:init-fn admin.core/init!}} this?
@lilactown --pseudo-names
would be :pseudo-names true
random question: is there a way to get chrome to tell me what JS corresponds to a line in a source map file?
well it’s being helpful in that I know what part of my CLJS code is slow. but I want to see the JS now 😛
seems like if it can go JS line -> source map, i should be able to go the other way!
I just use pseudo names for that. the names are close enough so you can figure out where it came from in the CLJS code
can't jump directly from CLJS loc -> JS loc since the code may be changed in ways that make that impossible 😛
@lilactown there might be tools similar to this buried in the closure compiler stuff that allow going that way? https://clojureverse.org/t/server-side-decoding-of-javascript-sourcemaps/1591/3?u=thheller
{:type :shadow.build.closure/invalid-closure-warning, :key :non-standard-jsdoc, :level :off, :shadow.build.log/level :warn}
this means you can remove :non-standard-jsdoc
from the build config
ok, it seems that it doesn’t need to move deps from project.clj to deps.edn, shadow-cljs can read deps from project.clj well
shadow-cljs doesn't read deps from project.clj in any way however. it just uses lein to launch itself.
if you have :lein true
in your config shadow-cljs watch app
literally runs lein run -m shadow.cljs.devtools.cli watch app
yes thats what I mean. you run shadow-cljs watch app
and that internally just calls lein run -m shadow.cljs.devtools.cli watch app
for you
I was looking at https://github.com/thheller/netlify-cljs and wondering if the same setup would work for a project using deps.edn instead of Lein.
@kenny the project doesn't actually use lein
. netlify just enables maven caching if it finds the project.clj
Gotcha. I was able to get it to work with the following:
curl -O
chmod +x linux-install-1.10.0.442.sh
install_dir=/opt/buildhome/clojure
mkdir -p ${install_dir}
./linux-install-1.10.0.442.sh --prefix ${install_dir}
echo "Installing Clojure to ${install_dir}/bin"
export PATH="${install_dir}/bin":$PATH
shadow-cljs unfortunately has too many deps so builds got way too slow for my taste without cache 😛