Sha256: 770b55dce8ac65f20391cf35b8c6cde33932170e28398073191e3207f034a415
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
Simple ClojureScript Project Example Using an External JavaScript Library One-time Setup ============== - Create a CLOJURESCRIPT_HOME environment variable which points to the ClojureScript root directory. - If you have not already done so, execute $CLOJURESCRIPT_HOME/script/bootstrap - Add $CLOJURESCRIPT_HOME/bin to your PATH. Simple external JavaScript file =============================== Run in Development Mode ----------------------- Development mode allows for each file to be loaded in a separate script tag so that errors can be easily tracked to the offending file. cljsc src > hello-js.js After running the above command, open hello-js-dev.html. Notice that each required JavaScript file has been loaded in its most readable form. Run Optimized JavaScript ------------------------ Once an application is ready for production, a single optimized file can be produced. cljsc src {:optimizations :advanced} > hello-js.js After running the above command, open hello-js.html to view the result. Using an externed JavaScript file ================================= To see how external calls are optimized away, execute the following: cljsc src '{:optimizations :advanced :output-to "hello-extern.js"}' After running the above command, open hello-extern.html to view the result. You should see nothing and possibly a JavaScript error. The solution is to compile the ClojureScript source with a referred externs file as follows: cljsc src '{:optimizations :advanced :output-to "hello-extern.js" :externs ["externs.js"]}' Again after running the above command, open hello-extern.html to view the result. You should see an alert box.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clementine-0.0.3 | ext/clojure-clojurescript-bef56a7/samples/hello-js/README.md |
clementine-0.0.2 | ext/clojure-clojurescript-bef56a7/samples/hello-js/README.md |