-
Notifications
You must be signed in to change notification settings - Fork 790
Source maps
ClojureScript now supports HTML source maps so that you can debug ClojureScript directly in the browser.
At the command line you can run something like the following, adjusted for your project:
$ cljsc src '{:optimizations :whitespace :output-dir "out" :output-to "main.js" :source-map "main.js.map"}'
You may then open a HTML file linking to the generated js file in Chrome. Make sure that source maps in Chrome are enabled via the Chrome Developer Tools settings.
Source maps also work with :optimizations
set to :none
, in this case the :source-map
value doesn't matter, it just needs to be a truth-y value - an individual source map file will be generated for every ClojureScript source file.
It's important to note there are some source map option restrictions when using an :optimizations
setting other than :none
. In these cases :output-to
, :output-dir
, and :source-map
must all share the exact same parent directory.
All source files will get copied into :output-dir
so that they can be resolved, however this is not useful in the case where you have web server. :source-map-path
can be used to define an arbitrary path prefix. So instead of source map file references resolving to something like resources/public/js/out
you can instead instead specify :source-map-path "js/out"
.
- Rationale
- Quick Start
- Differences from Clojure
- [Usage of Google Closure](Google Closure)