thheller / shadow-cljs

ClojureScript compilation made easy

Home Page:https://github.com/thheller/shadow-cljs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

:autoload false appears to reload js automatically when with :target browser

sstraust opened this issue · comments

here is my shadow-cljs.edn. I'm running shadow-cljs from cider (via cider-jack-in-cljs).

{
 :deps true
 :builds {:app
          {
           :devtools {
                      :autoload false
                      :ignore-warnings true
                      }
           :output-dir "out"
           :target :browser
           :modules {:main {:init-fn gptmafia.core/load-page}}
           }
       }
 }

I've disabled autoload, but on saving one of my clojurescript files, all of the warning messages pop up in my browser. It's super distracting for in-progress development, because when I save a half-finished file, my browser pops up with a bunch of warning messages saying everything is broken.

Weirdly, the browser does not autoload if I stop the build from the browser console. Is there any way to configure my shadow-cljs so that this doesn't happen? Am I missing something obvious?

Thanks!

Screenshot 2024-05-23 at 11 05 15 AM

:autoload means exactly that. It only stops the code from being loaded automatically. It does not stop compilation and therefore will continue to show compiler warnings.

To get that you have to get a bit more manual and trigger actual compilation from the REPL. There are a couple helpers for that in shadow.cljs.devtools.api. Here is how that would look at the command line, which of course you likely want to do via your Editor.

npx shadow-cljs clj-repl

This drops you into a CLJ REPL, much like connecting your Editor would. You can then start the watch, but with autobuild disabled, meaning it only builds once and then waits

(shadow/watch :app {:autobuild false})

Then later to trigger actual build with all the changes that happened since the last build

(shadow/watch-compile! :app)
# or to run all active builds
(shadow/watch-compile-all!)

You can also toggle between autobuild on/off via

(shadow/watch-set-autobuild! :app true|false)

Thank you for the quick support!

shadow-cljs.edn:

:devtools {
    :autobuild false
}

is exactly what I was looking for!