Skip to content

Commit

Permalink
Sort JavaScript files in dependency order once, just before advanced …
Browse files Browse the repository at this point in the history
…compilation
  • Loading branch information
Brenton Ashworth committed Mar 30, 2012
1 parent e615f4c commit 2e5eee6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/clj/cljs/closure.clj
Expand Up @@ -347,12 +347,11 @@


(defn compile-dir (defn compile-dir
"Recursively compile all cljs files under the given source "Recursively compile all cljs files under the given source
directory. Return a list of JavaScriptFiles in dependency order." directory. Return a list of JavaScriptFiles."
[^File src-dir opts] [^File src-dir opts]
(let [out-dir (output-directory opts)] (let [out-dir (output-directory opts)]
(dependency-order (map compiled-file
(map compiled-file (comp/compile-root src-dir out-dir))))
(comp/compile-root src-dir out-dir)))))


(defn path-from-jarfile (defn path-from-jarfile
"Given the URL of a file within a jar, return the path of the file "Given the URL of a file within a jar, return the path of the file
Expand Down Expand Up @@ -514,8 +513,8 @@


(defn js-dependencies (defn js-dependencies
"Given a sequence of Closure namespace strings, return the list of "Given a sequence of Closure namespace strings, return the list of
all dependencies in dependency order. The returned list includes all all dependencies. The returned list includes all Google and
Google and third-party library dependencies. third-party library dependencies.
Third-party libraries are configured using the :libs option where Third-party libraries are configured using the :libs option where
the value is a list of directories containing third-party the value is a list of directories containing third-party
Expand All @@ -531,7 +530,7 @@
(recur (into (rest requires) new-req) (recur (into (rest requires) new-req)
(into visited new-req) (into visited new-req)
(conj deps node))) (conj deps node)))
(cons (get index "goog/base.js") (dependency-order deps)))))) (remove nil? deps)))))


(comment (comment
;; find dependencies ;; find dependencies
Expand All @@ -549,11 +548,10 @@


(defn cljs-dependencies (defn cljs-dependencies
"Given a list of all required namespaces, return a list of "Given a list of all required namespaces, return a list of
IJavaScripts which are the cljs dependencies in dependency IJavaScripts which are the cljs dependencies. The returned list will
order. The returned list will not only include the explicitly not only include the explicitly required files but any transitive
required files but any transitive depedencies as well. JavaScript depedencies as well. JavaScript files will be compiled to the
files will be compiled to the working directory if they do not working directory if they do not already exist.
already exist.
Only load dependencies from the classpath." Only load dependencies from the classpath."
[opts requires] [opts requires]
Expand All @@ -574,7 +572,7 @@
(recur (into (rest required-files) new-req) (recur (into (rest required-files) new-req)
(into visited new-req) (into visited new-req)
(conj js-deps js))) (conj js-deps js)))
(dependency-order js-deps)))))) (remove nil? js-deps))))))


(comment (comment
;; only get cljs deps ;; only get cljs deps
Expand Down Expand Up @@ -863,7 +861,9 @@
[(-compile (io/resource "cljs/nodejscli.cljs") all-opts)])) [(-compile (io/resource "cljs/nodejscli.cljs") all-opts)]))
js-sources (if (coll? compiled) js-sources (if (coll? compiled)
(apply add-dependencies all-opts compiled) (apply add-dependencies all-opts compiled)
(add-dependencies all-opts compiled))] (add-dependencies all-opts compiled))
js-sources (cons (javascript-file nil (io/resource "goog/base.js") ["goog"] nil)
(dependency-order js-sources))]
(if (:optimizations all-opts) (if (:optimizations all-opts)
(->> js-sources (->> js-sources
(apply optimize all-opts) (apply optimize all-opts)
Expand Down

0 comments on commit 2e5eee6

Please sign in to comment.