Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix the shadow-cljs warning from lib.core's macro re-export (#77521)

Chris Truterae56aaf2b27c
diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn
index d145a55bc91..648840580ca 100644
--- a/.clj-kondo/config.edn
+++ b/.clj-kondo/config.edn
@@ -759,6 +759,7 @@
metabase.test/with-temporary-raw-setting-values macros.metabase.test.util/with-temporary-raw-setting-values
metabase.users.models.user-test/with-groups! macros.metabase.users.models.user-test/with-groups!
metabase.util.namespaces/import-fn macros.metabase.util.namespaces/import-fn
+ metabase.util.namespaces/import-macro macros.metabase.util.namespaces/import-macro
metabase.xrays.related-test/with-world macros.metabase.xrays.related-test/with-world}}
:config-in-comment
diff --git a/.clj-kondo/macros/metabase/util/namespaces.clj b/.clj-kondo/macros/metabase/util/namespaces.clj
index 87d4358d6c5..ce2842a3545 100644
--- a/.clj-kondo/macros/metabase/util/namespaces.clj
+++ b/.clj-kondo/macros/metabase/util/namespaces.clj
@@ -6,3 +6,8 @@
`(def ~(-> sym name symbol) "docstring" ~sym))
([sym name]
`(def ~name "docstring" ~sym)))
+
+(defmacro import-macro
+ "Kondo macro replacement for [[metabase.util.namespaces/import-macro]]."
+ [sym]
+ `(def ~(-> sym name symbol) "docstring" ~sym))
diff --git a/src/metabase/lib/core.cljc b/src/metabase/lib/core.cljc
index 00d077e4354..bac55cb6c82 100644
--- a/src/metabase/lib/core.cljc
+++ b/src/metabase/lib/core.cljc
@@ -1422,7 +1422,6 @@
->legacy-MBQL
->mbql5
legacy-default-join-alias
- with-aggregation-list
without-cleaning]
[metabase.lib.convert.metadata-to-legacy
lib-metadata-column->legacy-metadata-column
@@ -1668,6 +1667,8 @@
replace-field-ids
replace-table-ids])
+(shared.ns/import-macro lib.convert/with-aggregation-list)
+
#?(:clj
(defmacro with-card-clean-hook
"Arranges for `hook-fn` to be called during `lib.convert`'s query cleaning process, and executes the `body`
diff --git a/src/metabase/util/namespaces.clj b/src/metabase/util/namespaces.clj
index 838f54a1421..b2cc0ae01dc 100644
--- a/src/metabase/util/namespaces.clj
+++ b/src/metabase/util/namespaces.clj
@@ -23,6 +23,15 @@
:clj `(p/import-fn ~target ~sym)
:cljs (redef target sym))))
+(defmacro import-macro
+ "Imports a single macro from another namespace, for JVM Clojure only.
+ In CLJS this expands to nothing: a macro has no runtime value to re-export, so CLJS callers must require the
+ defining namespace directly."
+ [target]
+ (macros/case
+ :clj `(p/import-macro ~target)
+ :cljs nil))
+
(defmacro import-fns
"Imports defns from other namespaces.
This uses [[import-fn]] to create pass-through local functions that reload nicely.