Skip to content
David Nolen edited this page Jan 11, 2015 · 136 revisions

Here is list of compiler options that can be passed to the ClojureScript compiler.

:output-to

The path to the JavaScript file that will be output.

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

:output-dir

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

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

:optimizations

The optimization level. May be :none, :whitespace, :simple, or :advanced. :none is the recommended setting for development, while :advanced is the recommended setting for production, unless something prevents it (incompatible external library, bug, etc.).

:none requires manual code loading and hence a separate HTML from the other options.

Defaults to :none.

:optimizations :none

:source-map

See https://github.com/clojure/clojurescript/wiki/Source-maps

:source-map true

:source-map-timestamp

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

:static-fns

Employs static dispatch to specific function arities in emitted JavaScript, as opposed to making use of the call construct. Defaults to false. Useful to have set to false at REPL development to facilitate function redefinition, and useful to set to true for release for performance.

:static-fns true

:warnings

This flag will turn on/off compiler warnings for references to undeclared vars, wrong function call arities, etc. Can be a boolean for enabling/disabling common warnings, or a map of specific warning keys with associated booleans. Defaults to true.

:warnings true
;; OR
:warnings {:fn-deprecated false} ;; suppress this warning

:elide-asserts

This flag will cause all (assert x ) calls to be removed during compilation, including implicit asserts associated with :pre and :post conditions. Useful for production. Default is always false even in advanced compilation. Does NOT specify goog.asserts.ENABLE_ASSERTS, which is different and used by the Closure library.

:elide-asserts true

:pretty-print

Determines whether the JavaScript output will be tabulated in a human-readable manner. Defaults to true.

:pretty-print true

:pseudo-names

With :advanced mode optimizations, determines whether readable names are emitted. This can be useful when debugging issues in the optimized JavaScript. Defaults to false.

:pseudo-names true

:print-input-delimiter

Determines whether comments will be output in the JavaScript that can be used to determine the original source of the compiled code.

Defaults to false.

:print-input-delimiter false

:target

If targeting nodejs add this line. Takes no other options at the moment.

:target :nodejs

:output-wrapper

Wrap the JavaScript output in (function(){...};)() to avoid clobbering globals. Defaults to true when using advanced compilation, false otherwise.

:output-wrapper false

:externs

Configure externs files for external libraries.

For this option, and those below, you can find a very good explanation at: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html

Defaults to the empty vector [].

:externs ["jquery-externs.js"]

:libs

Adds dependencies on external libraries. Note that files in these directories will be watched and a rebuild will occur if they are modified.

Defaults to the empty vector []

:libs ["closure/library/third_party/closure"]

:foreign-libs

Adds dependencies on foreign libraries. Be sure that the url returns a HTTP Code 200

Defaults to the empty vector []

:foreign-libs [{ :file "http://example.com/remote.js"
                 :provides  ["my.example"]}]

:preamble

Prepends the contents of the given files to each output file. Only valid with optimizations other than :none.

Defaults to the empty vector []

:preamble ["license.js"]

:language-in and :language-out

Configure the input and output languages for the closure library. May be :ecmascript3, ecmascript5, or ecmascript5-strict.

Defaults to :ecmascript3

:language-in  :ecmascript3
:language-out :ecmascript3

:closure-warnings

Configure warnings generated by the Closure compiler. A map from Closure warning to configuration value, only :error, :warning and :off are supported.

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

The following Closure warning options are exposed to ClojureScript:

:access-controls
:ambiguous-function-decl
:debugger-statement-present
:check-regexp
:check-types
:check-useless-code
:check-variables
:const
:constant-property
:deprecated
:duplicate-message
:es5-strict
:externs-validation
:fileoverview-jsdoc
:global-this
:internet-explorer-checks
:invalid-casts
:missing-properties
:non-standard-jsdoc
:strict-module-dep-check
:tweaks
:undefined-names
:undefined-variables
:unknown-defines
:visiblity

See the Closure Compiler Warning wiki for detailed descriptions.

Clone this wiki locally