Skip to content

Commit d9feda1

Browse files
committed
CLJS-1235: non-upstream :foreign-libs not copied to :output-dir
cljs.closure: - source-for-namespace namespaces for js namespaces should not be munged, just call str on ns :file may be a string representing a URL. Attempt to parse via URL ctor. cljs.repl: - load-namespace filter out the :seed when evaluating dep strings, the :seed is not a valid IJavaScript instance
1 parent cd4fe1b commit d9feda1

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/main/clojure/cljs/closure.clj

+9-4
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,16 @@
512512
(let [relpath (str path ".cljc")]
513513
(if-let [cljc-res (io/resource relpath)]
514514
{:relative-path relpath :uri cljc-res}
515-
(let [relpath (:file (get-in @compiler-env [:js-dependency-index ns-str]))]
516-
(if-let [js-res (and relpath (io/resource relpath))]
515+
(let [relpath (:file (get-in @compiler-env [:js-dependency-index (str ns)]))]
516+
(if-let [js-res (and relpath
517+
;; try to parse URL, otherwise just return local
518+
;; resource
519+
(or (try (URL. relpath) (catch Throwable t))
520+
(io/resource relpath)))]
517521
{:relative-path relpath :uri js-res}
518522
(throw
519-
(IllegalArgumentException. (str "Namespace " ns " does not exist"))))))))))
523+
(IllegalArgumentException.
524+
(str "Namespace " ns " does not exist"))))))))))
520525

521526
(defn cljs-dependencies
522527
"Given a list of all required namespaces, return a list of
@@ -997,7 +1002,7 @@
9971002
to the specified base file."
9981003
[^File base input]
9991004
(let [base-path (util/path-seq (.getCanonicalPath base))
1000-
input-path (util/path-seq (.getCanonicalPath (io/file ^URL (deps/-url input))))
1005+
input-path (util/path-seq (.getCanonicalPath (io/file (deps/-url input))))
10011006
count-base (count base-path)
10021007
common (count (take-while true? (map #(= %1 %2) base-path input-path)))
10031008
prefix (repeat (- count-base common 1) "..")]

src/main/clojure/cljs/repl.cljc

+5-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@
177177
;; source must supply at least :url - David
178178
sources (cljsc/add-dependencies
179179
(merge (env->opts repl-env) opts)
180-
{:requires [(name ns)] :type :seed
180+
{:requires [(name ns)]
181+
:type :seed
181182
:url (:uri (cljsc/source-for-namespace
182183
ns env/*compiler*))})
183184
deps (->> sources
@@ -187,7 +188,9 @@
187188
(if (:output-dir opts)
188189
;; REPLs that read from :output-dir just need to add deps,
189190
;; environment will handle actual loading - David
190-
(doseq [source (map #(cljsc/source-on-disk opts %) sources)]
191+
(doseq [source (->> sources
192+
(remove (comp #{:seed} :type))
193+
(map #(cljsc/source-on-disk opts %)))]
191194
(-evaluate repl-env "<cljs repl>" 1
192195
(cljsc/add-dep-string opts source)))
193196
;; REPLs that stream must manually load each dep - David

0 commit comments

Comments
 (0)