I'm on latest shadow-cljs (3.3.5) and Clojurescript (1.2.134) (I believe) and am getting warnings when compiling my apps (in thread)
------ WARNING #1 - :undeclared-var --------------------------------------------
Resource: cljs/analyzer/api.cljc:227:6
--------------------------------------------------------------------------------
224 | (resolve-extern env/*compiler* sym))
225 | ([state sym]
226 | (let [pre (ana/->pre sym)]
227 | (env/with-compiler-env state
------------^-------------------------------------------------------------------
Use of undeclared Var cljs.analyzer.api/clojure
--------------------------------------------------------------------------------
228 | (:info (ana/resolve-extern pre))))))
229 |
230 | (defn find-ns
231 | "Given a namespace return the corresponding namespace analysis map. Analagous
--------------------------------------------------------------------------------
------ WARNING #2 - :undeclared-var --------------------------------------------
Resource: cljs/analyzer/api.cljc:227:6
--------------------------------------------------------------------------------
224 | (resolve-extern env/*compiler* sym))
225 | ([state sym]
226 | (let [pre (ana/->pre sym)]
227 | (env/with-compiler-env state
------------^-------------------------------------------------------------------
Use of undeclared Var cljs.analyzer.api/java
--------------------------------------------------------------------------------
228 | (:info (ana/resolve-extern pre))))))
229 |
230 | (defn find-ns
231 | "Given a namespace return the corresponding namespace analysis map. Analagous
--------------------------------------------------------------------------------
------ WARNING #3 - :undeclared-var --------------------------------------------
Resource: cljs/analyzer/api.cljc:227:6
--------------------------------------------------------------------------------
224 | (resolve-extern env/*compiler* sym))
225 | ([state sym]
226 | (let [pre (ana/->pre sym)]
227 | (env/with-compiler-env state
------------^-------------------------------------------------------------------
Use of undeclared Var cljs.core/class
--------------------------------------------------------------------------------
228 | (:info (ana/resolve-extern pre))))))
229 |
230 | (defn find-ns
231 | "Given a namespace return the corresponding namespace analysis map. Analagous
--------------------------------------------------------------------------------These is the deps.edn tree
thheller/shadow-cljs 3.3.5
X org.clojure/data.json 2.5.1 :use-top
X org.clojure/tools.cli 1.1.230 :use-top
X org.clojure/tools.reader 1.5.2 :use-top
X nrepl/nrepl 1.3.1 :use-top
. cider/piggieback 0.6.0
. com.cognitect/transit-clj 1.0.333
. com.cognitect/transit-java 1.0.371 :newer-version
X com.fasterxml.jackson.core/jackson-core 2.14.2 :use-top
. org.msgpack/msgpack 0.6.12
. com.googlecode.json-simple/json-simple 1.1.1
. org.javassist/javassist 3.18.1-GA
. javax.xml.bind/jaxb-api 2.4.0-b180830.0359
. javax.activation/javax.activation-api 1.2.0
. com.cognitect/transit-cljs 0.8.280
. com.cognitect/transit-js 0.8.874
X org.clojure/core.async 1.8.741 :use-top
X org.clojure/clojurescript 1.12.134 :use-top
X com.google.javascript/closure-compiler v20250407 :superseded
. org.clojure/google-closure-library 0.0-20250515-f04e4c0e
. org.clojure/google-closure-library-third-party 0.0-20250515-f04e4c0e
. org.clojure/google-closure-library-third-party 0.0-20250515-f04e4c0e
. thheller/shadow-util 0.7.0
X hiccup/hiccup 1.0.5 :older-version
. thheller/shadow-client 1.4.0
X hiccup/hiccup 1.0.5 :older-version
. thheller/shadow-undertow 0.3.4
X org.clojure/core.async 1.5.648 :use-top
. io.undertow/undertow-core 2.3.10.Final
. org.jboss.logging/jboss-logging 3.4.3.Final
. org.jboss.xnio/xnio-api 3.8.8.Final
. org.wildfly.common/wildfly-common 1.5.4.Final
. org.wildfly.client/wildfly-client-config 1.0.1.Final
X org.jboss.logging/jboss-logging 3.3.1.Final :older-version
. org.jboss.xnio/xnio-nio 3.8.8.Final
. org.jboss.xnio/xnio-api 3.8.8.Final
X org.jboss.threads/jboss-threads 2.3.6.Final :older-version
. org.jboss.threads/jboss-threads 3.5.0.Final
X org.jboss.logging/jboss-logging 3.4.1.Final :older-version
. thheller/shadow-cljsjs 0.0.22
X hiccup/hiccup 1.0.5 :older-version
X ring/ring-core 1.14.1 :use-top
. io.methvin/directory-watcher 0.19.0
. net.java.dev.jna/jna 5.16.0
X org.slf4j/slf4j-api 1.7.36 :older-version
. expound/expound 0.9.0
X fipp/fipp 0.6.27 :superseded
X org.clojure/core.rrb-vector 0.1.2 :use-top
. com.bhauman/cljs-test-display 0.1.1these are legit warnings that sort of go unnoticed in regular CLJS since it still treats any symbol with a dot as "valid"
So nothing to worry about?
are you doing a self-hosted build? or what are you compiling that namespace in the first place?
I have no idea why that namespace is compiled... I am building a regular cljs app, this is in watch mode
This happened after we bumped a lot of libraries
If I understand correctly, a regular cljs app should not include that namespace?
oh no the warnings are legit and actual bugs
but in code used by barely noone, so nobody notices
non self-hosted code should not be including this namespace
(and the bajillion other things it brings)
it will make your build insanely large
How do I figure out what brings that namespace in?
you can create a build report https://shadow-cljs.github.io/docs/UsersGuide.html#build-report
on hover that will tell you how any particular namespace was included, just find cljs.analyzer.api and it'll tell you
(its in org.clojure/clojurescript)
I'll check.
we have the same warnings, looks like in our case it has something to do with re-frame:
more precisely with fn-traced macro
not re-frame. re-frame-10x. dunno why they would require that, but its a development tool, so won't be in your release build hopefully
good to know
wait .. thats a build report. which is a release build. so you should definitely look into using the stubs and setting that up correctly
:release
{:build-options
{:ns-aliases
{day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
thats the relevant bit you need in the build configlikely will make your build substantially smaller
Seems to be spec-tools?
I'll go through the docs, we have both, re-frame-10x and tracing dependencies, not sure why. Thanks.
Is it possible that the library bumps revealed this warning rather than created it? We were on shadow-cljs 2.28.20 before.
no clue. it has been there for a very long time. 2.28.20 isn't that old, but there have been a few CLJS release inbetween too. maybe older ones just didn't have the code with warnings
after setting up stubs it's still included via spec-tools 🙂
I just checked again and the code produced is definitely incorrect
ar env__1491__auto____$1 = ((cljs.core.map_QMARK_(env__1491__auto__))?cljs.core.atom.cljs$core$IFn$_invoke$arity$1(env__1491__auto__):(((((env__1491__auto__ instanceof clojure.lang.Atom)) &env__1491__auto__ instanceof clojure.lang.Atom can never succeed and will fail is ever actually run
but its from a function that is likely never called by anyone. so probably fine.
throw (new java.lang.IllegalArgumentException((""+"Compiler environment must be a map or atom containing a map, not " same for that one
Sure, but it sounds like one wants to avoid including that namespace at all? Like getting rid of spec-tools?
I personally don't even allow spec in any of my builds (for dev might be fine, but not release)
I've migrated to malli (and use that in builds) but still have a few remnants of spec and spec tools
in our case it's a transitive dependency of the reitit router
But reitit router shouldn't have to include spec tools unless you use spec in it?
malli is way worse than spec unfortunately 😞
In terms of build size?
yep
reitit is the same problem. trying to solve every possible problem out there, of which you are likely to never have 90% or so. yet you get all the code for it 😛
problem with spec in particular is that its all relying on a global "registry" atom to store things. the closure compiler can't tell if its ever used, so it keeps everything. and that then sort of infects everything else and just keeps so much code alive
that isn't actually the problem though 😛
its stuff like this not being properly swapped with reader conditionals or so https://github.com/clojure/clojurescript/blob/d30fa77e49949430dd82826ff29736411fb8db20/src/main/clojure/cljs/env.cljc#L74
granted that is tricky with macros, but regardless, it does produce broken code
Well I'm glad that I asked about the error - even if it has no effect it reminded me that I should get rid of spec-tools.
Thanks @thheller!