Skip to content

Instantly share code, notes, and snippets.

@roman01la
Last active October 30, 2017 02:40
Show Gist options
  • Save roman01la/7679ba46a59689f78d887fc786eaf53f to your computer and use it in GitHub Desktop.
Save roman01la/7679ba46a59689f78d887fc786eaf53f to your computer and use it in GitHub Desktop.
What it takes to build ClojureScript web app

What it takes to build ClojureScript web app

ClojureScript-only codebase

  1. Install Java
  2. Install Leiningen
  3. lein new figwheel my-app
  4. lein cljsbuild once min
  5. DONE

With JavaScript dependencies

CLJSJS

  1. Pull JavaScript dependencies from CLJSJS
  2. build

Advantages

  • No additional config
  • No externs needed

Disadvantages

  • Not all JS libraries are on CLJSJS
  • CLJSJS libraries are pre-built and unoptimized by Closure Compiler
  • Since deps code is unoptimized, output bundle size might increase drastically

Foreign libraries

Basically what CLJSJS packages do for you automatically

  1. Have JavaScript files locally
  2. Configure :foreign-libs compiler option
  3. Provide externs
  4. build

Disadvantages

  • Requires to configure every dependency file and relations between them
  • Requires to create and provide externs files
  • Foreign libraries code is unoptimized by Closure Compiler
  • Since deps code is unoptimized, output bundle size might increase drastically

While these are officially recommened ways to consume JavaScript from ClojureScript, there's a number of experimental tools which are trying to provide a better experience (see shadow-cljs).

One approach that is not described here would be to bundle ClojureScript and JavaScript code separately. But how you do it depends on so many parts, that it doesn't make sense to describe here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment