Skip to content

Instantly share code, notes, and snippets.

@jellea
Last active August 29, 2015 14:04
Show Gist options
  • Save jellea/3ac4c4e643329cc4ee4f to your computer and use it in GitHub Desktop.
Save jellea/3ac4c4e643329cc4ee4f to your computer and use it in GitHub Desktop.
Clojurescript and externs.

I guess a bit of documentation might come in handy since the documention on the compiler and externs is still poor

I wanted to include Hammer.js to my advanced compilation file output. So, I used the Closure extern generator to make a extern file. Adding the extern to my project.clj was easy, but I wanted it to be included in the output javascript as well. Apparently :preamble is meant for that, but it just didn't work. After a bit of fiddling around I found out that the preamble path is relative to <project root>/resources.

{:id "production"
 :source-paths ["src"]
 :compiler {
  :optimizations :advanced
  :output-to "www/out/triplet_mobile.js"
  :pretty-print false
  :preamble ["react/react.min.js" "hammerjs/hammer.js"]
  :externs ["react/externs/react.js" "hammer.extern.js"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment