             (cond->
               (seq chunks)
               (-> (update :index assoc :prepend "var $APP = global.$APP = {};\n")
-                  (add-chunk-modules mode chunks))))]
+                  (add-chunk-modules mode chunks))
+
+              build-worker?
+              (add-module-loaded-calls)))]
 
     (io/make-parents output-file)
 


        dev?
        (= :dev mode)

        modules
        (-> {:index {:entries [(output/ns-only init-fn)]

    modules
    chunks))

(defn prepend-str [a b]
  (str b a))

(defn add-module-loaded-calls [modules]
  (reduce-kv
    (fn [m module-id module]
      (update-in m [module-id :append-js]
        prepend-str (str "\nshadow.cljs.devtools.client.env.module_loaded('" (name module-id) "');\n")))
    modules
    modules))

(defn configure
  [{:keys [worker-info] :as state} mode {:keys [chunks init-fn output-dir] :as config}]
  (let [output-dir
        (io/file output-dir)

