Fork me on GitHub
#shadow-cljs
<
2023-12-06
>
Fredrik Andersson12:12:46

I have an issue with :target :node-script it doesn't update functions when I save a file. Shouldn't it do that, like it does in the browser? I think it did it before, but I'm uncertain.

Fredrik Andersson12:12:54

I can evaluate the function manually. And then it gets updated. But I was fond of the workflow where I would just save a file. ๐Ÿ˜„

thheller13:12:01

the workflow is the same, just might be doing something that can't be hot-reloaded. depends on what you are doing, but the limitations are the same as in the browser.

Fredrik Andersson13:12:55

ok, I reduced everything down to basically nothing in order to find any such problems

Fredrik Andersson13:12:32

but, then I know that there isn't an option in config or whatever. I will continue to see if I can find the reason.

thheller13:12:48

if you share the code I can probably tell you the reason ๐Ÿ˜›

thheller13:12:58

there is no extra config needed, same as the browser

Fredrik Andersson13:12:35

(ns ) (defn saysome [] (js/console.log "hadfass")) (comment (saysome)) (defn main [] (js/console.log "Starting dev process") (js/process.on "unhandledRejection" (fn [err] (js/console.log "ERROR") (js/console.log err) (tap> ["ERROR" err])))) (defn start "Hook to start. Also used as a hook for hot code reload." [] (js/console.warn "start called")) (defn stop "Hot code reload hook to shut down resources so hot code reload can work" [done] (js/console.warn "stop called"))

Fredrik Andersson13:12:11

if I change saysome function it should hot reload when I save the file. Right?

thheller13:12:08

depends on if you configured the :devtools {:after-load ...} since there is no ^:dev/after-load tag on start

Fredrik Andersson13:12:29

yes I do have those configured

thheller13:12:42

well, the function would still update regardless

thheller13:12:46

but yes that should work fine

thheller13:12:18

assuming of course that the node process properly connected back to shadow-cljs and didn't just immediately exit

Fredrik Andersson13:12:20

:macro-dev {:target :node-script :output-to "dist/runner/macro-dev.js" :main :compiler-options {:output-feature-set :es6} :dev {:closure-defines {anr.fire.admin/EMULATOR true anr.fire.admin/PROJECT-ID "macros-6d380"}} :release {:closure-defines {anr.fire.admin/EMULATOR false anr.fire.admin/PROJECT-ID "macros-6d380"}} :devtools { :before-load-async :after-load

Fredrik Andersson13:12:47

I can send the comment to the node environment from vim

thheller13:12:54

you are using :before-load-async but the stop never calls done

Fredrik Andersson13:12:56

I have to hurry. But thanks!

Ben Hammond14:12:52

Hi. I experimenting with switching my Shadow/React/UIx/MUI app over to Preact The preact docs talk about using resolve.alias to magically rewrite module paths over to preact/compat. https://preactjs.com/guide/v10/getting-started/#aliasing-react-to-preact Does shadow-cljs support this kind of js library aliasing? If not, what are the recommended alternatives?

Ben Hammond16:12:06

Will take a look. Perfect Thank you

Nundrum22:12:36

I've been trying to integrate page-renderer in my app, since I need a PWA that works offline. The problem is, I'm building a mostly static app to be served. In other words, I don't have a backend Clojure HTTP server running to handle traffic. I thought maybe I could use shadow-cljs clj-run ... to mimic what would normally happen, but that didn't work. Then I tried following https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Tutorials/js13kGames/Offline_Service_workers and had some success. Caching doesn't seem to work from the PWA when I turn on airplane mode. If I reload the page/app the console shows Content-Security-Policy: The page's settings blocked the loading of a resource at inline ("default-src"). The service worker appears to be registered:

Nundrum23:12:09

Ahhh it was a mess, but I figured it out. Part was scope, and part was bad formatting of a list in JS.

Chris McCormick09:12:13

What is page-renderer?

Nundrum14:12:07

It couldn't wrangle it to fit my project. Had to massage the MDN code into something that worked.

Ryan22:12:23

Just updated by IntelliJ + Cursive to latest version and suddenly my watches are failing with

The required namespace "module" is not available, it was required by "shadow.js.shim.module$module$node_modules$react$index.js".
any ideas of things to check?

Ryan22:12:35

I did some digging through my babashka tooling and found a task to reset the shadow-cljs cache, and now weโ€™re back in business ๐Ÿ™‚

{:task (shell (str "rm -fr ./.shadow-cljs/builds"))}

thheller07:12:36

that should never be necessary and the error looks like you maybe have something weird in your setup. shadow.js.shim.module$module$node_modules$react$index.js is not a name that should ever be generated

thheller07:12:15

and shadow-cljs doesn't care which editor or version thereof you use, so it makes no sense that changing that triggered any kind of error