cljs-dev

dnolen 2025-10-10T18:11:54.908239Z

landed :refer-global and :require-global https://github.com/clojure/clojurescript/commit/be21ba13822c2b3edcce0d3fac6d46a5fc6e6d0d

👀 1
🎉 7
dnolen 2025-10-10T18:12:44.933199Z

this one could use a lot of testing of course, and feedback

borkdude 2025-10-14T12:40:27.144159Z

Should this work? Only tried from REPL.

cljs.user=>  (set! js/globalThis.React (fn [] "hello")) ;; simulate including React from script tag
#object[Function]
cljs.user=> (ns foo (:require-global [React :as r]))
WARNING: foo is a single segment namespace at line 1 <cljs repl>
Execution error (AssertionError) at cljs.util/relative-name (util.cljc:200).
Assert failed: (or (file? x) (url? x))

dnolen 2025-10-14T13:00:10.260039Z

That is a REPL specific issue w/ the feature - feel free to file an issue w/ the above, will have to think about it.

borkdude 2025-10-14T13:00:55.652849Z

can I execute a node script from the command line, would that work in this setup?

borkdude 2025-10-14T13:01:03.656969Z

I mean without setting up a whole project

dnolen 2025-10-14T13:01:17.080109Z

Currently the feature relies on the build process / js dep indexing.

borkdude 2025-10-14T13:01:36.704259Z

ok.

dnolen 2025-10-14T13:02:04.652869Z

Maybe it is easy to solve, but can't load this up right now, so yeah please open a ticket and I'll ponder when I have more cycles

👍 1
borkdude 2025-10-14T13:02:35.679569Z

I mean, this may not be the typical use case for it, I was just trying to give it a quick spin

dnolen 2025-10-14T13:02:56.955439Z

yeah I understand completely, it is surprising it doesn't work at the REPL

dnolen 2025-10-14T13:03:08.831929Z

but that's because of the way I implemented it on top of :global-exports

borkdude 2025-10-14T13:03:21.757159Z

It might work when I do have npm deps etc in my project right

borkdude 2025-10-14T13:03:24.740119Z

in the REPL

dnolen 2025-10-14T13:03:34.066399Z

no

dnolen 2025-10-14T13:03:49.324019Z

the issue is you're declaring an ns at the REPL w/o a source file

borkdude 2025-10-14T13:04:11.843969Z

which isn't very typical, admittedly

dnolen 2025-10-14T13:04:24.849909Z

in builds, we parse all namespaces to figure out the inputs

dnolen 2025-10-14T13:04:35.524849Z

in that phase we elide global requires because they have no inputs

dnolen 2025-10-14T13:04:44.524109Z

but that path of course has nothing to do w/ REPLs

borkdude 2025-10-14T13:05:16.594759Z

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

🙏🏽 1