Hi! I had good time testing shadow-cljs on a frontend+firebase project so I’m trying to migrate an older one from lein. I’m down to getting a lot of warnings like this:
------ WARNING #4 - :undeclared-var --------------------------------------------
Resource: exoscale/coax/coercer.cljc:99:5
--------------------------------------------------------------------------------
96 | (inst? x)
97 | x
98 | (string? x)
99 | (invalid-on-throw!
I’m not sure why migration caused this warning to appear - AFAICT it is a java symbol that is not present in cljs so the warning is valid. However I’d like to solve or silence it while keeping other possible warnings. Updating coax to 2.0.5 did not help. Any ideas much appreciated!I guess the shadow-cljs specific question is if there’s a good way to silence this particular warning while still getting undeclared-var warnings from my own code
warnings from libraries should only show watch on the initial compile, but not repeat for watch recompiles. so I guess you can just ignore them?
there is an option to ignore warnings in certain namespaces, but that applies for all warnings in that ns
and is part of :warnings-as-errors
thanks! that sounds good. If I can silence this one namespace and also make warnings errors for CI/CD that’s ideal
I’ll look into it. Thanks again for the suggestion and of course shadow 🙂
:compiler-options {:warnings-as-errors {:ignore #{exoscale.coax.*}}}
in the build config. supports a wildcard at the end. or just the full set of namespaces to ignore.
should maybe be fixed in the lib though as it will contain a reference to java.lang.Exception in the code, which if that bit is ever reached, will of course fail.
hmm, I could not get it to silence with the option above, although I got it working for other warnings as expected. Looking a bit deeper, it looks like the offending var is a macro
(ns exoscale.coax.coercer
(:refer-clojure :exclude [identity])
(:require [clojure.string :as str]
#?@(:cljs [[cljs.reader]]
:clj [[clojure.instant]
[exoscale.coax.utils :refer [invalid-on-throw!]]]))
#?(:cljs (:require-macros [exoscale.coax.utils :refer [invalid-on-throw!]])
:clj (:import (java.util UUID)
( URI)))) maybe this type of conditional require is something not supported by shadow.cljs?
(https://github.com/exoscale/coax/tree/master/src/exoscale/coax)
exoscale has an https://github.com/exoscale/coax/issues/13 on this
the required macro is the problem. not the require of it. that issue and the related PR did indeed fix it, but I guess was reverted at some point since that code is not there anymore.
yes. I gather my options are a) patch the library b) ignore the warning. The issue is already threre in the lein build, the shadow build just warned me about it 👍