Fork me on GitHub
Patrick Brown00:05:30

The documentation for Shadow is so good I'm having trouble finding something simple 👍. Where can I find the keys for the opts map that shadow.cljs.devtools. server/start!, api/watch, and repl? Also if anyone has any reason why I shouldn't launch them from integrant repl, let me know.


I’m noticing a weird edge case with shadow-cljs compilation. When a (ns…) form is wrapped in a (do..) block, compilation fails with odd errors. Here’s a minimal example:

  (ns cljs.user
   (:require [cljs.core.async :refer [chan <! go-loop]])))

(def wait-chan (chan 1))

(go-loop []
  (<! wait-chan)
…results in this error:
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/neilhansen/Documents/quickstart-browser/src/cljs/user.cljs:9:3
   6 | 
   7 | (go-loop []
   8 |   (<! wait-chan)
   9 |   (recur))
Can't recur here at line 9 cljs/user.cljs
  10 | 
…why am I doing this in the first place? I was working on some custom editor tooling that involved evaluating the whole buffer. I thought I would be clever and wrap the buffer string in a (do…) block. Ran into this issue, so thought I’d ask about it!


@neil.hansen.31 don't wrap ns in a do. that is not supported. ns is a special form that needs to be the first form in the file. this isn't supported in regular CLJS either.


Just out of interest - shadow.cljs.devtools.server.config-watch doesn't use shadow.cljs.devtools.server.fs-watch but instead busy-loops with (Thread/sleep 1000). Is it just a historical artifact or is there some deliberate decision behind this?


fs-watch only watches directories recursively. overkill for a single file.

👍 1

does shadow-cljs do any hashing or comparison of modification times on files or pure file-event-watching? Skimming the code it looks like the latter, was wondering whether hashing files or storing last-modification dates was considered/done in an extension or something


the 3rd implies the 2nd so I'm not sure what you are asking? what is the problem or concern?


not problem or concern, design question


in theory one can use hashes of files to work out what needs to be recompiled and what doesn't one AFAIK could also use file modification times or filesystem events, but that's not persistent across "watch" sessions


cache takes care of that, which indeed does a md5 hash of the file


checking that shadow-cljs doesn't do the first and wondering why that choice was made as considering writing a tool for a different purpose that does do that


how does cache know when it's invalidated?


is this the "hash-optimized-module" code?


no, not related in any way


sorry, I am just searching for md5 in the source code