-
Notifications
You must be signed in to change notification settings - Fork 789
Advanced Compilation
If you are targeting traditional JavaScript clients (web browsers) it's important to think about advanced compilation from the very beginning. Otherwise you will inevitably find yourself going through issues that could have been easily avoided with a little bit of up front preparation.
It's best to simply avoid foreign libraries if a solution exists either in Google Closure Library or in an existing ClojureScript library. Foreign libraries must supply externs for advanced compilation to work consistently.
Of course, in some cases foreign libraries cannot be avoided.
If you must use a foreign library use a curated one like those provided by CLJSJS. These come packaged with externs so that you do not have to supply them yourself.
Occasionally you may find yourself needing a foreign library which has not been prepackaged.
When working with a foreign library which does not supply externs take the time to write an externs file for the API you intend to use. Externs file are surprisingly simple to provide. For example if the foreign library has some property Foo.bar
that you wish to access your externs file should have the following entry:
Foo.bar;
If the foreign library has some method Foo.baz
that you wish to invoke your externs file should have the following entry:
Foo.baz = function() {};
- Rationale
- Quick Start
- Differences from Clojure
- [Usage of Google Closure](Google Closure)