Permalink
Browse files

CLJS-77: support Closure defines

  • Loading branch information...
1 parent 2b8534a commit cb7e97f13ae6a03086f5d96ba58e5f3d5cba7dc3 @swannodette swannodette committed Dec 4, 2013
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/clj/cljs/closure.clj
View
@@ -135,10 +135,18 @@
:simple CompilationLevel/SIMPLE_OPTIMIZATIONS)
compiler-options (doto (CompilerOptions.)
(.setCodingConvention (ClosureCodingConvention.)))]
- (when (contains? opts :closure-warnings)
- (doseq [[type level] (:closure-warnings opts)]
- (. compiler-options
- (setWarningLevel (type warning-types) (level check-level)))))
+ (doseq [[key val] (:closure-defines opts)]
+ (let [key (name key)]
+ (cond
+ (string? val) (.setDefineToStringLiteral compiler-options key val)
+ (integer? val) (.setDefineToIntegerLiteral compiler-options key val)
+ (float? val) (.setDefineToDoubleLiteral compiler-options key val)
+ (or (true? val)
+ (false? val)) (.setDefineToBooleanLiteral compiler-options key val)
+ :else (println "value for" key "must be string, int, float, or bool"))))
+ (doseq [[type level] (:closure-warnings opts)]
+ (. compiler-options
+ (setWarningLevel (type warning-types) (level check-level))))
(when (contains? opts :source-map)
(set! (.sourceMapOutputPath compiler-options)
(:source-map opts))

0 comments on commit cb7e97f

Please sign in to comment.