Fork me on GitHub
#shadow-cljs
<
2021-07-06
>
thheller07:07:00

impossible to say without seeing the code and config. pretty much the only problems I ever had with module loading is with cache issues. eg. when you have an old shared.js but try to load newer admin.js or so but the hashes prevent that from happening usually. could be something like a service worker going crazy too though

Pavel Klavík20:07:55

We don't have any service worker at the moment.

Pavel Klavík20:07:17

And files have Git commit SHA appended, so there should be no collisions.

Pavel Klavík20:07:15

{:lein     true
 :jvm-opts ["-Dfile.encoding=UTF8" "-Xmx2G"]
 :nrepl    {:port 9000}
 :ssl      {:keystore "keystore.jks"
            :password "..."}
 :builds   {:client     {:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :module-loader    true
                         :modules          {:shared {:entries []}
                                            :main   {:init-fn    orgpad.client.core/init
                                                     :depends-on #{:shared}}
                                            :admin  {:entries    [orgpad.client.views.administration.core]
                                                     :depends-on #{:main}}
                                            :layout {:entries    [orgpad.client.layout.webworker.core]
                                                     :depends-on #{:shared}
                                                     :web-worker true}}
                         :compiler-options {:infer-externs      :auto
                                            :output-feature-set :es6}
                         :devtools         {:after-load     orgpad.client.core/mount-root
                                            :before-load    orgpad.client.core/stop-web-workers
                                            :watch-dir      "resources/public"
                                            :browser-inject :main
                                            :loader-mode    :eval}}
            :landing    {:target     :browser
                         :output-dir "landing/resources/js"
                         :asset-path "/js"
                         :modules    {:main {:init-fn orgpad.landing.dev/init}}
                         :devtools   {:http-root      "landing/resources"
                                      :http-port      3500
                                      :after-load     orgpad.landing.dev/mount-root
                                      :watch-dir      "landing/resources"
                                      :browser-inject :main}}
            :emails     {:target     :browser
                         :output-dir "emails/js"
                         :asset-path "/js"
                         :modules    {:main {:init-fn orgpad.server.email.dev/init}}
                         :devtools   {:http-root      "emails"
                                      :http-port      3600
                                      :after-load     orgpad.server.email.dev/mount-root
                                      :watch-dir      "emails"
                                      :browser-inject :main}}
            :screenshot {:target           :node-script
                         :main             orgpad.screenshot.core/main
                         :output-to        "screenshot/screenshot.js"
                         :devtools         {:autoload true}
                         :compiler-options {:optimizations :simple}}}}

thheller20:07:16

hmm you are not using :module-hash-names so how do you get the proper filenames into the loader?

Pavel Klavík21:07:37

release build is done by this:

(defn release []
  (let [version (System/getenv "GIT_SHA")]
    (when-not (= (shadow/release :client {:config-merge [{:release-version version}]}) :done)
      (throw (RuntimeException. "Shadow-cljs compilation failed.")))))

thheller21:07:21

FWIW there is a shadow/release! that'll throw if compile fails

thheller21:07:55

is admin something the regular user will actually use? or is it actual admin-only stuff?

thheller21:07:43

really not super important but admin specific stuff that regular users won't use is probably better off in a separate build

thheller21:07:13

but config wise it looks fine. don't know what could be going wrong with it

thheller21:07:02

when do you actually trigger lazy loads? directly on first load?

Pavel Klavík21:07:45

btw. is there a way to run newer version of Shadow with previous Clojurescript and Closure library?

Pavel Klavík21:07:35

when you enter administration, the lazy component is displayed and does the loading using the code Adam posted yesterday

thheller21:07:48

due to breaking changes all over the place you really can't mix versions too well

thheller21:07:59

you can try but no guarantees