cljs-dev 2024-10-07

Is it expected that when using cljs.analyzer.api/ns-publics on a non-existing (or not yet required) namespace, just returns an empty map, when used in the JVM? When used in a CLJS REPL it does throw something exception-like

@dnolen uploaded to JIRA

not intentional

@dnolen ok, I can make a ticket tomorrow. what's the best way to check if a namespace exists at all in the cljs.analyzer.api?

@dnolen I worked around it in my own project by first calling ana/find-ns to check if the namespace exist. Do you think it should be improved in CLJS proper to throw when ana/ns-publics is called on a non-existent namespace? One other possibility could be to return nil to indicate non-existence or so

I think aligning the expectations w/ Clojure would be good, I never use this myself - can you restate what happens in Clojure w/ missing ns? I can't parse what you said above earlier.

In JVM Clojure, you get an exception when calling (ns-publics 'non-existing-namespace)

Clojure 1.12.0
user=> (ns-publics 'non-existing-namespace)
Execution error at user/eval1 (REPL:1).
No namespace: non-existing-namespace found

whereas (cljs.analyzer.api/ns-publics 'non-existing.namespace) returns an empty map. I'll go ahead and make a JIRA (+ patch)

@dnolen here's my proposed patch: https://github.com/borkdude/clojurescript/commit/9272b76ae79992d30341c4f91f6185904470e73c if it looks alright to you, I'll upload it to JIRA