   [& args]
   `(.println System/err (str ~@args)))
 
-(defonce ns-first-segments (atom '#{"cljs" "clojure"}))
+(defn ns-first-segments []
+  (letfn [(get-first-ns-segment [ns] (first (string/split (str ns) #"\.")))]
+    (map get-first-ns-segment (keys @ana/namespaces))))
 
 ; Helper fn
 (defn shadow-depth [s]

    (loop [d 0, {:keys [shadow]} info]
      (cond
       shadow (recur (inc d) shadow)
       (@ns-first-segments (str name)) (inc d)
       :else d))))

(defn munge


(defmethod emit :ns
  [{:keys [name requires uses requires-macros env]}]
  (emitln "goog.provide('" (munge name) "');")
  (when-not (= name 'cljs.core)
    (emitln "goog.require('cljs.core');"))
