This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-24
Channels
- # announcements (4)
- # beginners (37)
- # boot (13)
- # boot-dev (3)
- # calva (122)
- # cider (16)
- # clara (13)
- # cljs-dev (3)
- # cljsrn (8)
- # clojure (311)
- # clojure-denver (1)
- # clojure-dev (14)
- # clojure-europe (7)
- # clojure-italy (36)
- # clojure-nl (3)
- # clojure-spec (11)
- # clojure-uk (77)
- # clojurescript (91)
- # core-async (10)
- # cursive (9)
- # data-science (5)
- # datomic (46)
- # devcards (2)
- # emacs (6)
- # figwheel-main (15)
- # fulcro (51)
- # jobs (3)
- # kaocha (10)
- # nrepl (6)
- # off-topic (53)
- # om (1)
- # onyx (2)
- # pathom (5)
- # reagent (50)
- # reitit (26)
- # shadow-cljs (153)
- # spacemacs (17)
- # specter (5)
- # speculative (1)
- # test-check (19)
- # tools-deps (15)
- # yada (3)
Hello, I'm using the material-components-web-react package with shadow-cljs. I use the material components in the browser, but also on Node.JS for server side rendering. This used to work fine, but now that I'm trying to update the material-components-web-react package I see the following error in Node.JS:
The code works fine in the browser. but only fails on Node. I guess this has something to do with the Javascript module system not being compatible. Any ideas how to solve this?
maybe this works https://www.npmjs.com/package/esm
@neo2551 shadow-cljs by default does not support dependencies per build. you currently can only emulate that when using project.clj
or deps.edn
Is there a way to set :closure-defines from the command line? I would like to pass the current git commit into the build.
(defn release [path]
(-> (shadow/get-build-config :your-build-id)
(assoc :output-dir path)
(shadow/release* {})))
Does anyone know a public project that uses the rum library and builds with shadow-cljs? Rum has some cljsjs dependencies on react stuff and I'm not sure how to replace them to make it work, an example would be great.
@thheller Thanks a lot for your answer
The JS generated by shadow-cljs doesn't seem to contain react. I don't get any errors in console, but my components aren't rendering. The JS file is about 130 Kb smaller than what falls out of lein-cljsbuild, and build report isn't showing any react/rum code.
At this point I just have rum in my shadow-cljs.edn dependencies (and use rum in my CLJS code).
rum mostly generates code via macro which means the code is in your namespaces not rum namespaces
that seems to work:
#object[java.net.URL 0x55589ef5 "jar:file:/home/jan/.m2/repository/thheller/shadow-cljsjs/0.0.16/shadow-cljsjs-0.0.16.jar!/cljsjs/react.cljs"]
No, I mount my rum component in another place at top level of the main cljs file. That's probably the issue, I think I don't have any main cljs file set anywhere in the shadow-cljs build
{:mybuild
{:target :browser
:modules {:main {:entries [your.actual.main-ns]}}
:devtools
{:after-load my-ui.common/on-js-reload}}}
https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html
so you were probably relying on the fact that cljsbuild just includes everything it finds
Yes I was missing the :entries bit (in lein-cljsbuild I have that as :main). It's working now! Thank you very much!
could just use :init-fn
to call what you are now calling at the top level instead of calling it
So here's probably a dumb idea. Everytime I run my app, I get warnings from library code. For example:
[:app] Build completed. (1038 files, 8 compiled, 4 warnings, 11.03s)
------ WARNING #1 --------------------------------------------------------------
File: zprint/focus.cljc:100:47
--------------------------------------------------------------------------------
97 | #_(println "range-ssv: start:" start "nwpath:" nwpath)
98 | start (skip-whitespace-ssv ssv start)
99 | ssv-next (next-ssv ssv start)
100 | end (if (and ssv-next (not= start 0)) (dec ssv-next) (dec (count ssv)))]
-----------------------------------------------------^--------------------------
cljs.core/-, all arguments must be numbers, got [#{nil clj-nil} number] instead
--------------------------------------------------------------------------------
101 | #_(println "range-ssv:" [start end])
102 | [start end]))
--------------------------------------------------------------------------------
------ WARNING #2 --------------------------------------------------------------
File: com/rpl/specter/impl.cljc:786:6
--------------------------------------------------------------------------------
783 | val))
784 |
785 | (mk-late-fn-records)
786 | (mk-late-fn)))
------------^-------------------------------------------------------------------
Use of undeclared Var com.rpl.specter.impl/java
--------------------------------------------------------------------------------
787 |
788 | #?(:clj
789 | (defn static-fn-code [afn args]
790 | `(~afn [email protected]))
--------------------------------------------------------------------------------
------ WARNING #3 --------------------------------------------------------------
File: com/rpl/specter.cljc:1275:19
--------------------------------------------------------------------------------
1272 | ns (namespace structure)]
1273 | (cond (keyword? structure) (keyword ns new-name)
1274 | (symbol? structure) (symbol ns new-name)
1275 | :else (i/throw-illegal "NAME can only be used on symbols or keywords - " structure)
-------------------------^------------------------------------------------------
Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
1276 | ))))
1277 |
1278 | (defnav ^{:doc "Navigates to the namespace portion of the keyword or symbol"}
1279 | NAMESPACE
--------------------------------------------------------------------------------
There's not much I can do about them except to open an issue on the repo or try to fix them myself. I was wondering if it made sense for some sort of option in shadow-cljs.edn
for :ignore-warnings-from-namespaces
or :only-show-warnings-from-this-ns-list
, so I could more easily see warnings/errors from code I actually control. If there already is something like this that I'm not aware of, my apologies for the large message. Thanks for listening!These build reports are really a great feature. I wouldn't have guessed that just requiring cljs.pprint yields almost +100 Kb after optimizations
It seems like you can’t have both an :http-handler
fn, and a :proxy-url
, right? Because the proxy will take over.
So if I want to do something fancy, I need drop the proxy-url and do the proxy on my own.
Is there some reliable way at runtime (that is, no macros) to get the filename of the file where a function was defined? OK to only work in dev mode.
@hoopes I agree that its unfortunate. I opened issues on the libs I know about and most of them are fixed already. https://github.com/nathanmarz/specter/issues/267
would it be enough to make warnings in code from libs just "shorter" so they don't show a source excerpt?
or even a different color, or whatever - maybe the non-lib errors are brighter, something that i can tell at a glance that it's actually my code, and not something i can (somewhat) safely ignore
@jkr.sw yeah currently cljs.pprint can't be optimized by Closure at all so it gets really huge. https://dev.clojure.org/jira/browse/CLJS-2885
proxy stuff is currently not as flexible as I'd like so yeah it current is one or the other not both
the server doesn't need to do anything special for shadow-cljs. just serve the files, nothing else.
@hoopes I'll start by re-ordering the warnings I guess. So warnings from local code come before library code
this is just my personal preference, so feel free to ignore, but the easiest ones to see are at the bottom (especially when you get the warnings over and over), so i'd prefer "mine" at the end
but saying i'd prefer
to the BDFL of shadow-cljs is a little presumptuous, so do what you think is best 🙂
if only there was a way to not do all this in the terminal and have a richer interface for warnings 😉
like http://localhost:9630/builds/app but better 😉
After move to lein-tools-deps
broke my shadow-cljs build.
"release" build still works
But when I use (shadow/watch :main)
from repl:
[:main] Build failure:
The required namespace "goog" is not available, it was required by "cljs/user.cljs".
I still use :lein {:profile "+dev,+client,+webdev"}
(slurp (io/resource "cljs/user.cljs"))
;; => (ns cljs.user)\n
(it's a empty namespace, I used it long time ago, now it's empty)Points to
#object[java.net.URL
0xb705e1b
"jar:file:/home/souenzzo/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"]
When i slurp it, it shows a lot of jsThe required namespace "goog" is not available, it was required by "cljs/user.cljs".
now with (io/resource "cljs/user.cljs") ;;=> nil
same after rm -rf .shadow .cljs ...anything-that-i-can-rm
I also moved from graalvm into JVM11
(-> (Thread/currentThread)
(.getContextClassLoader)
(.getResources "goog/base.js")
(enumeration-seq))
just one
"jar:file:/home/souenzzo/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"
you did test the resource using the actual shadow-cljs REPL with all the aliases activated right?
"jar:file:/home/souenzzo/.m2/repository/thheller/shadow-cljs/2.7.16/shadow-cljs-2.7.16.jar!/shadow/build.clj"
After put some jar's on maven Move back to lein without lein-tools-deps. I hope that on the next lein-tools-deps try it not occur
got it. loading a js library into the client at runtime. trying to call it errors out, likely due to advanced compilation
true
requires you to (set! *warn-on-infer* true)
for every source you want to enable it for
I seem to get this when using checkouts
ZipException too many length or distance symbols java.util.zip.InflaterInputStream.read (InflaterInputStream.java:164)
relevant trace:
[java.util.zip.InflaterInputStream read "InflaterInputStream.java" 164]
[java.io.FilterInputStream read "FilterInputStream.java" 133]
[java.io.BufferedInputStream read1 "BufferedInputStream.java" 284]
[java.io.BufferedInputStream read "BufferedInputStream.java" 345]
[sun.nio.cs.StreamDecoder readBytes "StreamDecoder.java" 284]
[sun.nio.cs.StreamDecoder implRead "StreamDecoder.java" 326]
[sun.nio.cs.StreamDecoder read "StreamDecoder.java" 178]
[java.io.InputStreamReader read "InputStreamReader.java" 184]
[java.io.BufferedReader fill "BufferedReader.java" 161]
[java.io.BufferedReader read1 "BufferedReader.java" 212]
[java.io.BufferedReader read "BufferedReader.java" 286]
[java.io.Reader read "Reader.java" 140]
[$fn__11010 invokeStatic "io.clj" 337]
[$fn__11010 invoke "io.clj" 334]
[clojure.lang.MultiFn invoke "MultiFn.java" 238]
[$copy invokeStatic "io.clj" 406]
[$copy doInvoke "io.clj" 391]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.core$slurp invokeStatic "core.clj" 6871]
[clojure.core$slurp doInvoke "core.clj" 6862]
[clojure.lang.RestFn invoke "RestFn.java" 410]
[shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath$fn__25207 invoke "npm_deps.clj" 164]
[clojure.core$map$fn__5587 invoke "core.clj" 2747]
[clojure.lang.LazySeq sval "LazySeq.java" 40]
[clojure.lang.LazySeq seq "LazySeq.java" 49]
[clojure.lang.Cons next "Cons.java" 39]
[clojure.lang.RT next "RT.java" 706]
[clojure.core$next__5108 invokeStatic "core.clj" 64]
[clojure.core.protocols$fn__7852 invokeStatic "protocols.clj" 169]
[clojure.core.protocols$fn__7852 invoke "protocols.clj" 124]
[clojure.core.protocols$fn__7807$G__7802__7816 invoke "protocols.clj" 19]
[clojure.core.protocols$seq_reduce invokeStatic "protocols.clj" 31]
[clojure.core.protocols$fn__7835 invokeStatic "protocols.clj" 75]
[clojure.core.protocols$fn__7835 invoke "protocols.clj" 75]
[clojure.core.protocols$fn__7781$G__7776__7794 invoke "protocols.clj" 13]
[clojure.core$reduce invokeStatic "core.clj" 6748]
[clojure.core$into invokeStatic "core.clj" 6815]
[clojure.core$into invoke "core.clj" 6807]
[shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath invokeStatic "npm_deps.clj" 168]
[shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath invoke "npm_deps.clj" 157]
[shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 204]
[shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 199]
im running shadow-cljs as a library, i.e. executing (shadow-cljs.npm-deps/main {} nil)
from my program
@joelsanchez try this in the REPL
(doseq [url (-> (Thread/currentThread)
(.getContextClassLoader)
(.getResources "deps.cljs")
(enumeration-seq))]
(try
(slurp url)
(catch Exception e
(prn [:failed url e]))))
seems it happens because I use checkouts though
leiningen doing weird stuff
check jar -tvf /home/joel/.m2/repository/ventas-core/ventas-core/0.0.12-SNAPSHOT/ventas-core-0.0.12-SNAPSHOT.jar
welp my jar is a bit full of crap but it didnt fail
guess if I remove that js stuff from the jar, which shouldn't be included anyway, it will work
but yeah that pretty clearly demonstrates why resources/public
is a bad idea as a default 😉
😅 thx
yes, seems a polite way of saying "your jar's full of crap"
I removed all of that from the jar, executed lein install
, jar -tvf
now shows much less files, but I get a different error now
go figure
I swear this didnt happen before checkouts
but dont worry, it's not critical
no idea. never had issues with checkouts and been using them in my work project for years
I’m getting the following warning
ident? already refers to: cljs.core/ident? being replaced by: om.util/ident?
cljs.core/ident?
was added not too long ago. so om.next
would need to exclude it to get rid of the warning