Open chriswatrous opened 5 years ago
You should be comparing this to ClojureScript on the JVM, not Clojure. I think this is by design but I can't check right now.
It doesn't seem to be a lumo bug. Here's what I was able to reproduce:
JVM Clojurescript with (cljs.repl/repl (cljs.repl.node/repl-env))
:
ClojureScript 1.10.758
cljs.user=> (when true (require '[clojure.set :refer [union]]))
goog.require could not find: clojure.set
Execution error (Error) at (<cljs repl>:1).
goog.require could not find: clojure.set
cljs.user=> (node:22086) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
cljs.user=> (identity (require '[clojure.set :refer [union]]))
Execution error (SyntaxError) at (<cljs repl>:1).
missing ) after argument list
cljs.user=> union
Execution error (TypeError) at (<cljs repl>:1).
Cannot read property 'union' of undefined
cljs.user=> (require '[clojure.set :refer [union]])
nil
cljs.user=> (union #{1 2} #{2 3})
#{1 2 3}
JVM Clojurescript with (cljs.repl/repl (cljs.repl.browser/repl-env))
:
ClojureScript 1.10.758
cljs.user=> (when true (require '[clojure.set :refer [union]]))
Execution error (Error) at (<cljs repl>:1).
goog.require could not find: clojure.set
cljs.user=> (identity (require '[clojure.set :refer [union]]))
Execution error (SyntaxError) at (<cljs repl>:1).
missing ) after argument list
cljs.user=> union
Execution error (TypeError) at (<cljs repl>:1).
Cannot read property 'union' of undefined
cljs.user=> (require '[clojure.set :refer [union]])
nil
cljs.user=> (union #{1 2} #{2 3})
#{1 2 3}
However, it doesn't look like a design decision to me, especially the SyntaxError.
I'm not sure if this is a Lumo or ClojureScript bug or if it's expected behavior:
These all work in Clojure.
I noticed this problem because the editor plugin I'm trying to use wraps the expression to be evaluated causing
require
andns
to not work. https://github.com/mauricioszabo/repl-tooling/blob/f7ed777fb66613df82c3e6783ba3bc159c2803ec/src/repl_tooling/repl_client/clojurescript.cljs#L15-L17.