cljs-dev

borkdude 2024-10-07T15:30:32.217679Z

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

borkdude 2024-10-09T12:55:50.066549Z

@dnolen uploaded to JIRA

dnolen 2024-10-09T17:04:31.650909Z

thanks

dnolen 2024-10-15T19:34:40.594249Z

merged

🙏 1
dnolen 2024-10-07T16:51:53.949449Z

not intentional

borkdude 2024-10-07T17:08:26.293049Z

@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?

borkdude 2024-10-08T10:01:00.610119Z

@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

dnolen 2024-10-08T12:04:32.013149Z

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.

borkdude 2024-10-08T12:06:40.894749Z

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

borkdude 2024-10-08T12:08:53.101729Z

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

borkdude 2024-10-08T12:14:19.016779Z

https://clojure.atlassian.net/browse/CLJS-3421

borkdude 2024-10-08T12:42:05.837199Z

@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

dnolen 2024-10-08T17:22:31.993489Z

looks ok!