Skip to content

Loading…

Add support for :externs and :use-only-custom-externs options #8

Closed
wants to merge 1 commit into from

3 participants

@jolby

No description provided.

@jli

Clojure only takes contributions through its own issue tracking system. Please see http://clojure.org/contributing.

Meanwhile, I also ran into this and submitted a similar patch: http://dev.clojure.org/jira/browse/CLJS-73. I thought io/resource threw an exception when I tried to apply it to a file, so I used io/file, but perhaps I was mistaken.

@jolby

Great, thanks John. Hopefully we'll your patch merged sometime soon.

@brentonashworth

A patch for this was submitted a while back. I have created an externs branch and applied that patch. Please test these changes with whatever you are working on and let us know if you find problems. You may let us know in JIRA, or the Clojure dev mailing list. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 6 additions and 8 deletions.
  1. +6 −8 src/clj/cljs/closure.clj
View
14 src/clj/cljs/closure.clj
@@ -101,16 +101,14 @@
Options may contain an :externs key with a list of file paths to
load. The :use-only-custom-externs flag may be used to indicate that
- the default externs should be excluded.
-
- TODO: Implement options described above."
+ the default externs should be excluded."
[opts]
- (let [default (CommandLineRunner/getDefaultExterns)]
+ (let [jsf #(js-source-file % (io/input-stream (io/resource %)))
+ default (if (:use-only-custom-externs opts) [] (vec (CommandLineRunner/getDefaultExterns)))
+ externs (if (:externs opts) (vec (concat default (map #(jsf %) (:externs opts)))) default)]
(if (= :nodejs (:target opts))
- (let [path "cljs/nodejs_externs.js"]
- (cons (js-source-file path (io/input-stream (io/resource path)))
- default))
- default)))
+ (conj externs (jsf "cljs/nodejs_externs.js"))
+ externs)))
(defn ^com.google.javascript.jscomp.Compiler make-closure-compiler []
(let [compiler (com.google.javascript.jscomp.Compiler.)]
Something went wrong with that request. Please try again.