Compiler Options



A path to :output-dir relative to your web server's root, if not already specified as such. Only required when :optimizations is :none and :main is set, because the generated :output-to file will then need to load other parts of the build at runtime.

:output-to "resources/public/main.js"
:output-dir "resources/public/js/compiled/out"
:asset-path "js/compiled/out" ;; <--- relative URL of output-dir



Cache compiler analysis to disk to enable faster cold build and REPL startup times. Defaults to true in REPL and when :optimizations is disabled. Each CLJS file is cached to :output-dir with analysis formatted by :cache-analysis-format.

  • foo.cljs - copied source
  • foo.cljs.cache.json - analysis in transit format, or
  • foo.cljs.cache.edn - analysis in edn format
:cache-analysis true


Set the output format of the analysis cache if :cache-analysis is enabled. Defaults to transit json.

                                 ;; for foo.cljs
:cache-analysis-format :transit  ;; <-- foo.cljs.cache.json (default)
:cache-analysis-format :edn      ;; <-- foo.cljs.cache.edn





Control specific warnings generated by the Closure compiler. Each warning must map to either :error, :warning, or :off.

:closure-warnings {:externs-validation :off}




Remove all assert calls during compilation, including :pre and :post condition checks for functions. Useful for production. Defaults to false, even in advanced mode.

:elide-asserts true



Files declaring JavaScript symbols that should not be munged under advanced :optimizations.

:externs ["react-externs.js"


Allows you to include and convert JavaScript libraries that are not proper Google Closure namespaces—if they are, use :libs instead. For an easier way to include libraries from npm use :npm-deps.

[{:file "local/file.js"         ;; file path or URL
  :provides ["my.example"]      ;; assign a fake namespace

  ;; optional keys
  :file-min "local/file.min.js" ;; used for :advanced optimizations
  :module-type ...              ;; :commonjs, :amd, or :es6
  :requires [""]         ;; inferred if :module-type supplied
  :preprocess ...}]             ;; custom preprocessor (e.g. JSX)


A helpful facility for generating :externs whenever a . form is used on a type-hinted symbol ^js/Foo.Bar x. Enable *warn-on-infer* to be warned of failed inferences. Successful inferences are written to inferred_externs.js in :output-dir.

:infer-externs true




Paths to JavaScript libraries that you wish to include in the build. Libs must be proper Google Closure namespaces, else use :foreign-libs or :npm-deps.

:libs ["src/js"                      ;; <-- all files in directory
       "src/org/example/example.js"] ;; <-- single file


Specifies an entry point namespace. Behavior depends on :optimizations:

  • :simple,:advanced - only namespaces reachable from main are built
  • :none - all namespaces are built, but the :output-to file will be generated such that main is executed for the appropriate :target (browser or Node).
:main ""


Employ code-splitting to replace the usual :output-to file with separate logical modules. Every namespace is assigned to exactly one logical module. Code-motion will enable code to be pulled across module boundaries when possible, but this is avoided if the compiler knows it will already be included on the page:

  • :output-to - output file of a module
  • :entries - namespaces to include (modules must have no entries in common)
  • :depends-on - modules expected to be included on the page beforehand
{:foo {:output-to "js/foo.js" :entries #{""}}
 :bar {:output-to "js/bar.js" :entries #{""} :depends-on #{:foo}}
 :baz {:output-to "js/baz.js" :entries #{"my.baz"} :depends-on #{:bar}}

 :cljs-base ;; <-- leftover namespaces are placed here for you
 {:output-to "js/cljs_base.js"}} ;; <-- specify to change base output


Include libraries from npm. This experimental feature downloads the dependencies from npm and generates a :foreign-libs entry for each.

:npm-deps {:react "15.4.2"
           :lodash "4.17.4"}


The compiler will produce JS based on the optimization level:

  • :none - multiple unminified files (fastest for development).
  • :whitespace - single file w/ comments and whitespace removed
  • :simple - single file w/ whitespace optimizations + minified local var names
  • :advanced - single file w/ aggressive renaming, dead code removal, and inlining
:optimizations :none     ;; <-- recommended for development
:optimizations :advanced ;; <-- recommended for production
:optimizations :simple   ;; <-- recommended for Node



Sets the output directory for temporary files used during compilation. Defaults to "out".

:output-dir "resources/public/js/out"


The path to the JavaScript file that will be output.

:output-to "resources/public/js/main.js"




A list of namespaces to load before :main, allowing you to preload extra code for specific builds. For example, a development build can use it to setup logging or connecting REPLs. Only applies when :optimizations is :none.

:preloads '[]


Determines if the JavaScript output will be formatted to be human-readable. Only applies if :optimizations are enabled. Defaults to false.

:pretty-print true


Allows you to retain var names similar to their original when compiling advanced :optimizations. Enable this along with :pretty-print if you wish to read the advanced output for debugging purposes.

:pseudo-names true


For correctness, this defaults to true in order to recompile dependent namespaces when a parent namespace changes. This prevents corrupted builds and swallowed warnings. However, this can impact compile times depending on the structure of the application.

:recompile-dependents false


To help debugging at runtime, creates a standard source map JSON file used by Node and browsers to map compiled JS lines to their original CLJS files. Use a string path if there is a single output file expected, otherwise use true to auto-assign source map filenames.

:source-map "out/"
:source-map true ;; <-- use if `:optimizations :none`, or any `:modules`


A compiled JS file can contain a sourceMappingURL comment, which cljs uses to locate the :source-map JSON file. You can prepend this location with a custom path if required by your web server configuration.

:source-map-asset-path "..."  ;; <-- custom server path of source map metadata


Source maps associate compiled JS lines to their original CLJS files. Use this option if you configured your web server to host these original CLJS files at a custom path. If present, it is prepended to all sources inside the :source-map file.

:source-map-path "..."  ;; <-- custom server path of original CLJS files


Add cache busting timestamps to source map urls. This is helpful for keeping source maps up to date when live reloading code.

:source-map-timestamp true


Controls how multi-arity function calls are generated. A "static" call means the dispatch to the appropriate arity is handled at compile time (better performance), whereas a "dynamic" call means the dispatch is handled at run time (allows safer redefinition in REPL). Static is enabled by default in advanced :optimizations.

:static-fns true


Determines the target environment the compiled code is expected to run on. Use :nodejs for Node.js. If no target is specified, the browser environment is assumed.

:target :nodejs  ;; <-- use when targeting Node.js





Show the steps the compiler is taking to create the build.

:verbose true



Enable all or specific compiler warnings. See full details for all warning options. Defaults to true.

:warnings true                  ;; enable all (default)
:warnings {:fn-deprecated true} ;; enable specific warnings