-
Notifications
You must be signed in to change notification settings - Fork 10
CLJS compiler analyzer
The cljs.compiler and cljs.analyzer packages do a bunch of stuff that sometimes get in the way of what shadow-build is trying to do. Sometimes they don't get in the way but are useless or do unnecessary work.
Writing them down here so I don't forget, also monitor them in case something upstream changes.
-
cljs.analyzer/*passes*if nil will set default passes of[infer-type ns-side-effects]. Must not ever runns-side-effectsso always bind*passes*before callinganalyze. -
cljs.analyzer/empty-envtakes no arguments but requireenv/*compiler-env*and*cljs-ns*to be bound. -
cljs.analyzer/parse-nsreplaced byshadow.cljs.util/parse-ns. Some of the side effects were moved tons-side-effectsbut it still modifies the compiler env and has many other side effects. Instead of making a pure version of this there is a "fake" pure version that resets compiler env back to the state it was before (WTF?). Any changes toparse-nsand(defmethod parse 'ns ...)must be ported. It still has some issues, some have tickets.shadow-buildis a lot stricter about thensform and will throw for some things the CLJSparse-nswill happily ignore. ie. duplicate requires for the samens, duplicate imports. -
:emit-constants, most of the issues with incremental compilation for this where fixed by using stable names for constants. It still has issues around advanced compilation since the Closure Compiler does not move the generated constants between modules. (cross module motion does not move calls withnew). All of this was replaced by the closure pass to move constants. Must ensure that nothing:emit-constantsrelated is ever activated forshadow-build.
-
cljs.analyzer/analyze-formwhich is called for every single form callscljs.analyzer/load-core. That method checks whether it has run before but instead should only be run ONCE instead. -
load-corealso calls(cljs.analyzer/intern-macros 'cljs.core)for EVERY SINGLE FORM. -
(def implicit-nses '#{goog goog.object goog.string goog.array Math String}). I can understandgoog,Math,String, but why are the other implicit for every singlens? Would the:requirehurt so much?cljs.corealready ensures that they are loaded.