Fork me on GitHub
#shadow-cljs
<
2022-06-23
>
JAtkins12:06:38

Any idea why the shadow status pages would be broken? I’ve seen Unknown, waiting for recompile. on the /build/xxx pages for the shadow server since at least release 2.15.2. I just tried upgrading to 2.19.4 today and still see the same page even if I cause the build to recompile by updating a watched file.

thheller15:06:34

@jatkin the "unknown" state is shown when the UI is loaded after the build finished compiling. since it wasn't around to receive the build result. the next compilation should show the result. dunno why you have no buttons though?

JAtkins13:06:28

You can see in the middle a compiler error appear. But the shadow build page doesn’t react. It could be down to how I’m starting the server.

(shadow.cljs.devtools.server/start!)
(shadow.cljs.devtools.api/watch build-id)
(shadow.cljs.devtools.api/nrepl-select build-id)
(shadow.cljs.devtools.api/repl build-id)

thheller16:06:52

@jatkin this is an ancient version of shadow-cljs. the UI looks very different nowadays, so can't say what is going on. definitely try upgrading first. the starting is fine although api/nrepl-select and api/repl do the same thing. so calling both seems like a mistake.

thheller15:06:43

there should be a force compile option

thheller15:06:12

" still see the same page". that screenshot is not from the latest version?

winsome15:06:08

I'm trying to build a library that will be used from node, is there a way to include static assets in the library? I've currently got a (fs.readFileSync (str "resources/" filename)) call, but it's looking at the "resources" directory of the project where it's used, as opposed to the "resources" directory in the library itself.

winsome15:06:49

Is there a sort of io/resource equivalent in cljs land?

thheller17:06:36

@winsome there is no io/resource equivalent since node doesn't have a classpath. but you control the library and the files that come with it. you can use the special js/__dirname to get the directory of the executing file. so just (path/resolve js/__dirname "foo.txt") would give you the full path in your library which you can then read

thheller17:06:37

the .js file is also in the cli folder. you can look at the node_modules/shadow-cljs package

winsome18:06:24

Thanks, that's a promising approach. When I run (path/resolve js/__dirname) from the repl in my.namespace I get "/absolute/path/to/my/proj/root". However, when I wrap it in a function:

(defn read-resource [filename]
  (println (path/resolve js/__dirname)))
I get "/abolute/path/to/my/proj/root/.cljs_node_repl/.cljs_node_repl/my/namespace".

thheller18:06:54

I guess you are not using shadow-cljs? js/__dirname yields the wrong folder given how the regular CLJS repls handle file loading

winsome18:06:56

hmm, no, not for the library. I might re-evaluate that decision though if it enables this.