Created
November 19, 2012 19:02
-
-
Save sgrove/4112913 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn parse-ns [src dest] | |
(with-core-cljs | |
(binding [ana/*cljs-ns* 'cljs.user] | |
(loop [forms (forms-seq src)] | |
(if (seq forms) | |
(let [env (ana/empty-env) | |
ast (ana/analyze env (first forms))] | |
(if (= (:op ast) :ns) | |
(let [ns-name (:name ast) | |
deps (merge (:uses ast) (:requires ast))] | |
{:ns (or ns-name 'cljs.user) | |
:provides [ns-name] | |
:requires (if (= ns-name 'cljs.core) | |
(set (vals deps)) | |
(conj (set (vals deps)) 'cljs.core)) | |
:file dest}) | |
(recur (rest forms))))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Seans-MacBook-Air-2:clojurescript sgrove$ patch -p1 < patch.diff | |
patching file src/clj/cljs/compiler.clj | |
Seans-MacBook-Air-2:clojurescript sgrove$ cd .. | |
# Ran `lein cljsbuild auto` | |
Seans-MacBook-Air-2:cljs-sscce sgrove$ grep -E 'goog.(require|provide)\("cljs_sscce' resources/public/js/main.js | head -n 5 | |
goog.provide("cljs_sscce.c"); | |
goog.provide("cljs_sscce.b"); | |
goog.require("cljs_sscce.c"); | |
goog.provide("cljs_sscce.d"); | |
goog.provide("cljs_sscce.e"); | |
# Killed and re-ran `lein cljsbuild auto` | |
Seans-MacBook-Air-2:cljs-sscce sgrove$ touch src-cljs/cljs_sscce/b.cljs | |
Seans-MacBook-Air-2:cljs-sscce sgrove$ grep -E 'goog.(require|provide)\("cljs_sscce' resources/public/js/main.js | head -n 5 | |
goog.provide("cljs_sscce.d"); | |
goog.provide("cljs_sscce.e"); | |
goog.require("cljs_sscce.b"); | |
goog.require("cljs_sscce.d"); | |
goog.provide("cljs_sscce.c"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiling ClojureScript. | |
Compiling "resources/public/js/main.js" from "src-cljs"... | |
Successfully compiled "resources/public/js/main.js" in 11.528707 seconds. | |
^CSeans-MacBook-Air-2:cljs-sscce sgrove$ lein cljsbuild auto | |
Compiling ClojureScript. | |
Compiling "resources/public/js/main.js" from "src-cljs"... | |
Successfully compiled "resources/public/js/main.js" in 5.898944 seconds. | |
^CSeans-MacBook-Air-2:cljs-sscce sgrove$ lein -v | |
Leiningen 2.0.0-preview10 on Java 1.6.0_31 Java HotSpot(TM) 64-Bit Server VM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject cljs-sscce "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.4.0"]] | |
:plugins [[lein-cljsbuild "0.2.9"]] | |
:hooks [leiningen.cljsbuild] | |
:cljsbuild {:builds [{:incremental true | |
:source-path "src-cljs" | |
:compiler {:output-to "resources/public/js/main.js" | |
:optimizations :whitespace | |
:pretty-print true}}]} | |
:resource-paths ["clojurescript/src/clj" | |
"clojurescript/src/cljs"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
clojurescript checked out to ./clojurescript:
commit cd66e6b9e63ad5ef1896a9c7a117148beb04301d
Author: Max Penet m@qbits.cc
Date: Mon Nov 19 11:45:48 2012 +0100
Git status:
On branch master
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: src/clj/cljs/compiler.clj
Untracked files:
(use "git add ..." to include in what will be committed)
patch.diff
no changes added to commit (use "git add" and/or "git commit -a")
Git diff
$ git diff
diff --git a/src/clj/cljs/compiler.clj b/src/clj/cljs/compiler.clj
index 4f5e1e4..978f3fe 100644
--- a/src/clj/cljs/compiler.clj
+++ b/src/clj/cljs/compiler.clj
@@ -808,6 +808,24 @@
(or (not (.exists dest))
(> (.lastModified src) (.lastModified dest))))
+(defn parse-ns [src dest]
(with-core-cljs
(binding [ana/cljs-ns 'cljs.user]
(defn compile-file
"Compiles src to a file of the same name, but with a .js extension,
in the src file's directory.
@@ -831,7 +849,7 @@
(if (requires-compilation? src-file dest-file)
(do (mkdirs dest-file)
(compile-file* src-file dest-file))
(comment