Setup is based on clojurescript getting started guide. I've added a require statement to the core ns and using the latest master sha
deps.edn
{:deps {org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript.git"
:sha "ec0fc33030ae1858a29c52f38e81fba4180d492b"}}}
src/hello_world/core.cljs
(ns hello-world.core
(:require [goog.object :as gobj]))
We can compile and run the repl in one step and see the aliases resolving.
rm -rf .cpcache out
clj -m cljs.main -co '{:main hello-world.core}' -c -r
ClojureScript 0.0.630944134
cljs.user=> (in-ns 'hello-world.core)
nil
hello-world.core=> (gobj/get #js{:a 1} "a")
1
But we can break it by doing compile before running the repl
rm -rf .cpcache out
clj -m cljs.main -co '{:main hello-world.core}' -c
clj -m cljs.main -co '{:main hello-world.core}' -r
ClojureScript 0.0.630944134
cljs.user=> (in-ns 'hello-world.core)
nil
hello-world.core=> (gobj/get #js{:a 1} "a")
WARNING: No such namespace: gobj, could not locate gobj.cljs, gobj.cljc, or JavaScript source providing "gobj" at line 1 <cljs repl>
WARNING: Use of undeclared Var gobj/get at line 1 <cljs repl>
Execution error (ReferenceError) at (<cljs repl>:1).
gobj is not defined
You can workaround the problem by setting :analyze-path
rm -rf .cpcache out
clj -m cljs.main -co '{:main hello-world.core}' -c
clj -m cljs.main -co '{:main hello-world.core :analyze-path ["src"]}' -r
ClojureScript 0.0.630944134
cljs.user=> (in-ns 'hello-world.core)
nil
hello-world.core=> (gobj/get #js{:a 1} "a")
1
NOTES: Adding -c
to the repl lines doesn't help if it's already compiled. Presumably that's skipping the analysis work.