Skip to content

Advanced Compilation

Mike Fikes edited this page Apr 9, 2018 · 10 revisions

Even though code size may not be a huge issue with mobile apps, advanced compilation can reduce launch latency, especially on older devices. For example, timings on an iPad 2 for a ClojureScript + React Native app compiled with :simple result in 3-second launch latency, while :advanced reduces this to 2 seconds.

When creating production builds, use of :advanced may help with code size (thus making it unnecessary to configure the heap size for the React Native packager).

The topics discussed at Advanced Compilation are applicable.

Simply including react-native-externs as a dependency can cover React Native itself, but you need to be sure to deal with the name shortening that may occur for other 3rd party components you might be using.

Tips suggested by @jeaye (in Slack) to avoid the externs problem of Clojurescript.

  1. If you'd prefer not to use externs files, you can either use the facilities available in goog.object, such as goog.object/get, goog.object/set, and goog.object/getValueByKeys, or you can use the cljs-oops library.
  2. You can make use of the :infer-externs compiler option to help automatically generate externs based on call patterns in your code.

The cljs-oops has a very good introduction on the benefits of using it instead of clojurescript native .- field access operator

Clone this wiki locally