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
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,11 @@

(defn compile-dir
"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]
(let [out-dir (output-directory opts)]
(dependency-order
(map compiled-file
(comp/compile-root src-dir out-dir)))))
(map compiled-file
(comp/compile-root src-dir out-dir))))

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

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

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

(comment
;; only get cljs deps
Expand Down Expand Up @@ -863,7 +861,9 @@
[(-compile (io/resource "cljs/nodejscli.cljs") all-opts)]))
js-sources (if (coll? 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)
(->> js-sources
(apply optimize all-opts)
Expand Down

0 comments on commit 2e5eee6

Please sign in to comment.