thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.25k stars 178 forks source link

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

Closed sstraust closed 4 months ago

sstraust commented 4 months ago

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
thheller commented 4 months ago

: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)
sstraust commented 4 months ago

Thank you for the quick support!

shadow-cljs.edn:

:devtools {
    :autobuild false
}

is exactly what I was looking for!