landed :refer-global and :require-global https://github.com/clojure/clojurescript/commit/be21ba13822c2b3edcce0d3fac6d46a5fc6e6d0d
this one could use a lot of testing of course, and feedback
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))That is a REPL specific issue w/ the feature - feel free to file an issue w/ the above, will have to think about it.
can I execute a node script from the command line, would that work in this setup?
I mean without setting up a whole project
Currently the feature relies on the build process / js dep indexing.
ok.
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
I mean, this may not be the typical use case for it, I was just trying to give it a quick spin
yeah I understand completely, it is surprising it doesn't work at the REPL
but that's because of the way I implemented it on top of :global-exports
It might work when I do have npm deps etc in my project right
in the REPL
no
the issue is you're declaring an ns at the REPL w/o a source file
which isn't very typical, admittedly
in builds, we parse all namespaces to figure out the inputs
in that phase we elide global requires because they have no inputs
but that path of course has nothing to do w/ REPLs